Skip to content

BB055 RPG36

The BB055.rpg36.txt RPG program is called by the main OCL program (likely BB600.ocl36.txt) within the invoice posting workflow on an IBM System/36 environment. Its primary function is to manage the release or posting of batches by updating the batch control file (BBIBCH) based on the program mode (PGM) and batch status. The program handles different batch processing stages (invoice entry, edit, forms, and posting) and updates the batch record accordingly. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.


Process Steps of the BB055 RPG Program

The BB055 program processes a batch record in BBIBCH, updates its status based on the input program mode (PGM), and handles specific logic for forms and posting stages.

  1. File Initialization:
  2. Opens the following file:
    • BBIBCH: Update file (UF), 48 bytes, 2-byte alternate index, 2-byte key, disk-based. Stores batch control records.
  3. Defines input fields for BBIBCH:

    • KYALSL (103–105): Selection criteria (ALL or company-specific).
    • BATCH# (490–491): Batch number (numeric).
    • PGM (504): Program mode (I, E, F, P for invoice entry, edit, forms, or post).
    • RECCNT (475–482): Record count (numeric).
    • RTOPST (defined in output, 1 character): Ready-to-post flag (Y or N).
  4. Batch Record Retrieval:

  5. Chains to BBIBCH using BATCH# as the key (C BATCH# CHAINBBIBCH 99).
  6. If the record is found (N99), proceeds with processing; otherwise, skips to the end.

  7. Conditional Processing Based on Program Mode:

  8. Checks the PGM field to determine the batch processing stage:

    • Invoice Entry (PGM = 'I'):
    • Executes exception output REL (EXCPTREL).
    • Updates BBIBCH with:
      • Positions 6–7: Blanks (' ', likely status or flag).
      • Position 8: Blanks (' ').
      • RECCNT at position 39: Updates record count.
    • Edit (PGM = 'E'):
    • Executes exception output EDIT (EXCPTEDIT).
    • Updates BBIBCH with the same fields as REL:
      • Positions 6–7: Blanks.
      • Position 8: Blanks.
      • RECCNT at position 39.
    • Forms (PGM = 'F'):
    • Checks KYALSL for selection criteria:
      • If KYALSL = 'ALL', sets RTOPST = 'Y' (ready to post).
      • Otherwise, sets RTOPST = 'N' (not ready to post).
    • Executes exception output FORM (EXCPTFORM).
    • Updates BBIBCH with:
      • Positions 6–7: Blanks.
      • Position 8: Blanks.
      • Position 9: 'Y' (indicates forms processed).
      • RECCNT at position 39.
      • RTOPST at position 42.
    • Post (PGM = 'P'):
    • Checks RECCNT:
      • If RECCNT = 0 (all records posted), executes POST (EXCPTPOST):
      • Updates BBIBCH with:
        • Position 1: 'D' (delete flag, marks batch as posted).
        • Position 6: 'P' (posted status).
        • RECCNT at position 39.
      • If RECCNT ≠ 0, executes REL (EXCPTREL):
      • Updates BBIBCH with:
        • Positions 6–7: Blanks.
        • Position 8: Blanks.
        • RECCNT at position 39.
    • Default (Other PGM Values):
    • Executes REL (EXCPTREL) with the same updates as above.
  9. Cycle Completion:

  10. Sets the last record indicator (LR) to terminate the RPG cycle (SETON LR).
  11. Closes the BBIBCH file and ends the program.

Business Rules

  1. Batch Status Update:
  2. Updates BBIBCH based on the program mode (PGM):

    • I (Invoice Entry): Clears status fields and updates record count.
    • E (Edit): Same as invoice entry.
    • F (Forms): Sets forms flag ('Y') and ready-to-post flag (RTOPST) based on KYALSL ('Y' for ALL, 'N' otherwise).
    • P (Post): Marks batch as posted ('D', 'P') if all records are processed (RECCNT = 0); otherwise, reverts to release status.
  3. Forms Processing:

  4. For PGM = 'F', checks if all orders are selected (KYALSL = 'ALL') to set RTOPST = 'Y' (ready to post) or 'N' (not ready).

  5. Posting Validation:

  6. Only marks a batch as posted ('D', 'P') if RECCNT = 0, ensuring all records in the batch are processed.

  7. Default Behavior:

  8. For unrecognized PGM values, defaults to release status (REL), clearing status fields and updating record count.

  9. No Error Handling:

  10. Assumes the batch record exists in BBIBCH and input fields are valid. If the batch is not found (99 on), no updates are performed.

  11. Integration with ARGLMS:

  12. Part of the invoice posting workflow, managing batch status to track progress through invoice entry, editing, forms printing, and posting.

Tables (Files) Used

  1. BBIBCH:
  2. Description: Batch control file.
  3. Attributes: Update file (UF), 48 bytes, 2-byte alternate index, 2-byte key, disk-based.
  4. Fields Used:
    • KYALSL (103–105): Selection criteria (ALL or company-specific).
    • BATCH# (490–491): Batch number (key).
    • PGM (504): Program mode (I, E, F, P).
    • RECCNT (475–482): Record count.
    • RTOPST (output, position 42): Ready-to-post flag (Y or N).
  5. Purpose: Stores batch control information for invoice processing.
  6. Usage: Chained for retrieval (CHAINBBIBCH) and updated via exception outputs (REL, EDIT, FORM, POST).

External Programs Called

The BB055 RPG program does not explicitly call any external programs. It is called by the main OCL (e.g., BB600.ocl36.txt) and operates solely on the BBIBCH file to manage batch status.


Summary

The BB055 RPG program, called by the main OCL (e.g., BB600.ocl36.txt), manages batch status by: - Retrieving a batch record from BBIBCH using BATCH#. - Updating BBIBCH based on PGM: - I (Invoice Entry): Clears status fields, updates RECCNT (REL). - E (Edit): Same as invoice entry (EDIT). - F (Forms): Sets forms flag, RTOPST (Y for ALL, N otherwise), and updates RECCNT (FORM). - P (Post): Marks batch as posted ('D', 'P') if RECCNT = 0 (POST); otherwise, reverts to REL. - Defaulting to REL for unrecognized PGM values. - Terminating with SETON LR after processing.

Tables Used: BBIBCH (batch control). External Programs Called: None.

This program ensures accurate batch status management in the ARGLMS invoice posting workflow, tracking progress through various processing stages.