MainframeSupports
tip week 8/2009:

More precisely this tip should be called a warning. Some time ago I discovered the hard way that there are some pitfalls when using REXX from TSO. When you issue a CALL statement or performs a function call in REXX then the REXX interpreter will start by looking after a label in the program with the specified name. If there is no such label the REXX interpreter looks for another REXX with the specified name.

When REXX performs an exernal call I believed (before I got wiser) REXX would start by searching the SYSEXEC concatenation followed by a search in the SYSPROC concatenation precisely in the same manner as ISPF SELECT CMD and TSO does. It is unfortunately much more complicated. If the REXX issuing the call is loaded from SYSPROC then REXX will look in the SYSPROC concatenation. I discovered this "trick" because I wanted to override a REXX in SYSPROC by putting a new version with the same name on SYSEXEC. But the new SYSEXEC version was to by big surprise not invoked. So the main rule in REXX is that a call from one REXX to another REXX is always performed using the concatenation from which the caller was loaded. If REXX fails to find the REXX in this concatenation it will switch to normal concatenation search.

Now imagine the following REXX:

/* REXX: CALLING (LOADED FROM SYSEXEC) */
ADDRESS TSO "ALTLIB ACTIVATE APPLICATION(EXEC) DATASET(MY.EXECS)"
CALL CALLER
ADDRESS TSO "ALTLIB DEACTIVATE APPLICATION(EXEC)"

If CALLING is loaded from SYSEXEC the REXX interpreter will start looking for CALLER in SYSEXEC. If CALLER is not found in SYSEXEC then REXX starts looking in ALTLIB but only if it was not found in SYSEXEC. This detail may be pretty frustrating as it may seem like the ALTLIB does not work at all if CALLER is found in SYSEXEC. To acheive the effect you want you must make the following change:

/* REXX: CALLING (LOADED FROM SYSEXEC) */
ADDRESS TSO "ALTLIB ACTIVATE APPLICATION(EXEC) DATASET(MY.EXECS)"
ADDRESS TSO "%CALLER"
ADDRESS TSO "ALTLIB DEACTIVATE APPLICATION(EXEC)"

if CALLER is already placed in SYSEXEC and you want to load it from the ALTLIB concatenation. By the way you can prevent REXX from looking for labels in your program by putting the name of the called REXX in quotes. Write CALL 'CALLER' instead of CALL CALLER to prevent label searching. Please use capital letters in quotes because according to the REXX manual it will not work with small letters.

Previous tip in english        Sidste danske tip        Tip list