Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DFSORT report using count and sum

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: DFSORT report using count and sum
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 Moderator


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

PostPosted: Tue Jun 30, 2009 9:10 pm    Post subject:
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    Post subject: Reply to: DFSORT report using count and sum
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 Moderator


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

PostPosted: Wed Jul 01, 2009 10:06 pm    Post subject:
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    Post subject: Reply to: DFSORT report using count and sum
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts Detailed Transaction History report f... Kyle Carroll CICS 5 Tue Oct 18, 2016 12:42 am
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Easytrieve - Report writing - Only 1 ... Abhi Nature CA Products 2 Wed Sep 14, 2016 11:40 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us