How to copy one value from dataset to another dataset using JCL

1.6k Views Asked by At

My question is i want to append one value from one dataset to another dataset.

Below is the screenshot of the first dataset. enter image description here

Below is the screenshot of the second dataset.

enter image description here

I want the 0 value which is present at the 50th position the needs to added in the second file at 50th position, so how i can do it using JCL using a sort step.

This needs to be done using a step in JCL , please help me out.

1

There are 1 best solutions below

0
On

I would suggest you to insert sequence numbers at the end (position 81) in both the datasets and do a RIGHT JOIN in DFSORT with sequence number as key. Here is a solution using ICETOOL which does all the tasks in one step.

//XXXXXXA JOB 1,NOTIFY=&SYSUID              
//STEP01  EXEC PGM=ICETOOL                  
//INA     DD DSN=XXXXXX.PS.A,DISP=SHR       
//INB     DD DSN=XXXXXX.PS.B,DISP=SHR       
//JNA DD DSN=&&JNA,DISP=(,DELETE),          
//       SPACE=(CYL,(1,0),RLSE),            
//       DCB=(LRECL=82,RECFM=FB,BLKSIZE=0)  
//JNB DD DSN=&&JNB,DISP=(,DELETE),          
//       SPACE=(CYL,(1,0),RLSE),            
//       DCB=(LRECL=82,RECFM=FB,BLKSIZE=0)  
//OUT     DD DSN=XXXXXX.PS,OUT3,
//        DISP=(,CATLG,DELETE), 
//        SPACE=(CYL,(1,0),RLSE),
//        DCB=(LRECL=80,RECFM=FB,BLKSIZE=0)                       
//TOOLMSG DD SYSOUT=*                       
//DFSMSG  DD SYSOUT=*                       
//SYSOUT  DD SYSOUT=*                       
//TOOLIN  DD *                              
  SORT FROM(INA) TO(JNA) USING(CTL1)        
  SORT FROM(INB) TO(JNB) USING(CTL1)        
  SORT JKFROM TO(OUT) USING(CTL2)           
/*                                          
//CTL1CNTL DD *                             
  SORT FIELDS=COPY                          
  OUTREC BUILD=(1,80,81:SEQNUM,2,ZD)        
//CTL2CNTL DD *                             
  JOINKEYS F1=JNA,FIELDS=(81,2,A)           
  JOINKEYS F2=JNB,FIELDS=(81,2,A)           
  REFORMAT FIELDS=(F2:1,49,F1:50,1,F2:51,30)
  JOIN UNPAIRED,F2                          
  SORT FIELDS=COPY                            

Contents in XXXXXX.PS.A dataset:

 ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 ***************************** Top of Data ******************************
                                                  7                      
 **************************** Bottom of Data **************************** 

Contents in XXXXXX.PS.B dataset:

 ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 ***************************** Top of Data ******************************
 PUT 'LCDT.ORDER.ORDRAD' LCD_BI_ORDERINFO_&OYMD._00 _01.txt              
 quit                                                                    
 /*                                                                      
 **************************** Bottom of Data ****************************

And, contents in the final output dataset, XXXXXX.PS.OUT3:

 ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 ***************************** Top of Data ******************************
 PUT 'LCDT.ORDER.ORDRAD' LCD_BI_ORDERINFO_&OYMD._07 _01.txt              
 quit                                                                    
 /*                                                                      
 **************************** Bottom of Data ****************************

Hope this helps.