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
 

 

Create totals from negative and positive values

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

Active User


Joined: 20 May 2010
Posts: 101
Location: canada

PostPosted: Thu Oct 03, 2013 3:16 am    Post subject: Create totals from negative and positive values
Reply with quote

Hi, Please help me:

I have file with 3 columns A - flag, B - amount, C- amount. this is sample:

F 100 200
K -10 100
K 30 -30
F -15 -20
F 20 -15
K 10 10

I need neg & pos totals by flags:

Flag column B (+) column B(-) column C (+) column C (-)
F 120 -15 200 -35
K 40 -10 110 -30

is it possible in sort or icetool?

Thanks.
Back to top
View user's profile Send private message

anatol

Active User


Joined: 20 May 2010
Posts: 101
Location: canada

PostPosted: Thu Oct 03, 2013 3:47 am    Post subject: Reply to: Create totals from negative and positive values
Reply with quote

better in code - to see the positions


Code:
 F    100   200 
 K    -10   100 
 K     30   -30 
 F    -15   -20 
 F     20   -15 
 K     10    10 


I need:

Code:
FLAG COLUMN B (+) COLUMN B(-) COLUMN C (+) COLUMN C (-)         
F       120         -15           200          -35               
K        40         -10           110          -30               
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Oct 03, 2013 4:13 am    Post subject:
Reply with quote

anatol,

It is tough to provide solutions with least details. You haven't mentioned anything about

1. The LRECL or RECFM of the Input/Output file
2. The length of each field to be summed.
3. The format of the field to be summed is it display or binary zoned decimal or packed decimal fields?


Assuming your input is display numeric fields(SFF) format, you can follow the below steps to get the desired results.


1. Create Key + 4slots of Packed decimal zeros and put the numeric values at the end say pos 81.

2. Use INREC IFTHEN to check for the values at position 81 for the length of the each field to find a space or plus sign for positive numeric values and then OVERLAY the 1 zero packed decimal slot with the value at 81 treating it as SFF and code HIT=NEXT for validating all the fields

3.Use another IFTHEN to check for the values at position 81 for the length of the each field to find a minus sign for negative numeric values and then OVERLAY the 2nd zero packed decimal slot with the value at 81 treating it as SFF and code HIT=NEXT for validating all the fields

4. Repeat step 2 and 3 for the next field which is at 87.

5. Sort on the key

6. SUM on the 4 PD slots

7. Using OUTREC convert the PD fields to readable format using edit masks
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 101
Location: canada

PostPosted: Thu Oct 03, 2013 5:08 am    Post subject: Reply to: Create totals from negative and positive values
Reply with quote

Thank you... the sample I've provided is not actual data - I need just idea for totals... it could be recfm=fb. lrecl=80... positions is irrelevant... need idea, i think I can create something, using your steps... Thanks
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 SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm


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