Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Multiple FINDREP

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
jerryte

Active User


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

PostPosted: Tue Jun 12, 2012 10:18 pm    Post subject: Multiple FINDREP
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: 578
Location: USA

PostPosted: Tue Jun 12, 2012 11:10 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Jun 12, 2012 11:39 pm    Post subject: Reply to: Multiple FINDREP
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    Post subject: Reply to: Multiple FINDREP
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: 578
Location: USA

PostPosted: Wed Jun 13, 2012 12:41 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Jun 13, 2012 12:51 am    Post subject: Reply to: Multiple FINDREP
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: 187
Location: Toronto, ON, Canada

PostPosted: Wed Jun 13, 2012 11:35 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changeman get multiple "Browse C... elixir1986 Compuware & Other Tools 4 Fri Jul 14, 2017 1:48 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. SDSF multiple spool datasets extracte... PJAlarcon CLIST & REXX 1 Fri Apr 21, 2017 10:50 pm
No new posts Validating file with multiple header/... mohitsaini DFSORT/ICETOOL 6 Thu Apr 13, 2017 1:53 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us