I have a sort parm in a JCL that is created using some REXX code as follows:
/* REXX */
'EXECIO * DISKR ZEROGDT (STEM ZGD.'
S21=' '
OUTVAR1=' SORT FIELDS=COPY'
'EXECIO 1 DISKW ACCOUNT (STEM OUTVAR'
DO I=1 TO ZGD.0
ACCTNBR=SUBSTR(ZGD.I,33,16)
IF I=1 THEN DO
OUTVAR1=" OMIT FORMAT=CH,COND=(33,16,EQ,C'"||ACCTNBR||"',OR,"
END
ELSE DO
IF I=ZGD.0 THEN OUTVAR1=S21||" 33,16,EQ,C'"||ACCTNBR||"')"
ELSE OUTVAR1=S21||" 33,16,EQ,C'"||ACCTNBR||"',OR,"
END
'EXECIO 1 DISKW ACCOUNT (STEM OUTVAR'
END
'EXECIO 0 DISKW ACCOUNT (FINIS'
I know that the above REXX code creates a sort parm as follows:
SORT FIELDS=COPY
OMIT FORMAT=CH,COND=(33,16,EQ,C'8257310018808572',OR,
33,16,EQ,C'8257310018076428',OR,
33,16,EQ,C'8257310017959681',OR,
33,16,EQ,C'8257310016504835',OR,
33,16,EQ,C'8257310016059467',OR)
But, it is not able to handle a single record in the input file. I am trying to modify the REXX code to handle a single record but have not been able to. Any help is appreciated.
The code below allows the first line to also be the last, the original code could not account for this because of the way the IF statements nested.
For a single line of input this should produce:
For multiple lines it should produce: