BB005 RPG36
The BB005.rpg36.txt
document is an RPG III (System/36 style) program called from the BB101.ocl36.txt
OCL program in an IBM System/36 or AS/400 (now IBM i) environment. Its primary function is to release or post a batch by updating the BBBTCH
file based on the program mode (PGM
). Below is a detailed explanation of the process steps, business rules, tables (files) used, and any external programs called.
Process Steps of the RPG Program¶
The BB005
RPG program updates the batch status in the BBBTCH
file to reflect actions such as releasing, generating a pick list, printing a bill of lading (BOL), or posting the batch. The process is driven by the PGM
parameter and involves a single file operation. The steps are as follows:
- Program Initialization:
- The program is defined with a header specification (
H P064
) and identified asBB005
. - It defines the
BBBTCH
file as update-capable (48 bytes, indexed, key length 2, access mode 2). -
The user data structure (
UDS
) defines input fields from the local data area:BATCH#
(positions 490-491, 2 digits): Batch number.PGM
(position 504, 1 character): Program mode ('O', 'L', 'B', or 'P').RECCNT
(positions 475-482, 8 digits): Record count.
-
Main Processing Logic:
- The program chains to the
BBBTCH
file usingBATCH#
as the key (line 0011). - If a record is found (
N99
, line 0013), it enters aDO
loop (B1
toE1
):- Checks the
PGM
value to determine the action: - If
PGM='O'
(Order Entry, lines 0015-0016):- Executes the
REL
exception output to release the batch.
- Executes the
- If
PGM='L'
(Pick List, lines 0018-0019):- Executes the
PICK
exception output to generate a pick list.
- Executes the
- If
PGM='B'
(Bill of Lading, lines 0021-0022):- Executes the
BOL
exception output to mark the BOL as printed.
- Executes the
- If
PGM='P'
(Post, lines 0024-0025):- Executes the
POST
exception output to post the batch.
- Executes the
- Else (lines 0027-0028):
- Defaults to executing the
REL
exception output ifPGM
is not 'O', 'L', 'B', or 'P'.
- Defaults to executing the
- The nested
IF
/END
structure ensures only one action is performed (lines 0015-0031).
- Checks the
-
Sets the last record indicator (
LR
) to exit the program (line 0035). -
Output Operations:
- The program defines four exception outputs to update the
BBBTCH
file:- REL (Lines 0038-0041):
- Clears the lock status (position 6) and workstation ID (positions 7-8).
- Updates the record count (
RECCNT
) at position 39. - PICK (Lines 0043-0047):
- Clears the lock status (position 6) and workstation ID (positions 7-8).
- Updates the record count (
RECCNT
) at position 39. - BOL (Lines 0049-0053):
- Clears the lock status (position 6) and workstation ID (positions 7-8).
- Sets the BOL printed flag to 'Y' (position 9).
- Updates the record count (
RECCNT
) at position 39. - POST (Lines 0055-0058):
- Sets the delete code to 'D' (position 1).
- Sets the lock status to 'P' (position 6).
- Updates the record count (
RECCNT
) at position 39.
Business Rules¶
The program enforces the following business rules for batch processing:
- Batch Existence:
-
The batch number (
BATCH#
) must exist in theBBBTCH
file. If not found (indicator 99), no updates are performed, and the program exits. -
Program Mode Actions:
-
The
PGM
parameter determines the action:'O'
(Order Entry): Releases the batch by clearing lock status and workstation ID.'L'
(Pick List): Prepares the batch for picking by clearing lock status and workstation ID.'B'
(Bill of Lading): Marks the batch as having a printed BOL ('Y') and clears lock status and workstation ID.'P'
(Post): Marks the batch as posted by setting the delete code to 'D' and lock status to 'P'.- Any other
PGM
value defaults to releasing the batch (clearing lock status and workstation ID).
-
Record Count Update:
-
The record count (
RECCNT
) is updated in theBBBTCH
file for all actions to reflect the current number of records in the batch. -
Batch Status Management:
- Releasing or generating a pick list clears the lock status and workstation ID, making the batch available for further processing.
- Posting a batch marks it as deleted (
ABDEL='D'
) and sets the lock status to 'P' (posted), effectively closing the batch. -
The BOL printed flag is set only when
PGM='B'
. -
No Validation or Error Messaging:
- The program assumes the calling OCL program (
BB101.ocl36.txt
) has validated the batch number and program mode. - No error messages are defined or displayed, and processing is unconditional for matched records.
Tables (Files) Used¶
The program interacts with the following file:
- BBBTCH: Update-capable batch header file (48 bytes, indexed, key length 2).
- Fields updated:
- Position 1: Delete code (
ABDEL
, set to 'D' forPOST
). - Position 6: Lock status (
ABLOCK
, cleared or set to 'P' forPOST
). - Positions 7-8: Workstation ID (
ABLKWS
, cleared). - Position 9: BOL printed flag (
ABPRTD
, set to 'Y' forBOL
). - Positions 32-39: Record count (
ABREC
, updated withRECCNT
).
- Position 1: Delete code (
External Programs Called¶
The BB005
RPG program does not call any external programs. All processing is handled internally through file updates and exception outputs.
Summary¶
The BB005
RPG program, called from the BB101.ocl36.txt
OCL program, updates the BBBTCH
file to release, prepare for picking, mark as BOL printed, or post a batch based on the PGM
parameter ('O', 'L', 'B', or 'P'). It chains to the batch record using BATCH#
, updates fields like lock status, workstation ID, BOL printed flag, delete code, and record count, and exits. Business rules ensure appropriate status updates based on the program mode, with no additional validations or error messaging. The program interacts solely with the BBBTCH
file and does not call external programs, relying on internal logic for all operations.