Explain the difference between SBMJOB and CALL in CL.

Difference Between SBMJOB and CALL in CL (Control Language) on IBM i (AS/400) :

SBMJOB and CALL are both Control Language (CL) commands used to execute programs, but they work differently in terms of execution method, job processing, and system resource management.

1. CALL Command :

The CALL command executes a program immediately in the current job (interactive or batch).

Syntax :

CALL PGM(MYPGM) PARM('VALUE1' 'VALUE2')

 

Characteristics of CALL :

* Runs synchronously – The program executes immediately and must finish before the next command runs.
* Uses the current job's resources – Runs in the same job as the calling program.
* Tied to the user's session – If the session ends, the program stops.
* Common in interactive jobs – Typically used for menu-driven applications.

Example Usage :
  • Running a report immediately within a user's session.
  • Executing a program as part of a CL script.

2. SBMJOB Command
:

The SBMJOB command submits a job to run in batch mode, allowing it to execute separately from the current session.

Syntax :

SBMJOB CMD(CALL PGM(MYPGM)) JOB(MYBATCHJOB)

 

Characteristics of SBMJOB :

* Runs asynchronously – The job runs in the background while the user can continue working.
* Uses a batch subsystem – The submitted job runs in a separate batch job queue.
* Independent execution – Even if the user logs off, the job continues running.
* Good for long-running tasks – Ideal for reports, backups, mass data processing, etc.

Example Usage :
  • Submitting a long report so the user can continue working.
  • Running nightly data processing in a batch queue.

3. Key Differences Between CALL and SBMJOB
Feature CALL SBMJOB
Execution Mode Synchronous (waits to finish) Asynchronous (runs in background)
Job Type Runs in the current interactive/batch job Runs in a separate batch job
User Interaction Tied to user session Runs independently
Resource Usage Uses current job’s resources Uses a batch subsystem
Best Used For Immediate program execution Background processing, long tasks
Continues If User Logs Off? No Yes

4. Example Use Case Comparison :

Scenario: A user wants to generate a large report.

  • If they use CALL, they must wait until the report finishes.
  • If they use SBMJOB, they can continue working while the report runs in the background.