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:¶
- File Initialization:
-
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).
-
Record Processing (INVTOT):
- The program reads each record from
INVTOTsequentially using the RPG cycle (NS 01). - Key fields extracted include:
INVDEL(1 byte, position 1): Active/delete flag.INVCO(2 bytes, positions 2–3): Company number (level breakL2).INVORD(6 bytes, positions 4–9): Order number (level breakL1).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.
-
The program uses level breaks (
L1for order number,L2for company number) to organize output and calculate totals. -
Record Processing (BBTRAN):
-
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
JB01changes).
-
Retrieve Additional Data:
- The program accesses
BICONTandARCUSTto retrieve billing control and customer information:BICONT: Provides billing control data (e.g., company-specific settings).ARCUST: Provides customer details, such asARNAME(customer name).
-
These files are used to enrich the report output with customer and billing details.
-
Report Generation:
- 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 (
L2NU1for company totals,LRNU1for 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
JB02change). MILISTP1is directed to a different printer (P1) for specific memo invoice output.- REPORT:
- General output file for additional reporting, directed to specific output queues (
SJPOSTorTESTOUTQ) perBB600.ocl36.txt.
- Invoice Register (
-
The program uses output specifications to format headers, detail lines, and totals, with level break indicators (
L1,L2,LR) for company and final totals. -
Handling Supplemental Data and Customer-Owned Product (per JB01):
- The program processes new fields for customer-owned product shipments, header supplemental data, detail supplemental data, and accessorials/marks tables.
-
These fields are likely included in
BBTRANand used to enhance reporting or update related files. -
Spoolflex Support (per MG03):
-
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. -
Cycle Completion:
- The RPG cycle processes all records in
INVTOT, matching withBBTRANrecords, until the end of the file. - Company totals (
L2ITOTM,L2DETM,L2ICSTM,L2GRSPM,L2GPERM) and final totals (LRITOTM,LRDETM,LRICSTM,LRGRSPM,LRGPERM) are printed at level breaks (L2for company,LRfor final). - The program terminates after processing, closing all files.
Business Rules¶
- Invoice Filtering:
- Records with
INVDEL = 'D'(deleted) orBODEL = 'D'are skipped to exclude inactive or deleted invoices from reports. -
Memo invoices (
MEMO = 'Y') are processed separately for the Memo Invoice Register (MILIST,MILISTP1). -
Level Breaks:
- 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.
-
Totals are calculated for invoice total (
INVTOT), detail amount (INVDET), cost (INVCST), gross profit (INVGRP), and gross margin percentage (INVGPC). -
Gross Profit Suppression:
-
The Gross Profit Register (
LIST2) is suppressed if switch 1 is set (SWITCH 1XXXXXXXinBB600.ocl36.txt), preventing sensitive financial data from being printed. -
Memo Invoice Reporting (per JB02):
-
Headings for the Memo Invoice Register (
MILIST,MILISTP1) are printed only if the report contains data, avoiding empty reports. -
Customer-Owned Product and Supplemental Data (per JB01):
- The program handles new fields for customer-owned product shipments and updates tables for header supplemental data, detail supplemental data, and accessorials/marks.
-
These fields are included in reports or used to update related files, ensuring accurate tracking of specialized invoice data.
-
Spoolflex Integration (per MG03):
-
The program includes data (e.g., invoice number, customer number) to support Spoolflex in naming PDF output files correctly for distribution.
-
No Error Handling:
- 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. -
No explicit error handling is included for file access or data validation.
-
EDI Workflow Integration:
- 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¶
- INVTOT:
- Description: Invoice totals file.
- Attributes: 128 bytes per record, primary input file (
IP), 21-byte alternate index (AI), disk-based. - 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.
- Purpose: Contains summarized invoice data for reporting.
-
Usage: Read sequentially to generate invoice and gross profit reports.
-
BBTRAN:
- Description: Invoice transaction file.
- Attributes: 512 bytes per record, input file (
IF), 21-byte alternate index, 492-byte alternate index, disk-based. - 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).
- Purpose: Contains detailed invoice transaction data.
-
Usage: Read to match with
INVTOTrecords and provide header details for reports. -
BICONT:
- Description: Billing control file.
- Attributes: 256 bytes per record, input file (
IC), 2-byte alternate index, disk-based. - Fields Used:
BCNAME(30 bytes): Company name.
- Purpose: Provides billing control data, such as company-specific settings.
-
Usage: Accessed to retrieve company details for report headers.
-
ARCUST:
- Description: A/R customer file.
- Attributes: 384 bytes per record, input file (
IC), 8-byte alternate index, disk-based. - Fields Used:
ARNAME(customer name): Used in report output.
- Purpose: Contains customer information for invoice reporting.
-
Usage: Accessed to retrieve customer names for reports.
-
LIST:
- Description: Printer file for Invoice Register.
- Attributes: 132 bytes per record, output file (
O), printer-based, overflow indicatorOF. - Fields Used: Invoice number, customer number, customer name, totals, etc.
- Purpose: Outputs the Invoice Register report.
-
Usage: Receives formatted invoice details and headers.
-
REPORT:
- Description: Printer file for general reporting.
- Attributes: 132 bytes per record, output file (
O), printer-based, overflow indicatorOA. - Purpose: Outputs additional report data, directed to specific queues (
SJPOST,TESTOUTQ). -
Usage: Receives report output as specified in the OCL program.
-
LIST2:
- Description: Printer file for Gross Profit Register.
- Attributes: 132 bytes per record, output file (
O), printer-based, overflow indicatorOG. - Fields Used:
BOINV#,BOCUSTZ,ARNAME,INVTOTM,INVDETM,INVCSTM,INVGRPM,INVGPCM, company totals (L2ITOTM, etc.), final totals (LRITOTM, etc.). - Purpose: Outputs the Gross Profit Register with financial details.
-
Usage: Receives gross profit data, suppressed if switch 1 is set.
-
MILIST:
- Description: Printer file for Memo Invoice Register (printer
P5). - Attributes: 132 bytes per record, output file (
O), printer-based, overflow indicatorOC. - Purpose: Outputs memo invoice details for records where
MEMO = 'Y'. -
Usage: Receives memo invoice report output, with headings printed only if data exists (per
JB02). -
MILISTP1:
- Description: Printer file for Memo Invoice Register (printer
P1). - Attributes: 132 bytes per record, output file (
O), printer-based, overflow indicatorOD. - Purpose: Outputs memo invoice details to a different printer for specific distribution.
- Usage: Same as
MILISTbut directed to printerP1.
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.