Skip to content

BB005 RPG36

Process Steps of the RPG Program (BB005.rpg36.txt)

The RPG program BB005 is designed for the IBM System/36 environment and is called by the BB170 OCL procedure as the final step to release or post a batch in an order management system. Its primary function is to update the batch status in the BBBTCH file based on the processing mode (PGM) specified in the local data area. The program handles different batch actions (release, pick list, bill of lading, or posting) by updating specific fields in the batch record, such as lock status, printed flags, and delete indicators. The program is straightforward, with a single chained access and conditional logic for updating the BBBTCH file. Below is a step-by-step breakdown of the process, executed within the standard RPG cycle:

  1. Read Input from Local Data Area:
  2. Access the local data area (UDS) to retrieve:

    • BATCH# (offset 490-491, 2-digit batch number).
    • PGM (offset 504, 1-character mode: 'O' for order entry, 'L' for pick list, 'B' for bill of lading, 'P' for posting).
    • RECCNT (offset 475-482, 8-digit record count).
  3. Chain to BBBTCH File:

  4. Perform a chain (random read) to the BBBTCH file (update-capable, 48-byte records, 2-byte alphanumeric key, indexed) using BATCH# as the key.
  5. If the batch record is found (indicator 99 off), proceed with processing; if not found (99 on), skip to the end.

  6. Update Batch Record Based on PGM Mode:

  7. If a record is found (N99), enter a DO loop to process the batch update:

    • If PGM = 'O' (Order Entry):
    • Execute exception output REL (release):
      • Clear position 6 (ABLOCK, lock status) to blank.
      • Clear positions 7-8 (ABLKWS, lock workstation ID) to blanks.
      • Write RECCNT (record count) to positions 32-39 (ABREC).
    • Else If PGM = 'L' (Pick List):
    • Execute exception output PICK:
      • Clear position 6 (ABLOCK) to blank.
      • Clear positions 7-8 (ABLKWS) to blanks.
      • Write RECCNT to positions 32-39 (ABREC).
    • Else If PGM = 'B' (Bill of Lading):
    • Execute exception output BOL:
      • Clear position 6 (ABLOCK) to blank.
      • Clear positions 7-8 (ABLKWS) to blanks.
      • Set position 9 (ABPRTD, BOL printed flag) to 'Y'.
      • Write RECCNT to positions 32-39 (ABREC).
    • Else If PGM = 'P' (Posting):
    • Execute exception output POST:
      • Set position 1 (ABDEL, delete flag) to 'D'.
      • Set position 6 (ABLOCK) to 'P' (posted).
      • Write RECCNT to positions 32-39 (ABREC).
    • Else (Default):
    • Execute exception output REL (same as PGM='O'):
      • Clear position 6 (ABLOCK) to blank.
      • Clear positions 7-8 (ABLKWS) to blanks.
      • Write RECCNT to positions 32-39 (ABREC).
  8. End Program:

  9. Set on the LR (last record) indicator to terminate the program after processing the batch record.
  10. Return control to the calling OCL procedure (BB170).

Business Rules

  • Batch Status Updates:
  • The program updates the batch record in BBBTCH based on the processing mode (PGM):
    • 'O' (Order Entry): Releases the batch by clearing lock fields (ABLOCK, ABLKWS).
    • 'L' (Pick List): Clears locks, indicating pick list processing is complete.
    • 'B' (Bill of Lading): Clears locks and sets the BOL printed flag (ABPRTD='Y').
    • 'P' (Posting): Marks the batch as posted (ABLOCK='P') and deleted (ABDEL='D').
  • The default action (if PGM is invalid) is to release the batch (clear locks).
  • Record Count Tracking:
  • Updates the batch record count (ABREC) with RECCNT from the local data area, ensuring accurate tracking of records in the batch.
  • Lock Management:
  • Clears lock status (ABLOCK) and workstation ID (ABLKWS) for most modes to release the batch for further processing.
  • For posting (PGM='P'), sets ABLOCK to 'P' to indicate the batch is finalized.
  • Batch Deletion:
  • When posting (PGM='P'), marks the batch as deleted (ABDEL='D'), preventing further use.
  • Data Integrity:
  • Uses a chained access to ensure the correct batch (BATCH#) is updated.
  • If the batch is not found (99 on), no update occurs, avoiding errors.
  • File Access:
  • BBBTCH is update-capable (UC), allowing direct modification of batch records.
  • The program assumes the batch number (BATCH#) is valid, as set by the calling OCL.

Tables Used

  • BBBTCH:
  • Update-capable file, 48-byte records, 2-byte alphanumeric key, indexed (2AI).
  • Stores batch control records.
  • Fields updated: ABDEL (1, delete flag), ABLOCK (6, lock status), ABLKWS (7-8, lock workstation ID), ABPRTD (9, BOL printed flag), ABREC (32-39, record count).

External Programs Called

  • None. BB005 is self-contained, with no subroutines or calls to other programs. It relies solely on file I/O (chain and exception outputs: REL, PICK, BOL, POST) to update the batch record.

The program is a simple utility that finalizes batch processing by updating the batch status and clearing locks, ensuring the batch is released or marked as posted/deleted as part of the order management workflow.