View previous topic :: View next topic
|
Author |
Message |
janaonline
New User
Joined: 13 Dec 2007 Posts: 11 Location: USA, California
|
|
|
|
Using REXX I've created a tool to set up a job to different region. But got stuck with one change. The source JCL has different printer name as destination. e.g. DEST=PRT505 and I have to change all the occurence as DEST=* but I don't have the list of occurences. So wildly I have to replace the printer name with *. Please help/suggest me to finish this. Thanks. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
Use the EDIT service with the MACRO option.
O. |
|
Back to top |
|
|
Kurt Deininger
New User
Joined: 13 Jul 2010 Posts: 19 Location: Frankfurt/Germany
|
|
|
|
Hi janaonline,
Try this one:
Code: |
/* REXX */
address tso "alloc fi(oldjcl) da("oldfile") shr reuse"
address tso "execio * diskr oldjcl (open stem jcl. finis)"
address tso "free fi(oldjcl)"
txt_old="DEST=PRT505"
lng_old=length(txt_old)
txt_new="DEST=*"
do jcl_row=1 to jcl.0
jcl_lin=jcl.jcl_row
jcl_col=length(jcl_lin)
if jcl_col>0 then do
do forever
jcl_col=lastpos(txt_old,jcl_lin,jcl_col)
if jcl_col=0 then do
leave
end
jcl_lin=left(jcl_lin,jcl_col-1)txt_new !! ,
substr(jcl_lin,jcl_col+lng_old)
end
end
jcl.jcl_row=jcl_lin
end
address tso "alloc fi(newjcl) da("newfile") shr reuse"
address tso "execio * diskw newjcl (open stem jcl. finis)"
address tso "free fi(newjcl)"
exit |
Cheers Kurt
Amended post to use code tags |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Kurt,
Please learn to use the code tags shown below
Code: |
[code] your stuff in here [/code] |
Sorry, but I think that Ofer71 has given the best answer. A simple edit macro is far easier than reading and analysing every line of every member and processing them one by one. |
|
Back to top |
|
|
Kurt Deininger
New User
Joined: 13 Jul 2010 Posts: 19 Location: Frankfurt/Germany
|
|
|
|
expat,
Thanks for the hint and for fixing the code. I admit Ofer71's
solution is better. He must have submitted it whilst I was coding
mine in between working. It's all good fun anyhow and I like the
site.
Cheers Kurt |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Kurt,
All good contributers are most welcome
so keep up the good contributions |
|
Back to top |
|
|
janaonline
New User
Joined: 13 Dec 2007 Posts: 11 Location: USA, California
|
|
|
|
ofer71 wrote: |
Use the EDIT service with the MACRO option.
O. |
Thanks for your input. I have used the same to finish my program.
However this is only useful if we know what exactly to be searched and replaced.
For e.g
Code: |
"ISREDIT C ALL 'DEST=ACCT07' 'DEST=LOCAL'"
|
Since i have the complete list of printer names, i could do finish it.
But question is, say i don't have the list of printer names and i have to wildly search for "DEST=" and replace the printer name with "LOCAL" irrespectively.
Thanks for your time. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
If you are writing your edit macro in Rexx, you could use a combination of edit commands and Rexx to do the substitution, e.g.
Code: |
address isredit "FIND DEST="
do while (rc=0)
address isredit "(L1) = CURSOR"
address isredit "(D1) = LINE &L1"
p1 = pos("DEST=",d1)
p2 = pos(",",d1,p1)
d1 = substr(d1,1,p1-1) || "DEST=LOCAL," || substr(d1,p2+1)
address isredit "LINE &L1 = (D1)"
address isredit "FIND DEST="
end
|
(Note the assumption that the printer name is always delimited on the right by a comma which is not the last character on the line. Also, I wrote this "on the fly" and without testing it.) |
|
Back to top |
|
|
|