FR711P RPGLE
The RPG program FR711P is a prompt program for the Freight Out Reconciliation Report, designed to collect and validate user input before calling a print program. Below is an explanation of the process steps, external programs called, and tables used, based on the provided source code.
Process Steps of the RPG Program (FR711P)¶
The program follows a structured process to prompt the user for input, validate it, and call a print program (FR711PC) to generate the report. Here's a breakdown of the steps:
- Initialization (
*inzsrSubroutine): - Purpose: Sets up initial variables and environment.
-
Actions:
- Receives an input parameter
p$fgrp(file group: 'G' or 'Z') to determine which database files to override. - Sets the
fmtagnflag to*ONto enable the main processing loop for the display file. - Loads the header text (
c$hdr1) from thehdrarray for the display file. - Captures the current date and time into
t#timeand converts it into a date format (t#cymd) for use in the report. - Defines a key list (
key1) for database access, using fieldswkco(company) andc1loc(location).
- Receives an input parameter
-
Open Database Tables (
opntblSubroutine): - Purpose: Opens the necessary database files with appropriate overrides.
-
Actions:
- Checks the
p$fgrpparameter to determine whether to apply overrides for 'G' (general) or 'Z' (alternate) files. - Executes
QCMDEXCto apply overrides forglcontandinlocfiles: - For 'G': Overrides
glconttogglcontandinloctoginloc. - For 'Z': Overrides
glconttozglcontandinloctozinloc. - Opens the
glcontandinlocfiles for reading.
- Checks the
-
Process Display File (
srfmtSubroutine): - Purpose: Displays the prompt screen and processes user input.
-
Actions:
- Enters a loop (
fmtagn = *ON) to repeatedly display theFMT01format of the display file (fr711pd) usingEXFMT. - Clears error indicators (50-69) to reset validation states.
- Checks for function key presses:
- F3 (Exit): Sets
fmtagnto*OFFto exit the loop and terminate the program. - F4 (Field Prompting): Calls the
promptsubroutine to assist with field input (though the subroutine is empty in the provided code). - Validates input fields by calling the
f01edtsubroutine. - If validation passes (
*in50 = *OFF), calls thecallpgmsubroutine to invoke the print program and exits the loop. - If validation fails, redisplays the screen with error messages.
- Enters a loop (
-
Validate Input Fields (
f01edtSubroutine): - Purpose: Validates user-entered data on the prompt screen.
-
Actions:
- Company (
c1co): - Chains to the
glcontfile to verify the company code. - If invalid or blank (
*in99 = *ONorc1co = *zeros), sets error indicator*in50and*in51and displays error messagecom(01)("Invalid Company Entered"). - If valid, retrieves the company name (
gcname) intof$cnam. - Report Date Month (
c1mm): - Checks if the month is between 1 and 12.
- If invalid (
c1mm < 1orc1mm > 12), sets*in50and*in52and displays error messagecom(02)("Invalid Month Entered"). - Report Date Year (
c1yy): - Checks if the year is non-zero.
- If invalid (
c1yy = 0), sets*in50and*in53and displays error messagecom(03)("Invalid Year Entered"). - Location (
c1loc): - If non-blank, chains to the
inlocfile usingkey1(company and location). - If invalid (
*in99 = *ON), sets*in50and*in54and displays error messagecom(04)("Invalid Loc Entered"). - Sort Option (
c1sort): - Validates that the sort code is either 'C' or 'L'.
- If invalid, sets
*in50and*in56and displays error messagecom(05)("Invalid Sort Entered, Valid Codes: C/L"). - Month Selection (
c1selmo) (added in revisionsjb01andjb02): - Validates that the month selection is one of 'M', 'O', 'C', 'A', or blank.
- If invalid, sets
*in50and*in56and displays error messagecom(06)("Invalid Selected Month, Valid Codes: M/O/C/A/' '"). - If any validation fails,
*in50is set to*ON, causing the screen to redisplay with error messages.
- Company (
-
Call Print Program (
callpgmSubroutine): - Purpose: Prepares parameters and calls the print program.
-
Actions:
- Sets the report date (
w$rdat) by determining the century (w$cen): - If
c1yy >= 40, sets century to 19 (e.g., 1940–1999). - Otherwise, sets century to 20 (e.g., 2000–2039).
- Moves input fields (
c1co,w$rdat,c1loc,c1caid,c1sort,c1selmo) to output parameters (o$co,o$rdat,o$loc,o$caid,o$sort,o$selmo). - Calls the external program
FR711PC, passing the following parameters: o$co(Company, 2 characters)o$rdat(Report Date, 8 digits)o$loc(Location, 3 characters)o$caid(Carrier ID, 6 characters)o$sort(Sort option, 1 character)o$selmo(Month selection, 1 character)o$fgrp(File group, 1 character, passed from inputp$fgrp)- Sets the report date day to 31 (
w$day), assuming the last day of the month for the report.
- Sets the report date (
-
Program Termination:
- Closes all open files (
close *all). - Sets
*inlr = *ONto indicate the program is ending. - Returns control to the caller.
External Programs Called¶
- FR711PC: The print program called by the
callpgmsubroutine to generate the Freight Out Reconciliation Report based on the validated input parameters. - QCMDEXC: A system program used to execute override commands for the
glcontandinlocfiles in theopntblsubroutine.
Tables Used¶
- Display File:
-
fr711pd: The display file used for the user interface, with formatFMT01for prompting and displaying errors. -
Database Files:
glcont: Input-only file for company data, overridden to eithergglcontorzglcontbased on thep$fgrpparameter.inloc: Input-only file for location data, overridden to eitherginlocorzinlocbased on thep$fgrpparameter.
Additional Notes¶
- Month Selection Options (from revisions
jb01andjb02): M: Selected month only, including all (open and closed) records.O: Selected month, open records only.C: Selected month, closed records only.A: All open records from previous and selected months.-
Blank: Previous month open records and selected month all records.
-
Indicator Usage: The program uses indicators (19, 21–69, 70–99) for screen control, error handling, and database operations, as detailed in the header comments.
-
Field Prefixes:
f$: Display file fields (input/output).k$: Key list fields.s$: Selected subfile values.p$: Input parameters.o$: Output parameters.-
w$: Work fields. -
Compile Notes: The program is compiled using PDM options
c1orc2, indicating specific compilation configurations.
This program serves as a front-end interface for collecting and validating user input, ensuring data integrity before passing it to the report generation program (FR711PC).