IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to pass the control from rexx to rexx


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
asukumar

New User


Joined: 15 Apr 2009
Posts: 8
Location: bangalore

PostPosted: Tue Dec 15, 2009 5:34 am
Reply with quote

Hi,

As per one of our business request I have written a small rexx to exclude the records based on the values passed from the main rexx to sub-rexx.

The request is whenever a match is NOT found in the main rexx then based on the value, all the relevant lines needs to be excluded and then deleted from the file. Excluding and deleting is being done in the sub-rexx. Now the issue is, for example, if a match is found in the 4th row then how to pass the CONTROL to the sub-rexx to exclude the 4th row from the input file?

Please check my below main-rexx and sub-rexx for details and suggest me the solution.

Main-Rexx

/* REXX */
"ISREDIT MACRO"
filename1 = "'NUHAD.HAM910.LP11.D091209'"
"allocate da("filenam1") dd(INPUT1) shr reu"
/* "EXECIO 0 DISKR MYDD(OPEN" */
"execio * diskr INPUT1 (stem inp1. finis)"
TRACE I
I=1
PARA1:
ALPHA = SUBSTR(inp1.i,84,2)
IF ALPHA <> 'CH' THEN
SIGNAL PARA2
ELSE DO
I = I+1
SIGNAL PARA1
END
PARA2:
"ISPEXEC EDIT DATASET("FILENAM1") MACRO(NEWRX)"
I = I+1
SIGNAL PARA1


Sub-Rexx:

TRACE I
"ISREDIT MACRO"
"ISREDIT (LINEVAL) = LINE .ZCSR"
ADDRESS TSO
AGENCY = SUBSTR(LINEVAL,4,7)
"ISREDIT X ALL "
"ISREDIT F "AGENCY" ALL"
"ISREDIT DEL ALL NX"
"ISREDIT RES "
"ISREDIT END "
ADDRESS 'ISPEXEC'
RETURN
ADDRESS 'ISREDIT' END.


I know "ISREDIT (LINEVAL) = LINE .ZCSR" takes only the record on which the cursor is placed...but i have searched for a correct command but didn't find any so far...

I have tried using CALL NEWRX AGENCY command to call the sub-rexx, but no luck. Can some one please help me?

Thanks in advance.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Dec 15, 2009 6:40 am
Reply with quote

critique on code start:

well, each time you invoke the EDIT MACRO - NEWRX within an edit session of the ds, you delete a line and then save the ds and return to the main rexx.

say you decide line 3 is to be deleted.
so if your edit macro works, then you delete line 3, save the ds and return.

at this time what was line 4 in the ds is now line 3.
so if you, in your main rexx decide to delete line 4,
you will in effect delete line 5 with you macro.

critique on code end:


suggestion: put all the find CH in 82 in your sub rexx and delete from there.

another suggestion: learn how to use CALL as a PERFORM and stop using signal as a goto.

actually, you could put all this garbage in one REXX and just invoke it when you are in an edit session. sure is a lot of code to accomplish a simple task. i.e. you are over complicating the task.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Dec 15, 2009 7:07 am
Reply with quote

an addendum:

you have so many false assumptions in your code, it will never work.
you are not deleting any lines in your macro.
Code:

"ISREDIT MACRO"
"ISREDIT (LINEVAL) = LINE .ZCSR"
ADDRESS TSO
AGENCY = SUBSTR(LINEVAL,4,7)
"ISREDIT X ALL "
"ISREDIT F "AGENCY" ALL"
"ISREDIT DEL ALL NX"
"ISREDIT RES "
"ISREDIT END "
ADDRESS 'ISPEXEC'
RETURN
ADDRESS 'ISREDIT' END.


the first line is the only one that is correct.

when you first enter an edit session, where is the cursor?
WTF is AGENCY other than a variable?
AGENCY = SUBSTR(LINEVAL,4,7) populate agency with the value at postion 4 for a length of 7 in the variable LINEVAL

here is a link to the ISPF for z/OS library. Pick your verison and do some reading.

here is the latestChapter 11. Edit macro commands and assignment statements

and again, you should just write a 4 line edit macro that you can invoke during and edit session.

x all
f all 'CH' 84
del all nx
end
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Tue Dec 15, 2009 7:22 am
Reply with quote

Can you describe how you invoke main-rexx? It looks like you want to editing a dataset... more details on that.

And also confirm that the file you want to clean up is another file altogether.

I agree with Dick about not using SIGNAL. Though, I think it should be a DO WHILE loop.

Also, if there are many calls to sub-rexx (or NEWRX, which is it, really?), then I agree there is too much overhead in starting / stopping editor. There should be only one call to the editor and the editor macro should read the control list and process any excludes / deletes that it needs to.

I disagree with Dick about "not deleting any lines". I think it will delete lines, but just not the ones that should be deleted.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Dec 15, 2009 8:58 am
Reply with quote

My suggested 4 liner will not do what the TS wants, but I am too tired to attempt to read his code and try to determine what he wanted to do.

and Pedro, you are correct he might just manage to get something deleted.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Dec 15, 2009 7:03 pm
Reply with quote

I'm a little confused here because your code bears little if any resemblence to your explanation.
I would interpret your requirement as below and ask for clarification where needed.

You are reading a file, processing each record.
If it has 'CH' in columns 84/85 then you ignore the record.
If it does not, then you want to take a value from pos 4 len 7 of ......
- a) The current record being processed
- b) The first record of the dataset asis, as this is where the data will come from with your coded macro.

With this value, you then want to remove every record which contains this value.

What happens to records that you ignored previously and I assume you wish to keep which contain an exclude value from records processed later.

You really do need to write your requirement very clearly for everyone to understand, and by doing so will avoid any problems from misinterpretted replies.
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 400
Location: Mumbai

PostPosted: Tue Dec 15, 2009 10:40 pm
Reply with quote

just another critique: Signal in Rexx is not really the same as GOTO in COBOL. It has side effects.

However, Signal is just as difficult to read and debug as GOTO. You should use regular subroutines with Call and Return instead.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top