FR710B RPG
The RPG program FR710B is responsible for printing the Freight Out Accrual Report using data from the FR710W work file, which was populated by FR710A. Called by FR710C, it generates a detailed report with totals at the freight general ledger (GL) and company levels, and supports two output formats: a standard report (LIST164) and an Excel-compatible format (LIST378) added in revision MG01. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.
Process Steps of the FR710B Program¶
- Program Initialization (
*INZSRSubroutine): - Purpose: Initializes the program environment and sets up variables.
-
Steps:
- Receives three input parameters:
P$CO: Company number (2 characters).P$RDAT: Report date (8 digits,CCYYMMDDformat).P$FGRP: File group ('G' or 'Z') for file overrides.- Moves
P$RDATtoD$RDATfor use in report headers. - Defines a key list (
KEY) for accessingGLMASTusingW1CO(company),W$ACCT(account), andW$SUB(sub-account) from theW1FRGLfield. - Initializes arrays
STR('* ') andHYP('- ') for formatting report lines. - Sets
PRTOVRto*ONto trigger header printing on the first page. - Sets
PRTHDRto*OFFto control report header printing. - Calls the
OPNTBLsubroutine to open files.
-
Open Database Tables (
OPNTBLSubroutine): - Purpose: Opens input files with appropriate overrides based on the file group.
-
Steps:
- Checks the
P$FGRPparameter ('G' or 'Z'). - For 'G', applies overrides from the
OVGarray to point toGGLMASTandGGLCONT. - For 'Z', applies overrides from the
OVZarray to point toZGLMASTandZGLCONT. - Executes overrides using the
QCMDEXCsystem API, passing the override command and length (80). - Opens the
GLMASTandGLCONTfiles.
- Checks the
-
Main Processing Loop:
- Purpose: Processes records from the
FR710Wfile, which is defined with level breaks (L1for freight GL,L2for company). -
Steps:
- Company Level Break (
*INL2): - If a company-level break occurs (
*INL2is*ON), initializes company-level totals (L2BFRT,L2EFRT,L2AFRT,L2DIFF) to zero. - Sets
PRTOVRto*ONto print headers. - Chains to
GLCONTusingW1COto retrieve the company name (GCNAME) intoR$CNAM. If not found (*IN99is*ON), clearsR$CNAM. - Freight GL Level Break (
*INL1): - If a freight GL-level break occurs (
*INL1is*ON), initializes GL-level totals (L1BFRT,L1EFRT,L1AFRT,L1DIFF) to zero. - Chains to
GLMASTusing theKEYkey list to retrieve the GL description (GLDESC) intoR$DESC. If not found (*IN99is*ON), clearsR$DESC. - Calls the
DTLsubroutine to process detail records. - At the freight GL level break (
L1), callsL1TOTLto print GL totals. - At the company level break (
L2), callsL2TOTLto print company totals. - Note: The
LRTOTLsubroutine for final totals is commented out, suggesting it may not be used in the current implementation.
- Company Level Break (
-
Process Detail Records (
DTLSubroutine): - Purpose: Processes each record from
FR710Wand prints detail lines. -
Steps:
- Accumulates detail amounts into GL-level totals:
W1BFRT(billed freight) toL1BFRT.W1EFRT(expected carrier) toL1EFRT.W1AFRT(actual carrier) toL1AFRT.W1DIFF(difference) toL1DIFF.- Tracks positive and negative differences:
- If
W1DIFF> 0, adds toL2POST(carrier charges greater). - If
W1DIFF≤ 0, adds toL2NEGT(carrier charges less). - Converts the ship date (
W1SDAT) toW$SDATand adjusts it by multiplying by 100.0001 (likely for formatting or sorting purposes). - Calls
OVRFLOto handle page overflow. - Writes a detail line to the report using the
DETLexception output.
-
Print Freight GL Totals (
L1TOTLSubroutine): - Purpose: Prints totals for each freight GL group.
-
Steps:
- Calls
OVRFLOto handle page overflow. - Writes the GL total line (
TOTL1) withW1FRGL,R$DESC,L1BFRT,L1EFRT,L1AFRT, andL1DIFF. - Turns off indicator
*IN82(likely used for formatting). - Accumulates GL totals into company totals (
L2BFRT,L2EFRT,L2AFRT,L2DIFF).
- Calls
-
Print Company Totals (
L2TOTLSubroutine): - Purpose: Prints totals for each company group.
-
Steps:
- Calls
OVRFLOto handle page overflow. - Writes the company total line (
TOTL2) withL2BFRT,L2EFRT,L2AFRT,L2DIFF,L2POST, andL2NEGT. - Accumulates company totals into report-level totals (
LRBFRT,LREFRT,LRAFRT,LRDIFF).
- Calls
-
Handle Page Overflow (
OVRFLOSubroutine): - Purpose: Manages page breaks and prints report headers when needed.
-
Steps:
- If overflow indicator
*INOFis*ON, setsPRTOVRand*IN82to*ON. - If
PRTOVRis*ON, writes the report header (HDR01) and resetsPRTOVRto*OFF.
- If overflow indicator
-
Program Termination:
- Purpose: Completes processing and closes files.
- Steps:
- The program implicitly closes files at the end (via
*INLRin the RPG cycle, though not explicitly shown). - Returns control to the caller (
FR710C).
- The program implicitly closes files at the end (via
Business Rules¶
- Report Structure:
- The report is organized by company (
W1CO, levelL2) and freight GL (W1FRGL, levelL1), with detail lines for each record inFR710W. - Detail lines include company, freight GL, routing, ship date, customer number, customer name, order number, serial number, invoice number, type, quantity, unit of measure, billed freight (
W1BFRT), expected carrier (W1EFRT), actual carrier (W1AFRT), difference (W1DIFF), close status, and sequence number. - Totals are printed at the freight GL level (
TOTL1) and company level (TOTL2), including billed, expected, and actual freight amounts, and differences. - Company totals include a breakdown of positive (
L2POST) and negative (L2NEGT) differences to highlight carrier charge discrepancies. - Output Formats:
LIST164: Standard report format with a width of 164 characters, designed for traditional printing.LIST378: Wider format (378 characters) added for Excel creation (revisionMG01), with adjusted column positions for better spreadsheet compatibility.- File Overrides:
- Uses
P$FGRPto select between 'G' (production:GGLMAST,GGLCONT) and 'Z' (development:ZGLMAST,ZGLCONT) file sets. - Data Enrichment:
- Retrieves company name (
GCNAME) fromGLCONTand GL description (GLDESC) fromGLMASTto enhance report readability. - If lookups fail (
*IN99), fields are cleared to avoid errors. - Page Management:
- Headers are printed on page overflow or when triggered by
PRTOVR, including company, report title, page number, job details, date, time, and selected report date. - Date Formatting:
- The report date (
D$RDAT) is split intoD$MM(month) andD$CCYY(year) for header display. - Ship date (
W1SDAT) is adjusted for formatting purposes.
Tables Used¶
- Input Files:
FR710W: Primary input file (record formatFR710WPF) containing freight accrual data fromFR710A. Processed with level breaks onW1CO(L2) andW1FRGL(L1).GLMAST: General ledger master file, used to retrieve the freight GL description (GLDESC) forW1FRGL.GLCONT: Company master file, used to retrieve the company name (GCNAME) forW1CO.- Output Files:
LIST164: Printer file for the standard report (164 characters wide).LIST378: Printer file for the Excel-compatible report (378 characters wide, revisionMG01).- File Overrides:
- For
P$FGRP= 'G':GGLMAST,GGLCONT. - For
P$FGRP= 'Z':ZGLMAST,ZGLCONT.
External Programs Called¶
- QCMDEXC: System API used to execute file override commands for
GLMASTandGLCONT.
Additional Notes¶
- Revision MG01 (11/27/2017):
- Added the
LIST378printer file to support Excel output, with wider column spacing to accommodate spreadsheet formatting. - Error Handling:
- Uses indicator
*IN99to handle failed lookups inGLMASTandGLCONT, clearing output fields to prevent errors. - Lacks explicit error handling for file I/O or printing issues.
- Commented Code:
- The
LRTOTLsubroutine is commented out, suggesting that report-level totals are not currently printed, possibly due to requirements changes. - Purpose:
- The program formats and prints the Freight Out Accrual Report, providing a detailed breakdown of freight charges and discrepancies, with totals to aid financial analysis.
This program completes the report generation process by producing a formatted output from the FR710W work file, supporting both traditional and Excel-compatible formats for flexibility in reporting.