%TRIML Built-In Functions in rpgle

%TRIML function is used to trim leading spaces 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 %TRIML funtion is %TRIML(Source String : characters to trim)

Example –%triml built-in function 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('   $***005.25***  ')
0002.00 D TrimChar        S             30A
0003.00
0004.00 C* Without 2nd parameter, %Triml only trims blank spaces on the left
0005.00 C                   Eval      TrimChar =%Triml(InputChar)
0006.00 C     TrimChar      DSPLY
0007.00 C
0008.00 C* Use 2nd parameter to trim $ and blanks on the left
0009.00 C                   Eval      TrimChar =%Triml(InputChar:'$ ')
0010.00 C     TrimChar      DSPLY
0011.00 C
0012.00 C* Use 2nd parameter to trim $, blank and * on the left
0013.00 C                   Eval      TrimChar =%Triml(InputChar:'$ *')
0014.00 C     TrimChar      DSPLY
0015.00 C
0016.00 C* Use 2nd parameter to trim $, blank, * and 0 on the left
0017.00 C                   Eval      TrimChar =%Triml(InputChar:'$ *0')
0018.00 C     TrimChar      DSPLY
0019.00
0020.00 C                   Seton                                        LR
        ****************** End of data ********************************************


Output

DSPLY  $***005.25***
DSPLY  ***005.25*** 
DSPLY  005.25***    
DSPLY  5.25*** 











User Comments:



Subscribe

.  


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