| IBM MAINFRAME HELP FORUMS for COBOL, JCL, CICS, DB2, IMS etc... Help & Support Forums for IBM Mainframe computers Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7, CA-11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, VSAM, ISPF, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
|
| View previous topic :: View next topic |
| Author |
Message |
janaonline
Joined: 13 Dec 2007
Posts: 3
Location: India
|
| Posted: Tue Jul 08, 2008 7:10 pm Post subject: Help needed to search and insert a string using REXX |
|
|
I need REXX code which does the following:
1. Search a string in all the members
2. If the string is found in any of the member then need to insert a string before the searched string. |
|
| Back to top |
|
dbzTHEdinosauer
Joined: 20 Oct 2006
Posts: 1387
Location: germany
|
| Posted: Tue Jul 08, 2008 7:21 pm Post subject: |
|
|
help yourself.
use the search. I know that there are several examples of search all members.
the insert:
after a find hit:
(workline) = linenum .zcsr
insert <yourstuff> before workline |
|
| Back to top |
|
janaonline
Joined: 13 Dec 2007
Posts: 3
Location: India
|
| Posted: Tue Jul 08, 2008 7:25 pm Post subject: |
|
|
Thanks for your immediate reply.
IF VAR3 = 'BEFORE' THEN
DO
I = 1
DO K = 1 TO CONTENTS.0
IF POS( VAR1 , CONTENTS.K) > 0 THEN DO
FOUND = 'Y'
OUTPUT.I = VAR2
I = I + 1
END
OUTPUT.I = CONTENTS.K
I = I + 1
END
END
the above code will insert the string as a separate line, but i need it to insert just before the searched string. Could you please help in this??
Thanks!!! |
|
| Back to top |
|
dbzTHEdinosauer
Joined: 20 Oct 2006
Posts: 1387
Location: germany
|
| Posted: Tue Jul 08, 2008 7:54 pm Post subject: |
|
|
you can do this two ways.
1. use execio to read and write the records for the member. this way you would use stems (as your example). I have no suggestion for this, I would not do it this way.
2. use edit macro commands and have your rexx invoke each member via EDIT, then do your FIND, determine line no of hit, insert before lineno. restart you search at lineno + 1 (you insert a line before line 10, line 10 becomes line 11. if you don't start at line 12, you will be in a loop, finding things on the old line 10 -now 11- and inserting again.) |
|
| Back to top |
|
superk
Joined: 26 Apr 2004
Posts: 3098
Location: Charlotte,NC USA
|
| Posted: Tue Jul 08, 2008 8:24 pm Post subject: Reply to: Help needed to search and insert a string using RE |
|
|
If you want to stick with using EXECIO instead of an edit macro (which DOES look to be the better option here), you might go with this:
var1 is the search string
var2 is the insertion string
Code:
"EXECIO * DISKR ddname (STEM contents. FINIS"
Do i = 1 To contents.0
If Pos(var1,contents.i) <> 0 Then
Do
Queue var2
Queue contents.i
End
Else Queue contents.i
End
"EXECIO "Queued()" DISKW ddname (FINIS"
|
|
| Back to top |
|
enrico-sorichetti
Joined: 14 Mar 2007
Posts: 2560
Location: italy
|
| Posted: Tue Jul 08, 2008 8:46 pm Post subject: Reply to: Help needed to search and insert a string using RE |
|
|
here is a thread with a bit of string manipulation...
http://ibmmainframes.com/viewtopic.php?t=31958&highlight=substr |
|
| Back to top |
|
dbzTHEdinosauer
Joined: 20 Oct 2006
Posts: 1387
Location: germany
|
| Posted: Tue Jul 08, 2008 8:47 pm Post subject: |
|
|
Kevin,
I have failed to say this before, but, you give good advice and your code is clean. |
|
| Back to top |
|
superk
Joined: 26 Apr 2004
Posts: 3098
Location: Charlotte,NC USA
|
| Posted: Tue Jul 08, 2008 8:55 pm Post subject: Reply to: Help needed to search and insert a string using RE |
|
|
| Thanks for the kind words. Maybe I should let my boss read this? :wink: |
|
| Back to top |
|
enrico-sorichetti
Joined: 14 Mar 2007
Posts: 2560
Location: italy
|
| Posted: Tue Jul 08, 2008 8:57 pm Post subject: Reply to: Help needed to search and insert a string using RE |
|
|
Quote: Maybe I should let my boss read this?
Nahhh.....
he might complain that You spend too much time surfing the net :wink: |
|
| Back to top |
|
janaonline
Joined: 13 Dec 2007
Posts: 3
Location: India
|
| Posted: Tue Jul 15, 2008 6:52 pm Post subject: |
|
|
| Thanks a lot for all your suggestion. That was really helpful.. |
|
| Back to top |
|
| |
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM
|