Page 1 of 1

Change data at point of match

PostPosted: Fri Dec 04, 2009 5:36 pm
by Kevin Jenkins
Grateful to know if and how DFSORT can handle the following data manipulation. Latest maintenance is PTF UK900913 from July 2008.

In a sequential file, if character string "STX" is in position 1, and strings "5013546030160" and "5000169000001'" are also found somewhere (although their position can vary) in the same record, then modify only "5000169000001'" to "1A2B3C4D5E6F7'"

This is just one of 40+ conditional modifications I would like to make in the same jobstep.

Grateful in advance assistance you are able to offer.

Regards, Kevin

Re: Change data at point of match

PostPosted: Fri Dec 04, 2009 8:46 pm
by skolusu
Kevin Jenkins,

Assuming your input is FB and lrecl of 80 the following JCL will give you the desired results

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
STX          5013546030160       5000169000001 - SHOULD CHANGE         
STX   5013546030160       5000169000002 - UNTOUCHED                   
STX      5013546030160       5000169000001 - SHOULD CHANGE             
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'STX',AND,4,76,SS,EQ,C'5013546030160',
                      AND,4,76,SS,EQ,C'5000169000001'),               
        FINDREP=(INOUT=(C'5000169000001',C'1A2B3C4D5E6F7')))           
//*


The output of this is

STX          5013546030160       1A2B3C4D5E6F7 - SHOULD CHANGE   
STX   5013546030160       5000169000002 - UNTOUCHED               
STX      5013546030160       1A2B3C4D5E6F7 - SHOULD CHANGE       

Re: Change data at point of match

PostPosted: Fri Dec 04, 2009 8:52 pm
by Kevin Jenkins
Skolsu

Many thanks for your response I'll test as soon as I am able. Appreciate you taking the time to respond.

Regards, Kevin

Re: Change data at point of match

PostPosted: Thu Dec 10, 2009 9:57 pm
by Kevin Jenkins
Skolsu

Many thanks for your advice, testing of which has proved successful.

Cheers, Kevin