Monday, January 31, 2011

Sort - Insert field in between and copy records from input based on condition

//STEP030  EXEC  PGM=SORT                           
//SYSOUT   DD  SYSOUT=*                             
//SORTIN   DD  DSN=TCTPU.DLPXV1.ACTUAR.FOUND,       
//             DISP=SHR                             
//SORTOUT  DD  DSN=TCTPU.DLPXV1.ACTUAR.FOUND.FEB,   
//             DISP=(OLD,CATLG,DELETE),             
//             UNIT=SYSDA,                          
//             SPACE=(CYL,(50,5),RLSE)              
//SYSIN    DD  *                                    
  SORT FIELDS=COPY                                  
  INCLUDE COND=(8,4,CH,NE,C'2009') 

  OUTREC FIELDS=(1,7,C'~',8,8,C'~',17,8) 
//*                                                 
 INCLUDE COND=(8,4,CH,NE,C'2009')  (Copies records if in  position 8 and upto 4 chars NE 2009) 
OUTREC FIELDS=(1,7,C'~',8,8,C'~',17,8) (Copies records which has met above condition and output will be 1 to 7 from input with ~ in position 8 and 9 position will be from input's 8th position until 8 chars and ~ in 17 position and 18th position will be from input's 17 position)    


Output:

M065774~20100310~S0003765
M065771~20100310~T0059855
M065406~20100224~T0061059

No comments:

Post a Comment