IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DFSORT report using count and sum


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
agsathyan

New User


Joined: 06 Apr 2009
Posts: 4
Location: India

PostPosted: Tue Jun 30, 2009 2:53 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Jun 30, 2009 9:10 pm
Reply with quote

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
View user's profile Send private message
agsathyan

New User


Joined: 06 Apr 2009
Posts: 4
Location: India

PostPosted: Wed Jul 01, 2009 9:48 am
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jul 01, 2009 10:06 pm
Reply with quote

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
View user's profile Send private message
agsathyan

New User


Joined: 06 Apr 2009
Posts: 4
Location: India

PostPosted: Thu Jul 02, 2009 11:56 am
Reply with quote

Thank you very much Frank, really amazed with your code and its result...
HATS OFF icon_smile.gif
Thanks for your support..
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top