|
|
| Author |
Message |
agsathyan
New User
Joined: 06 Apr 2009 Posts: 3 Location: India
|
|
|
|
Hi Team,
We are using Z/OS DFSORT V1R5 in our shop.
Input:
File:
Format:VB
LRECL: 532
Data Types:
TYPE : CHAR(1) starts at position 31
AMOUNT: DEC FIXED (9,2) starts at position 77 (just for clarity, I have mentioned below amounts in readable form)
| Code: |
TYPE AMOUNT
A 0.00
M +31.75
I +8.50
A -11.44
M -25.75
I -30.34
A +55.12
I 0.00
|
Requirement:
a) sort based on TYPE
b) count based on values i.e, positive ( >0), negative ( <0) and zero ( =0)
c) sum based on values i.e, positive ( >0), negative ( <0) and zero ( =0)
Output:
To be in readable report format as below
Note: since M does not have a 0.00 in input, output count should be populated with a 0
| Code: |
TYPE POSITIVE NEGATIVE ZERO POSITIVE-SUM NEGATIVE-SUM
A 1 1 1 +55.12 -11.44
I 1 1 1 +8.50 -30.45
M 1 1 0 +31.75 -25.75
|
File:
Format:FB
LRECL: 133
Can anyone help me here? |
|
| Back to top |
|
 |
References
|
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 5978 Location: San Jose, CA
|
|
|
|
It isn't clear from your example exactly what you want to do.
Can you only have at most one positive, one negative and one zero value for each type as shown in your example? Or can you actually have mre than one of each value? For example, could you have:
| Code: |
A +31.75
A +22.83
A -16.00
A -12.00
A 0.00
A 0.00
|
and if so, what would you want for the output record?
Also, when you give the position as 31, is that counting the RDW in positions 1-4 or is the position really 35, not 31? |
|
| Back to top |
|
 |
agsathyan
New User
Joined: 06 Apr 2009 Posts: 3 Location: India
|
|
|
|
Thanks for your reply... please find more information:
a) there can be more TYPE and more AMOUNT. like as you said
| Code: |
A can have +31.75,+22.83,-16.00,-12.00,0.00,0.00 .....
I can have +8.50,-30.34,0.00,-55.95,-9.99 ......
M can have +33.87,-3.89,0.00,-45,76,0.00,0.00 .....
X can have +22.83,+33.87,-12.00,0.00 ....
B can have +33.87,-3.89,0.00,-45.00,-76.00,-23.45,0.00 .....
:
|
b) in output, I want TYPE to be in sorted order and
count of all positive, negative, zero values, total of all positive values and total of all negative values for a given TYPE. for example, with above inputs, output should be as below:
| Code: |
TYPE POSITIVE NEGATIVE ZERO POSITIVE-SUM NEGATIVE-SUM
A 2 2 2 +54.58 -28.00
B 1 4 2 +33.87 -148.34
I 1 3 1 +8.50 -96.28
M 1 2 3 +22.83 -28.00
X 2 1 1 +56.70 -12.00
|
c) regarding positions,
This count does not include RDW and it is the real position of fields TYPE and AMOUNT as below:
TYPE : CHAR(1) starts at position 31
AMOUNT: DEC FIXED (9,2) starts at position 77
Hope this is clear now.
Thanks in advance for your support. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 5978 Location: San Jose, CA
|
|
|
|
Here's a DFSORT job that will do what you asked for.
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB/532)
//SORTOUT DD DSN=... output file (FB/133)
//SYSIN DD *
INREC IFTHEN=(WHEN=(81,5,PD,GT,0),
BUILD=(1,4,5:35,1,6:C'100',9:81,5,14:X'000000000C')),
IFTHEN=(WHEN=(81,5,PD,LT,0),
BUILD=(1,4,5:35,1,6:C'010',9:X'000000000C',14:81,5)),
IFTHEN=(WHEN=NONE,
BUILD=(1,4,5:35,1,6:C'001',9:2X'000000000C'))
SORT FIELDS=(5,1,CH,A)
OUTFIL VTOF,REMOVECC,NODETAIL,
HEADER2=('TYPE POSITIVE NEGATIVE ZERO POSITIVE-SUM ',
'NEGATIVE-SUM'),
BUILD=(133X),
SECTIONS=(5,1,
TRAILER3=(2:5,1,
14:TOT=(6,1,ZD,M10,LENGTH=2),
24:TOT=(7,1,ZD,M10,LENGTH=2),
30:TOT=(8,1,ZD,M10,LENGTH=2),
40:TOT=(9,5,PD,EDIT=(+IIT.TT)),
55:TOT=(14,5,PD,EDIT=(-IIT.TT))))
/*
|
|
|
| Back to top |
|
 |
agsathyan
New User
Joined: 06 Apr 2009 Posts: 3 Location: India
|
|
|
|
Thank you very much Frank, really amazed with your code and its result...
HATS OFF
Thanks for your support.. |
|
| Back to top |
|
 |
|
|
|