BI921 RPG36
The provided document, BI921.rpg36.txt
, is an RPG (Report Program Generator) program for an IBM System/36 or AS/400 environment, named BI921
. It is called by the OCL program BI921.ocl36.txt
and is responsible for generating the "Product Tax Master List" report. The program processes sorted tax data, retrieves company and product information, and formats it for printing. Below, I’ll explain the process steps, business rules, tables/files used, and any external programs called, based on the RPG source code.
Process Steps of the RPG Program¶
The BI921
RPG program reads sorted tax data from the BIPRTX
file, retrieves related company and product information, and generates a formatted report on a printer. Here’s a detailed breakdown of the process steps:
- Program Initialization (Header and File Definitions):
- Line 0002 (H-Spec): The header specification (
H P064 B
) defines the program asBI921
, withP064
as an identifier andB
indicating batch mode. - Lines 0004-0007 (F-Specs):
BIPRTX
: Primary input file (IP
), disk-based, 64 bytes per record, containing sorted tax data.BICONT
: Input file (IC
), disk-based, 256 bytes per record, indexed (2AI
), with 2 keys, used for company data.GSTABL
: Commented out (**
), previously used for product data but replaced (per modification noteJK01
).GSPROD
: Input file (IF
), disk-based, 512 bytes per record, indexed (6AI
), with 8 keys, used for product data (replacingGSTABL
perJK01
).PRINT
: Output file (O
), printer-based, 132 bytes per record, used for the report output.
- Lines 0008-0009 (E-Specs):
SEP
: Array of 66 elements, 2 bytes each, used for separator lines in the report.MSG
: Array of 5 elements, 40 bytes each, with one message defined: "MISCELLANEOUS INVOICE LINES" (used for 'MISC' product codes).
-
Lines 0010-0024 (I-Specs):
BIPRTX
(formatNS 01
):PTDEL
(1): Delete code ('D' indicates deleted records).PTCONO
(2-3): Company number.PTSTAT
(4-5): State code.PTPROD
(6-9): Product code.PTDELV
(10): Delivered code.PTTXC1
toPTTXC0
(11-50): Tax codes 1-10 (expanded from 5 to 10 perLT01
modification).BICONT
:BCNAME
(4-33): Company name.GSPROD
:TPDEL
(1): Delete flag.TPDESC
(14-43): Product description (complete).TPDES1
(14-33): Partial product description (used in output).TPPRGP
(89-90): Product group code.TPPRCL
(127-129): Product class code.TPABDS
(145-154): Short description.TPFLCD
(252): Additional field (possibly a flag or code).
-
Main Program Logic (C-Specs):
- Lines 0026-0032 (Level 2 Processing):
- Executes for each company (
L2
control break, based onPTCONO
change): - Sets
SEP
to '* ' for report formatting. - Captures current time (
TIME TIMDAT 120
) and moves it toTIME
(positions 7-12) andDATE
(positions 1-6). - Chains to
BICONT
usingPTCONO
to retrieveBCNAME
(company name). If not found (indicator 92), processing continues without a name.
- Executes for each company (
-
Lines 0035-0048 (Level 1 Processing):
- Executes for each
BIPRTX
record (01
input): - Constructs a key (
KLPROD
) by combiningPTCONO
(company number) andPTPROD
(product code). - Chains to
GSPROD
usingKLPROD
to retrieve product description (TPDESC
,TPDES1
, etc.). If not found (indicator 90), setsTPDESC
to blanks. - If
PTPROD
is 'MISC' and indicator 90 is on (product not found), setsTPDESC
to "MISCELLANEOUS INVOICE LINES" (MSG,1
). - Note: The commented
GSTABL
logic (TBKEY
,TBKEY6
) was replaced byGSPROD
(perJK01
).
- Executes for each
-
Report Output (O-Specs, Lines 0050-0088):
- Header Output (Lines 0050-0075):
- At control level
L2
(company change) or overflow (OF
), prints: - Company name (
BCNAME
) at position 30. - "PAGE" and page number (
PAGE
) at positions 104-108. - "DATE" and formatted date (
DATE
) at positions 120-129. - Report title "PRODUCT TAX MASTER LIST" at position 78.
- "TIME" and formatted time (
TIME
) at positions 120-129. - Separator line (
SEP
) at position 132. - Column headers: "STATE" (5), "PRODUCT CODE" (11), "DELV" (38), "TAX CODES ..." (69).
- At control level
- Detail Output (Lines 0076-0088):
- At control level
L1
(each record) and input record (01
): - Prints state (
PTSTAT
) at position 3. - Product code (
PTPROD
) at position 11. - Product description (
TPDES1
) at position 33. - Delivered code (
PTDELV
) at position 37. - Tax codes
PTTXC1
toPTTXC0
at positions 49, 56, 63, 70, 77, 84, 91, 98, 105, 112. - Output occurs only for non-deleted records (implicitly, as
PTDEL='D'
is not checked but could skip processing).
- At control level
Business Rules¶
Based on the program logic and comments, the following business rules apply:
1. Data Inclusion:
- Only non-deleted records from BIPRTX
(where PTDEL ≠ 'D'
) are processed, though the program does not explicitly check PTDEL
.
- Records are grouped by company (PTCONO
), with headers printed on company changes (L2
).
- Product Description Handling:
- Product descriptions are retrieved from
GSPROD
using a composite key (KLPROD = PTCONO + PTPROD
). - If a product is not found in
GSPROD
(indicator 90), the description is blanked. -
If the product code is 'MISC' and not found, the description is set to "MISCELLANEOUS INVOICE LINES".
-
Tax Code Expansion:
-
Per modification
LT01
(07/82/2011), tax codes were expanded from 5 (PTTXC1
toPTTXC5
) to 10 (PTTXC1
toPTTXC0
), allowing more tax codes per product. -
Report Formatting:
- The report includes a header with company name, date, time, and page number, printed on company changes or page overflow.
- Detail lines list state, product code, product description, delivered code, and up to 10 tax codes.
-
Separator lines (
SEP = '* '
) and column headers are printed for clarity. -
Data Validation:
- Company numbers (
PTCONO
) are validated againstBICONT
to retrieve company names. If not found (indicator 92), the name is omitted. - Product codes are validated against
GSPROD
. If not found, descriptions are handled as described above.
Tables/Files Used¶
The RPG program uses the following files:
1. BIPRTX:
- Type: Primary input file (IP
), disk-based, 64 bytes per record.
- Purpose: Contains sorted tax data (from BI921.ocl36.txt
sort).
- Fields: PTDEL
(delete code), PTCONO
(company number), PTSTAT
(state), PTPROD
(product code), PTDELV
(delivered code), PTTXC1
to PTTXC0
(tax codes 1-10).
2. BICONT:
- Type: Input file (IC
), disk-based, 256 bytes, indexed (2AI
).
- Purpose: Provides company names (BCNAME
) for report headers.
- Fields: BCNAME
(company name).
3. GSPROD:
- Type: Input file (IF
), disk-based, 512 bytes, indexed (6AI
).
- Purpose: Provides product descriptions and related data (replaced GSTABL
per JK01
).
- Fields: TPDEL
(delete flag), TPDESC
(full description), TPDES1
(partial description), TPPRGP
(product group), TPPRCL
(product class), TPABDS
(short description), TPFLCD
(flag/code).
4. GSTABL (Commented Out):
- Type: Input file (IC
), disk-based, 256 bytes, indexed (12AI
).
- Purpose: Previously used for product descriptions but replaced by GSPROD
(per JK01
).
- Fields: TBDESC
(description, commented out).
5. PRINT:
- Type: Output file (O
), printer-based, 132 bytes per record.
- Purpose: Outputs the formatted product tax master list report.
- Fields: Includes BCNAME
, DATE
, TIME
, PAGE
, SEP
, PTSTAT
, PTPROD
, TPDES1
, PTDELV
, PTTXC1
to PTTXC0
, and literals (e.g., "PRODUCT TAX MASTER LIST").
6. MSG (Array/Table):
- Type: Program-defined array (5 elements, 40 bytes each).
- Purpose: Stores messages, with one defined: "MISCELLANEOUS INVOICE LINES" for 'MISC' product codes.
External Programs Called¶
The RPG program does not explicitly call any external programs (no CALL
operations in the C-Specs). It is invoked by the OCL program BI921.ocl36.txt
and performs its task independently, relying on file inputs and printer output.
Summary¶
- Process Steps: The program processes sorted tax data from
BIPRTX
, retrieves company names fromBICONT
and product descriptions fromGSPROD
, and generates a report onPRINT
. It groups output by company (L2
), prints headers with company, date, time, and page information, and details each record with state, product code, description, delivered code, and up to 10 tax codes. Special handling applies for 'MISC' products. - Business Rules:
- Groups records by company with headers on changes.
- Retrieves company names from
BICONT
, defaulting to blank if not found. - Retrieves product descriptions from
GSPROD
, using "MISCELLANEOUS INVOICE LINES" for 'MISC' codes if not found. - Supports 10 tax codes per product (expanded per
LT01
). - Formats report with separators and column headers.
- Tables/Files Used:
BIPRTX
: Sorted tax data.BICONT
: Company names.GSPROD
: Product descriptions.GSTABL
: Commented out, previously used for product data.PRINT
: Report output.MSG
: Message array for 'MISC' products.- External Programs Called: None.
Notes¶
- Modifications:
LT01
(07/82/2011): Expanded tax codes from 5 to 10 (PTTXC6
toPTTXC0
).JK01
(01/31/23): ReplacedGSTABL
withGSPROD
for product data, updating file access and fields.- Context with OCL: The OCL program
BI921.ocl36.txt
sortsBIPRTX
into?9?BI921
, which this program reads asBIPRTX
. It also usesBICONT
,GSTABL
(if uncommented), andGSPROD
as specified in the OCL. - Limitations: The program assumes
BIPRTX
is pre-sorted (by#GSORT
in the OCL) and does not explicitly filter deleted records (PTDEL='D'
), though this may be handled by the sort or prior validation inBI921P
.
If you need further analysis (e.g., sample data, report format visualization, or integration with BI921P
), or if you want me to search for related information, let me know!