Calling REXX external function from Cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Calling REXX external function from Cobol

Postby ManfredU » Fri Feb 10, 2012 11:57 pm

I've got a REXX external function coded in assembler, which I'm using successfully from REXX. Is it possible to call it from a Cobol program as well and how would that look like? Thanks!
ManfredU
 
Posts: 4
Joined: Fri Feb 10, 2012 11:25 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Calling REXX external function from Cobol

Postby enrico-sorichetti » Sat Feb 11, 2012 12:04 am

REXX external function has a very specific meaning
do You realize that the parameter passing conventions are completely different from the standard?

start here
http://publibz.boulder.ibm.com/cgi-bin/ ... s/IKJ4BK90
and proceed to
http://publibz.boulder.ibm.com/cgi-bin/ ... 0626210253
and to
http://publibz.boulder.ibm.com/cgi-bin/ ... T#FIRSTHIT
to arrive here for the details
http://publibz.boulder.ibm.com/cgi-bin/ ... 0253&CASE=
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Calling REXX external function from Cobol

Postby ManfredU » Sat Feb 11, 2012 12:22 am

enrico-sorichetti wrote:REXX external function has a very specific meaning
do You realize that the parameter passing conventions are completely different from the standard?


Yes, that's why I'm asking if it would be doable at all. Including retrieving the return value?
ManfredU
 
Posts: 4
Joined: Fri Feb 10, 2012 11:25 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Calling REXX external function from Cobol

Postby BillyBoyo » Sun Feb 12, 2012 4:27 am

Is your Assembler program Language Environment "compilant"? If so, it might be possible. Make a cut-down version which does something noticeable when called, and try it, by setting up a table of address/lengths and then calling with the table. A return value should be possible as well. The manual shows how to call C functions, and if it is similar-enough there is a chance.

However, if not LE compliant, go whistle.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Calling REXX external function from Cobol

Postby enrico-sorichetti » Sun Feb 12, 2012 4:44 am

LE compliancy does not make any difference ....
rexx external function has a specific meaning as far as the execution environment and parameter passing are concerned ...
for example when using retcode = function(....)
the return code is not passed using reg 15 it is passed using the REXX evalblock...
( a non zero r15 will result in REXX issuing the message Incorrect call to routine

and... and... and... ;)
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Calling REXX external function from Cobol

Postby BillyBoyo » Sun Feb 12, 2012 6:20 am

If not LE compliant, won't (probably) work from (LE Compliant) Cobol.

If the rexx external function requires a specific execution environment, that would be an issue.

Cobol can call a C/C++ function, doesn't use the R15 return-code (has a tucked-away piece of storage you can specify).

Looking at the parameter set-up and the ability to receive the return-value from a "function call", it could be "possible". Either or both of the two "environment" things could kill the possibility.

and... and... and... certainly. I haven't done it, so I don't know what lurks. Don't have TS's assembler mini-version.

Does the usage have to be a "rexx external function"? Can't the rexx just use a module which is OK for the Cobol program to call? Maybe not "cool" enough.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Calling REXX external function from Cobol

Postby NicC » Sun Feb 12, 2012 11:15 am

Could one call the function from a rexx snippet called from the cobol program? Wouldn't try it in production though!
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Calling REXX external function from Cobol

Postby enrico-sorichetti » Sun Feb 12, 2012 2:07 pm

Does the usage have to be a "rexx external function"?

if the <function> has been written as a rexx external function that' s it
Can't the rexx just use a module which is OK for the Cobol program to call?

if the <thing> has already been written, it must be REwritten as a <standard> callable <object>

REXX variables are variable-length strings and REXX takes care of everything,
as seen here http://publibz.boulder.ibm.com/cgi-bin/ ... 0253&CASE=
where rexx takes care of all the length issues
values can be passed back to the calling REXX
1 - using rexx SHV interface for REXX under TSO or IRXJCL
2 - using IKJCT441 ( TSO generic variable access routine ) for REXX under TSO
- both methods have pros/cons
1 - valid only for REXX scripts
2 - allows to share variables with CLISTS

using the Address <environment> facility any assembler subroutine can be called from REXX ( see IGGCSI00 )
but then all the variable handling is less than automated ( the user must provide for fixed/variable length issues )
Maybe not "cool" enough.

coolness does not make any difference, it is just impractical

Could one call the function from a rexx snippet called from the cobol program?

but then there would be the issue of passing back to COBOL the results
COBOL/REXX is kind of unidirectional, things can be passed to REXX, not back :geek:
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Calling REXX external function from Cobol

Postby BillyBoyo » Sun Feb 12, 2012 4:21 pm

I think we are going round in circles and digging ourselves in deeper, somehow.

Cobol can build the parameter block like that. On the Call, the RETURNING phrase could be used to receive the function value into a data-item defined in the Cobol programl.

If the parameter-block/return value would be the same for calling rexx, then that is good. I've been told calling rexx from Cobol is possible.

As for further two-communication between Cobol/rexx the address/length gives the option of changing the data at that address, doesn't it?

I may be missing something "obvious" because I haven't done any of this. From the manual I can't see the problem with these parts.

The "evironment" stuff can turn out to be a different thing entirely. Parameters/communication/return-value should work. Not with a "vanilla" CALL, but nothing too complex or obscure.

Without the assembler snippet I can't test it :-)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Calling REXX external function from Cobol

Postby ManfredU » Sun Feb 12, 2012 4:31 pm

enrico-sorichetti wrote:
Does the usage have to be a "rexx external function"?

if the <function> has been written as a rexx external function that' s it


Yes, it does already exist and is working fine (from rexx).

enrico-sorichetti wrote:
Can't the rexx just use a module which is OK for the Cobol program to call?

if the <thing> has already been written, it must be REwritten as a <standard> callable <object>


Creating a second version for Cobol would of course be an option, but unfortunately it's probably beyond my capabilities...

enrico-sorichetti wrote:REXX variables are variable-length strings and REXX takes care of everything,
as seen here http://publibz.boulder.ibm.com/cgi-bin/ ... 0253&CASE=
where rexx takes care of all the length issues
values can be passed back to the calling REXX
1 - using rexx SHV interface for REXX under TSO or IRXJCL
2 - using IKJCT441 ( TSO generic variable access routine ) for REXX under TSO
- both methods have pros/cons
1 - valid only for REXX scripts
2 - allows to share variables with CLISTS


As far as I can see evalblock and SHV is used.

enrico-sorichetti wrote:
Could one call the function from a rexx snippet called from the cobol program?

but then there would be the issue of passing back to COBOL the results
COBOL/REXX is kind of unidirectional, things can be passed to REXX, not back :geek:


And this would probably be very slow as well.
ManfredU
 
Posts: 4
Joined: Fri Feb 10, 2012 11:25 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post