Well, Friday was a long week, and that often leads to fatal mistakes. Here the
mistake is using "printable" items as the source-data for the FINDREP. This
would be a problem if the value was a subset of the PARM.
So, changed those to non-printable. That would fix it up, but the code is still
suffering from having to change horses in mid-stream. And there's the
fat-fingering, which is an all-too-common issue.
Leads to sort symbols, WHEN=INIT, two FINDREPs with STARTPOS and DO=1 and
SHIFT=NO.
//CHEKPARM EXEC PGM=SORT,PARM='JP1"&PARM1",JP2"&PARM2"'
//SYMNAMES DD *
* RECORD FIELDS TO CREATE AND MANIPLUATE
FIRST-COMPARATOR,*,80,CH
SECOND-COMPARATOR,*,=,=
* CONSTANTS
DUMMY-VALUE1-TO-REPLACE,X'FD'
DUMMY-VALUE2-TO-REPLACE,X'FE'
//SYMNOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY,STOPAFT=1
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(FIRST-COMPARATOR:
DUMMY-VALUE1-TO-REPLACE,
79X,
SECOND-COMPARATOR:
DUMMY-VALUE2-TO-REPLACE,
79X)),
IFTHEN=(WHEN=INIT,
FINDREP=(IN=DUMMY-VALUE1-TO-REPLACE,
OUT=JP1,
STARTPOS=1,
DO=1,
SHIFT=NO)),
IFTHEN=(WHEN=INIT,
FINDREP=(IN=DUMMY-VALUE2-TO-REPLACE,
OUT=JP2,
STARTPOS=81,
DO=1,
SHIFT=NO))
OUTFIL INCLUDE=(FIRST-COMPARATOR,
EQ,
SECOND-COMPARATOR),
NULLOFL=RC4
//SORTIN DD *
CONTENT IMMATERIAL
If concerned that it is overly wordy (some people have a problem with that),
this is after DFSORT has resolved all the symbols (including the matching JCL
symbol values I used for this particular run):
OPTION COPY,STOPAFT=1
INREC
IFTHEN=(WHEN=INIT,OVERLAY=(1:X'FD',79X,81:X'FE',79X)),IFTHEN=(WH*
EN=INIT,FINDREP=(IN=X'FD',OUT=C'AC',STARTPOS=1,DO=1,SHIF*
T=NO)),IFTHEN=(WHEN=INIT,FINDREP=(IN=X'FE',OUT=C'AC',STA*
RTPOS=81,DO=1,SHIFT=NO))
OUTFIL INCLUDE=(1,80,CH,EQ,81,80,CH),NULLOFL=RC4
For me there are lots of advantages to using sort symbols, including adding an
element of "self-documentation" and sparing the fat fingers from a run that
gets RC=0 but had a typo. With symbols, a typo will generally get RC=16. With
naked control cards, it'll often get a run, just the wrong one.
On Saturday, 14 May 2016 00:08:27 UTC+2, Bill Woodger wrote:
> DFSORT using JPn symbols:
>
> // SET PARM1=XY
> // SET PARM2=AB
> //STEP0100 EXEC PGM=SORT,PARM='JP1"&PARM1",JP2"&PARM2"'
> //SYMNOUT DD SYSOUT=*
> //SYSOUT DD SYSOUT=*
> //SORTOUT DD SYSOUT=*
> //SYSIN DD *
> OPTION COPY,STOPAFT=1
>
> INREC OVERLAY=(01:C'A',
> 80X,
> 80:C'B',
> 80X)
> OUTREC FINDREP=(INOUT=(C'A',
> JP1,
> C'B',
> JP2))
> OUTFIL INCLUDE=(01,80,CH,
> EQ,
> 81,80,CH),
> NULLOFL=RC4
> //SORTIN DD *
> CONTENT IMMATERIAL
>
>
> Will work prior to z/OS 2.x for anyone who needs that.
>
> The actual values of the symbols are automatically documents on the SYMNOUT
> dataset.
>
> NULLOFL allows the setting of some specific RC values when the OUTFIL dataset
> has no records.
>
> Original code was shorter, but testing (failed) with null symbols required
> changes.
>
> Code may be different with a later DFSORT, but then you'd have access to the
> EXPORT anyway (which could be used directly in a SORT step anyway).
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN