Skip to content

BB055 RPG36

The BB055.rpg36.txt is an RPG/36 program called from the BB502.ocl36.txt OCL program and referenced in the BB502.rpg36.txt program (in the BPOST subroutine). It is designed to release or post a batch of records in the BBIBCH file, updating the batch status based on the program code (PGM) and other conditions. Below, I’ll explain the process steps, business rules, tables used, and external programs called based on the provided RPG source code.


Process Steps of the RPG Program

The BB055 program processes a batch identified by a batch number (BATCH#) and updates the BBIBCH file based on the program code (PGM) and batch selection criteria (KYALSL). It performs actions such as releasing, editing, marking for forms printing, or posting the batch. Here’s a step-by-step breakdown of the process:

  1. Program Initialization:
  2. The program defines the BBIBCH file as an update file (48 bytes, indexed, key length 2 bytes, disk-based).
  3. Input specifications (I) map fields from the BBIBCH file and the User Data Structure (UDS):
    • KYALSL (positions 103–105): Batch selection criteria (ALL or other values).
    • BATCH# (positions 490–491, 2 digits): Batch number.
    • PGM (position 504, 1 character): Program code (I, E, F, or P).
    • RECCNT (positions 475–482, 8 digits): Record count in the batch.
  4. Output specifications (O) define four exception output operations (REL, EDIT, FORM, POST) to update the BBIBCH file.

  5. Chain to Batch Record:

  6. The program uses the BATCH# to perform a CHAIN operation on the BBIBCH file to locate the batch record.
  7. If the record is not found (indicator 99 on), the program skips processing and proceeds to termination.

  8. Process Based on Program Code (PGM):

  9. If the batch record is found (indicator 99 off), the program evaluates the PGM field:

    • If PGM = 'I' (Invoice Entry):
    • Writes an exception record (REL) to update the BBIBCH file, clearing positions 6–8 and updating RECCNT.
    • If PGM = 'E' (Edit):
    • Writes an exception record (EDIT) to update the BBIBCH file, clearing positions 6–8 and updating RECCNT.
    • If PGM = 'F' (Forms):
    • Checks the batch selection criteria (KYALSL):
      • If KYALSL = 'ALL', sets RTOPST (ready to post) to 'Y'.
      • Otherwise, sets RTOPST to 'N'.
    • Writes an exception record (FORM) to update the BBIBCH file, setting position 9 to 'Y', updating RECCNT, and setting RTOPST.
    • If PGM = 'P' (Post):
    • Checks the record count (RECCNT):
      • If RECCNT = 0 (all records posted), writes an exception record (POST), setting position 1 to 'D' (delete), position 6 to 'P' (posted), and updating RECCNT.
      • Otherwise, writes an exception record (REL), clearing positions 6–8 and updating RECCNT.
    • For any other PGM value:
    • Writes an exception record (REL), clearing positions 6–8 and updating RECCNT.
  10. Program Termination:

  11. The program sets the LR (Last Record) indicator and ends, completing the batch update.

Business Rules

The program enforces the following business rules, inferred from the code and context:

  1. Batch Validation:
  2. The batch number (BATCH#) must exist in the BBIBCH file for processing to occur.
  3. If the batch is not found, no updates are performed.

  4. Program Code Processing:

  5. The PGM field determines the action:

    • I: Indicates invoice entry, releasing the batch.
    • E: Indicates edit processing, updating the batch status.
    • F: Marks the batch for forms printing, setting readiness to post based on selection criteria.
    • P: Posts the batch, marking it as deleted if all records are processed (RECCNT = 0).
    • Other values default to releasing the batch.
  6. Forms Printing and Posting Readiness:

  7. For PGM = 'F', if all orders are selected (KYALSL = 'ALL'), the batch is marked ready to post (RTOPST = 'Y'); otherwise, it is marked not ready (RTOPST = 'N').

  8. Batch Posting:

  9. For PGM = 'P', the batch is marked as deleted ('D') and posted ('P') only if all records are processed (RECCNT = 0).
  10. If records remain (RECCNT ≠ 0), the batch is released without marking it as posted.

  11. Integration with Order Entry:

  12. The program is part of the BB500 order entry suite (called by BB502) and manages batch status updates for shipment processing, ensuring batches are properly released, edited, printed, or posted.

  13. Error Handling:

  14. If the batch record is not found, the program exits without error, relying on the calling program to handle the absence of a batch.

Tables (Files) Used

The program uses one file, as defined in the F (File) specification:

  1. BBIBCH: Batch control file (48 bytes, indexed, update-capable, key length 2 bytes). Contains fields:
  2. KYALSL (batch selection criteria, e.g., ALL).
  3. BATCH# (batch number).
  4. PGM (program code: I, E, F, P).
  5. RECCNT (record count).
  6. RTOPST (ready to post flag, used in FORM output).

External Programs Called

The program does not call any external programs. It is a self-contained utility that performs file updates based on input parameters and internal logic.


Summary

The BB055 RPG/36 program is a utility called from the BB502 OCL program to release or post batches in the BBIBCH file. It updates batch status based on the program code (PGM): releasing for invoice entry (I) or edit (E), marking for forms printing (F) with readiness to post based on KYALSL, or posting (P) if all records are processed (RECCNT = 0). The program uses one file (BBIBCH) and does not call external programs, ensuring proper batch management for order entry and shipment processing.

If you need further details on specific logic, integration with BB502, or additional analysis (e.g., X posts or web searches), let me know! Additionally, if you want to update the previous use cases or function requirement document to include BB055, please specify, and I can incorporate its functionality.