Skip to content

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

  1. Program Setup and File Definitions:
  2. Header Specification (H):
    • Line 0002: Defines the program name (AP765P) and parameter P014, which may be a control parameter passed from the OCL program.
  3. File Specification (F):
    • Line 0008: Defines a workstation file SCREEN (512 bytes) for interactive input/output, used to display and capture data via a display device (e.g., a terminal screen).
  4. Extension Specification (E):
    • Line 0009: Defines an array MSG with 5 elements, each 35 characters long, to store error messages (loaded from the ** MESSAGES section at the end of the program).
  5. Input Specifications (I):

    • Lines 0010-0027: Define the screen format AP765PS1 (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 (C or L).
    • TYPE (1 char, position 110): Type of 1099 form (I for Interest, D for Dividend, M for Miscellaneous, N for Non-Employee Compensation).
  6. Initialization:

  7. Lines 0029-0031: Reset indicators 81, 90, 91, 92, 93, 94, 95, and 96 to off using SETOF.
  8. Line 0032: Initialize the error message field MSGE to blanks.
  9. Line 0038: Set indicator 60 on (likely used to control screen display or program flow).

  10. Handle Special Key (KG):

  11. Lines 0034-0036: If the KG key (likely a function key like F3 for exit) is pressed:

    • Reset indicator 81 (if set).
    • Set indicator U1 and LR (Last Record, signaling program termination).
    • Jump to the END tag to exit the program.
  12. Check for Format 09 (NS 09):

  13. Lines 0040-0041: If the program is processing format 09 (likely a control format or condition):

    • Set indicators 81 and 94 on.
    • Jump to the END tag to exit the program.
  14. Main Processing (Format 01):

  15. Line 0043: If processing format 01 (the main screen input format AP765PS1), execute the subroutine SUBSC1 to validate input fields.

  16. Validation Subroutine (SUBSC1):

  17. Lines 0047-0077: The SUBSC1 subroutine validates the input fields from the screen:
    • HEAD1 Validation (Lines 0049-0052):
    • Check if HEAD1 is blank.
    • If blank, set indicators 81 and 91 on, move message MSG,1 ("FIRST HEADING CANNOT BE BLANK") to MSGE, and jump to ENDSC1.
    • HEAD2 Validation (Lines 0054-0057):
    • Check if HEAD2 is blank.
    • If blank, set indicators 81 and 92 on, move message MSG,2 ("SECOND HEADING CANNOT BE BLANK") to MSGE, and jump to ENDSC1.
    • ID# Validation (Lines 0059-0062):
    • Check if ID# is blank.
    • If blank, set indicators 81 and 93 on, move message MSG,3 ("ID# CANNOT BE BLANK - TRY AGAIN!") to MSGE, and jump to ENDSC1.
    • TYPE Validation (Lines 0064-0069):
    • Check if TYPE is one of the valid values: D (Dividend), I (Interest), M (Miscellaneous), or N (Non-Employee Compensation).
    • If not valid, set indicators 81 and 95 on, move message MSG,4 ("ENTER I-INT, D-DIV, M-MISC, N-NEC") to MSGE, and jump to ENDSC1.
    • CURLST Validation (Lines 0071-0075):
    • Check if CURLST is either C (Current) or L (Last).
    • If not valid, set indicators 81 and 96 on, move message MSG,5 ("ENTER 'C'-CURR OR 'L'-LAST") to MSGE, and jump to ENDSC1.
  18. 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).

  19. Program Termination:

  20. Line 0045: The END tag marks the program’s termination point.
  21. If validations pass, the program likely proceeds to write the validated data to the screen or another process (not shown in this code snippet).

  22. Output Specifications:

  23. Lines 0079-0088: Define the output format for the SCREEN file (format AP765PS1):
    • Output fields HEAD1, HEAD2, HEAD3, ID#, ENTAMT, TYPE, and CURLST to their respective positions (1-110).
    • Output the error message MSGE at position 145.
    • The output is conditional on indicator 81 (likely used to display errors or re-display the screen for corrections).

Business Rules

  1. Mandatory Fields:
  2. HEAD1, HEAD2, and ID# must not be blank. If any are blank, the program displays an error message and prevents further processing.
  3. Valid 1099 Type:
  4. The TYPE field 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).
  5. Invalid values trigger an error message.
  6. Current or Last Indicator:
  7. The CURLST field must be either C (Current) or L (Last). Invalid values trigger an error message.
  8. Error Handling:
  9. If any validation fails, the program sets indicator 81 and a specific indicator (91, 92, 93, 95, or 96) to highlight the error field, displays an error message, and redisplays the screen for correction.
  10. User Exit:
  11. Pressing the KG key (e.g., F3) allows the user to exit the program immediately, setting U1 and LR indicators.
  12. Screen Interaction:
  13. The program uses a workstation file (SCREEN) to display input fields and error messages interactively, allowing the user to correct invalid inputs.

Tables Used

  1. MSG Array:
  2. Defined in the E specification (Line 0009).
  3. A table of 5 elements, each 35 characters long, loaded from the ** MESSAGES section 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"
  4. Used to display error messages when validation fails.

  5. SCREEN File:

  6. Defined in the F specification (Line 0008).
  7. A workstation file used for interactive input/output, with format AP765PS1 for 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

  1. Screen Output (AP765PS1):
  2. 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, or N).
    • CURLST (position 110): Current/Last indicator (C or L).
    • MSGE (position 145): Error message (if any).
  3. The output is conditional on indicator 81, which is set when validation fails to redisplay the screen with an error message.

  4. No File Outputs:

  5. The program does not directly write to any database files. The validated data is likely passed to subsequent programs (AP765 or AP765N) for further processing, such as updating the GAPVEND file or generating 1099 forms.

Summary

  • Purpose: The RPG program AP765P provides 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 SUBSC1 subroutine, and redisplays the screen with error messages if validations fail. Users can exit using the KG key.
  • Business Rules: Enforce non-blank headings and ID#, valid 1099 types (I, D, M, N), and valid CURLST values (C, L).
  • Tables Used: MSG array (for error messages) and SCREEN workstation file (for input/output).
  • External Programs: None called directly, but likely interacts with AP765 or AP765N as 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.