Page 1 of 1

host command environment routine in REXX

PostPosted: Fri Jun 23, 2023 4:43 pm
by macuko
Dear experienced mainframe programmers,

For the past couple of years I have been happy to use this site when I was looking for a solution to a mainframe related problem. This is the first time I am asking for help.

I have my own Host Command Environment (MYOWN) - added by program REXXCOMM - CBT830(E4350A4A) and I created a host command environment routine (MYPGM) in REXX (compiled and link-edited with stub CPPL) but I cannot use it in an EXEC in the following way (got 0C4 abend):
Address MYOWN "long parameter string"


If I use stub MVS instead of CPPL, no 0C4 but the parameter ("long parameter string") is not passed to the compiled REXX program at all. I finally tried all the stubs, but only for MVS I do not get 0C4 abend.

Am I correct that I cannot use REXX to create a host command environment routine? (Unfortunately, I do not have Assembler/Cobol experience...)

Thanks in advance!

Re: host command environment routine in REXX

PostPosted: Sun Jun 25, 2023 9:52 am
by Pedro
The parameter list for a host command is described in Rexx Reference, section "Host command environment routine". As far as I can tell, the parameters do not map to any of those choices that are available as the stub for a compiled rexx program. I do not think you can do what you want to do.

But I question why you are trying to do that. Why do you need your own host command environment if you are not writing in assembler?

It seems like you can execute the program with:
1. compile and link with stub CPPL
2. Execute with
Address TSO "MYPGM long parameter string"



Details of host command environment routine parameters: https://www.ibm.com/docs/en/zos/2.1.0?t ... nt-routine

Re: host command environment routine in REXX

PostPosted: Sun Jun 25, 2023 2:55 pm
by macuko
Thanks for your answer, Pedro!

As far as I can tell, the parameters do not map to any of those choices that are available as the stub for a compiled rexx program.

I see, this is exactly what I expected... Thank you!

But I question why you are trying to do that. Why do you need your own host command environment if you are not writing in assembler?

Yes, good question. Long story short:
I have a REXX program that is used by clients who have a product that uses own host command environment. This product cannot be installed on my development system, but I want to "simulate" this host command environment in order to test my REXX program and simulate the actual running of the program during client demos. And I do not want to maintane 2 programs (the real program and the simulator). I would prefer to simulate the client environment on my own development system.

Here is my idea for a solution:
Create a "driver" program in Assembler which would do nothing but receive parameters from Address MYOWN instruction and it would pass the parameters unchanged to my simulator REXX program. Sounds easy, but not with 0 Assembler knowledge.
I tried searching on the internet but could not find a specific solution. I see IBM examples of how to call REXX from Assembler but first of all it would be nice to see a sample Assembler program that shows how to process the parameters according to the host command environment routine rules (you linked).

Address TSO "MYPGM long parameter string"

By the way, your suggested solution works fine. I use this in some other places when I only need to emulate a command, not a host command environment.

Re: host command environment routine in REXX

PostPosted: Sun Jun 25, 2023 11:34 pm
by Pedro
I understand your desire to simulate the production environment. I am a strong proponent of scaffolding programs. When I was a developer at IBM, I wrote several thousand lines of scaffolding code to simulate the response from IMS operator commands. I used it to test my component before my peers' work was ready. This was also particularly useful to test rare error situations.

I agree that an assembler program would be best, but you have to consider what is feasible based on your skills. My suggestion is to have two lines of scaffolding. Consider the following example, where MYOWN is different in the production system vs. the test system:

MYOWN = 'MYOWN'
If MVSVAR('SYSNAME') = 'TESTSYS1' Then /*system name from parmlib*/
  MYOWN = 'TSO MYPGM'
 
...

Address MYOWN "long parameter string"


This might not work for a simple 'Address MYOWN' command to switch host environments.

Re: host command environment routine in REXX

PostPosted: Mon Jun 26, 2023 12:23 am
by macuko
Wow. That is a brilliant solution. Simple, but great. I did not even think of that...
Thank you very much, Pedro!

Maybe later I will give it a try and ask in the Assembler topic if anyone has a sample code for processing the parameters of host commant environment routine.

But for now I am fine with this solution. Thanks again!

Re: host command environment routine in REXX

PostPosted: Tue Jun 27, 2023 8:24 pm
by macuko
I tested it and unfortunately it does not work without "Interpret". But of course it can still be used. ;)
MYOWN = 'MYOWN'
If MVSVAR('SYSNAME') = 'TESTSYS1' Then /*system name from parmlib*/
  MYOWN = 'TSO MYPGM'
 
...

Interpret 'Address 'MYOWN '"long parameter string"'