Page 1 of 1

Selecting either of 2 i/p files using SORT JCL

PostPosted: Sat Jan 13, 2018 6:01 pm
by gershome
Hi, I have three input files(IN1, IN2, IN3).
IN1 will have either 'Y' or 'N'
If it is 'Y', I need IN2 to be copied to the sort out file
If it is 'N', I need IN3 to be copied to the sort out file.

Can someone help me out on the logic using SORT JCL?
Note: There should be only one o/p file, i.e. either IN2 or IN3.

Re: Selecting either of 2 i/p files using SORT JCL

PostPosted: Sun Jan 14, 2018 3:29 am
by NicC
Are you wanting the sort JCL or the sort control cards?

I think something like this was asked before so have you searched the forum?

BTW - in MVS they are data sets not files. Files are the pipelines between your program and the data set.

Re: Selecting either of 2 i/p files using SORT JCL

PostPosted: Mon Jan 15, 2018 7:42 am
by gershome
Hi, I would need the sort control card.
I have tried in the forum, but couldn't find one..

Re: Selecting either of 2 i/p files using SORT JCL

PostPosted: Mon Jan 15, 2018 4:41 pm
by NicC
I had a big look around several forums and going back 2 years but could not find what I was looking for. However...
I think the answer is that you cannot use sort to select your input data set. That has to be done by another process. There ar 2 ways I can think of off the top of my head:
1 - code a small program to read data set 1 and set a return code. Have two sort steps following - one for each data set. Which step is to be executed will be determined by the return code from the first step.
2 - code a small program to read data set 1 and generate and submit a sort job with the appropriate input data set.

Re: Selecting either of 2 i/p files using SORT JCL

PostPosted: Mon Jan 15, 2018 5:27 pm
by gershome
Thanks Nic for your response.

Re: Selecting either of 2 i/p files using SORT JCL

PostPosted: Sat Feb 10, 2018 12:09 am
by Aki88
Hello,

Am fairly sure that this requirement is closed by now; but just in case you still want to explore an option of doing it in *SORT, here is a plausible solution.
This is untested, as I haven't had access to mainframe for sometime now, but this should work, errors if any, should be minor.

The new jobs that will be submitted will have IN2 or IN3 depending upon the INCLUDE condition's result.


//SORTIN   DD *                                                
Y                                                              
/*                                                              
//IN2      DD SYSOUT=(*,INTRDR)                                
//IN3      DD SYSOUT=(*,INTRDR)                                
//SYSIN    DD *                                                
 SORT FIELDS=COPY                                              
 OUTFIL INCLUDE=(1,1,CH,EQ,C'Y'),                              
        FNAMES=IN2,                                            
        BUILD=(C'//TEST#    JOB ''',C' ''',C',''TEST'',',/,    
              C'//         CLASS=A,MSGCLASS=X,             ',/,
              C'//         MSGLEVEL=(1,1),NOTIFY=&SYSUID,  ',/,
              C'//         REGION=0M                       ',/,
              C'//*',77X,/,                                    
              C'//STEP001  EXEC PGM=SORT                   ',/,
              C'//DFSMSG   DD SYSOUT=*                     ',/,
              C'//SORTIN   DD DISP=SHR,DSN=<IN2>           ',/,
              C'//SORTOUT  DD SYSOUT=*                     ',/,
              C'//SYSIN    DD *                            ',/,
              C' SORT FIELDS=COPY                          ',/,
              C'/*                                         ',/,
              C'//',78X)                                        
 OUTFIL INCLUDE=(1,1,CH,EQ,C'N'),                              
        FNAMES=IN3,                                            
        BUILD=(C'//TEST#    JOB ''',C' ''',C',''TEST'',',/,    
              C'//         CLASS=A,MSGCLASS=X,             ',/,
              C'//         MSGLEVEL=(1,1),NOTIFY=&SYSUID,  ',/,
              C'//         REGION=0M                       ',/,
              C'//*',77X,/,                                    
              C'//STEP001  EXEC PGM=SORT                   ',/,
              C'//DFSMSG   DD SYSOUT=*                     ',/,
              C'//SORTIN   DD DISP=SHR,DSN=<IN3>           ',/,
              C'//SORTOUT  DD SYSOUT=*                     ',/,
              C'//SYSIN    DD *                            ',/,
              C' SORT FIELDS=COPY                          ',/,
              C'/*                                         ',/,
              C'//',78X)                                        
/*