Group jobs

The following information about group jobs is included as reference material for maintenance of older environments. In today's computing environment, it is typical for a single workstation to have separate sessions for separate functions.

The group jobs are similar to secondary interactive jobs requested by pressing the System Request key; however, up to 16 group jobs can be started for each sign on at a workstation (32 total when there is a secondary interactive job) and the application program can handle interruptions more easily.

Group job benefits

The following lists some of the benefits of group jobs.
  • The workstation user can press the Attention key to interrupt work in one interactive group job, change to any of several other interactive group jobs, and return to the original group job quickly. The Attention key is made valid by the Set Attention Program (SETATNPGM) command and can be used independently of group jobs.
  • Using group jobs with display station pass-through provides a convenient and fast way to change among many interactive jobs on many different systems in a network.

Group job concepts

  • Group jobs apply only to interactive jobs.
  • Up to 16 group jobs can exist in one group (16 more are available if the user transfers to a secondary interactive job).
  • Group jobs are unique to a user (they are not shared by multiple users).
  • Only one group job at a time is active (the others are suspended).
  • Each group job is independent and has its own job log, spooled files, library QTEMP, and so forth.
  • A group job is called by the Transfer to Group Job (TFRGRPJOB) command. This command is typically run from a user-written menu program, which is called by pressing the Attention key (the SETATNPGM command must have been previously run).
  • A 512-byte group data area can be used to pass data between one group job and another. This group data area is implicitly created by the Change Group Attributes (CHGGRPA) command. The CL Programming book contains more information on group data areas.

Changing to and from a group job

To change a nongroup job to a group job and to change a group job back to a nongroup job (if it is the only job in the group), use the Change Group Attributes (CHGGRPA) command.

Creating a new group job

To create a new group job, use the Transfer Group Job (TFRGRPJOB) command.
Note: After each use of the TFRGRPJOB command, the SETATNPGM command must be used to set the Attention key on, if required.

Transferring from one group job to another

To transfer from one group job to another group job in the same group, use the Transfer Group Job (TFRGRPJOB) command.
Note:
  1. After each use of the TFRGRPJOB command, the SETATNPGM command must be used to set the Attention key on, if required.
  2. If you are in an update operation, use the Check Record Lock (CHKRCDLCK) command to check if the job has any record locks before transferring to another group job.

Transferring control from one group job to another

You can transfer control from one group job to another if you have an Attention-key handling program. When the Attention key is pressed, an Attention-key-handling program can either present a menu (from which the user chooses a group job) or immediately transfer the user to another group job. Attention-key-handling support makes it easy to transfer control from one group job to another quickly, without ending one job to go to the other.

Transferring to another group job without seeing a menu

You can use the Attention key to transfer directly to another job without seeing a menu. For example, the Attention-key-handling program for group job A could transfer to group job B. The Attention-key-handling program for group job B could transfer back to group job A. This allows a single keystroke to be used to switch between functions.

Ending a group job

  • To end one group job in a group, use the End Group Job (ENDGRPJOB) command.
  • To end all group jobs in the group, use the SIGNOFF command.
    Note: The ENDJOB command supports the parameter ADLINTJOBS. If *GRPJOB is specified and the job specified on the JOB parameter is a group job, all jobs associated with the group end.

    Additionally, the End Group Job (ENDGRPJOB) command does not support the signal SIGTERM. However, the End Job (ENDJOB) command does support the signal SIGTERM.

Ensuring a normal group job end

In some environments it may be desirable to force the end user to correctly end certain group jobs rather than issuing the ENDGRPJOB command. For example, assume that the user may have a group job where there is a complex update involved and you want to be sure the job is ended normally. Another example is where the user may be in the middle of a SEU session and should complete the function normally.

It is possible to achieve this with the support given by the system. For example, you could use the following instructions:
  1. Set a switch in the group data area that could be tested by each of the group jobs to function as the shutdown switch. That is, when the switch is set on, the group jobs function should be ended.
  2. Access the active group job names by using the RTVGRPA command and the GRPJOBL return variable.
  3. Compare each name accessed (start with the second group job) against a predetermined list of the group job names that should be correctly ended.
  4. If the group job name is not in the list, it can be ended immediately by the ENDGRPJOB command.
  5. If the job must be correctly ended, transfer to the group job using the TFRGRPJOB command.
The Attention-key-handling program for all group jobs must be sensitive to the shutdown switch and would prevent transferring to another group job if the switch is set on.

If you have a controlling program for each of the group jobs that controls what happens when the user ends the function of the group job (for example, the update program), it could also test the shutdown switch and do a return. This ends the group job and returns control to the previous active group job.

The Attention-key-handling program can use the CHKRCDLCK command to determine if the workstation user pressed the Attention key when the application had a record locked for update. In this case, the attention program may send a message instructing the user to complete the operation before using the Attention key.

Group job theory

The CHGGRPA command identifies the current job as a group job and gives it a group job name to uniquely identify it in the group. (At this point the group has only one group job.) Each group job is unique for a user. Two different users do not share the same group job. When a job is designated as a group job, it then has the capability to call a new group job. There are also restrictions on group jobs (such as RRTJOB, TFRJOB may not be used). When there is only one active job in the group, that job can become a nongroup job.

Allowing group jobs to communicate

To allow group jobs to communicate with each other, a special 512-byte data area called a group data area is automatically created when a job becomes a group job. The group data area can only be accessed by jobs in the group by using the special value *GDA in the DTAARA parameter of the data area command.

Calling a group job

The use of group jobs does not require an Attention-key-menu approach as described in this section. A group job can be called from any application program or by the GRPJOB(*SELECT) parameter on the TFRGRPJOB command.

Group jobs and system request function

The Group Job function is similar to the System Request function in that there is only one job active at a time while the others are suspended. Group jobs differ from system request in the following ways:
  • Starting a group job does not require signing on. The same user profile and environment are used.
  • Up to 16 group jobs can exist at any one time. The user must select which group job to transfer to, whereas using system request permits the user to transfer between only two jobs. Normally in group jobs, a menu reached by pressing the Attention key allows the user to select which group job to transfer to. It is possible to use group jobs together with system request for a total of 32 group jobs available for a single user. However, these 32 jobs are in two separate groups, each group having its own group data area and other group attributes.
  • The System Request function allows the workstation user to suspend a job while the keyboard is locked and application functions are in progress. This can interrupt a logical sequence of events. For example, records may be left locked. In contrast, the Attention key is active only when the keyboard is unlocked for input. Also, the application can control when the Attention key is active, and prevent its use at inappropriate times. The System Request function is always available if the workstation user has authority to it.
    Note: The Presystem Request Program exit program is called when the user presses the System Request Key. The operating system calls the user-written exit program through the registration facility when the user presses the System Request key. One parameter is used for input and output. After the exit programs from the registration facility are called, the System Request menu is called based on the value that is returned in the System Request menu display flag. For additional information, see the System API Reference.