%TRIM Built-In Functions in rpgle

%TRIM function is used to trim blank spaces from both sides of a string.

It can also be used to trim characters other than blanks. We can mention those characters to be trimmed in parameter 2.

Format of %TRIM funtion is %TRIM(Source String : characters to trim)


Example -%TRIM Built-In Functions in rpgle




 Columns . . . :    6  80                                              AMIT/QRPGSRC
 SEU==>                                                                     TESTRPG
 FMT *   *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8
        *************** Beginning of data *****************************************
0001.00 D InputChar       S             30A   INZ('$*****5.25***0000    ')
0002.00 D TrimChar        S             30A
0003.00
0004.00 C* Without 2nd parameter, %Trim only trims blank spaces on both sides
0005.00 C                   Eval      TrimChar =%Trim(InputChar)
0006.00 C     TrimChar      DSPLY
0007.00 C
0008.00 C* Use 2nd parameter to trim 0 and blanks
0009.00 C                   Eval      TrimChar =%Trim(InputChar:'0 ')
0010.00 C     TrimChar      DSPLY
0011.00 C
0012.00 C* Use 2nd parameter to trim 0, blank and *
0013.00 C                   Eval      TrimChar =%Trim(InputChar:'0 *')
0014.00 C     TrimChar      DSPLY
0015.00 C
0016.00 C* Use 2nd parameter to trim 0, blank, * and $
0017.00 C                   Eval      TrimChar =%Trim(InputChar:'0 *$')
0018.00 C     TrimChar      DSPLY
0019.00
0020.00 C                   Seton                                        LR
        ****************** End of data ********************************************


Output

DSPLY  $*****5.25***0000
DSPLY  $*****5.25***    
DSPLY  $*****5.25       
DSPLY  5.25











User Comments:



Subscribe

.  


Copyright © www.go4as400.com, 2013-2023. Copyright notice   Terms of services   Privacy policy