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: 1338
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: 1338
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 Help with SORT - I need to validate d... DFSORT/ICETOOL 7
No new posts Help required to reset decimal points... DFSORT/ICETOOL 10
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Is this possible via sort (in one pass)? SYNCSORT 4
No new posts GDG generation name to GDG Base name ... DFSORT/ICETOOL 3
Search our Forums:

Back to Top