AP300P RPG
The provided RPG program, AP300P.rpg36.txt
, is an RPG II program designed for the IBM System/36 environment, used in conjunction with the previously analyzed OCL script (AP300P.ocl36.txt
). This program handles the prompting and validation for an Accounts Payable (A/P) monthly or yearly update process, specifically for updating Month-to-Date (MTD) and Year-to-Date (YTD) fields in the vendor master file. Below, I’ll explain the process steps, business rules, tables used, and external programs called, ensuring a clear and concise analysis tailored to the System/36 context.
Process Steps of the RPG Program¶
The RPG program AP300P
is a prompting program that displays a screen to collect user input for the A/P update process, validates the input, and sets parameters for the update. Here’s a step-by-step breakdown of the process:
- File and Data Structure Definitions:
- Files:
SCREEN
: A workstation file (display file) with 512-byte records, used to interact with the user via a screen format (AP300PS1
).APCONT
: A disk file (vendor master file) with 256-byte records, indexed (2AI
) with two keys, used for validation and data retrieval.
- Arrays and Data Structures:
MSG
: An array of 8 elements, each 40 characters, holding error messages (defined at the end of the program).CO
: An array of 10 elements, each 35 characters, used to store company numbers and names for display.UDS
: User Data Structure (Local Data Area) for passing parameters, with fields likeKYALCO
,KYCO1
,KYCO2
,KYCO3
,KYJOBQ
,KYCANC
,KYYTDY
, andKYCCYY
.
-
Indicators:
- Indicators
01
,09
,10
,11
,12
,50–55
,81
,90
control program flow, screen display, and error handling. KG
is a control-level indicator for cancel operations.
- Indicators
-
Initialization (Lines 0036–0043):
- Clears the
MSG40
field (used for error messages) to blanks. - Turns off indicators
50–54
(error indicators),81
(screen display), and90
(general error). -
If the
KG
(cancel) indicator is on, setsKYCANC
toCANCEL
and skips further processing. -
One-Time Setup Subroutine (
ONETIM
, Lines 0050–0077): - Executed once when indicator
09
is on (first cycle, line 0045). - Purpose: Populates the
CO
array with company numbers and names fromAPCONT
for display on the screen. -
Steps:
- Initializes index
X
to 1. - Sets the file pointer to the first record in
APCONT
using key01
(SETLL
). - Loops through
APCONT
records (AGNONE
loop): - Reads a record (
READ APCONT
). - Skips records marked as deleted (
ACDEL = 'D'
). - Checks if the company number (
ACCO
) is not99
andX
is less than 11 (to limit to 10 companies). - If valid, formats the company number with a hyphen (
COXX
) and moves it along with the company name (ACNAME
) to theCO
array at indexX
. - Increments
X
and continues until the end of the file orX > 10
. - Sets defaults:
KYALCO = 'ALL'
: Default to process all companies.KYJOBQ = ' '
: Default to no job queue.KYYTDY = ' '
: Default to not clearing YTD.KYCCYY = 0
: Default year to zero.
- Initializes index
-
Main Screen Processing Subroutine (
S1
, Lines 0079–0153): - Executed when indicator
01
is on (line 0047), handling user input validation and screen display. - Purpose: Validates user input from the
SCREEN
file (formatAP300PS1
) and sets parameters for the update process. -
Steps:
- Validate Company Selection (Lines 0083–0099):
- Checks if
KYALCO
isCO
(specific companies) orALL
(all companies). - If neither, sets error indicators
81
,90
,50
, displays messageMSG,2
("SECOND ENTRY MUST BE 'CO' OR 'ALL'"), and jumps toENDS1
. - If
KYALCO = 'CO'
, checks ifKYCO1
,KYCO2
,KYCO3
(company numbers) are all zero; if so, sets error indicators81
,90
,51
, displaysMSG,3
("INVALID COMPANY NUMBER"), and jumps toENDS1
. - If
KYALCO = 'ALL'
and any ofKYCO1
,KYCO2
,KYCO3
are non-zero, sets error indicators81
,90
,51
, displaysMSG,4
("IF ALL, THEN DO NOT ENTER COMPANIES"), and jumps toENDS1
. - Validate Specific Companies (Lines 0103–0124):
- If
KYALCO = 'CO'
, validates each non-zero company number (KYCO1
,KYCO2
,KYCO3
) usingCHAIN
to look up the company inAPCONT
. - If a company number is invalid (not found), sets error indicators (
81
,90
, and51
,52
, or53
respectively), displaysMSG,5
("IF CO, THEN ENTER VALID COMPANIES"), and jumps toENDS1
. - Validate All Companies (Lines 0128–0136):
- If
KYALCO = 'ALL'
, sets the file pointer to the first record inAPCONT
(SETLL '01'
) and reads records to ensure valid data, but no specific validation is performed here. - Validate YTD Selection (Lines 0139–0143):
- Checks if
KYYTDY
isY
(clear YTD) or blank (do not clear). - If neither, sets error indicators
81
,90
,54
, displaysMSG,7
("YTD ENTRY MUST BE 'Y' OR ' '"), and jumps toENDS1
. - If
KYYTDY = 'Y'
, checks ifKYCCYY
(year) is non-zero; if zero, sets error indicators81
,90
,54
, displaysMSG,8
("IF CLEAR YTD=Y, THEN KEY A 4 DIGIT YEAR"), and jumps toENDS1
. - Validate Job Queue Selection (Lines 0147–0151):
- Checks if
KYJOBQ
isY
(submit to job queue),N
, or blank (run immediately). - If invalid, sets error indicators
81
,90
,55
, displaysMSG,6
("JOB QUEUE ENTRY MUST BE 'Y' OR ' '"), and jumps toENDS1
. - Screen Output (Lines 0156–0165):
- If indicator
81
is on, displays theSCREEN
file with formatAP300PS1
, showing:KYALCO
,KYCO1
,KYCO2
,KYCO3
(company selection fields).CO
array (company numbers and names).KYYTDY
(YTD clear flag).KYCCYY
(year for YTD clear).KYJOBQ
(job queue flag).MSG40
(error message).
-
Program Flow:
- The program loops through the
S1
subroutine until all validations pass or the user cancels (KYCANC = 'CANCEL'
). - If validations fail, error messages are displayed, and the screen is redisplayed for user correction.
- If validations pass, the program sets the Local Data Area fields (
KYALCO
,KYCO1
, etc.) and returns control to the OCL script, which uses these to execute the update (viaAP300
or job queue).
Business Rules¶
The program enforces the following business rules for the A/P update process:
- Company Selection:
- Users must select either
ALL
companies or specific companies (CO
). - If
ALL
is selected, no specific company numbers (KYCO1
,KYCO2
,KYCO3
) should be entered. - If
CO
is selected, at least one valid company number must be entered, and each must exist in theAPCONT
file. -
Invalid company selections trigger error messages (
MSG,2
,MSG,3
,MSG,4
,MSG,5
). -
YTD Processing:
- Users can choose to clear YTD fields (
KYYTDY = 'Y'
) or not (KYYTDY = ' '
). - If YTD is to be cleared, a valid 4-digit year (
KYCCYY
) must be provided (non-zero). - Invalid YTD selections trigger error messages (
MSG,7
,MSG,8
). -
Note: Clearing YTD is noted to involve saving the vendor file for 1099 processing, indicating a tax-related requirement.
-
Job Queue Option:
- Users can choose to submit the update job to a queue (
KYJOBQ = 'Y'
) or run it immediately (KYJOBQ = ' '
orN
). -
Invalid job queue entries trigger error message
MSG,6
. -
Cancel Option:
-
The program allows cancellation by setting
KYCANC
toCANCEL
, which is checked in the OCL script to terminate processing. -
Data Validation:
- Only non-deleted records (
ACDEL ≠ 'D'
) and company numbers not equal to99
are considered valid for display in theCO
array. -
Up to 10 companies are displayed on the screen for selection.
-
Error Handling:
- The program uses indicators (
50–55
,81
,90
) to flag errors and display appropriate messages from theMSG
array. - Errors prevent further processing until corrected, ensuring data integrity.
Tables (Files) Used¶
The program uses the following files:
- SCREEN:
- Type: Workstation file (display file).
- Purpose: Displays the
AP300PS1
screen format for user input and output, including company selection, YTD options, job queue choice, and error messages. -
Fields:
KYALCO
,KYCO1
,KYCO2
,KYCO3
,CO
(array),KYYTDY
,KYCCYY
,KYJOBQ
,MSG40
. -
APCONT:
- Type: Indexed disk file (256 bytes, 2 keys).
- Purpose: Vendor master file containing company data for validation and display.
- Fields:
ACDEL
(1 byte): Deletion flag ('D'
for deleted).ACCO
(2 bytes): Company number.ACNAME
(30 bytes): Company name.
- Operations:
SETLL
,READ
,CHAIN
for accessing records.
External Programs Called¶
The RPG program does not directly call external programs via RPG operations (e.g., CALL
). However, it interacts with the OCL script (AP300P.ocl36.txt
), which may call:
- AP300:
- Referenced in the OCL script as either a direct execution (
AP300 ,,,,,,,,?9?
) or job queue submission (JOBQ ?CLIB?,AP300
). - Likely the program that performs the actual MTD/YTD update using parameters set by
AP300P
. - The RPG program sets up the Local Data Area (
UDS
) fields (KYALCO
,KYCO1
, etc.) thatAP300
uses.
No other programs are explicitly called within the RPG code.
Summary¶
Process Overview:
- AP300P
is a prompting and validation program for the A/P monthly/yearly update process.
- It displays a screen (AP300PS1
) to collect user input for company selection (ALL
or specific companies), YTD clearing (Y
or blank), year (if YTD is cleared), and job queue option (Y
, N
, or blank).
- It validates input against the APCONT
file and business rules, displaying error messages if invalid.
- The validated parameters are stored in the Local Data Area for use by the OCL script and subsequent programs (e.g., AP300
).
- The program ensures data integrity by enforcing strict validation and providing user feedback.
Business Rules:
- Company selection must be ALL
or valid company numbers (CO
).
- YTD clearing requires a valid 4-digit year if selected.
- Job queue option must be Y
, N
, or blank.
- Errors are flagged and displayed to prevent incorrect updates.
- Cancellation is supported via the KYCANC
field.
Tables Used:
- SCREEN
: Workstation file for user interaction.
- APCONT
: Vendor master file for company data.
External Programs:
- AP300
: Likely called by the OCL script to perform the update, using parameters set by AP300P
.
This program acts as the user interface and validation layer, ensuring the A/P update process is configured correctly before execution. If you need further details (e.g., the AP300
program logic or screen format details), please provide additional context or files!