MainframeSupports
tip week 46/2008:

In week 25/2007 I described how to execute TSO commands from COBOL and PL/I. When doing so in batch your program is required to run in TSO using program IKJEFT01. I think it will be much more elegant if I am able to use EXEC PGM=MYTSOPGM instead of EXEC PGM=IKJEFT01 and still be able to use TSO commands.

To my surprise a little research revealed that it is indeed possible to execute TSO commands without using IKJEFT01. A module called TSOENV starts the TSO command processor a makes it available for your executing program. When TSOENV has been called once you may execute as many TSO commands as you like using TSOLNK and it works just as good as when you use IKJEFT01 as the main program.

Execute TSOENV from COBOL like this:

* WORKING STORAGE DECLARATIONS
 01  PARM1 PICTURE S9(9) COMP.
 01  PARM2 PICTURE S9(9) COMP.
 01  PARM3 PICTURE S9(9) COMP.
 01  PARM4 PICTURE S9(9) COMP.
 01  PARM5 POINTER.

* STATEMENTS IN PROCEDURE DIVISIONS
     MOVE 0 TO PARM1
     SET PARM5 TO NULL
     CALL 'TSOENV' USING PARM1 PARM2 PARM3 PARM4 PARM5
     IF RETURN-CODE NOT = 0
       DISPLAY 'TSOENV FAILED WITH RETURN-CODE = ' RETURN-CODE
     END-IF

In PL/I it is just as simple:

DCL PARM1 FIXED BIN(31);
DCL PARM2 FIXED BIN(31);
DCL PARM3 FIXED BIN(31);
DCL PARM4 FIXED BIN(31);
DCL PARM5 FIXED BIN(31);
DCL TSOENV EXT ENTRY OPTIONS(ASM INTER RETCODE);

PARM1 = 0;
PARM5 = NULL();
CALL TSOENV(PARM1, PARM2, PARM3, PARM4, PARM5);
IF PLIRETV() ^= 0
THEN
  DISPLAY('TSOENV FAILED WITH RETURN-CODE = ' !! PLIRETV());

If RETURN-CODE or PLIRETV() is not equal to zero it may very well be because the TSO command processor is already established and you are already ready to call TSOLNK without any problems. In fact you may code all your TSO command executing programs with a call to TSOENV and just ignore the return code. Then your TSO commands will always work and you do not have to worry about whether IKJEFT01 was invoked or not.

I have a strong feeling telling me that there are limits to the amount of TSO commands which will work when the TSO command processor has been invoked using TSOENV. I have not tried RACF commands or HSM commands and I am not sure they will work. Until now I have only used the commands described in the TSO command reference and they work fine.

Previous tip in english        Sidste danske tip        Tip list