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
 
Query on summing up the fields

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

Active User


Joined: 14 Sep 2009
Posts: 168
Location: Coimbatore

PostPosted: Mon Jan 21, 2019 7:18 pm    Post subject: Query on summing up the fields
Reply with quote

Hi,

Can you please help me with a solution for an issue.

Input file:
Code:
1234567890-000000160-000000156
1234567890-000000159 000000155
1234567890 000000158-000000154


The sort card I used to convert SFF to ZD is,
Code:
SORT FIELDS=COPY               
OUTREC BUILD=(1,10,           
              10,10,SFF,TO=ZD,
              20,10,SFF,TO=ZD)


The sort card used to convert back to SFF format is,
Code:
SORT FIELDS=(1,10,CH,A)       
SUM FIELDS=(10,10,20,10),FORMAT=ZD

Note: I do have 80 columns to be summed up like this. I have mentioned two of it as an sample.

Expected Output file:
Code:
1234567890-000000161-000000155


But am getting output as,
Code:
123456789000000001610000000155



Query:
How can I get it back to SFF format(original format) after addition. Can you please help me ?.

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

Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2104
Location: NY,USA

PostPosted: Mon Jan 21, 2019 7:37 pm    Post subject:
Reply with quote

One way to solve is to make a use of EDIT/SIGN option in SECTIONS and TRAILER3.
Back to top
View user's profile Send private message
Joerg.Findeisen

New User


Joined: 15 Aug 2015
Posts: 16
Location: Germany

PostPosted: Tue Jan 22, 2019 12:04 pm    Post subject:
Reply with quote

SECTIONS would work if it is presorted already. It makes more sense to me to first convert the SFF (or CSF) fields to PD and SUM them up then. OUTREC/OUTFIL will later do what's requested using the suggested EDIT and SIGNS method.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8763
Location: Welsh Wales

PostPosted: Tue Jan 22, 2019 12:37 pm    Post subject:
Reply with quote

Ok, just from an admin point of view.

Please explain to me what the hell this topic has to do with VSAM or JCL.
Pleeeeeeease do not tell me that you are running a JCL for this
There are two forum sections, on each for both of the major sort products, just in case that you had not noticed.

So which sort product are you using, and it's release level - and the topic will be moved accordingly.

If no response is receive the topic will be locked.
Back to top
View user's profile Send private message
Joerg.Findeisen

New User


Joined: 15 Aug 2015
Posts: 16
Location: Germany

PostPosted: Tue Jan 22, 2019 4:03 pm    Post subject:
Reply with quote

@expat: Move it to DFSORT section please. Guess that is the closest match.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2454
Location: @my desk

PostPosted: Tue Jan 22, 2019 6:42 pm    Post subject:
Reply with quote

Quote:
SORT FIELDS=(1,10,CH,A)
SUM FIELDS=(10,10,20,10),FORMAT=ZD
If your sort key is at position 1-10, I'd assume your sum field would start at pos-11 instead of 10.
Back to top
View user's profile Send private message
Joerg.Findeisen

New User


Joined: 15 Aug 2015
Posts: 16
Location: Germany

PostPosted: Wed Jan 23, 2019 12:53 am    Post subject:
Reply with quote

Last line of the sample input should have two spaces after the key I'd say. Best way to avoid any overlaps seem to be a PARSE with FIXLEN=10 and REPEAT.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2104
Location: NY,USA

PostPosted: Wed Jan 23, 2019 9:20 pm    Post subject:
Reply with quote

Joerg.Findeisen, Right and TS is sorting the records in the snippet shown in the first post , that can be leveraged in SECTIONS solution.

Let us wait for TS to respond us further.
Back to top
View user's profile Send private message
Joerg.Findeisen

New User


Joined: 15 Aug 2015
Posts: 16
Location: Germany

PostPosted: Fri Jan 25, 2019 3:08 am    Post subject:
Reply with quote

@Rohit: You are right of course, thanks for pointing that out to me. I started right away with having had a look at the two sort steps initially provided. Your proposal is the easiest one as it does not require any previous converts.

If there are additional conditions to be applied I'd rather use the SUM statement instead.

Cheers,
Joerg
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 168
Location: Coimbatore

PostPosted: Tue Jan 29, 2019 7:23 pm    Post subject:
Reply with quote

Hi Rohit,

I achieved it using EDIT/SIGN. Thanks for your help. I need one more help on the same.

Input file: I do have the same record with header and trailer and also some additional records in the same file.
Code:

H20190129000000
1234567890  -000000160-000000156
1234567890  -000000159 000000155
1234567890   000000158-000000154
T00003
H20190129000000
1234567890  -000000160-000000156
1234567890  -000000159 000000155
1234567890   000000158-000000154
1234567890   000000158-000000154
T00004


Expected output:
I do have few more columns in input file, using keys I am summing it up and I have to update the trailer count for that particular Header and Trailer like below. Here for ex, am grouping and summing up the second set and the output has to be like,
Code:

H20190129000000
1234567890  -000000160-000000156
1234567890  -000000159 000000155
1234567890   000000158-000000154
T00003
H20190129000000
1234567890  -000000160-000000156
1234567890  -000000159 000000155
1234567890   000000158-000000154
T00003


Can you please help me a way to achieve it ?. I can have how many ever Header and trailer in the same file. but it has to update only for that particular set.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2454
Location: @my desk

PostPosted: Wed Jan 30, 2019 7:55 pm    Post subject:
Reply with quote

abdulrafi,
Quote:
Here for ex, am grouping and summing up the second set
What amount have you summed up in the second set? Looks like you just got rid of the last duplicate record. After summing on the keys, will it not be one record for the key-1234567890 in the second set?
Quote:
it has to update only for that particular set
How do you identify a 'particular set'?
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 General Query on DB2 table design subratarec DB2 3 Thu Feb 14, 2019 12:49 pm
No new posts Query on secondary index Suja.Sai IMS DB/DC 1 Wed Oct 31, 2018 9:47 pm
No new posts Query regarding STOP REGION XX ABDU... ashek15 IMS DB/DC 11 Fri Oct 19, 2018 10:13 am
No new posts Facing issue while executing multi ro... aagarwal88 DB2 6 Tue Oct 02, 2018 8:11 am
No new posts DB2 SQL Query to fetch all instances ... MallikarjunSM DB2 2 Thu Sep 27, 2018 6:46 pm

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