ENDJOB (End Job)

ENDJOB Command syntax diagram

 

Purpose

The End Job (ENDJOB) command ends the specified job and any associated inline data files. The job may be on a job queue, it may be active within a system, or it may have already completed running.

You can specify that the application program is given time to control end-of-job processing. If no time is given or if cleanup cannot be performed within the given time, the system performs minimal end-of-job processing, which can include:

All spooled files associated with the job being ended can also be deleted or allowed to remain on the output queue.

 

Restrictions

  1. The issuer of the command must be running under a user profile which is the same as the job user identity of the job being ended, or the issuer of the command must be running under a user profile which has job control (*JOBCTL) special authority.

    The job user identity is the name of the user profile by which a job is known to other jobs. It is described in more detail in the Work Management Link to PDF book.

 

Required Parameters

JOB
Specifies the name of the job that is ended. If no job qualifier is given, all of the jobs currently in the system are searched for the simple job name. If more than one of the specified name is found, a qualified job name must be specified.

A job identifier is a qualified name with up to three elements. For example:

job-name
user-name/job-name
job-number/user-name/job-name

More information on this parameter is in Commonly used parameters.

job-name: Specify the name of the job that is ended.

user-name: Specify the name of the user of the job that is ended.

job-number: Specify the number of the job that is ended.

 

Optional Parameters

OPTION
Specifies whether the job is ended in a controlled manner, which lets the application program perform end-of-job processing, or is ended immediately. In either case, the system performs certain job cleanup processing.

*CNTRLD: The job is ended in a controlled manner. This allows the program to perform cleanup (end-of-job processing). The application has the amount of time specified on the DELAY parameter to complete cleanup before the job is ended.

*IMMED: The job ends immediately and the system performs end-of-job cleanup. System cleanup can take from a brief amount of time to several minutes.

Note: This value is recommended only if specifying the *CNTRLD value has been unsuccessful. When you specify the *IMMED value, you can get undesirable results, for example, from data that has been partially updated.

DELAY
Specifies the amount of time (in seconds) that the job has to complete its end-of-job processing during a controlled end. If the end-of-job processing is not completed before the end of the delay time, the job is ended immediately, and only system cleanup is performed.

The delay time does not start until the job becomes active if the job is suspended because of one of the following conditions:

  • The system request option 1 is selected.
  • The job is held by the Hold Job (HLDJOB) command.
  • The job is transferred by the Transfer Secondary Job (TFRSECJOB) command.
  • The job is transferred by the Transfer Group Job (TFRGRPJOB) command.

Note: This parameter is valid only when OPTION(*CNTRLD) is specified.

30: A maximum delay time of 30 seconds is allowed for cleanup before the job is ended.

delay-time: Specify the maximum amount of delay time (in seconds) before the job is ended. Valid values range from 1 through 999999 seconds. For additional information on the use of the DELAY parameter for ending an end-of-file delay job, refer to the EOFDLY (End of File Delay) parameter of the Override Database File (OVRDBF) command.

SPLFILE
Specifies whether to delete the spooled files created by this job. Regardless of whether the spooled files are deleted, the job logs related to the spooled files are kept.

*NO: The spooled files are not deleted. They are kept for normal processing by a writer. Start of changeWhen the job ends, the spooled file action (SPLFACN) job attribute determines whether spooled files are detached from the job or kept with the job.>

*YES: The spooled files are deleted. If the job has already ended and the spooled file action for the job is to detach the spooled files, the End Job (ENDJOB) command will not find the job and the spooled files will not be deleted.>

LOGLMT
Specifies the logging limit, which is the maximum number of message entries that are written to the job log printer file (QPJOBLOG) from the message queue of an ending job.

If a job to be ended with this command is already ending, the value specified on this parameter can change the logging limit of the job that is ending. The following are examples of how the logging limit can be changed:

  1. If the value specified is greater than the number of messages written at the time the command is issued, messages continue to be written until the new limit is reached.
  2. If the value specified is less than the number of messages already written to the spooled file, a message indicating that the limit has been reached is immediately put in the spooled file as the last entry. The remaining messages on the queue are ignored.
  3. If 0 (zero) is specified before any messages are written to the spooled file, no job log is produced for the job that is ending.

*SAME: The value does not change. If no logging limit has been established previously for the job, the system uses the *NOMAX value.

*NOMAX: There is no maximum number of message entries logged. All messages on the job message queue are written to the job log.

maximum-logged-entries: Specify the maximum number of messages written to the job log.

ADLINTJOBS
Specifies whether additional interactive jobs associated with the job specified in the JOB parameter are being ended. The additional interactive jobs can be group jobs or all jobs associated with the work station (group and secondary jobs) where the job specified in the JOB parameter is running. The job specified in the JOB parameter does not have to be the active job. A job name entered on the JOB parameter must resolve to a single interactive job for this parameter to be used. If the job is not an interactive job, an error message is sent.

*NONE: Only the job specified in the JOB parameter is ended.

*GRPJOB: If the job specified in the JOB parameter is a group job, all jobs associated with the group are ended. If the job is not a group job, the job specified in the JOB parameter is ended.

*ALL: All interactive jobs running on the work station associated with the job specified in the JOB parameter are ended, including group jobs and secondary jobs.

DUPJOBOPT
Specifies the action taken when duplicate jobs are found by this command.

*SELECT: The selection display is shown when duplicate jobs are found during an interactive session. Otherwise, a message is issued.

*MSG: A message is issued when duplicate jobs are found.

Examples for ENDJOB

Example 1: Ending a Job Immediately

ENDJOB   JOB(JOB1)  OPTION(*IMMED)  SPLFILE(*YES)

This command ends a job named JOB1 immediately. Spooled output produced by the job is deleted; the job log is saved.

Example 2: Saving Spooled Output

ENDJOB   JOB(001234/XYZ/JOB2)  OPTION(*CNTRLD)
  DELAY(50)  SPLFILE(*NO)

This command ends a job named 001234/XYZ/JOB2. Spooled output is saved for normal processing by the spooling writer. The job has 50 seconds to perform any cleanup routines, after which it is ended immediately.

Error messages for ENDJOB

*ESCAPE Messages

CPF1317
No response from subsystem for job &3/&2/&1.
CPF1321
Job &1 user &2 job number &3 not found.
CPF1332
End of duplicate job names.
CPF1340
Job control function not performed.
CPF1341
Reader or writer &3/&2/&1 not allowed as job name.
CPF1342
Current job not allowed as job name on this command.
CPF1343
Job &3/&2/&1 not valid job type for function.
CPF1344
Not authorized to control job &3/&2/&1.
CPF1351
Function check occurred in subsystem for job &3/&2/&1.
CPF1352
Function not done. &3/&2/&1 in transition condition.
CPF1359
ENDJOBABN not allowed at this time for job &3/&2/&1.
CPF1360
&3/&2/&1 already ending because of ENDJOBABN.
CPF1361
Job &3/&2/&1 already ending with *IMMED option.
CPF1362
Job &3/&2/&1 has completed.
CPF1363
Job &3/&2/&1 is already ending *CNTRLD.
CPF8172
Spool control block for job &10/&9/&8 damaged.