The output should contian the summed up value for amount field for a particular bank. It should contain a header for a bank with sum of the amount and all the records contributiong for that sum should be present below. The expected output is
Joined: 02 Jan 2009 Posts: 115 Location: Hyderabad
Couldn't do this using ICETOOL/SORT. SO I am trying using ICEMAN
As a first step i tried using ICEMAN with the following sort card
Code:
//SYSIN DD *
OPTION VLSHRT
SORT FIELDS=(31,5,CH,A)
SUM FIELDS=(5,4,ZD)
/*
But in the sum value of the o/p file, i am getting some junk values in the last character. Merge a key to all these records "header" or at the end 01,02,03 .
and step I tried to merge the output of setp one with original file using a key that was put in step one.
This is just an idea i have. And I am working on it.
Folks, Please help If you have any ideas.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
kranthikumarb,
There are a couple of problems with the code you have shown. What happens if the amount when summed exceeds 9999? Since you only 4 bytes to accomdate the amount, would you truncate? Also you are only creating a 38 byte output file. Is that you really want? Based on the control cards you used here is a 2 step process which would give you the desired results.
Code:
//* CREATE 2 FILES
//* HDR = SUM OF AMOUNT FIELDS BASED ON BANK AND ADD KEYWORD HEADER
//* DTL = APPEND THE KEYWORD "DETAIL" TO EACH RECORD
//*
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=INPPUT,DISP=SHR
//HDR DD DSN=&&H1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//DTL DD DSN=&&D1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN DD *
OPTION VLSHRT
SORT FIELDS=(28,5,CH,A)
OUTFIL FNAMES=HDR,REMOVECC,NODETAIL,BUILD=(1,4,34X),
SECTIONS=(28,5,
TRAILER3=(C'HEADER',
TOT=(5,4,ZD,M11,LENGTH=4),
X,10,10,1X,21,6,1X,28,5))
OUTFIL FNAMES=DTL,
BUILD=(1,4,C'DETAIL',5,4,1X,10,10,1X,21,6,1X,28,5)
/*
//* SORT THE ABOVE 2 FILES SO AS TO GROUP THE SAME BANK RECORDS TOGETHER
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&H1,DISP=SHR
// DD DSN=&&D1,DISP=SHR
//SORTOUT DD SYSOUT=*
OPTION VLSHRT,EQUALS
SORT FIELDS=(34,5,CH,A)
/*
Joined: 02 Jan 2009 Posts: 115 Location: Hyderabad
Hi skolusu,
Thanks for your reply. But the one I poseted is a trial version kinda thing. I tested with some sample input just. I've taken care about the amount fields ( 4 chars....) in the original JCL.
Never the less I've taken your code as well, I'll implement the best logic.
Once again many thanks.