Need a 1step JCL to seperate header and detail records

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

Post Reply
bhargavi_ns
Member
Posts: 18
Joined: Wed Sep 21, 2011 9:47 am

Need a 1step JCL to seperate header and detail records

Post by bhargavi_ns » Wed Mar 06, 2013 3:19 pm

input -
00header-record
01Sub-header-record
10d1
10d2
10d3
10d4
10d5
98Sub-trailer-record
99Trailer-record

need output as -

output1-
00header-record
01Sub-header-record
98Sub-trailer-record
99Trailer-record

output2-
10d1
10d2
10d3
10d4
10d5

Can we do this in one step in JCL ??

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Mar 06, 2013 4:07 pm

Yes,

Look at OUTFIL INCLUDE=, and OUTFIL SAVE.

INCLUDE the headers/trailers to one file, and SAVE will get everything else to the second file.

bhargavi_ns
Member
Posts: 18
Joined: Wed Sep 21, 2011 9:47 am

Post by bhargavi_ns » Wed Mar 13, 2013 10:28 am

//S1 EXEC PGM=SORT
//SYSUDUMP DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN= input..
//SORTOF1 DD DSN= output1..
//SORTOF2 DD DSN= output2..
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FILES=1,INCLUDE=(1,2,SS,EQ,C'00,01,98,99')
OUTFIL FILES=2,INCLUDE=(1,2,SS,EQ,C'10')
/*

Thanks.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Mar 13, 2013 12:28 pm

Yes, good work. Seeing your data values, I'd just tweak it a little.

Code: Select all

//S1 EXEC PGM=SORT                                       
//SYSUDUMP  DD SYSOUT=*                                  
//SYSOUT DD SYSOUT=*                                     
//SORTIN DD DSN= input..  
//SORTOF1 DD DSN= output1..
//SORTOF2 DD DSN= output2..               
//SYSIN DD *
  SORT FIELDS=COPY                                 
  OUTFIL FILES=2,INCLUDE=(1,2,CH,EQ,C'10')
  OUTFIL FILES=1,SAVE
/*
The SAVE will get "everything which is not on file 2 (the 10's) onto file 1. The "SS" can be replaced by CH for the situation where there is only one value.

I suggested the other way around, assuming that there was more than one detail record, and fewer than three header/trailer records. But, seeing what you have, this is clearer, and only requires amending if/when new types of detail records are created.

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