BB001 RPG36
The provided document is an RPG (Report Program Generator) program named BB001.rpg36.txt, which is called by the BB150P OCL program for Order Entry Batch Selection in an IBM System/36 or AS/400 environment. This program manages the selection, creation, updating, and deletion of batches for Bills of Lading (BOL) processing. Below, I’ll explain the process steps, business rules, tables (files) used, and external programs called.
Process Steps of the BB001 RPG Program¶
The BB001 RPG program handles batch selection and management for order entry processes. It interacts with a workstation screen (SCREEN) and manages batch records in the BBBTCH and BBBTCHX files. The program is structured around subroutines and screen interactions. Here’s a breakdown of the process steps:
- Initialization (ONETIM Subroutine):
- Clears the
CANCELfield and initializes counters (BLIM,Z2,Z7,Z8) to zero. - Positions the
BBBTCHfile at the beginning (SETLL BBBTCH). - Calls the
DRLFWDsubroutine to read and display batch records. - Sets indicators (e.g.,
21,83) for screen control and checks the program mode (PGM):- If
PGM = 'O', indicator44is turned off (likely for order entry mode). - If
PGM ≠ 'O', indicator44is turned on (for other modes, e.g., printing or posting).
- If
Purpose: Sets up the program environment, initializes variables, and prepares the first batch record for display.
- Screen Processing:
- The program uses three screen formats (
BB001S1,BB001S2,BB001S3) for different interactions:- S1 (Screen 1): Displays a list of batches and allows the user to select or create a batch.
- S2 (Screen 2): Confirms batch selection or deletion.
- S3 (Screen 3): Handles cancellation or reset of a batch.
- The main logic checks conditions (
01,02,03) to execute the corresponding subroutine (S1,S2,S3) based on user input.
Purpose: Manages user interaction through the workstation screen for batch selection or manipulation.
- S1 Subroutine (Batch Selection or Creation):
- If the
KGkey (cancel) is pressed:- Sets
CANCEL = 'CANCEL', turns on the Last Record (LR) indicator, and exits.
- Sets
- If the user enters a batch number (
BTCH#X = 0):- New Batch Creation:
- Checks if the program mode is order entry (
PGM = 'O'). If not, displays error messageCOM,2("CANNOT CREATE A BATCH NOW") and exits. - Retrieves the next batch number from
ABNXTBinBBBTCHX(viaCHAIN). - Increments
ABNXTBand updates the file (EXCPT UPDNXB). - If
ABNXTBreaches99, resets it to1. - Initializes fields for the new batch:
- Description (
LKDESC = COM,11= "AVAILABLE"). - Print status (
PRTD = 'N'). - Creation date (
DATE) and last update date (LUDT) based on system date (UDATE). - Record count (
#REC = 0).
- Description (
- Checks if the batch number already exists (
CHAIN BBBTCHX). If it does, loops to get the next batch number. - Adds the new batch record (
EXCPT ADDBCH) and setsLRto exit.
- If the user selects an existing batch (
BTCH#X ≠ 0):- Retrieves the batch record (
CHAIN BBBTCHX). - Validates the batch:
- If the batch is deleted (
ABDEL = 'D') or batch number is99, displays errorCOM,1("INVALID BATCH NO.") and exits. - If the batch source (
ABSRCE) does not matchPAR13C(e.g.,PPfor Viscosity ASN or non-PP), displays errorCOM,1and exits. - If the batch is locked (
ABLOCK ≠ *BLANK) and not by the current user (ABUSER ≠ USER), displays errorCOM,3("BATCH # IN USE") and releases the batch (EXCPT RELBCH). - If the batch is locked for posting (
ABLOCK = 'O') andPGM = 'P', displays errorCOM,5("BATCH # IN USE--CANNOT POST NOW") and exits. - If valid, populates fields for display (e.g.,
LKDESC,PRTD,USER,DTMDY,#REC). - If the user requests deletion (
DEL = 'D'), displays confirmation messageCOM,4("CMD 4 - TO DELETE EXISTING BATCH") and sets indicator22for the delete confirmation screen. - Updates the batch record (
EXCPT UPDBCH) if not deleting, and setsLRor indicator24based on mode.
- Retrieves the batch record (
Purpose: Handles batch creation or selection, with validation to ensure batch availability and compatibility with the program mode.
- S2 Subroutine (Batch Confirmation or Deletion):
- If the
KAkey is pressed (new batch or navigation):- Positions the
BBBTCHfile and callsDRLFWDto display the next batch.
- Positions the
- If deletion is confirmed (
DEL = 'D'andKDkey pressed):- Deletes the batch record (
EXCPT DELBCH) and setsLRto exit.
- Deletes the batch record (
- If a new batch is being added:
- Checks if the batch number exists (
CHAIN BBBTCHX). If not, adds the batch (EXCPT ADDBCH) and setsLR.
- Checks if the batch number exists (
Purpose: Confirms batch selection or processes batch deletion.
- S3 Subroutine (Cancel or Reset):
- If the
KGkey is pressed:- Retrieves the batch record (
CHAIN BBBTCHX). - If found, saves the batch with original lock status (
EXCPT SAVBCH). - Sets
CANCEL = 'CANCEL', resets indicators, and setsLRto exit.
- Retrieves the batch record (
Purpose: Resets or cancels the batch selection process, preserving the original batch state.
- DRLFWD Subroutine (Detail Roll Forward):
- Reads the next record from
BBBTCHand populates display fields (e.g.,BTC,LKD,LKW,PRT,USR,DTE,LUD,#RC). - Skips records if:
- The batch number is
99or marked as deleted (ABDEL = 'D'). - The batch source (
ABSRCE) does not matchPAR13C(commented-out logic suggests validation forPPor non-PPmodes).
- The batch number is
- Maps lock status (
ABLOCK) to descriptive messages:*BLANK:COM,11("AVAILABLE").O:COM,12("ORD ENTRY").L:COM,13("PICK LIST").P:COM,14("POSTING").B:COM,15("BOL PRINT").
- Continues reading until 10 records are loaded or the end of the file is reached.
Purpose: Displays a list of available batches for selection.
- DRLBAK Subroutine (Detail Roll Backward):
- Sets indicator
21to refresh the screen but does not implement backward navigation logic (appears incomplete).
Purpose: Intended to navigate backward through batch records (not fully implemented).
- ROLLKY Subroutine (Handle Roll Keys):
- Checks the workstation status (
STATUS) for roll keys (e.g.,01122for forward,01123for backward). - Calls
DRLFWDfor forward navigation orDRLBAKfor backward navigation. - Clears the status and resets indicators.
Purpose: Manages pagination or scrolling through batch records.
- DETCLR Subroutine (Clear Display Fields):
- Resets display arrays (
BTC,LKD,LKW,PRT,USR,DTE,LUD,#RC) to zero or blanks.
Purpose: Clears the screen fields before loading new batch data.
-
Output Operations:
- Updates
BBBTCHXwith the next batch number (UPDNXB). - Adds a new batch record (
ADDBCH). - Updates an existing batch record (
UPDBCH). - Deletes a batch record (
DELBCH). - Releases a batch by restoring its lock status (
RELBCH). - Saves a batch with its original lock status (
SAVBCH).
Purpose: Performs file operations to maintain batch data.
- Updates
Business Rules¶
The program enforces the following business rules:
1. Concurrency Control:
- Prevents batch creation if the program mode is not order entry (PGM ≠ 'O').
- Prevents access to a batch if it is locked (ABLOCK ≠ *BLANK) by another user (ABUSER ≠ USER) or workstation, unless the current user locked it.
- Prevents posting (PGM = 'P') if the batch is locked for order entry (ABLOCK = 'O').
- Batch Number Management:
- Batch numbers are assigned sequentially from
ABNXTB(1 to 99, resetting to 1 after 99). - Batch number
99is reserved and considered invalid for selection. -
Duplicate batch numbers are avoided by checking
BBBTCHXbefore adding a new batch. -
Batch Source Validation:
-
The batch source (
ABSRCE) must match the parameterPAR13C(e.g.,PPfor Viscosity ASN or non-PPfor other modes). Mismatched batches are skipped or rejected. -
Deletion Control:
- Batches marked for deletion (
ABDEL = 'D') are invalid and cannot be selected. -
Deletion requires confirmation via the
S2screen (DEL = 'D'andKDkey). -
Lock Status:
- Batches can be locked for:
- Order Entry (
O). - Pick List (
L). - Posting (
P). - BOL Print (
B). - Available (
*BLANK).
- Order Entry (
-
Lock status is displayed to the user with descriptive messages.
-
Data Integrity:
- Creation and last update dates are derived from the system date (
UDATE). - The record count (
#REC) is maintained for each batch. - The program ensures that batch records are updated or saved correctly to preserve their state.
Tables (Files) Used¶
The program interacts with the following files:
1. SCREEN:
- A workstation file for displaying and capturing user input.
- Uses formats BB001S1, BB001S2, and BB001S3 for batch selection, confirmation, and cancellation.
2. BBBTCH:
- Input file (ID), 48 bytes, logical file with 2 access paths, indexed.
- Stores batch records with fields like batch number, lock status, user ID, creation date, etc.
3. BBBTCHX:
- Update-capable file (UC), 48 bytes, physical or logical file with 2 access paths, indexed.
- Stores the same batch data as BBBTCH, with additional control fields like ABNXTB (next batch number).
Fields in BBBTCH and BBBTCHX:
- ABDEL (1 char): Delete code ('D' for deleted).
- ABBTCH (2 num): Batch number.
- ABLOCK (1 char): Lock status (O, L, P, B, or blank).
- ABLKWS (2 char): Workstation ID locking the batch.
- ABPRTD (1 char): BOL printed status ('N' or other).
- ABUSER (8 char): User ID.
- ABDATE (6 num): Creation date (CYMD format).
- ABLUDT (6 num): Last update date (CYMD format).
- ABREC (8 num): Number of records in the batch.
- ABSRCE (2 char): Batch source (e.g., PP for Viscosity ASN).
- ABNXTB (2 num): Next available batch number.
External Programs Called¶
The BB001 RPG program does not explicitly call any external programs. It operates as a standalone program, interacting with the workstation and files directly.
Summary¶
The BB001 RPG program is responsible for batch selection and management in the order entry process for Bills of Lading. It:
- Displays and navigates batch records using a workstation screen.
- Allows creation of new batches (in order entry mode) or selection of existing batches.
- Enforces business rules for batch number assignment, concurrency, lock status, and source validation.
- Updates, deletes, or releases batch records in BBBTCH and BBBTCHX.
- Uses subroutines (ONETIM, S1, S2, S3, DRLFWD, DRLBAK, ROLLKY, DETCLR) to modularize logic.
Files Used: SCREEN (workstation), BBBTCH (batch input), BBBTCHX (batch update).
External Programs: None.
If you need further details (e.g., specific field mappings, screen layouts, or additional context from the OCL program), let me know!