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

How to pass parameters to another REXX program


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

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Mon Jan 05, 2009 5:39 pm
Reply with quote

Hi,

I have this caller program(main program)
Code:
/**** REXX ************************************/
SAY 'MAIN PRG'                                   
EX 'REXX.EXEC(CALLED)' 'SUSHANTH' EX             


This is the sub-program which is also in the same PDS. the name of the program is CALLED
Code:
/**** REXX ************************************/     
SAY 'IN-SUB'                                         
ARG PARM1                                           
SELECT                                               
 WHEN PARM1='SUSHANTH' THEN SAY 'HELLO SUSHANTH'     
 OTHERWISE SAY 'WHO ARE YOU ? WHAT IS YOUR PURPOSE ?'
END                                                 


Invalid keyword, sushanth is coming as error message.

this is the trace information
Code:
MAIN PRG                                       
     4 *-* EX 'REXX.EXEC(CALLED)' 'SUSHANTH' EX
       >L>   "EX"                             
        >L>   "REXX.EXEC(CALLED)"               
        >O>   "EX REXX.EXEC(CALLED)"             
        >L>   "SUSHANTH"                         
        >O>   "EX REXX.EXEC(CALLED) SUSHANTH"   
        >L>   "EX"                               
        >O>   "EX REXX.EXEC(CALLED) SUSHANTH EX"
 INVALID KEYWORD, SUSHANTH                       
        +++ RC(12) +++                           


Sushanth
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Mon Jan 05, 2009 5:48 pm
Reply with quote

Hey,

Got it
Code:
CALL CALLED 'SUSHANTH'   


What is the difference between CALL & EXEC ?

Sushanth
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Mon Jan 05, 2009 8:17 pm
Reply with quote

Interesting problem. I was looking in the TSO/E REXX documentation and I double-checked that against MVS/Quick-Ref for REXX and I couldn't find any evidence of a REXX instruction or function called "EX" or "EXEC". As far as I know, EXEC is a TSO command, as issuing the command "TSO HELP EXEC" gave me the description of the command. I don't know why when coded the way you did the REXX Interpreter doesn't return an error message such as
"IKJ56500I COMMAND EX NOT FOUND", but it doesn't.

To answer your question, EXEC is a TSO/E command, as is CALL. The difference given between them is:

"THE EXEC COMMAND INITIATES EXECUTION OF A COMMAND PROCEDURE."

"The CALL command loads and executes programs in executable form."

There is a TSO/E REXX "CALL" instruction which is used to Call a sub-routine or procedure, with the control returned back to the line of code immediately following the CALL instruction.
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Mon Jan 05, 2009 10:38 pm
Reply with quote

I agree you should use the rexx CALL instruction.

EXEC would have worked if you used double quotes around your parameters. Both the EXEC statement and rexx host commands use quote characters in their syntax, so in order to make sure the get passed through, you have to use two sets.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Tue Jan 06, 2009 10:39 am
Reply with quote

Pedro,

It worked....
Code:
/**** REXX ************************************/ 
SAY 'MAIN PRG'                                   
EX 'REXX.EXEC(CALLED)' "'SUSHANTH'" EX           
/*CALL CALLED 'SUSHANTH'*/                       


Thank You Very Much,
Sushanth Bobby
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Tue Jan 06, 2009 10:16 pm
Reply with quote

It is not clear if you were just testing for curiosity.

Note my previous comment:
Quote:
I agree you should use the rexx CALL instruction.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Wed Jan 07, 2009 9:53 am
Reply with quote

Pedro,

I was testing for my curiosity only.
In the real thing, as you said, i will use CALL instruction.

Thank You Very Much,
Sushanth Bobby
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Wed Jan 07, 2009 10:09 pm
Reply with quote

You said this worked:
Code:
/**** REXX ************************************/
SAY 'MAIN PRG'                                   
EX 'REXX.EXEC(CALLED)' "'SUSHANTH'" EX           
/*CALL CALLED 'SUSHANTH'*/ 


But I think there should be more quoted text:
Code:
/**** REXX ************************************/
SAY 'MAIN PRG'                                   
Address TSO
"EX 'REXX.EXEC(CALLED)' 'SUSHANTH' EX "
/*CALL CALLED 'SUSHANTH'*/ 

1. Otherwise you might have problems with dataset prefix. If someone else runs the program, it might not work.

2. very slight performance issue. Rexx will treat all non-quoted strings as variables and try to substitute. For example, the first characters are 'EX'... it will look for a variable named EX will not find one then use the name of the variable in uppercase. You already know it is not a variable, so do not make rexx do the additional processing.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Thu Jan 08, 2009 10:21 am
Reply with quote

Oh 0.k PEDRO,
Thanks for information.
Back to top
View user's profile Send private message
janaonline

New User


Joined: 13 Dec 2007
Posts: 11
Location: USA, California

PostPosted: Fri Sep 17, 2010 1:53 am
Reply with quote

Thanks guys!!!!

This was actually very useful for me and completed my assignment...

This forum is amazing.....

icon_smile.gif icon_smile.gif icon_smile.gif icon_smile.gif icon_smile.gif icon_smile.gif
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 Using API Gateway from CICS program CICS 0
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
Search our Forums:

Back to Top