Portal | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Please help - SORT with SUM fields and filter on same step

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
clearskynot

New User


Joined: 21 Apr 2010
Posts: 7
Location: USA

PostPosted: Thu Apr 09, 2020 11:01 am    Post subject: Please help - SORT with SUM fields and filter on same step
Reply with quote

Hi, I have 2 questions on using DFSORT on a FB dataset with 2 fields - Branch nbr, dollar value (PD). I want to group the input records on Branch Nbr and sum on the dollar field. I want to write to output file ONLY if the sum on dollar field is not 0.00 and less than 100.00.

1. Is it possible to achieve this in ONE sort step?
2. How should packed decimal be coded in include condition in sort step?

I/P file looks like below
A001 -100.00
A001 100.00
A002 300.00
A002 -250.00
A003 -400.00
A003 600.00

O/P file I need should be:
A002 50.00

I can do this in 2 sort steps but I was trying to do this in one step if possible. This is my first post. Hopefully, I have provided enough information to look into this. Can you please help?
Back to top
View user's profile Send private message

Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 336
Location: Bamberg, Germany

PostPosted: Thu Apr 09, 2020 11:35 am    Post subject:
Reply with quote

What have you tried? Please use code tags to make it easier to understand.
Back to top
View user's profile Send private message
clearskynot

New User


Joined: 21 Apr 2010
Posts: 7
Location: USA

PostPosted: Thu Apr 09, 2020 11:54 am    Post subject:
Reply with quote

Joerg.Findeisen wrote:
What have you tried? Please use code tags to make it easier to understand.


Thanks for looking into it. I could not get it in one step.
Below is how i was able to get the desired output with 2 steps:

1. SORT FIELDS=(1,4,CH,A)
SUM FIELDS=(5,6,PD)

2. SORT FIELDS=COPY
INCLUDE COND=(5,6,PD,NE,0,AND,5,6,PD,LT,10000)
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 336
Location: Bamberg, Germany

PostPosted: Thu Apr 09, 2020 12:24 pm    Post subject:
Reply with quote

Use OUTFIL and put your INCLUDE in there. That should be it. You are close to your One Ring to rule them All solution.
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 857
Location: Maryland

PostPosted: Thu Apr 09, 2020 6:12 pm    Post subject:
Reply with quote

The developers of all SORT products allowed to include their control statements in any order under //SYSIN DD.

This resulted in a huge mess in the beginners' mind, because they do not catch the order each statement is processed.

In practice, it make sense (much more sense than it appears from the first sight): to code statements in the same order they are handled by the SORT product. There is such diagram in existing manuals, but nobody pays any attention to it (if had RTFM at all).

The order of statements is as follows
Code:
 INCLUDE/OMIT COND=…
 INREC …
 SORT …
 SUM …
 …
 OUTREC …
 OUTFIL [INCLUDE/OMIT=…]
 OUTFIL [INCLUDE/OMIT=…]
 END

In case of JOIN operation
Code:
 JOINKEYS F1=…,[INCLUDE/OMIT=…]
 JOINKEYS F2=…,[INCLUDE/OMIT=…]
 JOIN UNPAIRED,...
 REFORMAT
 INCLUDE/OMIT COND=...
 SORT …
 SUM …
 …
 OUTREC …
 OUTFIL [INCLUDE/OMIT=…]
 OUTFIL [INCLUDE/OMIT=…]
 END
Back to top
View user's profile Send private message
clearskynot

New User


Joined: 21 Apr 2010
Posts: 7
Location: USA

PostPosted: Fri Apr 10, 2020 3:43 am    Post subject:
Reply with quote

Joerg.Findeisen wrote:
Use OUTFIL and put your INCLUDE in there. That should be it. You are close to your One Ring to rule them All solution.


That worked perfectly ! thank you !
Back to top
View user's profile Send private message
clearskynot

New User


Joined: 21 Apr 2010
Posts: 7
Location: USA

PostPosted: Fri Apr 10, 2020 3:43 am    Post subject:
Reply with quote

sergeyken wrote:
The developers of all SORT products allowed to include their control statements in any order under //SYSIN DD.

This resulted in a huge mess in the beginners' mind, because they do not catch the order each statement is processed.

In practice, it make sense (much more sense than it appears from the first sight): to code statements in the same order they are handled by the SORT product. There is such diagram in existing manuals, but nobody pays any attention to it (if had RTFM at all).

The order of statements is as follows
Code:
 INCLUDE/OMIT COND=…
 INREC …
 SORT …
 SUM …
 …
 OUTREC …
 OUTFIL [INCLUDE/OMIT=…]
 OUTFIL [INCLUDE/OMIT=…]
 END

In case of JOIN operation
Code:
 JOINKEYS F1=…,[INCLUDE/OMIT=…]
 JOINKEYS F2=…,[INCLUDE/OMIT=…]
 JOIN UNPAIRED,...
 REFORMAT
 INCLUDE/OMIT COND=...
 SORT …
 SUM …
 …
 OUTREC …
 OUTFIL [INCLUDE/OMIT=…]
 OUTFIL [INCLUDE/OMIT=…]
 END


Thank you for looking into this!
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 Copying data from prev record using SORT bshkris SYNCSORT 19 Thu Oct 15, 2020 3:29 pm
No new posts Combining more 4 files with sorted or... bshkris DFSORT/ICETOOL 3 Thu Oct 08, 2020 10:57 am
No new posts Break a record into fields, each fiel... jackare SYNCSORT 2 Thu Oct 08, 2020 5:26 am
This topic is locked: you cannot edit posts or make replies. Parsing more than 1000 columns in a s... ssuthagar SYNCSORT 10 Tue Sep 22, 2020 12:23 am
This topic is locked: you cannot edit posts or make replies. SORT the records based on the second ... Ramsee SYNCSORT 1 Wed Aug 19, 2020 3:01 pm

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