IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Multiple FINDREP


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 202
Location: Toronto, ON, Canada

PostPosted: Tue Jun 12, 2012 10:18 pm
Reply with quote

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.

Code:
OUTREC IFTHEN=(WHEN=(always true),FINDREP=(field1),HIT=NEXT),
  IFTHEN=(WHEN=(always true),FINDREP=(field2),HIT=NEXT),
  IFTHEN=(WHEN=(always true),FINDREP=(field3))


If someone can think of an easier way then let me know.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Jun 12, 2012 11:10 pm
Reply with quote

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...
Code:
//STEP0001 EXEC PGM=SORT                                       
//SORTIN   DD *                                               
SQLCODE 000 AND 100                                           
SQLCODE 013 AND 100                                           
//SORTOUT  DD  SYSOUT=*                                       
//SYSIN DD *                                                   
   SORT FIELDS=COPY                                           
   OUTREC BUILD=(1,12,                                         
                 9,3,CHANGE=(20,C'000',C'MEANS ONE THING'),   
                 NOMATCH=(C'NO DESC. FOUND'),                 
                12,9,                                         
                17,3,CHANGE=(20,C'100',C'MEANS ANOTHER THING'),
                 NOMATCH=(C'NO DESC. FOUND'))                 
/*                                                             
//SYSOUT DD SYSOUT=*                                           
//*                                                           

Code:
SQLCODE 000 MEANS ONE THING      AND 100 MEANS ANOTHER THING
SQLCODE 013 NO DESC. FOUND       AND 100 MEANS ANOTHER THING


Thanks,
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jun 12, 2012 11:39 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 13, 2012 12:11 am
Reply with quote

Jerryte,

As Bill mentioned you can use STARTPOS and ENDPOS parms. You can use multiple FindREP. Here is an example

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
----+----1----+----2----+----3----+----4----+----5----+----6----+----7
JERRYTE             BILL                SQLCODE             KOLUSU   
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                   
  INREC IFTHEN=(WHEN=INIT,                                           
  FINDREP=(STARTPOS=01,ENDPOS=20,INOUT=(C'JERRYTE',C'FINDREP'))),     
  IFTHEN=(WHEN=INIT,                                                 
  FINDREP=(STARTPOS=21,ENDPOS=40,INOUT=(C'BILL',C'WILLIAM'))),       
  IFTHEN=(WHEN=INIT,                                                 
  FINDREP=(STARTPOS=41,ENDPOS=60,INOUT=(C'SQLCODE',C'SQLCODE1'))),   
  IFTHEN=(WHEN=INIT,                                                 
  FINDREP=(STARTPOS=61,ENDPOS=80,INOUT=(C'KOLUSU',C'DFSORT')))       
//*


The output from this is
Code:

FINDREP             WILLIAM                SQLCODE1             DFSORT
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Wed Jun 13, 2012 12:41 am
Reply with quote

Bill/Kolusu,
Interesting... I didn't know it worked this way. Thank You.

Thanks,
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jun 13, 2012 12:51 am
Reply with quote

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.
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 202
Location: Toronto, ON, Canada

PostPosted: Wed Jun 13, 2012 11:35 pm
Reply with quote

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.

Sometime 1 tip leads to 2 more tips. Thanks all.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Grouping by multiple headers DFSORT/ICETOOL 7
Search our Forums:

Back to Top