CL & Bound Procedures

CLP can use ILE binding just like other HLL programs.

Confirming Using API

/*********************************************************************/
/* PROGRAM NAME - SCSIMBTRC                                          */
/*                                                                   */
/* FUNCTION     - Shell to show prompt and confirm text for the      */
/*              job to upload return files.                          */
/*                                                                   */
/* PROGRAMMER   - STEVE CROY           xx/xx/xxxx                    */
/*********************************************************************/
/*********************************************************************/
/*                   MODIFICATION LOG                                */
/*                                                                   */
/*   DATE    PROGRAMMER      DESCRIPTION                             */
/*********************************************************************/
             PGM

             DCLPRCOPT  DFTACTGRP(*NO) ACTGRP(SCSRPT) +
                          BNDSRVPGM((MST0002SV))

             DCL        VAR(&JOBKEY) TYPE(*CHAR) LEN(3)
             DCL        VAR(&TXT1) TYPE(*CHAR) LEN(255) VALUE('This +
                          is a request to submit the SCS mail trace +
                          return file upload. Are you sure you want +
                          to submit this upload request? Press +
                          ENTER to continue or F12 to cancel this +
                          action.')
             DCL        VAR(&TXT2) TYPE(*CHAR) LEN(27) +
                          VALUE('SCSIMBTRC - Warning')

             MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(EXITPGM))

             CALLPRC    PRC(SETJOBKEY)
             CALLPRC    PRC(DISPLAYMESSAGE) PARM((&TXT1 *BYREF) +
                          (&TXT2 *BYREF))
             CALLPRC    PRC(GETJOBKEY) RTNVAL(&JOBKEY)
             IF         COND(&JOBKEY *NE 'F3' *AND &JOBKEY *NE +
                          'F12') THEN(DO)

             SBMJOB     CMD(CALL PGM(SCS071CL)) JOB(SCSIMBTRC) +
                          JOBQ(*LIBL/CYCJOBQ) USER(SCROYSC)

             ENDDO

             CALLPRC    PRC(SETJOBKEY)

 EXITPGM:    RETURN
             ENDPGM 

This program shows CL binding to some system API's to confirm the an action. Each CALLPRC represents a call to a bound procedure. In this case the program accesses procedures SETJOBKEY, GETJOBKEY, and DISPLAYMESSAGE, procedures that were created to use IBM API's to provide a test display (without a display file) and allow the program to determine what function key was used. This forces the user to confirm the action before the program submits a job.

Since the CL program is bound to the APIs, there is no requirement for a display file to be included in the program. The dedualt job keys are set. The message is displayed using a text variable defined in the program. The procedure GETJOBKEY returns the user's response. If the ENTER key was used (confirming the action) the job continues to execute. If not, the process is conceled.

/*********************************************************************/
/* Program Name - EFS010CL                                           */
/*                                                                   */
/* Function     - This program was designed to build EFS Recon 1     */
/*                format data and move the data to the IFS           */
/*                                                                   */
/* Programmer   - Steve Croy                      06/06/2015         */
/*********************************************************************/
/*********************************************************************/
/*                   Modification log                                */
/*                                                                   */
/*   Date    Programmer      Description                             */
/* xx/xx/xx  xxxxxxxxxxxx    xxxxxxxxxxxxxxx                         */
/*********************************************************************/

             PGM

             DCLPRCOPT  DFTACTGRP(*NO) ACTGRP(FTPS) BNDDIR(EFS001_BD)

             DCL   VAR(&TYP1)     TYPE(*CHAR) LEN(1)   VALUE('C')
             DCL   VAR(&IFSFILE)  TYPE(*CHAR) LEN(120)
             DCL   VAR(&FILENAME) TYPE(*CHAR) LEN(40)
             DCL   VAR(&FILEPATH) TYPE(*CHAR) LEN(128)
             DCL   VAR(&PROGRAM)  TYPE(*CHAR) LEN(10)

             CALLPRC    PRC(GETAPOUTBOUNDPATH) RTNVAL(&FILEPATH)

             CALLPRC    PRC(GETRECON1FILENAME) PARM((&TYP1)) +
                          RTNVAL(&FILENAME)

             CALLPRC    PRC(GETAPRECON1PGM) RTNVAL(&PROGRAM)

             CHGVAR     VAR(&IFSFILE) VALUE(&FILEPATH |< &FILENAME )

             CLRPFM     FILE(EFS3467F)
             CALL       PGM(&PROGRAM)

             CPYTOIMPF  FROMFILE(EFS3467F) TOSTMF(&IFSFILE) +
                          MBROPT(*REPLACE) STMFCCSID(*PCASCII) +
                          RCDDLM(*CRLF) DTAFMT(*FIXED)
 TERMINATE:

             ENDPGM 

In the sample above CALLPRC commands, the call to bound procedures, uses the return value (RTNVAL) to populate the program variables. One of the values returned is the name of a program. The CLP then makes a dynamic call to the program named by the bound procedure.