View previous topic :: View next topic
|
Author |
Message |
jitu852
New User
Joined: 30 Apr 2007 Posts: 27 Location: Hyderabad
|
|
|
|
Hi,
i want to write a REXX so that i can take in put date from user and srchfor the perticular string and replace that string with the input data.
details:
i have a filed CYCLE=PRmmddyy in many jobs
and it is same in all jobs(ie PR99999999); i want to change this by user input date
NB:so advice me a good aproach for it. |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
jitu,
Follow this approach.
1) Read the template JCL in a stem variable
2) Form a loop and queue the lines one by one checking for the "PR99999999" using POS.
3) When PR99999999 is found, find the length, use LEFT/RIGHT to find the exact position of the data and overwrite the data entered by the user.
4) Queue the line till the last line.
5) Write the lines into a new/old dataset depending on your requirement.
Loop shd be like this
JCL should be read into a stem variable B
Code: |
do j = 1 to no_of_lines
posx = pos("99999999",B.J)
if posx > 0 then
do
b.j = strip(b.j)
len = length(b.j)
lstr = left(b.j,posx-1)
rstr = right(b.j,len-posx-7)
line = lstr||userdata||rstr
queue line
end |
Use the above code as the base and develop your REXX. |
|
Back to top |
|
|
jitu852
New User
Joined: 30 Apr 2007 Posts: 27 Location: Hyderabad
|
|
|
|
Thanks for quick and excellent reply |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
You are welcome. Develop your REXX exec and post if you still have queries. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Or you could use ISPF EDIT macro
REXX code
Code: |
"ISPEXEC EDIT DATSET('"Your dataset name"') MACRO(MACROE1)"
|
Macro code
Code: |
/* REXX */
"ISREDIT MACRO"
"ISREDIT C 'PR99999999' 'New value' ALL"
"ISREDIT END" |
|
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Jitu,
Expat wrote:
Quote: |
Or you could use ISPF EDIT macro |
This is the best and simple approach. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Aaru wrote: |
Jitu,
Expat wrote:
Quote: |
Or you could use ISPF EDIT macro |
This is the best and simple approach. |
Maybe, but I still stole a copy of your code |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Expat,
Quote: |
Maybe, but I still stole a copy of your code |
Code Re-use saves time and effort Thanks for letting us know a simpler solution. |
|
Back to top |
|
|
|