                           E X E C P G M


      This routine can be recalled from a Cobol or Assembler program 
to dynamically recall another program (i.e. recall it run-time),
with an optional parameters passed. Program launched can be any program
that normally is run stand-alone, passed parameters simulate parameters
normally in PARM= on EXEC JCL statement. In this JCL step will be added
DDs that this program requires; so calling program cannot use the same
DD of called program. In result of this, since a cobol program requires
SYSPRINT (for DISPLAY statement), and SYSIN (for ACCEPT) is deduced
that in MVS a cobol program cannot recall another cobol program.
With this routine, a Cobol can recall an assembler program (that don't
uses this two files) or an assembler program can recall a cobol.

      this routine can be used in this way:

      CALL 'EXECPGM' USING PROGNAME PARMLEN PARM.

      with, in Cobol:

           PROGNAME   PIC     X(8).
           PARMLEN    PIC    S9(7)  COMP.
           PARM       PIC   X(nnn).

      and in Assembler:

      CALL EXECPGM,(PROGNAME,PARMLEN,PARM),VL

           PROGNAME   DS  CL8
           PARMLEN    DS  F
           PARM       DS  CLnnn

      with this mean:

      PROGNAME        program name to execute
      PARMLEN         length nnn of following PARM, that can be from
                      0 (no PARM) to 100 bytes
      PARM            string containing optional parameters, used by 
                      called program as PARM in EXEC jcl statement.

      Returning to calling program EXECPGM fill PARMLEN variable with
return code of the called program.
      We remark that this routine can recall a stand-alone program, that
is not a routine or a program that is designed to be recalled, statically
(with linkedit) or dinamically at run time. Stand-alone program is launched
in EXEC PGM= jcl statement or directly from TSO user using TSO CALL statement.
      EXECPGM load requested program in memory from load library, transfer
control to it and at its end delete it clearing memory used by it. 
By the way, EXECPGM causes a performance loss in respect to a simple
use of a static CALL.

      Is not possible to use this routine in a CICS program.


      Example:

      ****************************************************************
      * Put in first SYSIN card the name of the program to recall
      *               (in column 1)
      * put in second SYSIN card parameter to pass or leave this line
      *               empty for no parameters
      ****************************************************************
       WORKING-STORAGE SECTION.
       77  PROGNAME   PIC     X(8).
       77  PARM       PIC    X(80).
       77  PARMLEN    PIC    S9(7)   COMP VALUE +80.
      ****************************************************************
       PROCEDURE DIVISION.
       INIZIO.
           ACCEPT NOMEPROG.
           ACCEPT PARM.
           IF NOMEPROG = SPACES   THEN
              DISPLAY 'MISSING PROGRAM NAME.'
              STOP RUN.
           IF PARM = SPACES   THEN
              MOVE  +0        TO PARMLEN
           ELSE
              MOVE +80        TO PARMLEN.
           DISPLAY 'PROGNAME = ' PROGNAME.
           DISPLAY 'PARMLEN  = ' PARMLEN.
           DISPLAY 'PARM     = ' PARM.
           CALL 'EXECPGM' USING PROGNAME PARMLEN PARM.
           DISPLAY 'RC = ' PARMLEN.
           STOP RUN.
      ********************************************************** END *

