Sort data replace



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

Sort data replace

Postby ratheshmkumar » Tue Aug 23, 2016 10:48 pm

Hi

I have 2 datasets and based on the value of the first dataset i need to update the values in the other dataset.

Dataset1
Source Date1 Date2
AAA 201601 20150901
BBB 201601 20151001
CCC 201601 20151101


Dataset2
Source field1 field2 BegDate1 field3 BegDate2
AAA HEADR1 201601
AAA NAME1 CITY1 20160101 STATE1 20160201
AAA NAME1 CITY1 20160101 STATE1 20160201
AAA NAME1 CITY1 20160101 STATE1 20160201
AAA TRAIL1 0003


The requirement is I need to match the source from dataset 1 with dataset 2, match the date1 from dataset 1 with the date in the header of dataset 2. If they are same, use the date2 from dataset 1 and change the Begdate1 of dataset 2 ie 20160101 to 20150901. Also my output dataset should have the header and trailer record also.

Thanks in advance for your help.
ratheshmkumar
 
Posts: 1
Joined: Fri Jul 06, 2012 7:43 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Sort data replace

 

Re: Sort data replace

Postby Magesh23586 » Wed Aug 24, 2016 12:50 am

Assuming LRECL=80
Is the match condition is only with dates ? I guess it should also include column1 "AAA",if not you can remove 5,3,A but you get three set of records as output, because "AAA", "BBB", "CCC", all the three records dates matches with file2.


//S1   EXEC  PGM=SORT                      
//SYSOUT DD SYSOUT=*                        
//INA DD *                                  
AAA 201601 20150901                        
BBB 201601 20151001                        
CCC 201601 20151101                        
//INB DD *                                  
AAA HEADR1 201601                          
AAA NAME1 CITY1 20160101 STATE1 20160201    
AAA NAME1 CITY1 20160101 STATE1 20160201    
AAA NAME1 CITY1 20160101 STATE1 20160201    
AAA TRAIL1 0003                            
//SORTOUT  DD SYSOUT=*                      
//SYSIN    DD *                            
                                           
  OPTION COPY                              
                                           
  JOINKEYS F1=INA,FIELDS=(1,3,A,05,06,A)    
  JOINKEYS F2=INB,FIELDS=(1,3,A,81,06,A)    
                                           
  REFORMAT FIELDS=(F2:1,80,F1:12,8,?)
  JOIN UNPAIRED,F2      
  
  INREC IFOUTLEN=80,                            
        IFTHEN=(WHEN=(89,1,CH,EQ,C'B',AND,      
                      05,6,CH,NE,C'HEADR1',AND,
                      05,6,CH,NE,C'TRAIL1'),    
                OVERLAY=(17:81,8))                            
                                                 
//JNF2CNTL DD *                                  
  INREC IFTHEN=(WHEN=GROUP,                      
                BEGIN=(5,6,CH,EQ,C'HEADR1'),      
                END=(5,6,CH,EQ,C'TRAIL1'),        
                PUSH=(81:12,6))          
 


Thanks
Magesh
Magesh23586
 
Posts: 35
Joined: Sat Jul 05, 2014 5:36 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Sort data replace

Postby NicC » Wed Aug 24, 2016 4:25 pm

Your post might have been more understandable ifyou had used the code tags to present your data - I fixed that up for you.
Also, you have datasets not files. I fixed that for you as well.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2676
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 102 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post