Pages

Wednesday, 30 April 2014

DFSORT REFORMAT, BUILD, IFTHEN, OVERLAY


The below sort card helps to reformat an input record. BUILD, OVERLAY and IFTHEN we use to reformat input record before sorting it.


Best Sort card
//MATCH EXEC PGM=SORTEx:2
//MATCH EXEC PGM=SORTEx:3
//MATCH EXEC PGM=SORTEx:1
//IN1 DD DSN=... input File1 (FB/10)
//IN2 DD DSN=... input File2 (FB/10)
//SORTOUT  DD SYSOUT=*  ...without duplicate records 
//SYSIN DD *  
INREC BUILD=(1,20,C’ABC’,26:5C’*’,  15,3,PD,EDIT=(TTT.TT),21,30,80:X)    
 /*

//IN1 DD DSN=... input File1 (FB/10)
//IN2 DD DSN=... input File2 (FB/10)
//SORTOUT  DD SYSOUT=*  ...without duplicate records 
//SYSIN DD * 
INREC OVERLAY=(45:45,8,TRAN=LTOU) 
 /*


//IN1 DD DSN=... input File1 (FB/10)
//IN2 DD DSN=... input File2 (FB/10)
//SORTOUT  DD SYSOUT=*  ...without duplicate records
 //SYSIN DD *  
INREC IFTHEN=(WHEN=(1,5,CH,EQ,C’TYPE1’),  BUILD=(1,40,C’**’,+1,TO= PD)),  IFTHEN=(WHEN=(1,5,CH,EQ,C’TYPE2’),  BUILD=(1,40,+2,TO=PD,X’FFFF’)),  IFTHEN=(WHEN=NONE),OVERLAY=(45:C’NONE’))  
/*
==> BUILD or FIELDS: Reformat each record by specifying all of its items one byone. Build gives you complete control over the items you want in yourreformatted INREC records and the order in which they appear. You can delete,rearrange and insert fields and constants. Example: INREC BUILD=(1,20,C’ABC’,26:5C’*’, 15,3,PD,EDIT=(TTT.TT),21,30,80:X) 

==>OVERLAY: Reformat each record by specifying just the items that overlayspecific columns. Overlay lets you change specific existing columns withoutaffecting the entire record. Example: INREC OVERLAY=(45:45,8,TRAN=LTOU)

==>IFTHEN clauses: Reformat different records in different ways by specifying how the build or overlay items are applied to records that meet given criteria. IFTHENclauses let you use sophisticated conditional logic to choose how different recordtypes are reformatted. Example: INREC IFTHEN=(WHEN=(1,5,CH,EQ,C’TYPE1’), BUILD=(1,40,C’**’,+1,TO= PD)), IFTHEN=(WHEN=(1,5,CH,EQ,C’TYPE2’), BUILD=(1,40,+2,TO=PD,X’FFFF’)), IFTHEN=(WHEN=NONE),OVERLAY=(45:C’NONE’))

No comments:

Post a Comment

Thank for comment.