Skip to content

BB003 RPG36

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

The RPG program BB003 is designed for the IBM System/36 environment and is called by the BB170 OCL procedure during batch deletion operations. Its primary function is to delete records from multiple order transaction files (BBORCL, BBOTHS1, BBOTDS1, BBOTA1) associated with a specific batch, as identified by records in the primary input file BBORTR. The program processes records sequentially from BBORTR and deletes corresponding records in the transaction files based on matching keys (company and order number). The program was updated (per comment DC01, dated 03/10/10) to include additional files BBOTHS1, BBOTDS1, and BBOTA1. Below is a step-by-step breakdown of the process, executed within the standard RPG cycle:

  1. Read BBORTR Records (Primary Input):
  2. Read each record from BBORTR (primary file, IP, 512-byte records, 11-byte alphanumeric key, indexed) sequentially using input specification NS 11.
  3. Extract fields: TCOORD (positions 2-9, company/order number), TKEY (2-12, composite key), TSEQ (10-12, sequence), TDDEL (1, delete flag), TDCO (2-3, company number), TDORD# (4-9, order number), TDCUST (13-18, customer number).
  4. Construct a 14-byte composite key (BBKEY) in a data structure, combining TDCO (company, 1-2), TDCUST (customer, 3-8), and TDORD# (order, 9-14).

  5. Delete Records from BBORCL:

  6. For each BBORTR record, chain (random read) to BBORCL (update-capable file, 256-byte records, 14-byte alphanumeric key) using BBKEY.
  7. If a record is found (indicator 99 off), issue an exception output (EDEL DELETE) to delete the BBORCL record.

  8. Delete Records from BBOTHS1:

  9. Set off indicator 99 (reset end-of-file).
  10. Set lower limit (SETLL) on BBOTHS1 (update-capable, 512-byte records, 8-byte alphanumeric key, externally described) using TCOORD (company/order number).
  11. Enter a loop (RDAGN1):

    • Read BBOTHS1 sequentially.
    • If not end-of-file (99 off) and TCOORD matches BOCOOR (company/order number, 2-9), issue an exception output (EDEL DELOTS) to delete the BBOTHS1 record.
    • Continue looping until no more matching records or end-of-file.
  12. Delete Records from BBOTDS1:

  13. Set off indicator 99.
  14. Move TCOORD to KL11 (11-byte key) and set lower limit on BBOTDS1 (update-capable, 512-byte records, 11-byte alphanumeric key, externally described) using KL11.
  15. Enter a loop (RDAGN2):

    • Read BBOTDS1 sequentially.
    • If not end-of-file (99 off) and TCOORD matches BDCOOR (company/order number, 2-9), issue an exception output (EDEL DELOTD) to delete the BBOTDS1 record.
    • Continue looping until no more matching records or end-of-file.
  16. Delete Records from BBOTA1:

  17. Set off indicator 99.
  18. Move TCOORD to KL13 (13-byte key) and set lower limit on BBOTA1 (update-capable, 512-byte records, 13-byte alphanumeric key, externally described) using KL13.
  19. Enter a loop (RDAGN3):

    • Read BBOTA1 sequentially.
    • If not end-of-file (99 off) and TCOORD matches BACOOR (company/order number, 2-9), issue an exception output (EDEL DELOTA) to delete the BBOTA1 record.
    • Continue looping until no more matching records or end-of-file.
  20. Program Cycle:

  21. The RPG cycle processes all BBORTR records sequentially (IP file).
  22. For each record, it performs chained deletion on BBORCL and sequential deletions on BBOTHS1, BBOTDS1, and BBOTA1.
  23. The program ends when all BBORTR records are processed (end of file, LR set implicitly).

Business Rules

  • Batch Deletion:
  • Deletes records from transaction files (BBORCL, BBOTHS1, BBOTDS1, BBOTA1) associated with orders in a batch, as identified by BBORTR.
  • Ensures all related records are removed during batch deletion, preventing orphaned data.
  • Key Matching:
  • BBORCL uses a 14-byte composite key (BBKEY: company + customer + order number) for precise record matching.
  • BBOTHS1, BBOTDS1, and BBOTA1 use TCOORD (company/order number, 8 bytes) for matching, with sequential reads to handle multiple records per order.
  • File Processing:
  • BBORTR is read sequentially as the primary file, driving the deletion process.
  • BBORCL is updated via chained access (random delete).
  • BBOTHS1, BBOTDS1, BBOTA1 are updated via sequential reads after setting a lower limit, deleting all records matching the company/order number.
  • No Error Handling:
  • If a BBORCL record is not found (99 on), no deletion occurs, and the program continues.
  • Non-matching or end-of-file conditions in BBOTHS1, BBOTDS1, BBOTA1 are ignored, assuming partial deletion is acceptable.
  • File Access:
  • BBORTR: Input-only (IP), sequential, 512-byte records, 11-byte key.
  • BBORCL: Update-capable (UC), 256-byte records, 14-byte key.
  • BBOTHS1, BBOTDS1, BBOTA1: Update-capable (UF), 512-byte records, externally described, with 8, 11, and 13-byte keys, respectively.
  • Data Integrity:
  • Ensures deletion only for records explicitly tied to the batch’s company/order number, maintaining referential integrity.
  • Supports cleanup of temporary (BBORCL), header (BBOTHS1), detail (BBOTDS1), and auxiliary (BBOTA1) transaction files.

Tables Used

  • BBORTR:
  • Primary input file, 512-byte records, 11-byte alphanumeric key, indexed (11AI).
  • Contains transaction or temporary order records.
  • Fields: TCOORD (2-9, company/order), TKEY (2-12, composite key), TSEQ (10-12, sequence), TDDEL (1, delete flag), TDCO (2-3, company), TDORD# (4-9, order number), TDCUST (13-18, customer number).
  • BBORCL:
  • Update-capable file, 256-byte records, 14-byte alphanumeric key, indexed (14AI).
  • Likely a transaction or control file for orders.
  • Deleted using BBKEY (company + customer + order number).
  • BBOTHS1:
  • Update-capable file, 512-byte records, 8-byte alphanumeric key, externally described (EXTK).
  • Likely an order header file.
  • Field: BOCOOR (2-9, company/order number).
  • BBOTDS1:
  • Update-capable file, 512-byte records, 11-byte alphanumeric key, externally described (EXTK).
  • Likely an order detail file.
  • Field: BDCOOR (2-9, company/order number).
  • BBOTA1:
  • Update-capable file, 512-byte records, 13-byte alphanumeric key, externally described (EXTK).
  • Likely an auxiliary or temporary order file.
  • Field: BACOOR (2-9, company/order number).

External Programs Called

  • None. BB003 is self-contained, with no subroutines or calls to other programs. It relies solely on file I/O (sequential reads and exception outputs) to delete records from the specified files.

The program is a utility for batch deletion, ensuring all transaction records tied to a batch’s orders are removed, supporting the cleanup process initiated by the BB170 OCL procedure.