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

Need Guidance with SORT to Find Sum of Each Digit of a Field


IBM Mainframe Forums -> HomeWorks & Requests
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
satish.ms10

Active User


Joined: 10 Aug 2009
Posts: 184
Location: India

PostPosted: Thu Jun 08, 2023 12:55 pm
Reply with quote

Hi All,

Hope you are doing well.

I am merging and sort two files using DFSORT and I have a situation to find the sum of each digit of a field in my input file.

Sample data looks like:

Field_1: 1 - 6 (6 bytes)
Field_2: 7 - 11 (5 bytes)

Code:

A1234511111
A1234622222
A1234733333
A1234844444


I want to find sum of each digit from Field_2 and place the value at end of the record from 12 to 14 (3 bytes). Example: 1+1+1+1+1 = 5

Expected Output:

Code:

A1234511111005
A1234622222010
A1234733333015
A1234844444020


Is this possible with DFSORT? Could you please guide which command(s) I should refer from DFSORT?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Thu Jun 08, 2023 2:42 pm
Reply with quote

Code:
OPTION COPY                                             
INREC OVERLAY=(12:((((7,1,ZD,ADD,8,1,ZD),ADD,9,1,ZD),ADD,
               10,1,ZD),ADD,11,1,ZD),M11,LENGTH=3)       
END
Back to top
View user's profile Send private message
satish.ms10

Active User


Joined: 10 Aug 2009
Posts: 184
Location: India

PostPosted: Thu Jun 08, 2023 3:20 pm
Reply with quote

Hi Joerg.Findeisen,

Thank you so much for your quick reply.

Just to check, is there any option if the numeric field is in PACKED DECIMAL format.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Thu Jun 08, 2023 4:20 pm
Reply with quote

Why not try it yourself? It should work as well.
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 -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top