View previous topic :: View next topic
|
Author |
Message |
dip62001
New User
Joined: 04 Jul 2005 Posts: 12 Location: Pune
|
|
|
|
CAn anyone given me the JCL for the below query please:
My input is :
Code: |
ABCDEFGHIJK T 3
LSKDSLDKSLS L 4
KSDKLADALKS T 4
ABCDEFGHIJK L 3
KSDKLADALKS T 2
LSKDSLDKSLS T 1
LSKDSLDKSLS T 3
LSKDSLDKSLS L 3
ABCDEFGHIJK T 1
ABCDEFGHIJK L 3
ABCDEFGHIJK L 2
|
tHE OUTPUT SHOULD LOOK LIKE:
Code: |
ABCDEFGHIJK T 4
ABCDEFGHIJK L 8
KSDKLADALKS T 6
LSKDSLDKSLS T 4
LSKDSLDKSLS L 7
|
in short , the Field 3 should be added based on Field1 and Field2
Field 2 can have the value T or L ... the output in Field3 should contain the sum based on Field1 with T , and Field1 with L (if there is any ) |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a DFSORT job that will do what you asked for. Although your example shows only 1 byte numeric values and totals in position 18, I assumed that your numeric values were actually in positions 15-18 and coded for that. I also added records with 2 byte numeric values for a better test. You can adjust the job if appropriate.
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABCDEFGHIJK T 3
LSKDSLDKSLS L 4
KSDKLADALKS T 4
ABCDEFGHIJK L 3
KSDKLADALKS T 2
LSKDSLDKSLS T 1
LSKDSLDKSLS T 3
LSKDSLDKSLS L 3
ABCDEFGHIJK T 1
ABCDEFGHIJK L 3
ABCDEFGHIJK L 2
11111111111 T 19
11111111111 T 13
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION ZDPRINT
SORT FIELDS=(1,11,CH,A,14,1,CH,D)
SUM FIELDS=(15,4,ZD)
OUTREC OVERLAY=(15:15,4,ZD,EDIT=(IIIT))
/*
|
SORTOUT would have:
Code: |
ABCDEFGHIJK T 4
ABCDEFGHIJK L 8
KSDKLADALKS T 6
LSKDSLDKSLS T 4
LSKDSLDKSLS L 7
11111111111 T 32
|
|
|
Back to top |
|
|
dip62001
New User
Joined: 04 Jul 2005 Posts: 12 Location: Pune
|
|
|
|
Hi
I cannot use ICEMAN here ... Can you send me the JCL with ICETOOL or SORT ?
Field1 is at column1 length 11
Field2 is at column 20 length 1 (value L or T)
Field3 is at column 22 length (upto 8 digits) |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Solution given by Frank should work for SORT also..
What error you are getting? post it here |
|
Back to top |
|
|
dip62001
New User
Joined: 04 Jul 2005 Posts: 12 Location: Pune
|
|
|
|
I am getting a SOC7 error |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
I cannot use ICEMAN here ... Can you send me the JCL with ICETOOL or SORT ? |
This statement makes no sense. PGM=ICEMAN and PGM=SORT both invoke DFSORT.
Quote: |
I am getting a SOC7 error |
That would be caused by an invalid ZD value in positions 15-18 (the SUM field). Since you didn't say, I had to guess at what positions your ZD field was in. You only showed one digit in your example and I assumed that digit was at position 18.
Given the new information you've supplied about the actual positions of your fields, you would need the following DFSORT job:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION ZDPRINT
SORT FIELDS=(1,11,CH,A,20,1,CH,D)
SUM FIELDS=(22,8,ZD)
OUTREC OVERLAY=(22:22,8,ZD,EDIT=(IIIIIIIT))
/*
|
|
|
Back to top |
|
|
|