Skip to content

BB705 RPG36

The provided document, BB705.rpg36.txt, is an RPG program for the IBM System/36, called by the OCL program BB705.ocl36.txt to generate a Pending Orders Report. It processes sorted order data and produces a formatted report based on company, location, request date, carrier, order, and sequence. Below, I’ll explain the process steps, business rules, tables used, and external programs called, integrating context from the previous programs (BB705P.ocl36.txt, BB705P.rpg36.txt, and BB705.ocl36.txt).

Process Steps of the RPG Program

The BB705 RPG program reads sorted order data from BBORDR (via BB705S from the OCL), retrieves additional details from supporting files, and outputs a formatted report to the LIST printer file. Here’s a step-by-step breakdown:

  1. File and Data Definitions:
  2. Input Files:
    • BBORDR (532 bytes, primary input, sorted data from BB705S): Contains order header, detail, and remark records.
    • ARCUST (384 bytes, indexed): Customer data.
    • SHIPTO (2048 bytes, indexed): Ship-to address data.
    • BICONT (256 bytes, indexed): Company data (used in BB705P for validation).
    • GSCTUM (64 bytes, indexed): Unit of measure or control data.
    • INLOC (512 bytes, indexed): Location data (used in BB705P for validation).
  3. Output File:
    • LIST (164 bytes, printer file): Outputs the formatted pending orders report.
  4. Arrays:
    • AST (82 elements, 2 characters): Stores asterisks for formatting (e.g., *** TOTAL ***).
    • HYP (82 elements, 2 characters): Stores hyphens for formatting (e.g., separators).
  5. Record Formats (from BBORDR):
    • Header (NS 01): Fields like BOCO (company), BORDNO (order number), BOCUST (customer), BOSHIP (ship-to), BORQDT (request date), etc.
    • Detail (NS 02): Fields like BDLOC (location), BDPROD (product), BDQTY (quantity), BDPRCE (price), etc.
    • Miscellaneous Detail (NS 03): Fields like BMMSTY (type), BMQTY (quantity), BMAMT (amount), etc.
    • Order Entry Remarks (NS 04): Fields like BXOMK1-4 (remarks).
    • Invoice/Dispatch Remarks (NS 05): Fields like BXIMK1-2 (invoice remarks), BXDSP1-4 (dispatch info).
    • Bill of Lading Remarks (NS 06): Fields like BXBMK1-4 (BOL remarks), BXFRNM (freight name), BXFRA1-3 (freight addresses).
  6. Program Modifications:

    • VV01: Changed product code (BDPROD) from numeric to alphanumeric.
    • DC01 (05/12/2010): Added call to MSHPADR for compressed ship-to address.
    • JB02 (05/31/2010): Revised MSHPADR parameters to include country (SCTY).
    • JB03 (10/18/2017): Removed order types 'M' (cash return) and 'C' (cash sale), with 'M' reused for product move.
  7. Initialization and Main Processing:

  8. The program uses RPG’s cycle-driven processing to read BBORDR records sequentially.
  9. Level Breaks:
    • L3 (company/location): Triggers on changes in BOCO or BOLOCT (temporary location, positions 513-515).
    • L2 (request date): Triggers on changes in BORQDT.
    • L1 (order): Triggers on changes in BORDNO.
  10. Header Subroutine (HDR):
    • Validates order type (BOTYPE = 'R' or 'M', per JB03 modification; sets indicator 27).
    • Retrieves customer data from ARCUST using ARKEY (company + customer number).
    • Retrieves ship-to data:
    • If BOSHIP = 0, uses customer address (ARNAME, ARADR1-4) and blanks SAD5, SCTY.
    • Otherwise, chains SHIPTO using KEY11 (company + customer or order number + ship-to).
    • Calls MSHPADR to get compressed ship-to address (SNAM, SAD1-5, SCTY).
    • Sets indicators 70-72, 61 based on non-blank address fields (SAD2-5).
    • Checks if prepaid amount (BOPAMT) is zero (sets 61).
  11. Detail Processing:

    • Processes header, detail, and remark records based on record type (NS 01-06).
    • Accumulates totals for quantities (BDQTY, BMQTY) and amounts (BDTOT, BMTOT, L1TOT).
  12. Report Output:

  13. Printer File (LIST):
    • Company/Location Header (D 102 L3): Prints company name (BCNAME), page number, system date (SYDATEY), program name, and system time (SYTIME).
    • Location Header (D 1 L3): Prints location code (BOLOCT), location name (LOCNAM), and date range (FRDMDYY to TODMDYY).
    • Request Date Header (D 0/01 L2): Prints request date (BORQDTY) and “PENDING ORDERS”.
    • Order Header (D 1 L1): Prints company (BOCO), order number (BORDNOZ), type (BOTYPE), customer (BOCUSTZ, ARNAME), ship-to (BOSHIPZ, SNAM, SAD1-5, SCTY), bill of lading (BOBOL#Z), order date (BOORDTY), pickup date (BORQDTY), time (BOTIME), carrier code (BOCACD), freight codes (BOFPER, BOFRCD), PO numbers (BOPORD, BOSHPO), user fields (BOVAR1-2), routing (BORTG1-2), terms (BOTERM), salesman (BOSLMN), delivery (BODELV), multi-load info (BOMULO, BOTOLOZ, BOLODAZ, BOLOVOM), and weekend pickup (BOWEPU).
    • Detail Lines (D 1 02 60): Prints location (BDLOC), product (BDPROD), quantity (BDQTY), price (BDPRCE), unit of measure (BDUM), no-charge code (BDNOCH), description (BDDESC), and total (BDTOT).
    • Miscellaneous Lines (D 1 03 60): Prints type (BMMSTY), quantity (BMQTY), amount (BMAMT), G/L number (BMGL#), description (BMDESC), and total (BMTOT).
    • Remarks:
    • Order Entry (PRTOEM, 62): Prints BXOMK1-4 if non-blank.
    • Dispatch Info (PRTDIM, 66): Prints BXDSP1-4 if non-blank.
    • Invoice Remarks (PRTIVM, 63): Prints BXIMK1-2 if non-blank.
    • BOL Remarks (PRTBOM, 64): Prints BXBMK1-4 if non-blank.
    • Freight Info (PRTFRM, 65): Prints BXFRNM, BXFRA1-3 if non-blank.
    • Totals:
    • Order Total (T 1 L1): Prints “ TOTAL ” and L1TOT.
    • Separator (T 11 L1): Prints asterisks (AST).
  14. Output Logic:

    • Remarks are printed only if non-blank (indicators 62-66).
    • Address fields (SAD2-5) are conditionally printed based on indicators 70-72, 61.
  15. Program Termination:

  16. The RPG cycle processes all records, outputs the report, and ends when BBORDR is exhausted.

Business Rules

The program enforces the following business rules for the pending orders report:

  1. Order Type Filtering:
  2. Only orders with BOTYPE = 'R' (regular) or 'M' (product move, per JB03) are included. Legacy types 'M' (cash return) and 'C' (cash sale) are excluded.

  3. Data Validation:

  4. Customer data is retrieved from ARCUST using company and customer number (BOCO, BOCUST).
  5. Ship-to data is retrieved from SHIPTO or defaults to customer address if BOSHIP = 0. For BOSHIP = 999 or 900, special key construction is used.
  6. The MSHPADR program compresses ship-to addresses, including country (SCTY, per JB02).

  7. Report Formatting:

  8. Hierarchical structure: Company/location (L3), request date (L2), order (L1).
  9. Includes detailed order information (customer, ship-to, dates, carrier, freight, etc.).
  10. Remarks (order, invoice, dispatch, BOL, freight) are printed only if non-blank.
  11. Totals are calculated for detail (BDTOT), miscellaneous (BMTOT), and order-level (L1TOT).

  12. Address Handling:

  13. Ship-to address (SAD1-5) is printed only for non-blank fields, with country (SCTY) included if available.
  14. Prepaid amount (BOPAMT) is highlighted if zero.

  15. Data Integration:

  16. Uses BICONT and INLOC for company and location details (consistent with BB705P validation).
  17. GSCTUM provides unit of measure data for detail lines.

Tables Used

  1. AST:
  2. Array (82 elements, 2 characters) for printing asterisks (e.g., *** TOTAL *** or separators).

  3. HYP:

  4. Array (82 elements, 2 characters) for printing hyphens (e.g., section separators).

  5. Files as Data Sources (function as relational tables):

  6. BBORDR: Sorted order data (header, detail, remarks).
  7. ARCUST: Customer data (name, address).
  8. SHIPTO: Ship-to address data.
  9. BICONT: Company data.
  10. GSCTUM: Unit of measure or control data.
  11. INLOC: Location data.

No additional RPG tables (e.g., TABxxx) are defined.

External Programs Called

  1. MSHPADR:
  2. Called in the HDR subroutine to retrieve compressed ship-to addresses.
  3. Parameters: KEY11 (company + customer/order + ship-to), SNAM, SAD1-5, SCTY.
  4. Added in DC01 (05/12/2010), with country support in JB02 (05/31/2010).

Summary

  • Process Steps:
  • Define input files (BBORDR, ARCUST, SHIPTO, BICONT, GSCTUM, INLOC) and output printer file (LIST).
  • Process BBORDR records using RPG cycle with level breaks (L3, L2, L1).
  • Execute HDR subroutine to validate order type, retrieve customer/ship-to data, and call MSHPADR for address compression.
  • Output report with headers (company, location, date, order), details (products, quantities, prices), remarks (order, invoice, dispatch, BOL, freight), and totals.
  • End when BBORDR is exhausted.

  • Business Rules:

  • Filter orders by type ('R', 'M').
  • Validate and retrieve customer/ship-to data.
  • Print non-blank remarks and addresses.
  • Calculate and display totals at order level.
  • Format report hierarchically for clarity.

  • Tables Used:

  • Arrays: AST (asterisks), HYP (hyphens).
  • Files: BBORDR, ARCUST, SHIPTO, BICONT, GSCTUM, INLOC.

  • External Programs Called:

  • MSHPADR: Retrieves compressed ship-to addresses.

This program completes the workflow started by BB705P (input validation) and BB705.ocl36.txt (data preparation/sorting). If you have the RPG code for BB7051 or file layouts for BBORDR, ARCUST, etc., I can provide further details. Let me know if you need additional analysis or a search for related information!