Joined: 29 Oct 2010 Posts: 202 Location: Toronto, ON, Canada
I discovered that on an OUTREC statement I can have only one FINDREP command. I wanted to run it against 2 different fields on the same record. To work around this I used the IFTHEN= using a condition that would always come true and the just repeat for each field.
jerryte,
FINDREP does not work at a field level. If you are asking if you have 2 (or more) values in the record that needs to be changed to some other values, refer to below example from DFSort Applicaton Programming. Pay close attention to INOUT.
If you want to change different input values to one values, you can do that using something like this INREC FINDREP=(IN=(X'00',X'FF'),OUT=C'')
Code:
OPTION COPY
OUTFIL FINDREP=(INOUT=(C'AM',C'IN THE MORNING',
C'PM',C'IN THE EVENING'),MAXLEN=70)
Sample Input
Code:
COFFEE AT 12:28 AM, TOAST AT 06:15 PM
MILK AT 03:17 PM, BAGELS AT 05:03 PM
PUDDING AT 09:32 AM
Output
Code:
COFFEE AT 12:28 IN THE MORNING, TOAST AT 06:15 IN THE EVENING
MILK AT 03:17 IN THE EVENING, BAGELS AT 05:03 IN THE EVENING
PUDDING AT 09:32 IN THE MORNING
For a field level change refer to CHANGE command... Here is a very simple example for CHANGE command...
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
FINDREP, with STARTPOS and ENDPOS, can be used on a field, or several fields.
IFTHEN=(WHEN=INIT gets you around the "dummy" condition, so that you can have several FINDREPS in the same step without a problem.
I think if you read the manual you'll also discover that there can only be one FINDREP on INREC, OUTREC or OUTFIL. Exactly like BUILD for instance. If you need more, the manual shows, you can use IFTHEN.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
No problem. DO= is also useful. If you know there is only one (or you only want to change one) BILL in the field/record, you can limit it to one successful FINDREP, without having to scan the remaining bytes in the field/record. Couple of other useful things to know in the manual. Powerful little thing, FINDREP.
Joined: 29 Oct 2010 Posts: 202 Location: Toronto, ON, Canada
My posting was intended to provide a tip to other developers. It was something I had discovered out of necessity. Using the IFTHEN is a workaround for the limitation of only one FINDREP statement.
By "field" I had meant multiple STARTPOS,ENDPOS pairs. To do this I need more then one FINDREP operation.
I had assumed that only one WHEN=INIT could be coded which is why I coded something else that would always be true. Since more then one can be used it makes this method much simplier. Thanks for posting that information.
First time I had seen the CHANGE option. I will have to give it a try some time.