FR710P RPGLE
The RPG program FR710P is a prompt program for the Freight Out Accrual Report, designed to collect user input (company number and date) and validate it before calling a print program. Below is a detailed explanation of the process steps, followed by the external programs called and the tables used.
Process Steps of the FR710P Program¶
- Program Initialization (
*inzsrSubroutine): - Purpose: Initializes the program environment and sets up initial values.
-
Steps:
- Receives an input parameter
p$fgrp(file group, either 'G' or 'Z') to determine which file override to apply. - Sets the
fmtagnflag to*onto control the main processing loop for the display file. - Loads the header text for the display panel (
c$hdr1) from thehdrarray. - Captures the current system date and time using the
timeoperation and populates thet#cymdfield with the current date in century-year-month-day format (CCYYMMDD). - Clears the
w$rdatwork field for the report date.
- Receives an input parameter
-
Open Database Tables (
opntblSubroutine): - Purpose: Opens the necessary database files with appropriate overrides based on the file group parameter.
-
Steps:
- Checks the
p$fgrpparameter to determine if it is 'G' or 'Z'. - If
p$fgrpis 'G', applies the override command from theovgarray (e.g.,ovrdbf file(glcont) tofile(*libl/gglcont) share(*no)). - If
p$fgrpis 'Z', applies the override command from theovzarray (e.g.,ovrdbf file(glcont) tofile(*libl/zglcont) share(*no)). - Executes the override command using the
QCMDEXCsystem API, passing the override string and its length. - Opens the
glcontfile for use in the program.
- Checks the
-
Process Display File (
srfmtSubroutine): - Purpose: Manages the user interface by displaying a prompt screen (
FMT01) and handling user input. -
Steps:
- Enters a loop controlled by the
fmtagnflag, which continues until the user exits or input is valid. - Displays the
FMT01format (likely a prompt screen for company number and date) using theexfmtoperation. - Clears error indicators (
*in50to*in69) to reset any previous error states. - Processes function keys pressed by the user:
- F3 (Exit): Sets
fmtagnto*offto exit the loop and terminate the program. - F4 (Prompt): Calls the
promptsubroutine to assist with field input (though the subroutine is currently empty). - If no exit or prompt key is pressed, calls the
f01edtsubroutine to validate input fields. - If validation passes (
*in50is*off), calls thecallpgmsubroutine to proceed with report generation and exits the loop. - If validation fails, the loop continues, redisplaying the screen with error messages.
- Enters a loop controlled by the
-
Field Validation (
f01edtSubroutine): - Purpose: Validates user-entered data (company number, month, and year) on the prompt screen.
-
Steps:
- Company Number Validation:
- Clears the company name field (
f$cnam). - Chains to the
glcontfile using the user-entered company number (c1co). - If the company number is invalid (
*in99is*on) or zero, sets error indicator*in50and*in51to*onand displays an error message fromcom(01)("Invalid Company Entered"). - If valid, retrieves the company name (
gcname) from theglcontfile and stores it inf$cnam. - Report Date Month Validation:
- If no prior errors (
*in50is*off), checks if the entered month (c1mm) is between 1 and 12. - If invalid, sets
*in50and*in52to*onand displays an error message fromcom(02)("Invalid Month Entered"). - Report Date Year Validation:
- If no prior errors, checks if the entered year (
c1yy) is non-zero. - If zero, sets
*in50and*in53to*onand displays an error message fromcom(03)("Invalid Year Entered").
-
Call Print Program (
callpgmSubroutine): - Purpose: Prepares parameters and calls the external print program to generate the report.
-
Steps:
- Sets the day portion of the report date (
w$day) to 31, assuming the report uses the last day of the month. - Determines the century for the report date (
w$cen): - If the year (
c1yy) is 40 or greater, sets the century to 19 (e.g., 1940). - Otherwise, sets the century to 20 (e.g., 2040).
- Moves the constructed report date (
w$rdat) and company number (c1co) to output parameterso$rdatando$co. - Calls the external program
FR710PC, passing: o$co(company number, 2 characters).o$rdat(report date, 8 digits inCCYYMMDDformat).o$fgrp(file group, 1 character, copied fromp$fgrp).- The called program (
FR710PC) presumably generates the Freight Out Accrual Report.
- Sets the day portion of the report date (
-
Program Termination:
- Closes all open files using
close *all. - Sets the last record indicator (
*inlr) to*onto signal program completion. - Returns control to the caller.
External Programs Called¶
- FR710PC: The print program called to generate the Freight Out Accrual Report, receiving parameters for company number, report date, and file group.
- QCMDEXC: A system API called to execute the file override command for the
glcontfile.
Tables Used¶
- glcont: A database file used to validate the company number (
c1co) and retrieve the company name (gcname). The file is opened with an override to eithergglcontorzglcontbased on thep$fgrpparameter ('G' or 'Z'). - ffr710pd: The display file (workstation file) used to present the prompt screen (
FMT01) to the user for input and error messages.
Additional Notes¶
- File Overrides: The program dynamically applies overrides to the
glcontfile to point to eithergglcontorzglcontbased on thep$fgrpparameter, allowing flexibility in accessing different data sets. - Error Handling: Uses indicators (
*in50to*in53) to flag validation errors and display corresponding messages from thecomarray. - Date Handling: Constructs the report date assuming the last day of the month (day = 31) and determines the century based on the year input.
- Prompt Subroutine: The
promptsubroutine is currently empty, suggesting it may be a placeholder for future field prompting functionality (e.g., a lookup or selection list triggered by F4).
This program serves as an interactive front-end to collect and validate user input before triggering the report generation process in FR710PC.