Skip to content

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:

  1. Initialization (ONETIM Subroutine):
  2. Clears the CANCEL field and initializes counters (BLIM, Z2, Z7, Z8) to zero.
  3. Positions the BBBTCH file at the beginning (SETLL BBBTCH).
  4. Calls the DRLFWD subroutine to read and display batch records.
  5. Sets indicators (e.g., 21, 83) for screen control and checks the program mode (PGM):
    • If PGM = 'O', indicator 44 is turned off (likely for order entry mode).
    • If PGM ≠ 'O', indicator 44 is turned on (for other modes, e.g., printing or posting).

Purpose: Sets up the program environment, initializes variables, and prepares the first batch record for display.

  1. Screen Processing:
  2. 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.
  3. 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.

  1. S1 Subroutine (Batch Selection or Creation):
  2. If the KG key (cancel) is pressed:
    • Sets CANCEL = 'CANCEL', turns on the Last Record (LR) indicator, and exits.
  3. 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 message COM,2 ("CANNOT CREATE A BATCH NOW") and exits.
    • Retrieves the next batch number from ABNXTB in BBBTCHX (via CHAIN).
    • Increments ABNXTB and updates the file (EXCPT UPDNXB).
    • If ABNXTB reaches 99, resets it to 1.
    • 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).
    • 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 sets LR to exit.
  4. 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 is 99, displays error COM,1 ("INVALID BATCH NO.") and exits.
    • If the batch source (ABSRCE) does not match PAR13C (e.g., PP for Viscosity ASN or non-PP), displays error COM,1 and exits.
    • If the batch is locked (ABLOCK ≠ *BLANK) and not by the current user (ABUSER ≠ USER), displays error COM,3 ("BATCH # IN USE") and releases the batch (EXCPT RELBCH).
    • If the batch is locked for posting (ABLOCK = 'O') and PGM = 'P', displays error COM,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 message COM,4 ("CMD 4 - TO DELETE EXISTING BATCH") and sets indicator 22 for the delete confirmation screen.
    • Updates the batch record (EXCPT UPDBCH) if not deleting, and sets LR or indicator 24 based on mode.

Purpose: Handles batch creation or selection, with validation to ensure batch availability and compatibility with the program mode.

  1. S2 Subroutine (Batch Confirmation or Deletion):
  2. If the KA key is pressed (new batch or navigation):
    • Positions the BBBTCH file and calls DRLFWD to display the next batch.
  3. If deletion is confirmed (DEL = 'D' and KD key pressed):
    • Deletes the batch record (EXCPT DELBCH) and sets LR to exit.
  4. If a new batch is being added:
    • Checks if the batch number exists (CHAIN BBBTCHX). If not, adds the batch (EXCPT ADDBCH) and sets LR.

Purpose: Confirms batch selection or processes batch deletion.

  1. S3 Subroutine (Cancel or Reset):
  2. If the KG key 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 sets LR to exit.

Purpose: Resets or cancels the batch selection process, preserving the original batch state.

  1. DRLFWD Subroutine (Detail Roll Forward):
  2. Reads the next record from BBBTCH and populates display fields (e.g., BTC, LKD, LKW, PRT, USR, DTE, LUD, #RC).
  3. Skips records if:
    • The batch number is 99 or marked as deleted (ABDEL = 'D').
    • The batch source (ABSRCE) does not match PAR13C (commented-out logic suggests validation for PP or non-PP modes).
  4. 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").
  5. Continues reading until 10 records are loaded or the end of the file is reached.

Purpose: Displays a list of available batches for selection.

  1. DRLBAK Subroutine (Detail Roll Backward):
  2. Sets indicator 21 to refresh the screen but does not implement backward navigation logic (appears incomplete).

Purpose: Intended to navigate backward through batch records (not fully implemented).

  1. ROLLKY Subroutine (Handle Roll Keys):
  2. Checks the workstation status (STATUS) for roll keys (e.g., 01122 for forward, 01123 for backward).
  3. Calls DRLFWD for forward navigation or DRLBAK for backward navigation.
  4. Clears the status and resets indicators.

Purpose: Manages pagination or scrolling through batch records.

  1. DETCLR Subroutine (Clear Display Fields):
  2. 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.

  1. Output Operations:

    • Updates BBBTCHX with 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.


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').

  1. Batch Number Management:
  2. Batch numbers are assigned sequentially from ABNXTB (1 to 99, resetting to 1 after 99).
  3. Batch number 99 is reserved and considered invalid for selection.
  4. Duplicate batch numbers are avoided by checking BBBTCHX before adding a new batch.

  5. Batch Source Validation:

  6. The batch source (ABSRCE) must match the parameter PAR13C (e.g., PP for Viscosity ASN or non-PP for other modes). Mismatched batches are skipped or rejected.

  7. Deletion Control:

  8. Batches marked for deletion (ABDEL = 'D') are invalid and cannot be selected.
  9. Deletion requires confirmation via the S2 screen (DEL = 'D' and KD key).

  10. Lock Status:

  11. Batches can be locked for:
    • Order Entry (O).
    • Pick List (L).
    • Posting (P).
    • BOL Print (B).
    • Available (*BLANK).
  12. Lock status is displayed to the user with descriptive messages.

  13. Data Integrity:

  14. Creation and last update dates are derived from the system date (UDATE).
  15. The record count (#REC) is maintained for each batch.
  16. 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!