MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Summarize numeric data with leading spaces using DFSORT

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
erasani
Beginner


Joined: 02 Oct 2021
Posts: 17
Topics: 7

PostPosted: Sat Oct 02, 2021 10:46 pm    Post subject: Summarize numeric data with leading spaces using DFSORT Reply with quote

Hi All,

I want to summarize the below Input Data based on first 11 positions. Basically, need to sum up the Amount fields. I have shown the Input and Output data below.

The complication is the Amount fields are with leading spaces. While summarizing, the Date field can be from any of the row and it doesnt matter.

I tried using DFSORT SUM FIELDS, got S0C7 due to leading spaces. Please let me know if there is any way i can achieve the desired output using ICETOOL or any other options. Thanks in advance.

Input Data:
Code:

----+----1----+----2----+----3----+--
11001213449     3.12    22.1109092021
11002334472    81.29    14.4409092021
11001213449    21.43     2.2910092021
11002334472     7.87     9.1310092021

Output Data:
Code:

----+----1----+----2----+----3----+--
11001213449    24.55    24.4009092021
11002334472    89.16    23.5709092021


Data layout

Code:

ACQ ID   - POSITIONS 01-05(5 BYTES)   
SYS NBR  - POSITIONS 06-09(4 BYTES)   
FEE TYPE - POSITIONS 10-11(2 BYTES) 
TOT AMT  - POSITIONS 12-20(9 BYTES) 
VOL AMT  - POSITIONS 21-29(9 BYTES) 
DATE     - POSITIONS 30-37(8 BYTES) 

Thanks
Prashanth
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sun Oct 03, 2021 2:16 am    Post subject: Reply with quote

erasani,

You have 2 options

1. You can use TRAILER 3 to summarize the free format data.
2. You can convert the UFF (Unsigned free format) or SFF(Signed free format) to Packed (PD), Zoned decimal(ZD) or Signed Binrary (FI) and then use SUM.

Option 1 will give you the data from the last record (in regards to the date field) and option 2 will give you the data from the first record provided you have equals coded.

Option 1: Untested
Code:

//STEP0100 EXEC PGM=SORT                         
//SYSOUT   DD SYSOUT=*                           
//SORTIN   DD *                                   
11001213449     3.12    22.1109092021             
11002334472    81.29    14.4409092021             
11001213449    21.43     2.2910092021             
11002334472     7.87     9.1310092021             
//SORTOUT  DD SYSOUT=*                           
//SYSIN    DD *                                   
  SORT FIELDS=(01,11,CH,A),EQUALS                 
                                                 
  OUTFIL REMOVECC,NODETAIL,                       
  SECTIONS=(01,11,                               
  TRAILER3=(01,11,                               
            TOT=(12,09,SFF,EDIT=(IIIIIT.TT)),     
            TOT=(21,09,SFF,EDIT=(IIIIIT.TT)),     
            30,8))                               
/*


Option 2: Untested
Code:

//STEP0100 EXEC PGM=SORT                   
//SYSOUT   DD SYSOUT=*                     
//SORTIN   DD *                           
11001213449     3.12    22.1109092021     
11002334472    81.29    14.4409092021     
11001213449    21.43     2.2910092021     
11002334472     7.87     9.1310092021     
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD *                           
  INREC OVERLAY=(38:12,09,SFF,PD,LENGTH=5,
                 44:21,09,SFF,PD,LENGTH=5)
                                           
  SORT FIELDS=(01,11,CH,A),EQUALS         
                                           
   SUM FIELDS=(38,05,PD,                   
               44,05,PD)                   
                                           
 OUTREC BUILD=(01,11,                     
               38,05,PD,EDIT=(IIIIIT.TT), 
               44,05,PD,EDIT=(IIIIIT.TT), 
               30,8)                       
/*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
erasani
Beginner


Joined: 02 Oct 2021
Posts: 17
Topics: 7

PostPosted: Sun Oct 03, 2021 11:19 pm    Post subject: Reply with quote

Thanks Kolusu..Both the options work perfectly fine
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group