Examples of Multi-Trans Scheduling

The following are some pseudocode examples of TPs that use multi-trans scheduling. When the TP is initiated, the shell code gets control first, calls Get_Transaction to obtain the first request, and repeats the call to get subsequent transactions. For example:

initialization for all users
CALL ATBGTRN to obtain work request
DO WHILE WORK_IS_REQUESTED
   ⋮
   transaction processing for the user
   ⋮
   CALL ATBGTRN to obtain the next work request
END WHILE
termination
You can code a transaction program to function as either standard or multi-trans, depending on the schedule type specified in the TP profile. To determine which TP schedule type it was invoked with, a transaction program can use the information extract service (see Extract_Information), and then do the appropriate processing. For example:
(extract TP information -- call ATBEXAI)
IF TP_IS_SCHEDULED_AS_A_STANDARD THEN
   initialization
   transaction processing for the user (TP scheduled as STANDARD)
   termination
ELSE
   initialization for all users
   CALL ATBGTRN to obtain work request
   DO WHILE WORK_IS_REQUESTED
   ⋮
      transaction processing for the user
   ⋮
      CALL ATBGTRN to obtain the next work request
   END WHILE
   termination
END IF

As an alternative to calling the Extract_Information service, the multi-trans shell can issue the Get_Transaction service in any case and continue with standard or multi-trans processing based on the return code from Get_Transaction. For example:

initialization (possibly for all users)
CALL ATBGTRN to obtain work request for a specific user
IF RC=16 (Not a multi-trans environment) THEN
   transaction processing for the user (TP scheduled as STANDARD)
ELSE
   DO WHILE WORK_IS_REQUESTED
   ⋮
      transaction processing for the user
   ⋮
      CALL ATBGTRN to obtain the next work request
   END WHILE
END IF
termination
The multi-trans program can return to its shell environment by calling the Return_Transaction service between conversations, to clean up resources or allocate new ones if necessary. For example:
initialization for all users
allocate data sets
CALL ATBGTRN to obtain work request
DO WHILE WORK_IS_REQUESTED
   ⋮
   transaction processing for the user
   ⋮
   IF data sets are full THEN
      CALL ATBRTRN to return to shell environment
      Reallocate data set
   CALL ATBGTRN to obtain the next work request
END WHILE
termination