Operations

180 Views


Operations performed by CL programs or procedures

This is an overview of the types of operations that can be performed by using CL programs or procedures.

In general, you can perform the following operations: 

  • Use variables, logic control commands, expressions, and built-in functions to manipulate and process data within a CL program or procedure:
PGM
DCL &C *LGL
DCL &A *DEC VALUE(22)
DCL &B *CHAR VALUE(ABCDE)
•
•
•
CHGVAR &A (&A + 30)
•
•
•
IF (&A < 50) THEN(CHGVAR &C ’1’)
•
DSPLIB (’Q’ ∨∨ &B)
•
IF (%SST(&B 5 1)=E) THEN(CHGVAR &A 12)
•
•
•
ENDPGM
  • Use a system value as a variable in a CL program or procedure.
  • Use a job attribute as a variable in a CL program or procedure.
  • Send and receive data to and from a display file with a CL program or procedure.
  • Create a CL program or procedure to monitor error messages for a job and to take corrective action if necessary
    			PGM
    			MONMSG MSGID(CPF0001) EXEC(GOTO ERROR)
    			CALL PROGA
    			CALL PROGB
    			RETURN
    ERROR:      SNDPGMMSG MSG(’A CALL command failed’) MSGTYPE(*ESCAPE)
    			ENDPGM
  • Control processing among procedures and programs and pass parameters from a CL program or procedure to other programs or procedures to override files.

A CL program or procedure can call programs or procedures written in other languages.

The preceding figure shows how control can be passed between a CL program or procedure, RPG IV, and Integrated Language Environment (ILE) COBOL procedures in an application. 

To use the application, a workstation user can request program A, which controls the entire application.

The figure shows a single bound program (PGMA) that is called using the CALL command with PGMA.

PGMA consists of the following procedures:

  • A CL procedure (PGMA) calling an RPG IV procedure (PGMB)
  • An RPG IV procedure (PGMB) calling another RPG IV procedure (PGMC)
  • An RPG IV procedure (PGMB) calling a CL procedure (PGMD)
  • A CL procedure (PGMA) calling an ILE COBOL procedure (PGME)
  • An ILE COBOL procedure (PGME) calling a CL procedure (PGMF)

The procedures can be created as indicated in the following example. You can enter source for procedures in separate source members. 

CRTCLMOD PGMA
CRTRPGMOD PGMB
CRTRPGMOD PGMC
CRTCLMOD PGMD
CRTCBLMOD PGME
CRTCLMOD PGMF
CRTPGM PGM(PGMA) +
MODULE(PGMA PGMB PGMC PGMD PGME PGMF) +
ENTMOD(*FIRST)

Post Comments