IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Query on summing up the fields


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Mon Jan 21, 2019 7:18 pm
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Mon Jan 21, 2019 7:37 pm
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

Senior Member


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

PostPosted: Tue Jan 22, 2019 12:04 pm
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: 8797
Location: Welsh Wales

PostPosted: Tue Jan 22, 2019 12:37 pm
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

Senior Member


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

PostPosted: Tue Jan 22, 2019 4:03 pm
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: 2481
Location: @my desk

PostPosted: Tue Jan 22, 2019 6:42 pm
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

Senior Member


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

PostPosted: Wed Jan 23, 2019 12:53 am
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Wed Jan 23, 2019 9:20 pm
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

Senior Member


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

PostPosted: Fri Jan 25, 2019 3:08 am
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: 184
Location: Coimbatore

PostPosted: Tue Jan 29, 2019 7:23 pm
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: 2481
Location: @my desk

PostPosted: Wed Jan 30, 2019 7:55 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top