Build sort card dynamically for group of records

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
Padmaja
Member
Posts: 2
Joined: Wed Jul 19, 2017 1:24 pm

Build sort card dynamically for group of records

Post by Padmaja » Wed Jul 13, 2022 4:47 pm

Hi,

I have a requirement where I need to build a sort card dynamically for group of records. I have coded the below to build the
sort conditions dynamically, it works fine but I am unable to do so for group of records.

Input is as below:
Input.png
Input.png (9.63 KiB) Viewed 21690 times
The group is identified when value changes in position (41,3) in input file

My job:
//SORT3 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SORTIN DD DSN=TTYA.EMANIP.MERCHANT.IN,DISP=SHR
//SORTOUT DD DSN=TTYA.EMANIP.MERCHANT.OUT,
// DISP=(OLD,CATLG,DELETE),RECFM=FB,
// LRECL=80,SPACE=(CYL,(30,20),RLSE)
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,
HEADER1=('SORT FIELDS=COPY ',/,
'OUTREC IFTHEN=(WHEN=(1,1,BI,NE,1,1,BI),BUILD=(1,80)),'),
BUILD=(C'IFTHEN=(WHEN=((111,40,SS,EQ,C''',1,40,C'''),AND,',/,
C'(111,40,SS,NE,C''',44,40,C''')),',/,
C'BUILD=(87,64,C''',1,43,C''')),',80:X),
TRAILER1=('IFTHEN=(WHEN=(1,1,BI,NE,1,1,BI),BUILD=(1,80))')
/*


Output.png shows how the sort card is built dynamically based on above code:
Input.png
Input.png (9.63 KiB) Viewed 21690 times
I want to group the conditions for the values in field (44,40) from input based on key in 41,3, as below:

Expected output:
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(1,1,BI,NE,1,1,BI),BUILD=(1,80)),
IFTHEN=(WHEN=((111,40,SS,EQ,C'MICROSOFT'),AND,
(111,40,SS,NE,C'XBOX'),AND,(111,40,SS,NE,C'PAYPAL'),AND,(111,40,SS,NE,C'GOOGLE'),AND,(111,40,SS,NE,C'CRV')),
Please help me build the sort card.

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others