Skip to content

BB600 RPG36

The RPG program BB600.rpg36.txt is called by the BB600.ocl36.txt OCL program within the invoice posting workflow. Its primary function is to generate the Invoice Register and Gross Profit Register, as well as the Memo Invoice Register, by processing invoice data from various files and producing printed reports. The program handles invoice totals, customer information, and gross profit calculations, with specific enhancements for handling customer-owned product shipments, supplemental data, and memo invoice reporting. Below is a detailed explanation of the process steps, business rules, tables (files) used, and external programs called.


Process Steps of the BB600 RPG Program

The BB600 RPG program processes invoice data from the INVTOT and BBTRAN files, retrieves additional data from BICONT and ARCUST, and generates reports on multiple printer files (LIST, REPORT, LIST2, MILIST, MILISTP1). It uses the RPG cycle to process records sequentially, producing detailed and summarized output for invoices and gross profit.

Process Steps:

  1. File Initialization:
  2. The program opens the following files:

    • INVTOT: Primary input file (IP), 128 bytes per record, 21-byte alternate index (AI), disk-based. Contains invoice totals.
    • BBTRAN: Input file (IF), 512 bytes per record, 21-byte alternate index, 492-byte alternate index, disk-based. Contains invoice transaction details.
    • BICONT: Input file (IC), 256 bytes per record, 2-byte alternate index, disk-based. Contains billing control data.
    • ARCUST: Input file (IC), 384 bytes per record, 8-byte alternate index, disk-based. Contains A/R customer data.
    • LIST, REPORT, LIST2, MILIST, MILISTP1: Output printer files (O), 132 bytes per record, used for printing various reports (Invoice Register, Gross Profit Register, Memo Invoice Register).
  3. Record Processing (INVTOT):

  4. The program reads each record from INVTOT sequentially using the RPG cycle (NS 01).
  5. Key fields extracted include:
    • INVDEL (1 byte, position 1): Active/delete flag.
    • INVCO (2 bytes, positions 2–3): Company number (level break L2).
    • INVORD (6 bytes, positions 4–9): Order number (level break L1).
    • INVCAR (10 bytes, positions 10–19): Carrier.
    • INVLIN (3 bytes, positions 20–22): Line sequence.
    • INVDET (5 bytes, positions 23–27, packed): Merchandise detail total.
    • INVMSC (5 bytes, positions 28–32, packed): Miscellaneous charges total.
    • INVNET (5 bytes, positions 33–37, packed): Net invoice total.
    • INVTXA (5 bytes, positions 38–42, packed): Tax amount.
    • INVDSA (5 bytes, positions 43–47, packed): Discount amount.
    • INVTOT (5 bytes, positions 48–52, packed): Invoice total.
    • INGRWT (5 bytes, positions 53–57, packed): Gross weight.
    • INVCST (5 bytes, positions 58–62, packed): Merchandise detail cost.
    • INVGRP (5 bytes, positions 63–67, packed): Gross profit.
    • INVGPC (4 bytes, positions 68–71): Gross margin percentage.
    • INVFRT (5 bytes, positions 72–76, packed): Freight charges.
    • MEMO (1 byte, position 80): Memo invoice flag.
  6. The program uses level breaks (L1 for order number, L2 for company number) to organize output and calculate totals.

  7. Record Processing (BBTRAN):

  8. The program reads matching records from BBTRAN (NS) to retrieve invoice header details, such as:

    • BODEL (1 byte, position 1): Delete flag ('D' for deleted records).
    • BOCO (2 bytes, positions 2–3): Company number.
    • BORDNO (6 bytes, positions 4–9): Order number.
    • BORSEQ (3 bytes, positions 10–12): Header line sequence.
    • BOCUST (6 bytes, positions 13–18): Customer number.
    • BOSHIP (3 bytes, positions 19–21): Ship-to number.
    • BORQDT (6 bytes, positions 22–27): Request date.
    • BOPODT (6 bytes, positions 28–33): Customer PO date.
    • BOINDTY (10 bytes): Invoice date (year format, used in output).
    • BOINV# (7 bytes): Invoice number.
    • Additional fields for supplemental data, accessorials, and marks (as per JB01 changes).
  9. Retrieve Additional Data:

  10. The program accesses BICONT and ARCUST to retrieve billing control and customer information:
    • BICONT: Provides billing control data (e.g., company-specific settings).
    • ARCUST: Provides customer details, such as ARNAME (customer name).
  11. These files are used to enrich the report output with customer and billing details.

  12. Report Generation:

  13. The program generates multiple reports using the printer files:
    • Invoice Register (LIST):
    • Outputs invoice details, including invoice number (BOINV#), customer number (BOCUST), customer name (ARNAME), and totals (INVTOT, INVDET, etc.).
    • Includes headers and footers with system date (SYDATEY), time (SYTIME), and page numbers (PAGE1).
    • Gross Profit Register (LIST2):
    • Outputs gross profit details, including invoice total (INVTOTM), detail amount (INVDETM), cost (INVCSTM), gross profit (INVGRPM), and gross margin percentage (INVGPCM).
    • Triggered by level breaks (L2NU1 for company totals, LRNU1 for final totals).
    • Includes headers with company name (BCNAME), invoice date (BOINDTY), and totals.
    • Memo Invoice Register (MILIST, MILISTP1):
    • Outputs memo invoices (records where MEMO = 'Y').
    • Headings are printed only if the report is not empty (per JB02 change).
    • MILISTP1 is directed to a different printer (P1) for specific memo invoice output.
    • REPORT:
    • General output file for additional reporting, directed to specific output queues (SJPOST or TESTOUTQ) per BB600.ocl36.txt.
  14. The program uses output specifications to format headers, detail lines, and totals, with level break indicators (L1, L2, LR) for company and final totals.

  15. Handling Supplemental Data and Customer-Owned Product (per JB01):

  16. The program processes new fields for customer-owned product shipments, header supplemental data, detail supplemental data, and accessorials/marks tables.
  17. These fields are likely included in BBTRAN and used to enhance reporting or update related files.

  18. Spoolflex Support (per MG03):

  19. The program includes data to help Spoolflex correctly name PDF output, likely by including specific fields (e.g., BOINV#, BOCUST) in the report output for proper file naming during distribution.

  20. Cycle Completion:

  21. The RPG cycle processes all records in INVTOT, matching with BBTRAN records, until the end of the file.
  22. Company totals (L2ITOTM, L2DETM, L2ICSTM, L2GRSPM, L2GPERM) and final totals (LRITOTM, LRDETM, LRICSTM, LRGRSPM, LRGPERM) are printed at level breaks (L2 for company, LR for final).
  23. The program terminates after processing, closing all files.

Business Rules

  1. Invoice Filtering:
  2. Records with INVDEL = 'D' (deleted) or BODEL = 'D' are skipped to exclude inactive or deleted invoices from reports.
  3. Memo invoices (MEMO = 'Y') are processed separately for the Memo Invoice Register (MILIST, MILISTP1).

  4. Level Breaks:

  5. The program uses level breaks to organize output:
    • L1: Order number (INVORD) for individual invoice details.
    • L2: Company number (INVCO) for company totals.
    • LR: Last record for final totals across all companies.
  6. Totals are calculated for invoice total (INVTOT), detail amount (INVDET), cost (INVCST), gross profit (INVGRP), and gross margin percentage (INVGPC).

  7. Gross Profit Suppression:

  8. The Gross Profit Register (LIST2) is suppressed if switch 1 is set (SWITCH 1XXXXXXX in BB600.ocl36.txt), preventing sensitive financial data from being printed.

  9. Memo Invoice Reporting (per JB02):

  10. Headings for the Memo Invoice Register (MILIST, MILISTP1) are printed only if the report contains data, avoiding empty reports.

  11. Customer-Owned Product and Supplemental Data (per JB01):

  12. The program handles new fields for customer-owned product shipments and updates tables for header supplemental data, detail supplemental data, and accessorials/marks.
  13. These fields are included in reports or used to update related files, ensuring accurate tracking of specialized invoice data.

  14. Spoolflex Integration (per MG03):

  15. The program includes data (e.g., invoice number, customer number) to support Spoolflex in naming PDF output files correctly for distribution.

  16. No Error Handling:

  17. The program assumes that input files (INVTOT, BBTRAN, BICONT, ARCUST) exist and contain valid data, and that printer files can be written to without issues.
  18. No explicit error handling is included for file access or data validation.

  19. EDI Workflow Integration:

  20. The program operates within the EDI workflow, using data prepared by earlier programs (e.g., BB513, BB517) to generate reports for invoice posting.

Tables (Files) Used

  1. INVTOT:
  2. Description: Invoice totals file.
  3. Attributes: 128 bytes per record, primary input file (IP), 21-byte alternate index (AI), disk-based.
  4. Fields Used:
    • BIKEY (21 bytes, positions 2–22): Key field.
    • INVDEL (1 byte, position 1): Active/delete flag.
    • INVCO (2 bytes, positions 2–3): Company number.
    • INVORD (6 bytes, positions 4–9): Order number.
    • INVCAR (10 bytes, positions 10–19): Carrier.
    • INVLIN (3 bytes, positions 20–22): Line sequence.
    • INVDET (5 bytes, positions 23–27, packed): Merchandise detail total.
    • INVMSC (5 bytes, positions 28–32, packed): Miscellaneous charges total.
    • INVNET (5 bytes, positions 33–37, packed): Net invoice total.
    • INVTXA (5 bytes, positions 38–42, packed): Tax amount.
    • INVDSA (5 bytes, positions 43–47, packed): Discount amount.
    • INVTOT (5 bytes, positions 48–52, packed): Invoice total.
    • INGRWT (5 bytes, positions 53–57, packed): Gross weight.
    • INVCST (5 bytes, positions 58–62, packed): Merchandise detail cost.
    • INVGRP (5 bytes, positions 63–67, packed): Gross profit.
    • INVGPC (4 bytes, positions 68–71): Gross margin percentage.
    • INVFRT (5 bytes, positions 72–76, packed): Freight charges.
    • MEMO (1 byte, position 80): Memo invoice flag.
  5. Purpose: Contains summarized invoice data for reporting.
  6. Usage: Read sequentially to generate invoice and gross profit reports.

  7. BBTRAN:

  8. Description: Invoice transaction file.
  9. Attributes: 512 bytes per record, input file (IF), 21-byte alternate index, 492-byte alternate index, disk-based.
  10. Fields Used:
    • BODEL (1 byte, position 1): Delete flag.
    • BOCO (2 bytes, positions 2–3): Company number.
    • BORDNO (6 bytes, positions 4–9): Order number.
    • BORSEQ (3 bytes, positions 10–12): Header line sequence.
    • BOCUST (6 bytes, positions 13–18): Customer number.
    • BOSHIP (3 bytes, positions 19–21): Ship-to number.
    • BORQDT (6 bytes, positions 22–27): Request date.
    • BOPODT (6 bytes, positions 28–33): Customer PO date.
    • BOINDTY (10 bytes): Invoice date (year format).
    • BOINV# (7 bytes): Invoice number.
    • Additional fields for supplemental data, accessorials, and marks (per JB01).
  11. Purpose: Contains detailed invoice transaction data.
  12. Usage: Read to match with INVTOT records and provide header details for reports.

  13. BICONT:

  14. Description: Billing control file.
  15. Attributes: 256 bytes per record, input file (IC), 2-byte alternate index, disk-based.
  16. Fields Used:
    • BCNAME (30 bytes): Company name.
  17. Purpose: Provides billing control data, such as company-specific settings.
  18. Usage: Accessed to retrieve company details for report headers.

  19. ARCUST:

  20. Description: A/R customer file.
  21. Attributes: 384 bytes per record, input file (IC), 8-byte alternate index, disk-based.
  22. Fields Used:
    • ARNAME (customer name): Used in report output.
  23. Purpose: Contains customer information for invoice reporting.
  24. Usage: Accessed to retrieve customer names for reports.

  25. LIST:

  26. Description: Printer file for Invoice Register.
  27. Attributes: 132 bytes per record, output file (O), printer-based, overflow indicator OF.
  28. Fields Used: Invoice number, customer number, customer name, totals, etc.
  29. Purpose: Outputs the Invoice Register report.
  30. Usage: Receives formatted invoice details and headers.

  31. REPORT:

  32. Description: Printer file for general reporting.
  33. Attributes: 132 bytes per record, output file (O), printer-based, overflow indicator OA.
  34. Purpose: Outputs additional report data, directed to specific queues (SJPOST, TESTOUTQ).
  35. Usage: Receives report output as specified in the OCL program.

  36. LIST2:

  37. Description: Printer file for Gross Profit Register.
  38. Attributes: 132 bytes per record, output file (O), printer-based, overflow indicator OG.
  39. Fields Used: BOINV#, BOCUSTZ, ARNAME, INVTOTM, INVDETM, INVCSTM, INVGRPM, INVGPCM, company totals (L2ITOTM, etc.), final totals (LRITOTM, etc.).
  40. Purpose: Outputs the Gross Profit Register with financial details.
  41. Usage: Receives gross profit data, suppressed if switch 1 is set.

  42. MILIST:

  43. Description: Printer file for Memo Invoice Register (printer P5).
  44. Attributes: 132 bytes per record, output file (O), printer-based, overflow indicator OC.
  45. Purpose: Outputs memo invoice details for records where MEMO = 'Y'.
  46. Usage: Receives memo invoice report output, with headings printed only if data exists (per JB02).

  47. MILISTP1:

  48. Description: Printer file for Memo Invoice Register (printer P1).
  49. Attributes: 132 bytes per record, output file (O), printer-based, overflow indicator OD.
  50. Purpose: Outputs memo invoice details to a different printer for specific distribution.
  51. Usage: Same as MILIST but directed to printer P1.

External Programs Called

The BB600 RPG program does not explicitly call any external programs. It is a self-contained program that processes input from INVTOT, BBTRAN, BICONT, and ARCUST and generates output to printer files.


Summary

The BB600 RPG program, called by BB600.ocl36.txt, generates the Invoice Register, Gross Profit Register, and Memo Invoice Register by: - Reading invoice totals from INVTOT and transaction details from BBTRAN. - Retrieving billing control (BICONT) and customer data (ARCUST) for report enrichment. - Producing reports on LIST (Invoice Register), LIST2 (Gross Profit Register), MILIST, and MILISTP1 (Memo Invoice Register). - Handling level breaks for company and final totals. - Supporting customer-owned product shipments, supplemental data, and Spoolflex PDF naming (per JB01, MG03). - Suppressing gross profit output if switch 1 is set and printing memo invoice headings only for non-empty reports (per JB02).

Tables Used: INVTOT (invoice totals), BBTRAN (invoice transactions), BICONT (billing control), ARCUST (A/R customer), LIST (Invoice Register), REPORT (general report), LIST2 (Gross Profit Register), MILIST (Memo Invoice Register, P5), MILISTP1 (Memo Invoice Register, P1). External Programs Called: None.

This program is a critical component of the invoice posting workflow, producing detailed financial and invoice reports for auditing and distribution, integrated with EDI and Spoolflex processes.