MainframeSupports
tip week 7/2011:

In my time as a mainframe programmer I have seen a lot of procedures and functions in PL/I which are able to remove trailing blanks. Even though PL/I has a large selection of built-in functions the IBM team behind PL/I did not provide us with a strip function. Luckily this has changed in the newest version of PL/I called Enterprise PL/I. Now we can all remove our home grown strip functions and use the authorised version.

As usual the PL/I lab has decided to be different. Removal of trailing blanks is performed by a function called STRIP in REXX and DB2 (DB2 has a RTRIM function to remove trailing characters, but it is just a specialized version of STRIP), but in PL/I it is called TRIM . The parameters for TRIM are of course also different and when you read the description of the parameters you end up being quite confused. I hope this overview is more clear:

The conclusion is that trailing blanks will be removed using the following TRIM:

mynonstrippedvariable = 'some nonsense       ';
put skip list('theStrippedResult=<' !! TRIM(mynonstrippedvariable, '', ' ') !! '>');

This example will print: theStrippedResult=<some nonsense>. By the way the result of TRIM is always a CHAR VARYING.

Previous tip in english        Sidste danske tip        Tip list