Page 1 of 1

copying a VB file and changing one field

PostPosted: Sat Feb 20, 2010 9:18 pm
by tjenkins99
Hello!
I would like to use DFSORT to copy a VB file and change just one field in the record.
I have successfully used the FIND and REPLACE parameter as follows:

//SYSIN DD *
OPTION COPY
INREC FINDREP=(INOUT=(C'AA20100218',C'BB20100218'))
/*

But, I would like to be more precise in case the string C'AA20100218' occurred more than once
within the record.
I used the following statements:

//SYSIN DD *
OPTION COPY
INREC FIELDS=(1:1,4,11,2,CHANGE=(2,C'AA',C'BB'))

I received a RC=0 but each record in the file only contained the field BB - all of the other fields are
missing.
Since the files are VB, I specified 1:1,4 to account for the 4-byte RDW field.
The only field I want to change is the 2-byte field starting at offset 11.

Could somebody point out what else I am missing?
Thanks.
Tom

Re: copying a VB file and changing one field

PostPosted: Tue Feb 23, 2010 12:19 am
by Frank Yaeger
Here's two different ways to change AA to BB in positions 11-12 with DFSORT:

//SYSIN DD *
  OPTION COPY                                               
  INREC FINDREP=(STARTPOS=11,ENDPOS=13,INOUT=(C'AA',C'BB')) 


//SYSIN DD *
  OPTION COPY                                                   
  INREC OVERLAY=(11:11,2,CHANGE=(2,C'AA',C'BB'),NOMATCH=(11,2))

Re: copying a VB file and changing one field

PostPosted: Tue Feb 23, 2010 8:03 pm
by tjenkins99
Hi Frank,

Thank you very much.
Those control cards gave me exactly what I needed.

Tom