Page 1 of 1

Receive value from called REXX to calling REXX

PostPosted: Thu Feb 21, 2013 11:47 pm
by nikesh_rai
Hi,

Is it possible to receive value from a rexx module. A rexx module REXX1 is calling another rexx module REXX2 with call statement:

CALL REXX2 XSUBSYS,XCRTRID,XTBLNME,XINPFLE,SQLRTCD


the value for SQLRTCD is being processed in REXX2, and I want to receive it in REXX1. Can you please suggest me on this..

Re: Receive value from called REXX to calling REXX

PostPosted: Fri Feb 22, 2013 12:04 am
by Akatsukami
I suggest that you either use ISPF VGET/VPUT services, or roll your own equivalents (if absolutely necessary).

Re: Receive value from called REXX to calling REXX

PostPosted: Fri Feb 22, 2013 12:10 am
by enrico-sorichetti
unfortunately what You ask for cannot be obtained by simple means

also in IT using the right terminology is essential for good communication

using the word module implies that You are running a compiled REXX , the name tells, modules
not an interpreted one

if You describe better the environment somebody might have better suggestions

Re: Receive value from called REXX to calling REXX

PostPosted: Fri Feb 22, 2013 3:23 am
by Pedro
Try calling it as a function:

SQLRTCD1  =  REXX2(XSUBSYS,XCRTRID,XTBLNME,XINPFLE)


where REXX2 ends with:
EXIT SQLRTCD

Re: Receive value from called REXX to calling REXX

PostPosted: Fri Feb 22, 2013 12:00 pm
by nikesh_rai
One more issue is there, the value I am passing from Rexx1 to Rexx2 is not being received in Rexx2. I tried to display the values and all are coming as blank.. is there anything I need to include in my code:

Rexx1:

CALL REXX2 XSUBSYS,XCRTRID,XTBLNME,XINPFLE,SQLRTCD


Rexx2:
SAY XSUBSYS                                     
SAY XCRTRID                                     
SAY XTBLNME                                     
ADDRESS ISPEXEC                                 
"VPUT(XSUBSYS,XCRTRID,XTBLNME)"                 
SAY XSUBSYS                                     
SAY XCRTRID                                     
SAY XTBLNME                                     
ADDRESS TSO 'SUBCOM DSNREXX'                     
IF RC = 1 THEN DO                               
   S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')   
END                                             

Re: Receive value from called REXX to calling REXX

PostPosted: Fri Feb 22, 2013 12:41 pm
by enrico-sorichetti
in the called function/subroutine You will have to <PARSE> the arglist or use the ARG(...) function

but... why not meditate a bit more on the manuals :geek:

Re: Receive value from called REXX to calling REXX

PostPosted: Fri Feb 22, 2013 12:54 pm
by nikesh_rai
Thanks Enrico,

Checked manulas... ARG is working for me.. my second issue has been resolved.. but not the first one.. :)
I am checking manuals for the Ist issue as well.. if got something.. will update here... and if not.. I will back again.. ;)

Re: Receive value from called REXX to calling REXX

PostPosted: Fri Feb 22, 2013 3:13 pm
by nikesh_rai
Got the 1st one also.. thanks Pedro.. you suggestion worked.. :)
Thanks to Enrico as well... :)

here is the code for refrence:

Rexx1:

CALL REXX2 XSUBSYS,XCRTRID,XTBLNME,XINPFLE,SQLRTCD 
SQLRTCD = REXX2(XSUBSYS,XCRTRID,XTBLNME,XINPFLE)   


Rexx2:

ARG XSUBSYS,XCRTRID,XTBLNME,XINPFLE,SQLRTCD     
SAY 'NIK1 ' XSUBSYS                             
SAY 'NIK2 ' XCRTRID                             
SAY 'NIK3 ' XTBLNME                             
SAY 'NIK4 ' XINPFLE                             
SAY 'NIK5 ' SQLRTCD                             
.......

IF (SQLCD1 ¬= 0 | SQLCD2 ¬= 0 | SQLCD3 ¬= 0 | SQLCD4 ¬= 0 |  ,   
    SQLCD5 ¬= 0 | SQLCD6 ¬= 0 | SQLCD7 ¬= 0 ) THEN               
    DO                                                           
       SQLRTCD = 1                                               
    END                                                         
ELSE                                                             
    DO                                                           
       IF SQLDA1 = 0 THEN                                       
          SQLRTCD = 2                                           
       ELSE DO                                                   
          SQLRTCD = 3                                           
       END                                                       
    END                                                         
                                                                 
RETURN (SQLRTCD)                                                 


Thanks
Nikesh

Re: Receive value from called REXX to calling REXX

PostPosted: Fri Feb 22, 2013 7:34 pm
by Pedro
CALL REXX2 XSUBSYS,XCRTRID,XTBLNME,XINPFLE,SQLRTCD
SQLRTCD = REXX2(XSUBSYS,XCRTRID,XTBLNME,XINPFLE)


You are calling REXX2 twice: once as an external routine and again as an external function. You do not need the first instance.

Re: Receive value from called REXX to calling REXX

PostPosted: Sat Feb 23, 2013 12:27 pm
by nikesh_rai
Thanks Pedro...

deleted first line.. and it is still working.. Thanks.. :)