Skip to content

BB620 RPG36

The BB620.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 remove posted invoices from the invoice transaction entry file (BBTRAN) and associated files (BBTRHS1, BBTRDS1, BBTRA1, BBTRANU, BBTRTX). It deletes header, detail, supplemental, and accessorial/marks records for posted invoices and writes records to an audit file (SA5SHA). The program includes revisions to handle new fields and supplemental/accessorial data (per JB01). Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.


Process Steps of the BB610 RPG Program

The BB620 program processes invoice transaction records from BBTRAN, identifies posted invoices, deletes associated records across multiple files, and logs deletions to SA5SHA for auditing.

  1. File Initialization:
  2. The program opens the following files:
    • Input/Update Files:
    • BBTRAN: Primary input/update file (UP), 512 bytes, 21-byte alternate index, 492-byte key, disk-based. Contains invoice transaction records (header, detail, marks, miscellaneous).
    • BBTRHS1: Update file (UF), 512 bytes, 18-byte alternate index, externally keyed (EXTK), disk-based. Stores supplemental header records.
    • BBTRDS1: Update file (UF), 512 bytes, 21-byte alternate index, externally keyed (EXTK), disk-based. Stores supplemental detail records.
    • BBTRA1: Update file (UF), 512 bytes, 23-byte alternate index, externally keyed (EXTK), disk-based. Stores accessorial/marks records.
    • BBTRANU: Update file (UF), 512 bytes, 21-byte alternate index, 492-byte key, disk-based. Likely a duplicate or alternate invoice transaction file.
    • BBTRTX: Update file (UF), 512 bytes, 11-byte alternate index, disk-based. Stores tax-related records.
    • Output File:
    • SA5SHA: Output file (O), 512 bytes, add capability (A), disk-based. Used for audit logging of deleted records.
  3. Defines record formats for BBTRAN with condition indicators:
    • 01 (Header): C0 at positions 10–12.
    • 02 (Detail): NC9 at position 10.
    • 03 (Miscellaneous): C9 at position 10.
    • 04 (Order Marks): C9, C6, C0 at positions 10–12.
    • 05 (Invoice Marks): C9, C6, C1 at positions 10–12.
    • 06 (BOL Marks): C9, C6, C2 at positions 10–12.
  4. Key fields:

    • COORD (2–9): Order key (company + order number).
    • ORKEY (2–12): Extended order key.
    • BOINV# (95–101): Invoice number.
    • BOSHDT (108–113): Ship date.
    • BOLKYH (492–509): Header key for supplemental records.
    • BOLKEY (492–512): Transaction key.
    • DEL (1): Delete flag.
  5. Record Processing (BBTRAN):

  6. Reads BBTRAN records sequentially using the RPG cycle (NS 01, OR 02, OR 03, OR 04, OR 05, OR 06).
  7. Identifies record type (header, detail, marks, miscellaneous) using condition indicators (C0, C9, C6, C1, C2).
  8. Processes records at level break L1 (likely company or order level).

  9. Deletion of Posted Invoices:

  10. For each posted invoice (criteria not specified, likely based on status or BOINV#):

    • Header Deletion:
    • Chains to BBTRANU using BOLKEY to locate the header record (C L1 BOLKEY CHAINBBTRANU 90).
    • If found (N90), executes exception output DELHDR to delete the header from BBTRANU (EDEL DELHDR).
    • Chains to BBTRHS1 using BOLKYH to locate the supplemental header (C L1 BOLKYH CHAINBBTRHS1 91).
    • If found (N91), executes DELHS to delete from BBTRHS1 (EDEL DELHS).
    • Detail Deletion:
    • Deletes detail records from BBTRAN (EDEL DELREC).
    • Deletes supplemental detail records from BBTRDS1 (EDEL DELDS).
    • Deletes tax records from BBTRTX (EDEL DELDTX).
    • Accessorial/Marks Deletion:
    • Sets lower limit for BBTRA1 using XXKY23 (constructed from BOLKYH + '00000') (C L1 XXKY23 SETLLBBTRA1).
    • Reads BBTRA1 records sequentially (C L1 READ BBTRA1 91EOF).
    • Compares ACOORR (accessorial order key) with BOLKYH (C L1 N91ACOORR COMP BOLKYH 9191).
    • If matching (91), executes RELA to release or process (E RELA).
    • If not matching, executes DELA to delete from BBTRA1 (EDEL DELA).
    • Continues until end of file (91EOF, jumps to ENDA).
  11. Audit Logging:

  12. Writes deleted record details to SA5SHA (EADD DELA):
    • Fields: BAREC1 (1–256), BAREC2 (257–512), 'BBTRA' (constant, position 200), 'BB620' (program name, position 210), SVINV# (invoice number, position 218), SVSHDT (ship date, position 227).
  13. Logs deletions for auditing purposes.

  14. Error Checking:

  15. Checks if error count (ERRCNT) is zero (C L1 ERRCNT IFEQ *ZERO).
  16. Proceeds with deletions only if no errors are detected.

  17. Cycle Completion:

  18. Processes all BBTRAN records at level break L1.
  19. Deletes associated records in BBTRANU, BBTRHS1, BBTRDS1, BBTRA1, BBTRTX.
  20. Logs deletions to SA5SHA.
  21. Terminates after processing, closing all files.

Business Rules

  1. Invoice Deletion:
  2. Removes posted invoices from BBTRAN, including header, detail, marks, and miscellaneous records.
  3. Deletes corresponding records from BBTRANU (header), BBTRHS1 (supplemental header), BBTRDS1 (supplemental detail), BBTRA1 (accessorial/marks), and BBTRTX (tax).

  4. Supplemental and Accessorial Data (per JB01):

  5. Manages new fields for customer-owned product shipments and other data.
  6. Adds, updates, or deletes records in BBTRHS1, BBTRDS1, and BBTRA1 to handle supplemental header, detail, and accessorial/marks data.

  7. Audit Logging:

  8. Logs all deletions to SA5SHA with invoice number (SVINV#), ship date (SVSHDT), and program metadata for tracking.

  9. Error Handling:

  10. Checks ERRCNT to ensure no errors before proceeding with deletions.
  11. Assumes input files contain valid data and output files can be written without issues.

  12. Record Type Identification:

  13. Uses condition indicators (C0, C9, C6, C1, C2) to distinguish header, detail, marks (order, invoice, BOL), and miscellaneous records.

  14. Key-Based Deletion:

  15. Uses BOLKEY and BOLKYH for chaining to BBTRANU and BBTRHS1.
  16. Constructs XXKY23 for BBTRA1 to process accessorial/marks records.

  17. Integration with ARGLMS:

  18. Part of the invoice posting workflow, ensuring posted invoices are removed from transaction files to maintain data integrity.

Tables (Files) Used

  1. BBTRAN:
  2. Description: Invoice transaction entry file.
  3. Attributes: Update file (UP), 512 bytes, 21-byte alternate index, 492-byte key, disk-based.
  4. Fields Used: COORD (2–9, order key), ORKEY (2–12, extended order key), BOINV# (95–101, invoice number), BOSHDT (108–113, ship date), DEL (1, delete flag).
  5. Purpose: Contains invoice transaction records (header, detail, marks, miscellaneous).
  6. Usage: Read to identify posted invoices, deleted via EDEL DELREC.

  7. BBTRHS1:

  8. Description: Supplemental header file.
  9. Attributes: Update file (UF), 512 bytes, 18-byte alternate index, externally keyed (EXTK), disk-based.
  10. Fields Used: BOLKYH (492–509, header key).
  11. Purpose: Stores supplemental header data.
  12. Usage: Deleted via EDEL DELHS.

  13. BBTRDS1:

  14. Description: Supplemental detail file.
  15. Attributes: Update file (UF), 512 bytes, 21-byte alternate index, externally keyed (EXTK), disk-based.
  16. Purpose: Stores supplemental detail data.
  17. Usage: Deleted via EDEL DELDS.

  18. BBTRA1:

  19. Description: Accessorial/marks file.
  20. Attributes: Update file (UF), 512 bytes, 23-byte alternate index, externally keyed (EXTK), disk-based.
  21. Fields Used: ACOORR (accessorial order key), XXKY23 (constructed key).
  22. Purpose: Stores accessorial and marks data.
  23. Usage: Processed (E RELA) or deleted (EDEL DELA) based on key match.

  24. BBTRANU:

  25. Description: Alternate invoice transaction file.
  26. Attributes: Update file (UF), 512 bytes, 21-byte alternate index, 492-byte key, disk-based.
  27. Fields Used: BOLKEY (492–512, transaction key).
  28. Purpose: Contains invoice transaction headers (possibly a duplicate or staging file).
  29. Usage: Deleted via EDEL DELHDR.

  30. BBTRTX:

  31. Description: Tax-related file.
  32. Attributes: Update file (UF), 512 bytes, 11-byte alternate index, disk-based.
  33. Purpose: Stores tax-related records.
  34. Usage: Deleted via EDEL DELDTX.

  35. SA5SHA:

  36. Description: Audit file.
  37. Attributes: Output file (O), 512 bytes, add capability (A), disk-based.
  38. Fields Used: BAREC1 (1–256), BAREC2 (257–512), 'BBTRA' (constant), 'BB620' (program name), SVINV# (invoice number), SVSHDT (ship date).
  39. Purpose: Logs deleted records for auditing.
  40. Usage: Written via EADD DELA.

External Programs Called

The BB620 RPG program does not explicitly call any external programs. It is a self-contained program that processes input from BBTRAN and related files and writes to SA5SHA.


Summary

The BB620 RPG program, called by the main OCL (e.g., BB600.ocl36.txt), removes posted invoices by: - Reading BBTRAN to identify posted invoices (header, detail, marks, miscellaneous). - Deleting records from BBTRAN (EDEL DELREC), BBTRANU (EDEL DELHDR), BBTRHS1 (EDEL DELHS), BBTRDS1 (EDEL DELDS), BBTRA1 (EDEL DELA), and BBTRTX (EDEL DELDTX). - Processing accessorial/marks records in BBTRA1 using XXKY23 for matching or deletion. - Logging deletions to SA5SHA with invoice and ship date details. - Handling supplemental and accessorial data (per JB01). - Checking ERRCNT to ensure error-free processing. - Terminating after processing all records.

Tables Used: BBTRAN (invoice transactions), BBTRHS1 (supplemental header), BBTRDS1 (supplemental detail), BBTRA1 (accessorial/marks), BBTRANU (alternate transactions), BBTRTX (tax records), SA5SHA (audit log). External Programs Called: None.

This program ensures data integrity in the ARGLMS system by removing posted invoices from transaction files and logging deletions for audit purposes.