Page 1 of 1

Use of temporary datasets between two successive sorts

PostPosted: Wed Jul 11, 2018 5:31 pm
by golemis
Hi,
I need to perform two successive sorts, using the result of the 1st as SORTIN to the second (to avoid questions, the sort field in not in a fixed position in the initial dataset, so I use the first sort to rearrange the layout with INTHEN(WHEN s and then the second sort to do the required sorting).
When I use a permanent dataset, to link the two sorts, everything works fine.
When I substitute this permanent dataset witha temporary one, the second sort succeeds, no complain or CR>0, but works as if the temp dataset was empty !
    ICE080I 0 IN MAIN STORAGE SORT
    ICE055I 0 INSERT 0, DELETE 0
    ICE054I 0 RECORDS - IN: 0, OUT: 0
    ICE173I 0 NO RECORDS FOR THE SORTOUT DATA SET - RC=0
Any idea what I am doing wrong ?

//PD0001S1 EXEC PGM=SORT
//*
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SYSLIST  DD SYSOUT=*
//SORTIN   DD DISP=SHR,DSN=HLQ.D040718.LOG
//SORTOUT  DD SYSOUT=*
//TEMPC    DD DSN=&TEMPC,DISP=(,PASS),
//         SPACE=(CYL,(1,5),RLSE),UNIT=SYSDA,
//         DCB=(RECFM=FB,LRECL=110)
//SYSIN    DD *
   SORT FIELDS=(15,8,CH,A)
   INCLUDE COND=(1,12,CH,EQ,C'JobComplete;')
   OUTREC IFTHEN=(WHEN=(25,1,CH,EQ,C' '),
     BUILD=(42,8,X,15,8,X,51,89,3X)),
          IFTHEN=(WHEN=NONE,
     BUILD=(41,8,X,15,8,X,50,90,2X))
   OUTFIL FNAMES=TEMPC
/*
//PD0001S2 EXEC PGM=SORT
//*
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SYSLIST  DD SYSOUT=*
//SORTIN   DD DISP=(,DELETE),DSN=*.PD0001S1.TEMPC,
//         DCB=(RECFM=FB,LRECL=110)
//SORTOUT  DD SYSOUT=A
//SYSIN    DD *
   SORT FIELDS=(1,8,CH,A)
/*

Re: Use of temporary datasets between two successive sorts

PostPosted: Wed Jul 11, 2018 5:59 pm
by Robert Sample
Your SORTIN for the second step will use the default for status -- which is NEW. When you attempt to read a record from a DISP=(NEW,DELETE) data set, what do you think happens?

Re: Use of temporary datasets between two successive sorts

PostPosted: Wed Jul 11, 2018 6:20 pm
by golemis
Thank you Robert, my bad, just added (OLD,DELETE) and all good now