AP765P RPG36
Explanation of the Process Steps and Business Rules in the RPG Program (AP765P.rpg36.txt)¶
The provided RPG program (AP765P.rpg36.txt) is an RPG III program for the IBM System/36 or AS/400, designed to handle user input for generating 1099 vendor forms, likely called by the OCL program AP765P.ocl36.txt. It defines a screen format (AP765PS1) for capturing and validating input data required for 1099 form processing. Below is a detailed explanation of the process steps, business rules, tables used, external programs called, and outputs.
Process Steps¶
- Program Setup and File Definitions:
- Header Specification (H):
- Line
0002: Defines the program name (AP765P) and parameterP014, which may be a control parameter passed from the OCL program.
- Line
- File Specification (F):
- Line
0008: Defines a workstation fileSCREEN(512 bytes) for interactive input/output, used to display and capture data via a display device (e.g., a terminal screen).
- Line
- Extension Specification (E):
- Line
0009: Defines an arrayMSGwith 5 elements, each 35 characters long, to store error messages (loaded from the** MESSAGESsection at the end of the program).
- Line
-
Input Specifications (I):
- Lines
0010-0027: Define the screen formatAP765PS1(used for both input and output) and a data structure (UDS) to hold the following fields: HEAD1(30 chars, positions 1-30): First heading (e.g., company name).HEAD2(30 chars, positions 31-60): Second heading (e.g., address line 1).HEAD3(30 chars, positions 61-90): Third heading (e.g., address line 2).ID#(10 chars, positions 91-100): Tax ID number.ENTAMT(8,2 numeric, positions 101-108): Entered amount (likely for 1099 payments).CURLST(1 char, position 109): Current or Last indicator (CorL).TYPE(1 char, position 110): Type of 1099 form (Ifor Interest,Dfor Dividend,Mfor Miscellaneous,Nfor Non-Employee Compensation).
- Lines
-
Initialization:
- Lines
0029-0031: Reset indicators81,90,91,92,93,94,95, and96to off usingSETOF. - Line
0032: Initialize the error message fieldMSGEto blanks. -
Line
0038: Set indicator60on (likely used to control screen display or program flow). -
Handle Special Key (KG):
-
Lines
0034-0036: If theKGkey (likely a function key like F3 for exit) is pressed:- Reset indicator
81(if set). - Set indicator
U1andLR(Last Record, signaling program termination). - Jump to the
ENDtag to exit the program.
- Reset indicator
-
Check for Format 09 (NS 09):
-
Lines
0040-0041: If the program is processing format09(likely a control format or condition):- Set indicators
81and94on. - Jump to the
ENDtag to exit the program.
- Set indicators
-
Main Processing (Format 01):
-
Line
0043: If processing format01(the main screen input formatAP765PS1), execute the subroutineSUBSC1to validate input fields. -
Validation Subroutine (SUBSC1):
- Lines
0047-0077: TheSUBSC1subroutine validates the input fields from the screen:- HEAD1 Validation (Lines
0049-0052): - Check if
HEAD1is blank. - If blank, set indicators
81and91on, move messageMSG,1("FIRST HEADING CANNOT BE BLANK") toMSGE, and jump toENDSC1. - HEAD2 Validation (Lines
0054-0057): - Check if
HEAD2is blank. - If blank, set indicators
81and92on, move messageMSG,2("SECOND HEADING CANNOT BE BLANK") toMSGE, and jump toENDSC1. - ID# Validation (Lines
0059-0062): - Check if
ID#is blank. - If blank, set indicators
81and93on, move messageMSG,3("ID# CANNOT BE BLANK - TRY AGAIN!") toMSGE, and jump toENDSC1. - TYPE Validation (Lines
0064-0069): - Check if
TYPEis one of the valid values:D(Dividend),I(Interest),M(Miscellaneous), orN(Non-Employee Compensation). - If not valid, set indicators
81and95on, move messageMSG,4("ENTER I-INT, D-DIV, M-MISC, N-NEC") toMSGE, and jump toENDSC1. - CURLST Validation (Lines
0071-0075): - Check if
CURLSTis eitherC(Current) orL(Last). - If not valid, set indicators
81and96on, move messageMSG,5("ENTER 'C'-CURR OR 'L'-LAST") toMSGE, and jump toENDSC1.
- HEAD1 Validation (Lines
-
If any validation fails, the program sets the appropriate error indicators and displays an error message (
MSGE) on the screen, then exits the subroutine (ENDSC1). -
Program Termination:
- Line
0045: TheENDtag marks the program’s termination point. -
If validations pass, the program likely proceeds to write the validated data to the screen or another process (not shown in this code snippet).
-
Output Specifications:
- Lines
0079-0088: Define the output format for theSCREENfile (formatAP765PS1):- Output fields
HEAD1,HEAD2,HEAD3,ID#,ENTAMT,TYPE, andCURLSTto their respective positions (1-110). - Output the error message
MSGEat position 145. - The output is conditional on indicator
81(likely used to display errors or re-display the screen for corrections).
- Output fields
Business Rules¶
- Mandatory Fields:
HEAD1,HEAD2, andID#must not be blank. If any are blank, the program displays an error message and prevents further processing.- Valid 1099 Type:
- The
TYPEfield must be one of:I(Interest, for 1099-INT).D(Dividend, for 1099-DIV).M(Miscellaneous, for 1099-MISC).N(Non-Employee Compensation, for 1099-NEC).
- Invalid values trigger an error message.
- Current or Last Indicator:
- The
CURLSTfield must be eitherC(Current) orL(Last). Invalid values trigger an error message. - Error Handling:
- If any validation fails, the program sets indicator
81and a specific indicator (91,92,93,95, or96) to highlight the error field, displays an error message, and redisplays the screen for correction. - User Exit:
- Pressing the
KGkey (e.g., F3) allows the user to exit the program immediately, settingU1andLRindicators. - Screen Interaction:
- The program uses a workstation file (
SCREEN) to display input fields and error messages interactively, allowing the user to correct invalid inputs.
Tables Used¶
- MSG Array:
- Defined in the
Especification (Line0009). - A table of 5 elements, each 35 characters long, loaded from the
** MESSAGESsection at the end of the program:MSG,1: "FIRST HEADING CANNOT BE BLANK"MSG,2: "SECOND HEADING CANNOT BE BLANK"MSG,3: "ID# CANNOT BE BLANK - TRY AGAIN!"MSG,4: "ENTER I-INT, D-DIV, M-MISC, N-NEC"MSG,5: "ENTER 'C'-CURR OR 'L'-LAST"
-
Used to display error messages when validation fails.
-
SCREEN File:
- Defined in the
Fspecification (Line0008). - A workstation file used for interactive input/output, with format
AP765PS1for capturing and displaying data.
Note: The program does not explicitly reference any database files (e.g., GAPVEND from the OCL program). It focuses on screen input validation, suggesting that data is either passed from the OCL program or handled in subsequent programs (e.g., AP765 or AP765N).
External Programs Called¶
No external programs are explicitly called within this RPG program. However, based on the context from the OCL program (AP765P.ocl36.txt):
- The RPG program AP765P is likely one of the programs (AP765 or AP765N) called by the OCL procedure.
- The OCL program references AP765 and AP765N, which may perform further processing of the validated data (e.g., generating 1099 forms or updating files).
Outputs¶
- Screen Output (AP765PS1):
- The program outputs the following fields to the workstation screen:
HEAD1(positions 1-30): First heading.HEAD2(positions 31-60): Second heading.HEAD3(positions 61-90): Third heading.ID#(positions 91-100): Tax ID number.ENTAMT(positions 101-108): Entered amount (numeric, 8 digits with 2 decimals).TYPE(position 109): 1099 form type (I,D,M, orN).CURLST(position 110): Current/Last indicator (CorL).MSGE(position 145): Error message (if any).
-
The output is conditional on indicator
81, which is set when validation fails to redisplay the screen with an error message. -
No File Outputs:
- The program does not directly write to any database files. The validated data is likely passed to subsequent programs (
AP765orAP765N) for further processing, such as updating theGAPVENDfile or generating 1099 forms.
Summary¶
- Purpose: The RPG program
AP765Pprovides an interactive screen (AP765PS1) for users to input data for 1099 vendor forms, including company headings, tax ID, amount, form type, and current/last indicator. It validates these inputs and displays error messages if validations fail. - Process: The program initializes, displays a screen for input, validates the fields using the
SUBSC1subroutine, and redisplays the screen with error messages if validations fail. Users can exit using theKGkey. - Business Rules: Enforce non-blank headings and ID#, valid 1099 types (
I,D,M,N), and validCURLSTvalues (C,L). - Tables Used:
MSGarray (for error messages) andSCREENworkstation file (for input/output). - External Programs: None called directly, but likely interacts with
AP765orAP765Nas part of the OCL procedure. - Outputs: Screen output to display input fields and error messages; no direct file outputs.
This program serves as the front-end validation step for 1099 form processing, ensuring accurate data entry before passing control to other programs for further processing.