MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using FINDREP, limit to a field

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
mickeygoo
Beginner


Joined: 15 Nov 2007
Posts: 26
Topics: 7

PostPosted: Tue Jun 09, 2009 9:57 am    Post subject: Using FINDREP, limit to a field Reply with quote

100-byte rec, 1st 20 bytes is a name (text) field. Need to replace "&" with "&" (XML), but shift only the text to the right of "&", and inside the 20 bytes, truncating if necessary; i.e., leave the rest of the record alone.

E.g.,

Code:
   Input:

----*----1----*----2----*----3----*----4----*----5----*----6----*----7--...
Black & Decker     Hello World!!!
Spic & Span CleanrsHow U Doin?!

Output:

----*----1----*----2----*----3----*----4----*----5----*----6----*----7--...
Black & Decker Hello World!!!
Spic & Span CleHow U Doin?!




Any ideas? TIA Very Happy
Back to top
View user's profile Send private message
callanand
Beginner


Joined: 12 Jun 2007
Posts: 23
Topics: 2

PostPosted: Tue Jun 09, 2009 10:54 am    Post subject: Reply with quote

mickeygoo,

Use this

Code:
//STEP05 EXEC PGM=FILEAID
//SYSPRINT DD SYSOUT=*
//DD01     DD *
   Black & Decker     Hello World!!!
   Spic & Span CleanrsHow U Doin?!

//DD01O    DD SYSOUT=*
//SYSIN    DD *
$$DD01 COPY EDITALL=(01,00,C"&",
                     C"&")
/*
Back to top
View user's profile Send private message
mickeygoo
Beginner


Joined: 15 Nov 2007
Posts: 26
Topics: 7

PostPosted: Tue Jun 09, 2009 11:10 am    Post subject: Reply with quote

thanks, callanand - or should I say "callan&" Mr. Green - but we don't have file-aid in our shop.

anyways, i did a workaround - basically created a 2nd file with just the 20-byte name field, did the FINDREP there, then superimposed it back into the original file - but if a cleaner, more Idea claps solution is available, I'm all ears.

Thank You again Exclamation Exclamation Exclamation
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Jun 09, 2009 12:40 pm    Post subject: Reply with quote

Mickeygoo,

Here is a DFSORT JCL which would give you the desired results.

Put the first 19 bytes at the end of the record and then use FINDREP function and overlay that back in pos 1

I assumed that your LRECL is FB 80 and the string to be replaced is in the first 19 bytes

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
BLACK & DECKER     HELLO WORLD!!!                           
SPIC & SPAN CLEANRSHOW U DOIN?!                             
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                           
  INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,OVERLAY=(81:1,19)),   
  IFTHEN=(WHEN=INIT,                                         
  FINDREP=(IN=C'&',OUT=C'&',STARTPOS=81,OVERRUN=TRUNC)),
  IFTHEN=(WHEN=INIT,BUILD=(81,19,20,61))                     
/*


The output from this job is
Code:

BLACK & DECKER HELLO WORLD!!!     
SPIC & SPAN CLEHOW U DOIN?!       

Callanand,

Did you test that solution? You are not limiting your scan criteria to the first 19 bytes and if your job will replace the contents of & found anywhere in the record. Moreover EDITALL shifts the data to the right and the LRECL is increased overall but does not truncate records at the end. Test your solutions before posting and see if you get the right results.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mickeygoo
Beginner


Joined: 15 Nov 2007
Posts: 26
Topics: 7

PostPosted: Tue Jun 09, 2009 2:11 pm    Post subject: Reply with quote

Outside-the-box thinking, I like it!!! Thank You
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group