RPG & CL development · Intermediate

CL & CLLE orchestration

Build reliable wrappers with typed parameters, scoped error handling, and cleanup.

Learn this topic first: Jobs, CL and batch work management →

7 explained questions · 5 practice MCQs

Questions and answers

1. What should CL do in an application? (Easy)

CL is well suited to orchestration: establish libraries and overrides, invoke programs, submit jobs, inspect attributes, and route messages. RPG or SQL is generally a better fit for substantial business-data transformation.

Keep the wrapper’s contract explicit. It should validate parameters, establish a known environment, call the business operation, and propagate failures meaningfully. A wrapper that silently ignores every message can turn a failed business process into a false scheduler success.

2. How do CLP and CLLE differ in the build flow? (Easy)

CLP is commonly associated with OPM CL program source, while CLLE uses the ILE CL compiler and can participate in modular ILE builds. CRTCLPGM creates an OPM CL program; CRTBNDCL creates a bound ILE CL program; CRTCLMOD creates an ILE CL module.

The actual build command controls the resulting object. When debugging behavior, inspect the compiled program attributes instead of relying only on the source member type.

3. What is command-level versus program-level MONMSG? (Intermediate)

A command-level MONMSG immediately follows the command it monitors. A program-level MONMSG is placed in the declaration portion and provides broader handling for eligible messages not handled locally. MONMSG handles escape, notify, and status messages, not every informational message in the job log.

Use narrow handlers for expected conditions, such as end of file. Broad handlers should preserve diagnostics, clean up, and report failure. Do not suppress CPF0000 just to make a script appear successful.

4. How do DCLF and RCVF support file processing? (Intermediate)

DCLF declares a file and brings its externally described fields into a CL program. RCVF receives a record from that declared file; a supported EOF message can be monitored to end a database read loop. Multiple-file usage requires the applicable declaration and identification conventions.

Use CL file reading for simple control tasks. Complex joins and transformations are usually clearer in SQL or RPG. Confirm which file is being read, and route unexpected file errors separately from normal end of input.

5. Why can CALL parameters cause decimal-data errors? (Intermediate)

A called program interprets the bytes it receives according to its parameter definitions. A caller supplying a different length or numeric representation can cause invalid decimal data or silent truncation. Interactive command defaults may not match the declared RPG interface.

Define typed CL variables for the call and match the receiving program exactly. Check character length, packed precision/scale, argument order, and omitted parameters. Diagnose the interface before blaming the contents of the database.

6. How do you structure loops and branches in CL? (Intermediate)

CL supports conditional commands and structured groups such as IF/ELSE, DO/ENDDO, and supported loop constructs including DOWHILE, DOUNTIL, and DOFOR. Choose the form that clearly expresses the termination condition.

For a file loop, distinguish normal EOF from unexpected errors and ensure each iteration makes progress. For retries, add a bounded attempt count and delay policy. A loop that ignores every error can turn a transient failure into a permanently active job.

7. How should a CL wrapper clean up and report failure? (Advanced)

Record the original failure context before cleanup commands generate additional messages. Remove only the overrides and temporary resources owned by the wrapper, and preserve the business operation’s failure status for its caller or scheduler.

Use distinct success and error paths, with common cleanup where practical. Do not issue an unconditional success message after a failed call. If rollback ownership belongs to the called transaction coordinator, the wrapper should not independently commit partial work.

Practice checkpoint

  1. 1. Which command creates an ILE CL module?
    1. CRTCLPGM
    2. CRTPF
    3. CRTCLMOD
    4. SBMJOB
  2. 2. Where does command-level MONMSG belong?
    1. Only at the end of the source
    2. Inside a DDS record format
    3. In a binding directory
    4. Immediately after the monitored command
  3. 3. Which is a suitable CL responsibility?
    1. Establish environment and orchestrate calls
    2. Replace every database query with text parsing
    3. Change all system values on startup
    4. Suppress all exceptions
  4. 4. What should a broad error handler preserve?
    1. Only a success message
    2. Original diagnostic context and failure status
    3. Only the last cleanup message
    4. Nothing after cleanup
  5. 5. A called RPG program expects packed(9:2). The caller must:
    1. Pass any nine-character text
    2. Always use an integer
    3. Pass a compatible representation and size
    4. Rely on the display value only
Show answer key and explanations

1. C — CRTCLMOD CRTCLMOD produces a module that can be bound into an ILE object.

2. D — Immediately after the monitored command Placement determines which command it monitors.

3. A — Establish environment and orchestrate calls CL wrappers are useful for controlled orchestration.

4. B — Original diagnostic context and failure status Cleanup should not hide the cause or falsely signal success.

5. C — Pass a compatible representation and size Parameter compatibility includes storage layout and scale, not just appearance.

IBM documentation and further reading