%REPLACE Built-In Functions in rpgle

%REPLACE function is used the segment of a string with the replacement string.

Format of this function is %REPLACE (Replacing string, actual string, starting position, offset)

Example –%replace built-in function in rpgle


In the example below, source string ‘search string’ will have replacement with replacement string ‘word’ from position 8 till length 6.



 
Columns . . . :    6  80                  Browse                    AMIT/QRPGLESRC
SEU==>                                                                     REPLACE
FMT D  DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
     *************** Beginning of data *******************************************
0001.00 D source          S             30A   inz ('Search string')
0002.00 D pos             S              5U 0
0003.00
0004.00  /FREE
0005.00     pos = %scan (' ' : source);
0006.00     source = %replace ( 'word': source : pos+1:6);
0007.00     DSPLY  source;
0008.00  /END-FREE
0009.00 C                   SETON                                        LR
        ******************************* End of data ******************************


Output

Search word










User Comments:



Subscribe

  Email:



Copyright © www.go4as400.com, 2013-2017. Copyright notice