File Split using DFSORT

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
Veera
Moderator
Posts: 111
Joined: Wed Feb 22, 2006 2:59 pm

File Split using DFSORT

Post by Veera » Sat Nov 15, 2008 9:08 am

Input File -> RECFM=FB,LRECL=6

Output Files also should be of Same RECFM,Same LRECL.

INPUT FILE SAMPLE DATA

HEADER
111111
333333
222222
444444
......
...... -> Like this there are N no of records. where N = even number
TRALER

I need to split the above input file into 2 O/P files using DFSORT.Both the output files should have the
header and trailer records as well.

Preferably not using the SUBSET function of DFSORT.

Thanks,
Veera.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Sun Nov 16, 2008 12:54 am

Which records should go in which output file? Do you just want the first n/2 records in output file1 and the second n/2 records in output file2? Or do you want the first n/2 sorted records in file1 and the second n/2 sorted records in file2? Or do you want records 1, 3, 5, ... in file1 and 2, 4, 6, ... in file 2 (sorted? unsorted?).

Is there anything in the header and trailer records that identify them (e.g. '0' in position 1 for header record and '9' in position 1 for trailer record). If so, what identfies them.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Veera
Moderator
Posts: 111
Joined: Wed Feb 22, 2006 2:59 pm

Post by Veera » Sun Nov 16, 2008 8:31 am

Do you just want the first n/2 records in output file1 and the second n/2 records in output file2?

yes.


Is there anything in the header and trailer records that identify them (e.g. '0' in position 1 for header record and '9' in position 1 for trailer record). If so, what identfies them.

00 -> In Header starting from position 1.
99 -> Trailer starting from position 1.

00xxx -> Header rec's
99xxx -> Trailer rec's

One more new requirement for the same Job.

xxx -> represents the total count of records in the input file.

So after the file is split XXX -> should be updated accordingly as XXX/2
in both header and trailer.

say if the total records in the input file are 10(excluding the header and trailer record) then after the split, each file header and trailer records should have 5 in it as total count of records.

Thanks,
Veera.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Mon Nov 17, 2008 2:57 am

Assuming that '00' and '99' don't appear in positions 1-2 of the data records, you can use this DFSORT/ICETOOL job to do what you asked for:

Code: Select all

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file (FB/6)
//OUT1 DD DSN=...  output file1 (FB/6)
//OUT2 DD DSN=...  output file2 (FB/6)
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
COPY FROM(IN) USING(CTL2)
/*
//CTL1CNTL DD *
  OMIT COND=(1,2,SS,EQ,C'00,99')
  INREC OVERLAY=(1:SEQNUM,3,ZD,
       4:1,3,ZD,DIV,+2,EDIT=(TTT),80:X)
  OUTFIL FNAMES=CTL2CNTL,REMOVECC,NODETAIL,
    TRAILER1=(C' OMIT COND=(1,2,SS,EQ,C''00,99'')',/,
     C' OUTFIL FNAMES=OUT1,ENDREC=',4,3,C',',/,
     C'  HEADER1=(''00',4,3,C'''),',/,
     C'  TRAILER1=(''99',4,3,C''')',/,
     C' OUTFIL FNAMES=OUT2,SAVE,',/,
     C'  HEADER1=(''00',4,3,C'''),',/,
     C'  TRAILER1=(''99',4,3,C''')')
/*
//CTL2CNTL DD DSN=&&C2,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Veera
Moderator
Posts: 111
Joined: Wed Feb 22, 2006 2:59 pm

Post by Veera » Mon Nov 17, 2008 8:10 am

Thanks a lot Frank, you are genius.

Theoretically it sounds simple, copy N/2 into first file and rest into second file. Building N was the crust and the tough part of the request. You always make it look so simple. It took a while and some paper work for me to understand it.

Thanks a ton.

Thanks,
Veera.

subasu
Member
Posts: 12
Joined: Tue Mar 24, 2009 1:12 pm

Split an input file into an O/P file depending on tags

Post by subasu » Fri Apr 24, 2009 11:23 am

Hi,

My input file is of the following format ( VBM,LRECL-32000)

X'D3A8C6'
---- resource
---- resource
---- resource
X'D3A9C6'
X'D3A8A8'
---- data
---- data
---- data
X'D3A9A8'

I need my O/P file( VBM,LRECL-32000) to contain only

X'D3A8A8'
---- data
---- data
---- data
X'D3A9A8'.

There are no specific tags or variables at specific positions to identify that the line is a data line or resource line but, resource and data lines are separated by diff tags as indicated above.

Please suggest a way to implement the same.

Thanks,
Subhadeep.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Apr 24, 2009 8:10 pm

You need to do a better job of describing what you want to do.

What are the "rules" for which records go in the output file? Do you want the input records with specific "tags" and the data records which follow them or something else? How do you identify a "tag" vs a data record? Do the records actually have the characters X'...' or is that your way of showing a binary value?

Also, in the future please start a new Topic instead of putting a different question in an existing topic.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

subasu
Member
Posts: 12
Joined: Tue Mar 24, 2009 1:12 pm

Post by subasu » Sun Apr 26, 2009 10:26 am

Hi Frank,

Let me try and explain in more detail.

There are 2 blocks in the input file, one is a block of resource and another is a block of data, which are separated by the four tags as described above, a tag depicting the first 3 chars in the record... X'D3....' are hex values of the first record of the line. I hope this makes it clearer. Please let me know if I need to explain more.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Mon Apr 27, 2009 10:17 pm

I'm still not sure I understand what you want to do. But since you say your file has RECFM=VBM, I'll assume your X'D3...' fields start in position 6 after the RDW and machine control character, and that you want the second group of records surrounded by X'D3A8' and X'D3A9' tags. If so, here's a DFSORT job that will do that.

Code: Select all

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,6:5)),
    IFTHEN=(WHEN=GROUP,BEGIN=(7,2,BI,EQ,X'D3A8'),
      END=(7,2,BI,EQ,X'D3A9'),PUSH=(5:ID=1))
  OUTFIL INCLUDE=(5,1,CH,EQ,C'2'),BUILD=(1,4,5:6)
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

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