Hi ,
I have a requirement in which i have two types of detail record, i need to create a trailer with with the counts of each detail record and also the total count.
Original file :
1XXXXX22434
2XXXA dsfdaf gfgdfgh
2XXXA dsfdaf gfgdfgh
2XXXA dsfdaf gfgdfgh
2XXXA dsfdaf gfgdfgh
3XXXA dsfdaf gfgdfgh
3XXXA dsfdaf gfgdfgh
3XXXA dsfdaf gfgdfgh
Expected Output :
1XXXXX22434 --> Header
2XXXA dsfdaf gfgdfgh -->Detail record with indicator 2
2XXXA dsfdaf gfgdfgh
2XXXA dsfdaf gfgdfgh
2XXXA dsfdaf gfgdfgh
3XXXA dsfdaf gfgdfgh -->Detail record with indicator 3
3XXXA dsfdaf gfgdfgh
3XXXA dsfdaf gfgdfgh
4000000004000000003000000007 --- > trailer should start with 4
The trailer should have the count of each type ( type 2 and type 3)detail record separately and also the total count of the detail record (type2 +type 3).
Header record will start with 1,the first set of detail records with 2 , next set of detail records will start with 3 and the trailer will be 4.
I was able to bring the total count in the trailer.. but i am not sure about bringing the separate count as per the detail record.Could someone please help me with this.
Thanks!
Create New trailer with count as per the detail record type
Moderators: Frank Yaeger, Moderator Group
Create New trailer with count as per the detail record type
Last edited by jaya1512 on Mon Sep 05, 2011 6:44 pm, edited 1 time in total.
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
You can use a DFSORT job like the following. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.
Code: Select all
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1XXXXX22434
2XXXA dsfdaf gfgdfgh
2XXXA dsfdaf gfgdfgh
2XXXA dsfdaf gfgdfgh
2XXXA dsfdaf gfgdfgh
3XXXA dsfdaf gfgdfgh
3XXXA dsfdaf gfgdfgh
3XXXA dsfdaf gfgdfgh
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'00')),
IFTHEN=(WHEN=(1,1,CH,EQ,C'2'),OVERLAY=(81:C'1')),
IFTHEN=(WHEN=(1,1,CH,EQ,C'3'),OVERLAY=(82:C'1'))
OUTFIL REMOVECC,
BUILD=(1,80),
TRAILER1=('4',TOT=(81,1,ZD,TO=ZD,LENGTH=9),
TOT=(82,1,ZD,TO=ZD,LENGTH=9),
COUNT-1=(TO=ZD,LENGTH=9))
/*
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
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Write trailer having count of each gruop based on record key
Hello,
I have the following requirement -
Input file has the structure -
1 header(first 2 characters are '10'),
some detail records(first 2 characters act as KEY - '21', '22', '23', etc),
1 trailer(first 2 characters '90') - total count,count of key 1 records, count of key 2 records, count of key 3 records and so on.
I have to filter out all records that have 'JD' at a particular position(position depends on record key) and write the records to a new file and also update the counts in the trailer.
Input file
10APPLIDDMMYYYY
21ABC J
21ABC JD
21ABC J
22ABC J
22ABC J
22ABC JD
22ABC JD
23ABC JD
23ABC JD
23ABC J
90000000010000000003000000004000000003
Output file
10APPLIDDMMYYYY
21ABC JD
22ABC JD
22ABC JD
23ABC JD
23ABC JD
90000000005000000001000000002000000002
I have written the following sort card that filters out the desired records. But was unable to come up with a solution for the trailer -
OPTION COPY
INCLUDE COND=((1,2,CH,EQ,C'21',AND,9,2,CH,EQ,C'JD'),OR,
(1,2,CH,EQ,C'22',AND,7,2,CH,EQ,C'JD'),OR,
(1,2,CH,EQ,C'23',AND,12,2,CH,EQ,C'JD'),OR,
1,2,CH,EQ,C'10',OR,
1,2,CH,EQ,C'90')
Could you please suggest how I may modify the sort card for getting the new trailer with correct counts. I would prefer just DFSORT without ICETOOL.
Thanks,
Sucho
I have the following requirement -
Input file has the structure -
1 header(first 2 characters are '10'),
some detail records(first 2 characters act as KEY - '21', '22', '23', etc),
1 trailer(first 2 characters '90') - total count,count of key 1 records, count of key 2 records, count of key 3 records and so on.
I have to filter out all records that have 'JD' at a particular position(position depends on record key) and write the records to a new file and also update the counts in the trailer.
Input file
10APPLIDDMMYYYY
21ABC J
21ABC JD
21ABC J
22ABC J
22ABC J
22ABC JD
22ABC JD
23ABC JD
23ABC JD
23ABC J
90000000010000000003000000004000000003
Output file
10APPLIDDMMYYYY
21ABC JD
22ABC JD
22ABC JD
23ABC JD
23ABC JD
90000000005000000001000000002000000002
I have written the following sort card that filters out the desired records. But was unable to come up with a solution for the trailer -
OPTION COPY
INCLUDE COND=((1,2,CH,EQ,C'21',AND,9,2,CH,EQ,C'JD'),OR,
(1,2,CH,EQ,C'22',AND,7,2,CH,EQ,C'JD'),OR,
(1,2,CH,EQ,C'23',AND,12,2,CH,EQ,C'JD'),OR,
1,2,CH,EQ,C'10',OR,
1,2,CH,EQ,C'90')
Could you please suggest how I may modify the sort card for getting the new trailer with correct counts. I would prefer just DFSORT without ICETOOL.
Thanks,
Sucho
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
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
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page