FR713B RPGLE
The FR713B program is an RPGLE program called by FR713C to print the Freight Out Reconciliation Report sorted by location. It reads data from the work file FR713W, retrieves additional information from reference files, and generates a printed report with headers, detail lines, and totals. It also supports an additional output for Excel creation (per revision mg01). Below, I’ll explain the process steps, business rules, database tables used, and external programs called, based on the provided RPGLE source code (noting that the code is truncated, limiting visibility into some subroutines).
Process Steps of the FR713B Program¶
The FR713B program processes the work file FR713W, organizes data hierarchically by company, location, state, city, and routing code, and produces a formatted report with totals at various levels. Here’s a detailed breakdown of the process steps based on the available code:
- Program Initialization (
*inzsrSubroutine, partially truncated): - Purpose: Sets up initial conditions and processes input parameters.
-
Actions (inferred from context and file definitions):
- Receives nine input parameters (as passed from
FR713C): p$co(2): Company code.p$fdat(8): From date (inCYMDformat).p$tdat(8): To date (inCYMDformat).p$loc(3): Location code.p$caid(6): Carrier ID.p$sort(1): Sort option ('L' for location, as this program is called byFR713C).p$cust(6): Customer code.p$car$(1): Flag to include zero-dollar freight records ('Y' or 'N').p$fgrp(1): File group ('G' or 'Z').- Moves input parameters to work fields (e.g.,
p$fdattow$fmdy,p$tdattow$tmdyfor display, likely inMMDDYYformat after conversion). - Initializes data structures for date conversion (
d#), freight GL account (w1frgl,w$acct,w$sub), routing code (w1rtg1,dsrtg1), and customer name (w1name,w$name). - Opens input files
FR713W,INLOC,GLCONT, and output filesFR714W2,LIST164, andLIST378(permg01for Excel output).
- Receives nine input parameters (as passed from
-
Open Database Tables:
- Purpose: Applies file overrides and opens necessary files.
-
Actions (inferred from file definitions and
OVG/OVZarrays):- Applies overrides for
INLOCandGLCONTbased onp$fgrp: - For
p$fgrp = 'G': Overrides toGINLOCandGGLCONT. - For
p$fgrp = 'Z': Overrides toZINLOCandZGLCONT. - Executes overrides using
QCMDEXC(likely in a subroutine likeopntbl, not shown due to truncation). - Opens
INLOCandGLCONTfor reading,FR713Was the primary input file,FR714W2for output, andLIST164/LIST378as printer files.
- Applies overrides for
-
Process Work File (
FR713W): - Purpose: Reads records from
FR713Wand organizes them hierarchically for reporting. -
Actions:
- Uses level-break indicators (
L1toL7) defined in the input specification (IFR713WPF): L7: Company (W1CO).L6: Location (W1LOC).L5: State (W1SST).L4: City (W1SCIT).L3: Routing code (W1RTG1).L2: Customer (W1CUST).L1: Order number (W1RDNO) and sequence number (W1SRN).- For each record read:
- Company Break (
*INL7 = *ON):- Sets
PRTOVRto*ONto indicate a new company section. - Clears company-level totals (
L7BFRT,L7EFRT,L7AFRT,L7DIFF,L7POST,L7NEGT). - Chains to
GLCONTusingW1COto retrieve the company name (GCNAME) intoR$CNAM. If not found (*IN99 = *ON), clearsR$CNAM.
- Sets
- Location Break (
*INL6 = *ON):- Sets
PRTOVRto*ON. - Clears location-level totals (
L6BFRT,L6EFRT,L6AFRT,L6DIFF,L6POST,L6NEGT). - Chains to
INLOCusingKEY(likely a key list withW1COandW1LOC) to retrieve the location name (ILNAME) intoR$ILNM. If not found, clearsR$ILNM.
- Sets
- State Break (
*INL5 = *ON):- Clears state-level totals (
L5BFRT,L5EFRT,L5AFRT,L5DIFF,L5POST,L5NEGT). - (Commented
PRTOVRsuggests it may not trigger a new section, possibly intentional for formatting.)
- Clears state-level totals (
- City Break (
*INL4 = *ON):- Calls the
OVRFLOsubroutine to handle page overflow (not shown due to truncation). - Prints a city-level detail line (
EXCEPT L4DTL). - Clears city-level totals (
L4BFRT,L4EFRT,L4AFRT,L4DIFF,L4POST,L4NEGT).
- Calls the
- Routing Code Break (
*INL3 = *ON):- Clears routing-level totals (
L3BFRT,L3EFRT,L3AFRT,L3DIFF,L3POST,L3NEGT). - (Further processing likely in truncated code.)
- Clears routing-level totals (
- Accumulates totals for booked freight (
W1BFRT), estimated freight (W1EFRT), actual/customer freight (W1AFRT), and differences (W1DIFF) at each level.
- Uses level-break indicators (
-
Print Report:
- Purpose: Generates the printed report using the
LIST164printer file (andLIST378for Excel permg01). -
Actions:
- Headers (
HDR01): - Prints company information (
W1CO,R$CNAM), report title ("FREIGHT OUT RECONCILIATION REPORT"), and page number (PAGE). - Includes job details (
PS#JOB,PS#PGM,PS#USR), location (W1LOC,R$ILNM), and date/time (PS#MDY,PS#HMS). - Displays selection criteria: location (
P$LOC), carrier (P$CAID), customer (P$CUST), zero-dollar flag (P$CAR$), and date range (W$FMDYtoW$TMDY). - Prints column headers for routing, product, destination, state, shipment date, customer, order number, sequence number, invoice, customer number, ship-to, type, quantity, unit of measure, freight code, billed freight, expected carrier, actual carrier, difference, and close status.
- Detail Lines (
DETL): - Prints fields from
FR713W: routing (DSRTG1), product (W1PROD), city (W1SCIT), state (W1SST), shipment date (W$SDAT), customer name (W$NAME), order number (W1RDNO), sequence number (W1SRN), invoice number (W1INVN), customer number (W1CUST), ship-to (W1SHIP), order type (W1TYPE), quantity (W1QTY), unit of measure (W1UM), freight code (W1FRCD), billed freight (W1BFRT), estimated freight (W1EFRT), actual freight (W1AFRT), difference (W1DIFF), and close status (W1CLOS). - Totals:
- Location Totals (
TOTL6): Prints location (W1LOC), totals for booked (L6BFRT), estimated (L6EFRT), actual (L6AFRT), and difference (L6DIFF), plus positive (L6POST) and negative (L6NEGT) carrier charges. - Company Totals (
TOTL7): Prints company totals for booked (L7BFRT), estimated (L7EFRT), actual (L7AFRT), difference (L7DIFF), positive (L7POST), and negative (L7NEGT) carrier charges. - Excel Output (
LIST378): - Added per
mg01(11/27/2017) to support Excel creation, likely with a wider format (378 characters vs. 164 forLIST164). - Specific formatting or output logic is not visible due to truncation.
- Headers (
-
Write to Secondary Work File (
FR714W2): - Purpose: Outputs data to
FR714W2, possibly for further processing or Excel export. -
Actions (inferred):
- Writes records to
FR714W2(not shown in the output specifications but defined as an output file). - Likely mirrors the detail or total data for compatibility with external tools.
- Writes records to
-
Program Termination (inferred):
- Purpose: Cleans up and exits.
- Actions:
- Closes all open files (
FR713W,INLOC,GLCONT,FR714W2,LIST164,LIST378). - Sets
*INLRto*ONand returns control toFR713C.
- Closes all open files (
Business Rules¶
The FR713B program enforces the following business rules:
1. Hierarchical Reporting:
- Organizes data by company (L7), location (L6), state (L5), city (L4), routing code (L3), customer (L2), and order/sequence (L1), using level-break logic to print subtotals and reset accumulators.
2. Reference Data Retrieval:
- Retrieves company name (GCNAME) from GLCONT and location name (ILNAME) from INLOC to enrich the report, defaulting to blank if not found.
3. Totals Calculation:
- Accumulates booked, estimated, and actual freight amounts, and differences at location (L6) and company (L7) levels.
- Tracks positive (L6POST, L7POST) and negative (L6NEGT, L7NEGT) carrier charge differences for reporting.
4. Selection Criteria Display:
- Includes user-selected parameters (location, carrier, customer, date range, zero-dollar flag) in the report header for clarity.
5. Excel Output:
- Supports a separate printer file (LIST378) for Excel-compatible output (per mg01), likely with a wider format to accommodate spreadsheet columns.
6. Page Overflow Handling:
- Uses the OVRFLO subroutine (not shown) to manage page breaks, triggered at the city level (L4DTL).
7. No Input Validation:
- Relies on FR713P for input validation, assuming all data in FR713W is correct.
Database Tables Used¶
The FR713B program directly accesses the following files:
1. FR713W (Freight Work File, Input, Primary):
- Primary input file containing processed freight data from FR713A.
- Keyed by company (W1CO), location (W1LOC), state (W1SST), city (W1SCIT), routing code (W1RTG1), customer (W1CUST), order number (W1RDNO), and sequence number (W1SRN).
- Fields used: W1CO, W1LOC, W1SST, W1SCIT, W1RTG1, W1CUST, W1RDNO, W1SRN, W1INVN, W1SHIP, W1TYPE, W1QTY, W1UM, W1FRCD, W1BFRT, W1EFRT, W1AFRT, W1DIFF, W1CLOS, W1PROD.
2. INLOC (Inventory Location, Input):
- Used to retrieve location name (ILNAME) for W1LOC.
- Keyed by company and location (via KEY, not shown but inferred).
- Overrides: GINLOC (for p$fgrp = 'G') or ZINLOC (for p$fgrp = 'Z').
3. GLCONT (General Ledger Control, Input):
- Used to retrieve company name (GCNAME) for W1CO.
- Keyed by company (W1CO).
- Overrides: GGLCONT (for p$fgrp = 'G') or ZGLCONT (for p$fgrp = 'Z').
4. FR714W2 (Secondary Work File, Output):
- Used to write data, possibly for Excel export or further processing.
- Specific fields written are not visible due to truncation.
5. LIST164 (Printer File, Output):
- Primary printer file (164 characters wide) for the standard report.
- Outputs headers (HDR01), detail lines (DETL), and totals (TOTL6, TOTL7).
6. LIST378 (Printer File, Output):
- Added per mg01 for Excel-compatible output (378 characters wide).
- Specific output format is not visible due to truncation.
External Programs Called¶
The FR713B program likely calls the following external program (inferred from context):
1. QCMDEXC:
- System API used to execute file override commands (OVRDBF) for INLOC and GLCONT in the opntbl subroutine (not shown due to truncation).
- Parameters: dbov## (override command string, 80 characters) and dbol## (command length, 15.5).
Additional Notes¶
- Revisions:
- mg01 (11/27/2017): Added
LIST378printer file for Excel-compatible output, expanding the report’s utility. - Truncated Code:
- The code is truncated (18,656 characters missing), omitting key subroutines like
OVRFLO, the main processing loop, and parts of the output logic forFR714W2andLIST378. However, the provided output specifications and level-break logic provide insight into the report structure. - Data Structures:
- Uses a date conversion data structure (
d#) to format dates (W$FMDY,W$TMDY,W$SDAT) inMMDDYYformat. - Uses data structures to split
W1FRGL(freight GL account) into account (W$ACCT) and subaccount (W$SUB), and to trimW1RTG1(routing code) andW1NAME(customer name) for display. - Printer Files:
LIST164is the standard report output (164 characters wide).LIST378supports a wider format for Excel, suggesting a more detailed or column-rich output.- Integration:
- Fits into the chain (
FR713P→FR713PC→FR713C→FR713A→FR713B) to produce the location-sorted report. - Location Code Length:
- The
p$locparameter is defined as LEN(3), consistent withFR713C, but differs fromFR714CandFR715C(LEN(2)), suggesting a potential system-specific discrepancy.
Summary¶
The FR713B program reads the FR713W work file, retrieves company and location names from GLCONT and INLOC, and generates a Freight Out Reconciliation Report sorted by location using LIST164 (and LIST378 for Excel). It organizes data hierarchically, prints headers with selection criteria, detail lines, and totals at location and company levels, and writes to FR714W2 for additional processing. The program enforces rules for hierarchical reporting, totals calculation, and reference data retrieval, relying on FR713P for input validation. It uses five files and likely calls QCMDEXC for file overrides.