|
View previous topic :: View next topic
|
| Author |
Message |
rohanthengal
Active User
.jpg)
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)
/* |
|
| Back to top |
|
 |
smijoss
Active User
Joined: 30 Aug 2007 Posts: 114 Location: pune
|
|
|
|
| Code: |
//SYSIN DD *
INREC FIELDS=(1,4,c'00',5,2)
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(5,4,ZD)
/*
|
|
|
| Back to top |
|
 |
rohanthengal
Active User
.jpg)
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
Thanks joss..
would you please explain how does it work ? |
|
| Back to top |
|
 |
rohanthengal
Active User
.jpg)
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
Thanks joss... once again i have understood it properly !
But i didnt get the meaning of C and X !
When should i go for X and when for C ? |
|
| Back to top |
|
 |
smijoss
Active User
Joined: 30 Aug 2007 Posts: 114 Location: pune
|
|
|
|
only Z stand for binary zero i.e. hex 00
only X would stand for a space : hex 40
C'<text>' stand for string
X'nn' stand for hex nn (in your case x'00' stands for low values)
if you need to understand it better ,
remove the SUM line and run the code ... u ll understand the editing
go through DFSORT: Getting Started
everything is given in detail hardly takes 2 day to finish off |
|
| Back to top |
|
 |
smijoss
Active User
Joined: 30 Aug 2007 Posts: 114 Location: pune
|
|
|
|
since you were using ZD i padded 0 to the left of you number to change the length of you field.
if it was binary (pic comp) you could have used X'00' or Z. it would have looked like
| Code: |
//SYSIN DD *
INREC FIELDS=(1,4,2Z,5,2)
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(5,4,BI)
/*
|
OR
| Code: |
//SYSIN DD *
INREC FIELDS=(1,4,x'0000',5,2)
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(5,4,BI)
|
/* |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a better way to do this with DFSORT - better because you don't have to know which kind of zeros to pad with - DFSORT figures it out for you:
For ZD value in 5-6:
| Code: |
INREC BUILD=(1,4,5,2,ZD,TO=ZD,LENGTH=4)
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(5,4,ZD)
|
For BI value in 5-6:
| Code: |
INREC BUILD=(1,4,5,2,ZD,TO=BI,LENGTH=4)
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(5,4,BI)
|
|
|
| Back to top |
|
 |
Gabriel Araujo Alves
New User
Joined: 20 Jul 2010 Posts: 38 Location: Brazil
|
|
|
|
Why when i put this, the second zero doesn't display?
| Code: |
| INREC FIELDS=(1,3,05,02,ZD,M11,LENGTH=04) |
look at sysout
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

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. |
|
| Back to top |
|
 |
Gabriel Araujo Alves
New User
Joined: 20 Jul 2010 Posts: 38 Location: Brazil
|
|
|
|
Look like i do...
| Code: |
//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 SYSOUT=*
//SYSIN DD *
INREC FIELDS=(1,3,05,02,ZD,M11,LENGTH=04)
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(5,2,ZD)
/* |
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

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:
Not sure what you were trying to do but whatever it is, you didn't do it right. |
|
| Back to top |
|
 |
Gabriel Araujo Alves
New User
Joined: 20 Jul 2010 Posts: 38 Location: Brazil
|
|
|
|
Really, i forget that inrec reformatted the fields.
thanks... |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|