JCL: Sum .. its urgent!!

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
Techie25
Member
Posts: 3
Joined: Thu Feb 26, 2009 2:37 am

JCL: Sum .. its urgent!!

Post by Techie25 » Thu Feb 26, 2009 3:09 am

Hi,
I have an input file which is as below:
Denis 100892 POS 320000 20-02-2009
Ralph 100893 POT 860000 22-02-2009
Denis 100892 POS 500000 20-02-2009
Ralph 100893 POT 880000 22-02-2009
Ralph 100893 POT 340000 22-02-2009
John 100895 POR 560000 23-02-2009
Denis 100892 POS 600000 20-02-2009



The ouput file should have a header record with sum of the 4th field and its detailed records below. The condition is that 1st, 2nd 3rd and 5th field should be same .
Since 'John'has only one record the output file should have 2 records saying its the header and also the detailed.

Desired output

Denis 100892 POS 1420000 20-02-2009 Header
Denis 100892 POS 600000 20-02-2009
Denis 100892 POS 500000 20-02-2009
Denis 100892 POS 320000 20-02-2009
John 100895 POR 560000 23-02-2009 Header
John 100895 POR 560000 23-02-2009
Ralph 100893 POT 2080000 22-02-2009 Header
Ralph 100893 POT 880000 22-02-2009
Ralph 100893 POT 860000 22-02-2009
Ralph 100893 POT 340000 22-02-2009

Please help me out!!
Many Thanks!!

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 Feb 26, 2009 3:47 am

You can use a DFSORT/ICETOOL job like the following to do what you asked for.

Code: Select all

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD *
Denis 100892 POS 320000 20-02-2009
Ralph 100893 POT 860000 22-02-2009
Denis 100892 POS 500000 20-02-2009
Ralph 100893 POT 880000 22-02-2009
Ralph 100893 POT 340000 22-02-2009
John  100895 POR 560000 23-02-2009
Denis 100892 POS 600000 20-02-2009
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC BUILD=(1,17,X,18,17,80:X)
  SORT FIELDS=(1,5,CH,A,7,6,CH,A,14,3,CH,A,26,10,CH,A)
  OUTFIL FNAMES=T1,REMOVECC,
   SECTIONS=(1,5,7,6,14,3,26,10,
     TRAILER3=(1,17,18:TOT=(18,7,UFF,EDIT=(IIIIIIT)),
      25,11,X,'Header'))
/*
//CTL2CNTL DD *
  OPTION EQUALS
  SORT FIELDS=(1,5,CH,A,7,6,CH,A,14,3,CH,A,26,10,CH,A,
   18,7,UFF,D,37,1,CH,D)
/*
OUT would have:

Code: Select all

Denis 100892 POS 1420000 20-02-2009 Header    
Denis 100892 POS  600000 20-02-2009           
Denis 100892 POS  500000 20-02-2009           
Denis 100892 POS  320000 20-02-2009           
John  100895 POR  560000 23-02-2009 Header    
John  100895 POR  560000 23-02-2009           
Ralph 100893 POT 2080000 22-02-2009 Header    
Ralph 100893 POT  880000 22-02-2009           
Ralph 100893 POT  860000 22-02-2009           
Ralph 100893 POT  340000 22-02-2009           
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

Techie25
Member
Posts: 3
Joined: Thu Feb 26, 2009 2:37 am

Post by Techie25 » Thu Feb 26, 2009 3:51 am

Thanks Frank i would test it and will let u know if further doubts....

Thank You again..
Many Thanks!!

Techie25
Member
Posts: 3
Joined: Thu Feb 26, 2009 2:37 am

Post by Techie25 » Sat Feb 28, 2009 8:35 pm

Hi Frank,
The above code works perfectly for the above set of inputs. How can i achieve the same if the file is VB of LRECL=2000? I added 4 to the positions and tried it abends.
Many Thanks!!

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 Mar 01, 2009 11:06 pm

Here's the DFSORT/ICETOOL job for a VB input file:

Code: Select all

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file (VB)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (VB)
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC BUILD=(1,4,5,17,X,22,17,46:X)
  SORT FIELDS=(5,5,CH,A,11,6,CH,A,18,3,CH,A,30,10,CH,A)
  OUTFIL FNAMES=T1,REMOVECC,
   SECTIONS=(5,5,11,6,18,3,30,10,
     TRAILER3=(1:5,17,18:TOT=(22,7,UFF,EDIT=(IIIIIIT)),
      29,11,X,'Header'))
/*
//CTL2CNTL DD *
  OPTION EQUALS
  SORT FIELDS=(5,5,CH,A,11,6,CH,A,18,3,CH,A,30,10,CH,A,
   22,7,UFF,D,41,1,CH,D)
/*
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