Skip to content

AR490P RPGLE

The provided RPGLE program, AR490P.rpgle.txt, is an RPG IV program converted from an earlier RPG version (likely RPG/400) using the TARGET/400 tool, as indicated by the conversion comments. This program handles the user interface and validation logic for a credit limit grouping list, interacting with a workstation file and database files. It is called by the OCL program AR490P.ocl36.txt previously analyzed. Below, I explain the process steps, business rules, tables/files used, and external programs called.


Process Steps of the RPG Program

The program is designed to prompt the user for input via a workstation display file, validate selections for company codes and job queue options, and prepare data for a credit limit grouping report. The steps are as follows:

  1. Program Initialization:
  2. Header Specifications:
    • H DFTACTGRP(*NO): Runs in a non-default activation group, allowing for modern RPG IV features.
    • H FIXNBR(*ZONED:*INPUTPACKED): Ensures zoned and packed numeric fields are handled correctly during input.
    • H DFTNAME(AR490P): Specifies the default program name as AR490P.
  3. Data Structures and Variables:
    • COM: A compile-time array with 5 error messages (40 characters each) for validation feedback.
    • DCO: A data structure with 10 subfields (DC01 to DC10, each 35 characters) to store company numbers and names.
    • UDS: A data structure for passing parameters (e.g., KYALCO, KYCO1, KYCO2, KYCO3, KYJOBQ, KYCOPY, KYCANC) to/from the OCL program.
  4. File Declarations:

    • AR490PD: A workstation file (display file) for user interaction, using the PROFOUNDUI(HANDLER) for modern UI rendering.
    • ARCONT: A disk file (256 bytes, indexed, key at position 2) containing company data.
    • GSCONT: Another disk file (512 bytes, indexed, key at position 2) for company validation.
  5. Workstation File Processing:

  6. Initial Check (QSCTL):
    • If QSCTL (control field) is blank:
    • Set *IN09 = '1' and *IN01 = '0' to indicate initial screen display.
    • Set QSCTL = 'R' to mark the screen as ready.
    • Else:
    • Set *IN09 = '0' and *IN01 = '1'.
    • Read the AR490S1 format from AR490PD.
    • If the last record is read (LR indicator), exit the program (RETURN).
  7. Clear Indicators and Message:

    • Reset message field MSG to blanks.
    • Turn off indicators *IN51, *IN52, *IN53, *IN54, *IN81, *IN90 to clear error states.
  8. Handle Cancel Key (*INKG):

  9. If the cancel key is pressed (*INKG = *ON):

    • Turn off *IN01 and *IN09.
    • Set *INLR = *ON to end the program.
    • Set KYCANC = 'CANCEL' to signal cancellation to the OCL program.
    • This allows the user to exit the program gracefully.
  10. Initial Setup (*IN09):

  11. If *IN09 = *ON (initial screen display):

    • Set *IN81 = *ON to indicate screen output.
    • Execute the ONETIM subroutine to populate company data.
  12. Screen Processing (*IN01):

  13. If *IN01 = *ON (user input received):

    • Execute the SCREEN1 subroutine to validate user input.
  14. Main Loop Control:

  15. If *IN81 = *OFF, set *INLR = *ON to end the program.
  16. If *IN81 = *ON, write the AR490S1 format to the display file to show the screen (with errors or data).

  17. ONETIM Subroutine:

  18. Purpose: Populate the company selection dropdown (DCO array) and initialize parameters.
  19. Steps:

    • Clear the DCO array.
    • Initialize counter X = 1 and credit limit ACLIM = 00.
    • Set the lower limit for ARCONT file using ACLIM (SETLL).
    • Read ARCONT records in a loop until end-of-file (*IN10 = *ON) or 10 companies are loaded:
    • Skip records marked as deleted (ACDEL = 'D').
    • Store company number (ACCO) and name (ACNAME) in DCO(X).
    • Increment X; stop if X = 10.
    • Move DCO(1) to DCO(10) into individual fields (DCO1 to DCO10) for display.
    • Check GSCONT file for a company number (GXCONO):
    • If found and non-zero, set KYALCO = 'CO ' and KYCO1 = GXCONO.
    • Else, set KYALCO = 'ALL'.
    • Set KYJOBQ = 'N' (default job queue selection).
    • Set KYCOPY = 01 (default number of copies).
  20. SCREEN1 Subroutine:

  21. Purpose: Validate user input for company selection and job queue.
  22. Steps:
    • Validate Company Selection:
    • Check if KYALCO is 'ALL' or 'CO '; if not, set error indicators *IN81, *IN90, display error message COM(1) ("COMPANY SELECTION MUST BE 'CO' or 'ALL'"), and exit.
    • If KYALCO = 'CO' and all company fields (KYCO1, KYCO2, KYCO3) are zero, set error indicators *IN81, *IN90, *IN51, display COM(2) ("IF CO, THEN ENTER VALID COMPANIES"), and exit.
    • If KYALCO = 'ALL' and any company field is non-zero, set error indicators *IN81, *IN90, *IN51, display COM(3) ("IF ALL, THEN DO NOT ENTER COMPANIES"), and exit.
    • If KYALCO = 'CO', validate each company number (KYCO1, KYCO2, KYCO3) using CHAIN to ARCONT:
      • If any company number is invalid (*IN10 = *ON), set error indicators *IN81, *IN90, and *IN51, *IN52, or *IN53 (depending on the field), display COM(4) ("INVALID COMPANY NUMBER"), and exit.
    • Validate Job Queue Selection:
    • Check if KYJOBQ is 'Y' or 'N'; if not, set error indicators *IN81, *IN90, *IN54, display COM(5) ("JOB QUEUE ENTRY MUST BE 'Y' OR 'N'"), and exit.
    • Validate Copies:
    • If KYCOPY = 00, set it to 01 to ensure at least one copy.
    • Exit the subroutine (ENDS1).

Business Rules

The program enforces the following business rules for generating a credit limit grouping list:

  1. Company Selection:
  2. The user must select either 'ALL' (all companies) or 'CO' (specific companies) via KYALCO.
  3. If 'CO' is selected, at least one valid company number (KYCO1, KYCO2, or KYCO3) must be provided.
  4. If 'ALL' is selected, no company numbers should be entered.
  5. Company numbers must exist in the ARCONT file and not be marked as deleted (ACDEL ≠ 'D').
  6. Invalid company selections trigger error messages and prevent further processing.

  7. Job Queue Selection:

  8. The user must specify whether the report runs in a job queue (KYJOBQ = 'Y') or interactively (KYJOBQ = 'N').
  9. Invalid job queue entries trigger an error message.

  10. Number of Copies:

  11. The number of report copies (KYCOPY) must be at least 1. If zero is entered, it is set to 1.

  12. Cancellation:

  13. If the user presses the cancel key, the program sets KYCANC = 'CANCEL' and exits, signaling the OCL program to terminate.

  14. Company Data Population:

  15. Up to 10 active companies (non-deleted) from ARCONT are loaded into the DCO array for display in a dropdown.
  16. The program checks GSCONT to determine if a specific company number should be preselected (KYALCO = 'CO ') or if all companies are selected (KYALCO = 'ALL').

Tables/Files Used

The program uses the following files: 1. AR490PD: - A workstation file (display file) for user interaction. - Contains the AR490S1 format for input/output. - Uses PROFOUNDUI(HANDLER) for modern UI rendering. 2. ARCONT: - A disk file (256 bytes, indexed, key at position 2). - Contains company data with fields: - ACDEL (1 byte): Delete flag ('D' for deleted). - ACCO (2 bytes, numeric): Company number. - ACNAME (30 bytes): Company name. - Used to validate company numbers and populate the dropdown. 3. GSCONT: - A disk file (512 bytes, indexed, key at position 2). - Contains company data with fields: - GXDEL (1 byte): Delete flag. - GXCONO (2 bytes, numeric): Company number. - Used to determine the default company selection.


External Programs Called

The RPG program does not explicitly call any external programs using CALL or similar operations. However: - It interacts with the PROFOUNDUI(HANDLER) for the AR490PD display file, which is a UI handler, not a program. - The OCL program (AR490P.ocl36.txt) that calls this RPG program references AR490, which may be invoked based on user input (KYJOBQ), but this is handled outside the RPG program.


Summary

  • Process Steps: The program initializes, displays a screen to prompt for company selection (ALL or specific companies), job queue option (Y or N), and number of copies. It populates a company dropdown from ARCONT, validates user input, and sets parameters for the OCL program to proceed (or cancel). The ONETIM subroutine loads company data, and SCREEN1 validates input.
  • Business Rules: Enforces valid company selection (ALL or CO with valid company numbers), job queue selection (Y or N), and ensures at least one copy. Invalid inputs trigger error messages, and cancellation is supported.
  • Tables/Files: AR490PD (workstation), ARCONT (company data), GSCONT (company validation).
  • External Programs: None explicitly called within the RPG program.

If you need further details (e.g., the display file format AR490S1 or additional context about AR490), please provide relevant files or information.