Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 22 Sun Aug 27, 2017 10:35 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us