Gen EDGE

  • 1.  How to replace a specific character in a text attribute

    Posted Feb 05, 2018 05:11 AM

    Hi,

     

    I have a requirement to change a value '-' with '/' in a text attribute. we use CA GEN 8.0 version. Application is on Client -Mainframe Server (GUI). Is there any function that can replace a particular value? I know findreplacestring function is there. But not sure if it can work on C client code and Cobol Code.

     

    Please share your suggestion. thanks.

     

    With Regards

    Vijayakumar



  • 2.  Re: How to replace a specific character in a text attribute

    Broadcom Employee
    Posted Feb 05, 2018 05:15 PM

    Hi Vijaykunar,

    The FindReplaceString function is only valid for GUI C client programs because it is an OLE based function. 

    Functions in Action Diagram Targeted For Windows Platforms - CA Gen - 8.6 - CA Technologies Documentation 

    ICCOO02W - CA Gen - 8.6 - CA Technologies Documentation 

     

    For a language/platform independent solution the user community might be able to provide other ideas.

    One option I can think of is as follows but rather long winded:

    Use the Find function to locate the position in a text attribute string of value '-'. 

    Use the Substr function to extract the parts of the string before and after the '-'

    Use the Concat function to reassemble the string parts with the required '/'. 

    Functions in Action Diagram - CA Gen - 8.6 - CA Technologies Documentation 

     

    Hope that helps

     

    Regards,

     

    Lynn



  • 3.  Re: How to replace a specific character in a text attribute

    Posted Feb 06, 2018 04:22 AM

    The easiest approach that is portable across all platforms would be:

     

    1 | SET temp_len.ief_supplied.count TO length( trim( temp_input.ief_supplied.command ) )
    2 | +=>FOR temp_pos.ief_supplied.count FROM 1 TO temp_len.ief_supplied.count BY 1
    3 | | SET temp_byte.ief_supplied.flag TO substr( temp_input.ief_supplied.command , temp_pos.ief_supplied.count , 1 )
    4 | | +->IF temp_byte.ief_supplied.flag = "-"
    5 | | | SET temp_byte.ief_supplied.flag TO "\"
    4 | | +--
    6 | | +->IF temp_pos.ief_supplied.count = 1
    7 | | | SET temp_output.ief_supplied.command TO temp_byte.ief_supplied.flag
    6 | | +> ELSE
    8 | | | SET temp_output.ief_supplied.command TO concat( substr( temp_output.ief_supplied.command , 1 , temp_pos.ief_supplied.count - 1 ) , temp_byte.ief_supplied.flag )
    6 | | +--
    2 | +--

     

    As long as you are not performing this thousands of times, it should be OK, but if performance is a consideration, then an EAB or inline code would be an alternative. 

     

    You could also change the code to use a single string rather than a separate input and output but this would require more processing time.