Skip to content

BB198 RPG36

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

This RPG III program (BB198) performs credit authorization for orders in a sorted transaction batch. It processes order headers and details to calculate values, retrieve descriptions, check for deletions/backorders, update customer order status, and generate a printed report (Credit Authorization Report) for review. The input is from a pre-sorted file (?9?BB198S from #GSORT in the OCL), ensuring headers come first, followed by marks and details. The program loops through records, applying calculations and validations, and outputs a report with order details and totals. It is called from the main OCL procedure (BB201.ocl36.txt) in the "Credit Authorization" section after sorting.

High-level process steps, executed in a level-break structure (L3 for company/customer changes, L1 for order changes):

  1. Initialization and Setup:
  2. Clears indicators (e.g., 10-17, 60-80) and totals (L1TOTL, L3TOTL set to zero).
  3. Prepares keys for chaining (e.g., BOKEY from positions 2-12).

  4. Header Record Processing (NS 01, Level L3):

  5. Reads header records from BBORTR.
  6. Skips if deleted (BODEL = 'D').
  7. Chains to SHIPTO using SHPKEY (customer + ship-to) for ship-to details.
  8. Chains to GSTABL using TRMKEY ('ARTERM' + BOTERM) for terms description (TRMDES); defaults to TBDESC if not found.
  9. Chains to ARCUST using COCUST (company + customer) for customer name (ARNAME).
  10. Prints header line (ORDLNE) with order#, customer#, name, dates, PO#, terms.
  11. Sets indicator 26 if BOTYPE = 'R' (credit invoice; formerly included 'M' per JB02 removal).
  12. Sets up detail reading: SETLL on BBORTA using OKEY11 (order# + '001'), then reads details in a loop until EOF or mismatch.

  13. Detail Line Processing (Loop within Header):

  14. Reads details from BBORTA.
  15. Skips if end-of-details (31 on), seq# > 899 (misc lines?), deleted (BDDEL = 'D'), or key mismatch (customer/order# != header).
  16. Adjusts quantity negative if credit invoice (26 on: BDQTY * -1).
  17. Sets 28 if no charge (BDNOCH = 'Y'), zeros BDTOTL in that case.
  18. Calculates line total (BDTOTL):
    • Builds CUKEY (company + product + container + UM).
    • Chains to GSCTUM for conversion factor (CUCVFA).
    • Converts qty (multiply/divide by CUCVFA based on CUOPER = 'M').
    • Multiplies converted qty by price (BDPRCE).
  19. Adds BDTOTL to order total (L1TOTL) and company total (L3TOTL).
  20. Retrieves product description:
    • Chains to GSPROD using KLPROD (company + product; replaces GSTABL per JK01).
    • Uses custom desc (BDCPDS) if provided; else alternate (TPALTD/TPDESC) or standard (TPDESC).
    • Sets 54 if two description lines needed.
  21. Prints detail line (DTLLNE) with billed customer (CSBMCU), description(s), container, qty, value.

  22. Status Update (Subroutine CUSSTS):

  23. Chains to CUSORD using KEY14 (company + customer + order#).
  24. Determines status (XXSTAT):
    • Sets 86 if backorder (BOSHP# = 1).
    • 'RO' (Revised Order) if not backorder/exists/no-cancel.
    • 'AO' (Active Order) if not backorder/new/no-cancel.
    • 'RB' (Revised Backorder) if backorder/exists/no-cancel.
    • 'AB' (Active Backorder) if backorder/new/no-cancel.
    • 'CN' (Cancelled Order) if cancelled (60 on, not shown in code but implied).
  25. No explicit write/update in code snippet, but implies update to CUSORD.

  26. Totals and Report Printing:

  27. At L1 break (order change): Prints order value total if printed (N92 per JB01), status message, type.
  28. At L3 break (company/customer change): Prints total order value.
  29. Handles overflow (OF) for page headers.
  30. Prints report headers (HDRLNE) with company name, dates, times, page#.

  31. End of Processing:

  32. Continues until EOF on BBORTR.
  33. No explicit error handling beyond not-found indicators (e.g., 91 for ARCUST).

Business Rules

  • Deletions and Skips:
  • Skips deleted headers/details (BODEL/BDDEL = 'D').
  • Ignores detail lines with seq# > 899 (likely misc/accessorials).
  • Mismatches in customer/order# between header/detail end processing.
  • Order Types:
  • 'R' flags credit invoice (26 on): Negates quantities for returns/credits.
  • Removed 'M' (cash return, reused for product move) and 'C' (cash sale) from credit flagging (JB02).
  • Calculations:
  • Line totals exclude no-charge items (BDNOCH = 'Y').
  • Quantity conversions use GSCTUM factors (multiply/divide based on operation).
  • Totals accumulate only printed orders (JB01: No totals if no details printed).
  • Descriptions:
  • Prioritizes custom (BDCPDS), then alternate (TPALTD/TPDESC), then standard from GSPROD (JK01 update).
  • Prints two lines if alternate/standard differ (54 on).
  • Status Updates (CUSORD):
  • Based on existence (85 off = exists), backorder (86 on), cancel (60 on).
  • 'Revised' for existing, 'Active' for new; append 'Backorder' if applicable; 'Cancelled' overrides.
  • Report:
  • Printed for authorization review, includes values for credit checks.
  • No totals if no orders/details (JB01).

Tables Used (Files)

Files are disk or printer, with keyed access where specified.

  • BBORTR: Input primary (IP) - Sorted transaction headers.
  • BBORTA: Input (IF) - Transaction details (setll/read).
  • BICONT: Input combined (IC) - Company/container info (not explicitly chained in snippet, but listed).
  • ARCUST: Input combined (IC) - A/R customer master (name).
  • GSCTUM: Input (IF) - Conversion units master (factors).
  • GSTABL: Input fixed (IF) - General tables (terms desc; partially replaced).
  • CUSORD: Input combined (IC) - Customer order status (chained/updated).
  • SHIPTO: Input combined (IC) - Ship-to master.
  • GSPROD: Input fixed (IF) - Product master (descriptions; JK01 addition).
  • LIST: Output (O) - Printer file for Credit Authorization Report.

External Programs Called

None. The program does not call any external programs (no CALL opcodes in the code). It relies on internal subroutines (HDR, CUSSTS) and file operations.