Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
I am trying to sum up in the case of overflow also. I referred manual but not getting exact usgae of INREC statement with X'00 etc. to handle overflow..! Please assist me in this to handle overflow....!
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SORTIN DD *
ONE 12
TWO 23
ONE 28
ONE 30
TWO 78
ONE 10
//SORTOUT DD DSN=xxx.DFSORT.OUTPUT,DISP=SHR
//SYSIN DD *
INREC FIELDS=(1,3,4:X'00')
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(5,2,ZD)
/*
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
M11 adjusts the pattern according to the implicit length of the input field (2 in this case). Specifying LENGTH extends the pattern with blanks on the left. EDIT=(TTTT) would give leading zeros if that's what you want.
I assume you have a SORT and SUM statement but I don't know what they look like. Please show ALL of the control statements you're using. Once I know the statements you're using, I'll be able to explain why you got what you got.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Your INREC and SORT statements give this result:
Code:
ONE 12
ONE 10
ONE 28
ONE 30
TWO 78
TWO 23
p,2,ZD,M11 gives TT because the input length is 2. LENGTH=4 extends that with 2 blanks on the left to give bbTT.
Your SUM statement is summing on 5,2,ZD instead of 6,2,ZD so you're actually summing ' 1' instead of '12', etc. This gives 07 for ONE and 09 for TWO in positions 5-6, and the 7th position is taken from the first record with each key. So you end up with:
Code:
ONE 072
TWO 098
Not sure what you were trying to do but whatever it is, you didn't do it right.