Skip to content

BB005 RPG36

The provided document is an RPG (Report Program Generator) program named BB005.rpg36.txt, called by the BB150P OCL program for Release or Post Batch operations in an IBM System/36 or AS/400 environment. This program updates batch records in the BBBTCH file based on the program mode (PGM) and batch number (BATCH#). Below, I’ll explain the process steps, business rules, tables (files) used, and external programs called.


Process Steps of the BB005 RPG Program

The BB005 RPG program is designed to release or post a batch by updating specific fields in the BBBTCH file. It operates in a straightforward manner, with conditional logic based on the program mode (PGM). Here’s a breakdown of the process steps:

  1. Retrieve Batch Record:
  2. The program uses the BATCH# (batch number, positions 490-491 in the User Data Structure, UDS) to retrieve the corresponding record from the BBBTCH file using a CHAIN operation.
  3. If the batch record is not found (indicator 99 is on), the program skips further processing and exits.

Purpose: Ensures the specified batch exists before attempting to update it.

  1. Process Based on Program Mode (PGM):
  2. If the batch record is found (N99), the program evaluates the PGM field (position 504 in UDS), which determines the type of batch operation:
    • PGM = 'O' (Order Entry):
    • Executes the REL exception output to update the batch record:
      • Clears the lock status (ABLOCK, position 6) to a blank space (' ').
      • Clears the workstation ID (ABLKWS, position 8) to blanks (' ').
      • Updates the record count (ABREC, position 39) with RECCNT (positions 475-482 in UDS).
    • PGM = 'L' (Pick List):
    • Executes the PICK exception output:
      • Clears the lock status (ABLOCK, position 6) to a blank space (' ').
      • Clears the workstation ID (ABLKWS, position 8) to blanks (' ').
      • Updates the record count (ABREC, position 39) with RECCNT.
    • PGM = 'B' (Bill of Lading Print):
    • Executes the BOL exception output:
      • Clears the lock status (ABLOCK, position 6) to a blank space (' ').
      • Clears the workstation ID (ABLKWS, position 8) to blanks (' ').
      • Sets the BOL printed status (ABPRTD, position 9) to 'Y'.
      • Updates the record count (ABREC, position 39) with RECCNT.
    • PGM = 'P' (Posting):
    • Executes the POST exception output:
      • Sets the delete code (ABDEL, position 1) to 'D' (marks the batch as deleted).
      • Sets the lock status (ABLOCK, position 6) to 'P' (indicating posting).
      • Updates the record count (ABREC, position 39) with RECCNT.
    • Default (PGM ≠ 'O', 'L', 'B', or 'P'):
    • Executes the REL exception output (same as PGM = 'O'):
      • Clears the lock status (ABLOCK) and workstation ID (ABLKWS).
      • Updates the record count (ABREC) with RECCNT.

Purpose: Updates the batch record based on the operation type, either releasing the batch (clearing locks), marking it as printed, or deleting it for posting.

  1. Exit Program:
  2. Sets the Last Record (LR) indicator to exit the program.

Purpose: Ensures the program terminates after processing the batch record.


Business Rules

The BB005 RPG program enforces the following business rules: 1. Batch Existence: - The program only processes a batch if it exists in the BBBTCH file. If the batch number (BATCH#) does not correspond to a valid record, no updates are performed.

  1. Program Mode Determines Action:
  2. The PGM field dictates the type of update:

    • 'O' (Order Entry) or 'L' (Pick List): Releases the batch by clearing lock fields (ABLOCK, ABLKWS) and updating the record count.
    • 'B' (BOL Print): Releases the batch and marks it as printed (ABPRTD = 'Y').
    • 'P' (Posting): Marks the batch as deleted (ABDEL = 'D') and sets the lock status to 'P'.
    • Any other PGM value defaults to a release operation (clearing locks).
  3. Record Count Update:

  4. The RECCNT value (number of records in the batch) is always updated in the ABREC field, ensuring the batch record reflects the current count.

  5. Concurrency and Lock Management:

  6. Releasing a batch (for PGM = 'O', 'L', or 'B') clears the lock status and workstation ID, making the batch available for other processes.
  7. Posting a batch (PGM = 'P') marks it as deleted, preventing further use.

  8. Data Integrity:

  9. The program ensures that updates to the BBBTCH file are atomic (via UC file mode for update-capable access).
  10. Only specific fields are modified based on the operation, preserving other data in the batch record.

Tables (Files) Used

The program interacts with the following file: 1. BBBTCH: - Update-capable file (UC), 48 bytes, logical file with 2 access paths, indexed. - Stores batch records with fields relevant to batch management. - Fields Updated: - ABDEL (position 1, 1 char): Delete code ('D' for posting). - ABLOCK (position 6, 1 char): Lock status (' ' for release, 'P' for posting). - ABLKWS (position 8, 2 char): Workstation ID (' ' for release). - ABPRTD (position 9, 1 char): BOL printed status ('Y' for BOL print). - ABREC (position 39, 8 num): Number of records in the batch (updated with RECCNT).

Input Fields from UDS: - BATCH# (positions 490-491, 2 num): Batch number used to locate the record. - PGM (position 504, 1 char): Program mode ('O', 'L', 'B', 'P', or other). - RECCNT (positions 475-482, 8 num): Record count to update ABREC.


External Programs Called

The BB005 RPG program does not explicitly call any external programs. It operates as a standalone program, performing file updates directly based on input parameters.


Summary

The BB005 RPG program is a simple utility for releasing or posting batches in the BBBTCH file, called by the BB150P OCL program. It: - Retrieves a batch record using BATCH#. - Updates the record based on the PGM mode: - Releases the batch (PGM = 'O', 'L', or default) by clearing locks. - Marks the batch as printed (PGM = 'B'). - Deletes the batch for posting (PGM = 'P'). - Always updates the record count (ABREC) with RECCNT. - Enforces business rules for batch existence, lock management, and operation-specific updates.

Files Used: BBBTCH (update-capable batch file). External Programs: None.

If you need further details (e.g., field-level mappings, interaction with the OCL program, or additional context), let me know!