View previous topic :: View next topic
|
Author |
Message |
mfarien
New User
Joined: 02 Mar 2007 Posts: 17 Location: USA
|
|
|
|
Hi,
I have 2 tasks here.
1.
I need to search a PDS for members and identify the ones which I have to change. My search is thru 3.14 where I look for the JOBS containing a PGM name , say NOB, I get 1100 members.
Now in the same PDS I search for JOBS containing PGM name, say NEM, I get 400 members. I have to make a change in all the JOBS which are not having NEM but DO have NOB. So in my case I have to change 700 JOBS ( 1100-700).
What would be the best way to get a listing of JOBS according to that condition ? I have tried my knowledge , but can not proceed any further.
2.
When I get this listing ( 700 JOBS ) I need to add a step (6 lines) before the existing LAST step in the JOB ( always before the last step) . Here the last step is ABEND. So just before the ABEND step I need to insert those 6 lines ( same lines for all the JOBS )
Abend steps are like this and there are more then one abend steps in the job, but always the last step is an ABEND step executing PGM=USERABND
ABEND3 EXEC PGM=USERABND
ABEND2 EXEC PGM=USERABND
JS07ABND EXEC PGM=USERABND
Thanks in advance if we can work thru it. |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
OK. Isn't step 1 just a matter of looking for duplicates in a list and eliminating them?
The first search finds 1100 members for NOB. If you then search only those 1100 members for NEM, then the result is those members which contain both NOB and NEM. Combine the lists, eliminate the duplicates, and you're left with just the 700 members containing NOB without NEM. |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
Step 2 sounds a little harder, since it seems logical that you'll have to read each member into an array, find where the last step occurs, and then insert your code immediately before that point, and write the entire updated member out. Then, repeat for each member. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Put your six lines into a member in the PDS
You could probably use one EDIT macro to do it all including the logic for seeing if the member has the correct program combination ...
Code: |
F 'PGM=NOB' FIRST
Rcx = RC
F 'PGM=NEM' FIRST
Rcy = RC
If Rcx = 0 & Rcy = 4 Then do
F 'EXEC PGM=' LAST
(CRSLINE,CRSCOL) = CURSOR
COPY member BEFORE crsline
End
|
Not syntactically correct, but enough to get the job done with a little effort by yourself. |
|
Back to top |
|
|
mfarien
New User
Joined: 02 Mar 2007 Posts: 17 Location: USA
|
|
|
|
OK, Where I am going to write the EDIT macro or which manual I should look to find more information on using the macros, writing, and using. Since morning I was looking to find about it, but any direction will help. |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
I don't usually post too much code these days, but having already done something very similar ..... If I have the code and it can be changed in seconds then I am happy to post. ..... Just amended my current version, and
have Not tested it
Obviously in batch you will need to allocate all of the required ISPF libraries.
1) Main REXX EXEC
Code: |
/* REXX *** LIST PDS AND INVOKE EDIT MACRO TO UPDATE MEMBERS */
Address Ispexec "Control Errors Return"
Pds = "pds name"
mac = 'UPDATPD1'
x = msg('off')
x=outtrap(list.)
"LISTDS '"Pds"' MEM "
x=outtrap(off)
Do aa = 7 to list.0
"Ispexec edit dataset('"Pds!!"("!!Strip(list.aa)!!")') MACRO("mac")"
End
|
The Macro
Code: |
/* REXX *** ISPF EDIT MACRO */
Address Ispexec "Control Errors Return"
"ISREDIT MACRO"
"ISREDIT F 'PGM=NOB' FIRST"
Rcx = RC
"ISREDIT F 'PGM=NEM' FIRST"
Rcy = RC
If Rcx = 0 & Rcy = 4 then do
"ISREDIT F 'PGM=' LAST"
"ISREDIT (CRSLINE) = " CURSOR
"ISREDIT COPY member BEFORE "CRSLINE
End
|
|
|
Back to top |
|
|
mfarien
New User
Joined: 02 Mar 2007 Posts: 17 Location: USA
|
|
|
|
Thanks for your help, but I am struck, I am trying my best to learn it, understand it and then do it, spending time in learning thru manuals.
I am able to execute the first macro, I have a Say statement in it, in the same PDS I kept 7 other members which should be modified with my 6 lines of code, when I run it, I see this Say statement 8 times. But no msgs from my main macro in which I have my search logic and a Copy to add 6 lines from a member. I have a say statement at start of my Main macro, but getting no display from it.
I think I am doing something wrong in executing. If you can spare some time, please respond.
I am executing it using this command, and I have not done any other setup( do I need to do ? )
TSO EXEC 'the-name-of-the-PDS(member-name)' EXEC .
I have tried looked into the manual as suggested above and also few manuals from IBM site.
I think as a beginner I need to start with understanding the fundamentals of how to execute. As a programmer I can understand the loops, passing variables and logic, but the setup pertaining to REXX and flow of calls etc I need to learn.
I got this from IBM site, description is very much to what I need to do but not the language specific keywords
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ISPZEM60/2.4.3?DT=20070722183423
Here is my code first code
Code: |
/* REXX *** LIST PDS AND INVOKE EDIT MACRO TO UPDATE MEMBERS */
ADDRESS ISPEXEC "CONTROL ERRORS RETURN"
PDS = 'V02173.ALL.NOBNEM'
MAC = 'MAINCODE'
X = MSG('OFF')
X=OUTTRAP(LIST.)
"LISTDS 'V02173.ALL.NOBNEM' MEM "
X=OUTTRAP(OFF)
DO AA = 7 TO LIST.0
SAY "CALLING MAINCODE MACRO"
"ISPEXEC EDIT DATASET('V02173.ALL.NOBNEM!!') MACRO("MAC")"
END |
And another code
Code: |
/* REXX *** ISPF EDIT MACRO */
ADDRESS ISPEXEC "CONTROL ERRORS RETURN"
"ISREDIT MACRO"
SAY "INSIDE MAINCODE MACRO"
"ISREDIT F 'PGM=NOB' FIRST"
RCX = RC
"ISREDIT F 'PGM=NEM' FIRST"
RCY = RC
IF RCX = 0 & RCY = 4 THEN DO
"ISREDIT F 'PGM=' LAST"
"ISREDIT (CRSLINE) = " CURSOR
"ISREDIT COPY LINES2AD BEFORE "CRSLINE
END |
|
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
I'm confused. Isn't 'V02173.ALL.NOBNEM' supposed to be a PDS? If so, don't you need the member name in your loop?
Code: |
...
DO AA = 7 TO LIST.0
SAY "CALLING MAINCODE MACRO"
"ISPEXEC EDIT DATASET('V02173.ALL.NOBNEM!!') MACRO("MAC")"
END
|
Shouldn't it be:
Code: |
...
DO AA = 7 TO LIST.0
SAY "CALLING MAINCODE MACRO FOR MEMBER" STRIP(LIST.AA)
"ISPEXEC EDIT DATASET('"PDS"("STRIP(LIST.AA)")') MACRO("MAC")"
END
|
Personally, I'd scale the REXX exec down a bit:
Code: |
/* REXX *** LIST PDS AND INVOKE EDIT MACRO TO UPDATE MEMBERS */
PDS = 'V02173.ALL.NOBNEM'
MAC = 'MAINCODE'
"ISPEXEC LMINIT DATAID(DID) DATASET('"PDS"') ENQ(SHR)"
"ISPEXEC LMOPEN DATAID("DID") OPTION(INPUT)"
DO FOREVER
"ISPEXEC LMMLIST DATAID("DID") OPTION(LIST) MEMBER(MEMB)"
IF RC <> 0 THEN LEAVE
SAY "CALLING MAINCODE MACRO FOR MEMBER" MEMB
"ISPEXEC EDIT DATASET('"PDS"("STRIP(MEMB)")') MACRO("MAC")"
END
"ISPEXEC LMCLOSE DATAID("DID")"
EXIT 0
|
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
The macro must be in a library defined in your SYSEXEC and / or SYSPROC allocations.
You can see these by entering TSO ISRDDN on your screen. |
|
Back to top |
|
|
|