sumfields on two fields



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

sumfields on two fields

Postby Sunindia » Sun Sep 03, 2017 10:54 am

Hi,

I have a below JCL. My input file has 5 fields,
Field1: Position 1 to 3(Primary Key)
Field2: Position 3 to 6
Field3: Position 7 to 9
Field4: Position 10 to 17
Field5: Position 18 to 20
I am trying to Sum two fields on the input file based on the Primary Key.
//SORTIN   DD  *                          
CDE00010020170831                        
CDE100000             ABC                      
CDE00010020170831                        
CDE100000             ABC                      
/*                                        
//SORTOUT  DD  SYSOUT=*                  
//SYSIN    DD  *                          
  SORT FIELDS=(1,3,CH,A)        
  SUM FIELDS=(4,3,ZD,7,3,ZD)              
/*        
 

Actual Result:
CDE20020020170831    

Expeced Result:
CDE20020020170831ABC


My expectation is when Value for a particular field is empty, take the value from next record. Can this be achieved using SORT?

Thank You.
Sunindia
 
Posts: 2
Joined: Sun Sep 03, 2017 10:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: sumfields on two fields

 

Re: sumfields on two fields

Postby Aki88 » Wed Sep 06, 2017 7:39 pm

Hello,

You're getting the output as below, because *SORT retains the first record as the base, and sums the remaining records into this record on the keys specified in the 'SORT FIELDS' keyword:


CDE20020020170831
 


Before we move to the solution, can you please let us know the expected output in case the input looks as below.
Note that I've shuffled the order of records slightly; but it still remains in-line with your original requirement.


//SORTIN   DD  *                          
CDE00010020170831                        
CDE100000             CDE                    
CDE00010020170831                        
CDE100000             ABC                      
CDE00010020170831                        
CDE100000             ABC                    
CDE00010020170831                        
CDE100000             CDE                      
/*          
 
Aki88
 
Posts: 369
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 35 times

Re: sumfields on two fields

Postby Sunindia » Wed Sep 06, 2017 8:13 pm

@Aki88, Thanks for the response.
Expected result:
CDE20020020170831ABC
CDE20020020170831CDE
Sunindia
 
Posts: 2
Joined: Sun Sep 03, 2017 10:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: sumfields on two fields

Postby Aki88 » Wed Sep 06, 2017 8:21 pm

Hello,

Umm, the expected output in this case might be incorrect if we go by the original post's expectation.
Can you please explain the logic on how this output was deduced; once you do the maths, you'll see the rationale behind my first statement.

Once we have this part figured out, then in solution, ICETOOL's extended operators such as FIRST, LAST etc. can be employed; or a logic can be built in DFSORT to achieve what you want.
Aki88
 
Posts: 369
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 35 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post