How REXX-enhanced processing works

Z Data Tools defines two special REXX variables, INREC and OUTREC, that you can use in the REXX statements that you supply to perform enhanced processing. When the Z Data Tools function or panel invokes REXX, the contents of each input record selected for processing are passed in both INREC and OUTREC. When REXX is invoked, the contents of INREC and OUTREC are identical, unless you are using the DSC function or the Copy Utility (option 3.3) with an output template that performs field mapping to reformat records. If you are using DSC or the Copy Utility to reformat records then, when REXX is invoked, INREC contains the input record, and OUTREC contains the reformatted output record.

The INREC variable is intended to be used as a reference variable. Any changes made to it are ignored by Z Data Tools. The OUTREC variable can be updated by the procedure, and (unless you “drop” the record from further processing, as described below) when REXX processing completes, is passed back for processing by the Z Data Tools panel or function that you are enhancing. For example, the following code processes a data set containing records with a type indicator in the first two bytes. Records with type '01' are all 80-bytes long and are to be passed on for output without change. Records with type '02' are variable in length, all less than 80 bytes long, and contain data divided into two sections (each at most 40 bytes long) by a slash character ('/'). These records are reformatted into two 40-byte halves that are concatenated to make 80-byte records to be passed on for output.
/* Reformat varying length records as fixed
   using an arbitrarily located delimiter   */
If Substr(inrec,1,2) == '02' Then Do
  Parse Var inrec left '/' right
  outrec = Left(left,40) || Left(right,40)

If the value of the OUTREC variable is longer than the record length allowed in the data set specified by the function or panel you are using, then it is truncated. If the value of OUTREC is shorter than the record length, it is padded using the character specified by the PAD field on the Set Processing Options (option 0) panel (if you are enhancing a panel) or the character specified by the PAD parameter of the SET function (if you are enhancing a function).