How to update records count in the header using JCL

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

nanda
Member
Posts: 5
Joined: Thu Jul 26, 2007 5:19 pm

How to update records count in the header using JCL

Post by nanda » Thu Aug 02, 2007 5:16 pm

Hi,

Suppose, I have file with '10' records. The header is showing the count of all records in the file. This file has some duplicate records.... say for ex. 2 duplicate records.

I need to create a new file by remove the duplicate records and updating count in the header record. i.e. my new file should have 8 records (after removing the 2 duplicate records from the file of 10 records) and header record should show the count as 8.

Please note that record counts and duplicate records will vary from file to file. How can i achieve this by JCL. We can remove duplicate records by using SORT utility. But, can we update the count in the header record dynamically by using jcl.

Thanks for your time.

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Aug 02, 2007 6:37 pm

3 questions:

how is the header record identified?
what is the criterea for duplicate records? (i.e. pos, length, type) attempt to make this compare size as small as possible.

what are the DCB parameters for you input file - I assume your output file will be the same.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

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

Post by Frank Yaeger » Thu Aug 02, 2007 9:12 pm

nanda,

Please show an example of the records in your input file and the expected output records. Give the RECFM and LRECL of the input file. Give the starting position, length and format of all relevant fields.
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

Nanda Krishna
Member
Posts: 1
Joined: Mon Mar 26, 2007 2:24 pm

Post by Nanda Krishna » Fri Aug 03, 2007 9:07 am

* Header record will start with AX10 and detail records starts with DRxxx
* criterea for duplicate records: SORT FIELDS=(1,13,CH,A)
* RECFM = VB
* LRECL = 304
* starting position, length and format of the field you are using to check
for duplicates = (1, 13, CHAR) i.e. SORT FIELDS=(1,13,CH,A)
* In the header, record count is from pos 59-62 (length of 4 char)
* Input file and Output file are of same format and length.

Please let me know if you need any other information. Thanks in Advance :)

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Fri Aug 03, 2007 12:14 pm

record count is from pos 59-62 (length of 4 char)
packed or display?
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

nanda
Member
Posts: 5
Joined: Thu Jul 26, 2007 5:19 pm

Post by nanda » Fri Aug 03, 2007 2:04 pm

Display

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 Aug 03, 2007 9:29 pm

Again: Please show an example of the records in the input file (just the relevant fields) and the records you expect in the output file.
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

nanda
Member
Posts: 5
Joined: Thu Jul 26, 2007 5:19 pm

Post by nanda » Sat Aug 04, 2007 6:47 pm

Sample input file:
--------------------
Header:
---------
AX00 20070804025000RAMTX00056790 00000000051357
* Here 0005 is the records count excluding hdr record and it starts
from pos. 59

Detail records:
-----------------
DRAPBBXA0
DRAPBBXA1
DRAPBBXA2 --> Duplicate record
DRAPBBXA2 --> Duplicate record
DRAPBBXA3

Sample output file should be ....
--------------------------------
Header:
---------
AX00 20070804025000RAMTX00056790 00000000041357

Detail records:
-----------------
DRAPBBXA0
DRAPBBXA1
DRAPBBXA2
DRAPBBXA3

* One duplicate record(DRAPBBXA2) from the i/p file removed and the
record count in the header is updated from 5 to 4.

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

Post by Frank Yaeger » Sat Aug 04, 2007 10:06 pm

Here's a DFSORT job that will do what you asked for. Since the input file is VB, we need to add 4 bytes (for the RDW) to your starting positions. I assumed that the header record can be identified by the 'A' in position 1.

Code: Select all

//S1    EXEC  PGM=ICEMAN                                         
//SYSOUT    DD  SYSOUT=*                                         
//SORTIN DD DSN=...  input file (VB)                             
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)       
//SYM DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)      
//SYSIN    DD    *                                               
  SORT FIELDS=(5,13,CH,A)                                        
  SUM FIELDS=NONE                                                
  OUTFIL FNAMES=T1                                               
  OUTFIL FNAMES=SYM,REMOVECC,NODETAIL,VTOF,                      
    BUILD=(80X),                                                 
    TRAILER1=('NEWCT,''',COUNT-1=(M11,LENGTH=4),C'''')           
/*
//S2    EXEC  PGM=ICEMAN                                         
//SYSOUT    DD  SYSOUT=*                                         
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)                           
//SORTIN DD DSN=&&T1,DISP=(OLD,PASS)                             
//SORTOUT DD DSN=... output file (VB)                             
//SYSIN    DD    *                                               
  OPTION COPY                                                    
  INREC IFTHEN=(WHEN=(5,1,CH,EQ,C'A'),                           
    OVERLAY=(63:NEWCT))                                          
/*
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

nanda
Member
Posts: 5
Joined: Thu Jul 26, 2007 5:19 pm

Post by nanda » Tue Aug 07, 2007 12:32 pm

Hi Frank,

Thanks for the DFSORT job. It is working as per expectations. But, when i am checking for syntax errors, i am getting the following error msg...(but the job ended with rc 00). Could you explain why it is so? Thanks for your time.

Sev Msg No. Message Text
-----------------------------------------------------
E1 8 DSS10065E Parameter 'COUNT-1' is unidentified.

nanda
Member
Posts: 5
Joined: Thu Jul 26, 2007 5:19 pm

Post by nanda » Tue Aug 07, 2007 1:52 pm

Thank you :)

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

Post by Frank Yaeger » Tue Aug 07, 2007 9:52 pm

Huh? Checking for syntax errors how? If you received a DFSORT syntax error, it would be an ICExxxA message and you would not get RC=0.
E1 8 DSS10065E Parameter 'COUNT-1' is unidentified.
This message is NOT from DFSORT. What program are you running that produces this error message?
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

jebbin
Member
Posts: 2
Joined: Fri Nov 13, 2009 9:13 pm

Post by jebbin » Fri Nov 13, 2009 9:19 pm

Hi Frank, i know this is quite old, but could you tell me whether i can use the same job for a fixed length file? If not what do i need to change to achieve similar results on a fixed length file?

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 Nov 13, 2009 10:00 pm

You can use a similar (though not identical) job for an FB file.

Please show me an example of the records in your input file and what you expect for output. Tell me the LRECL of the input file. Tell me the starting position, length and format of all relevant fields. Tell me how you identify the header and data records.
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

jebbin
Member
Posts: 2
Joined: Fri Nov 13, 2009 9:13 pm

Post by jebbin » Mon Nov 16, 2009 12:12 pm

Sample file:

Code: Select all

00000UHL1091109CBHCF
1001067578932000000148831000000000000200704100001004
1000567578932000000148831000000000000200704100001005
1000167578932000000148831000000000000200704100001006
1001067578932000000654893000000000000200702200001008
1000167578932000000654894000000000000200702200001008
1000567578932000000654894000000000000200702200001009
1001067578932000000654892000000000000200702200101011
1001067578932000001003931000000000000200701130101011
1001067578932000001004011000000000000200604050101010
1001067578932000001032311000000000000000000000101012
1000167578932000001208541000020060402200604030001106
1001067578932000001208541000020060402200604030001108
99999UTL100000012
Header: (1,5,ch,eq,'00000') or (6,4,eq,'UHL1')
Trailer: (1,5,ch,eq,'99999') or (6,4,eq,'UTL1').
The file first has to be sorted on the following criteria:
(6,20,CH,A,1,5,CH,A,26,1,CH,D,27,3,CH,D,30,8,CH,D,38,8,CH,D). After this duplicate needs to be removed based on (6,20,CH). I believe we would have to use two steps for this. first to sort on required criteria, but when duplicates are removed only (6,20,CH) should be considered. So its prob better to use a second step with Select rather than sum fields = none. LRECL=60 and RECFM = FB. Please let me know if you need more info.

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