Skip to content

AR931P RPGLE

The provided document, AR931P.rpgle.txt, is an RPGLE (Report Program Generator Language Extended) program for the IBM System/36 or AS/400 (IBM i) environment, converted from an older RPG format by the TARGET/400 tool. This program, AR931P, appears to handle the prompting and validation for generating an Accounts Receivable (A/R) Control File List. It interacts with a workstation (display file) to collect user input and validates it against data in the A/R control file. Below, I’ll explain the process steps, business rules, tables/files used, and any external programs called, referencing the previously provided OCL script (AR931P.ocl36.txt) for context.

Process Steps of the RPGLE Program

The AR931P program is designed to prompt the user for parameters (e.g., company selection, job queue settings) via a display file, validate the input, and prepare data for the A/R Control File List report. The steps are executed in a structured flow, with subroutines handling specific tasks. Here’s a detailed breakdown:

  1. Program Initialization:
  2. Header Specifications:
    • H DFTACTGRP(*NO): Runs the program in a named activation group (not the default), ensuring proper resource management.
    • H FIXNBR(*ZONED:*INPUTPACKED): Ensures zoned and packed decimal fields are handled correctly during input.
    • H DFTNAME(AR931P): Sets the default program name to AR931P.
  3. File Definitions:
    • FAR931PD CF E WORKSTN HANDLER('PROFOUNDUI(HANDLER)'): Defines the display file AR931PD (likely replacing the original CREEN) for user interaction, using the Profound UI handler for modernized UI support.
    • FARCONT IF F 256 2AIDISK KEYLOC(2): Defines the input file ARCONT (Accounts Receivable control file), with a record length of 256 bytes and a key starting at position 2.
    • FGSCONT IF F 512 2AIDISK KEYLOC(2): Defines another input file GSCONT, likely a general system control file, with a record length of 512 bytes and a key at position 2.
  4. Data Structures and Variables:
    • COM: A compile-time array of 5 elements (40 bytes each) containing error messages (e.g., "COMPANY SELECTION MUST BE 'CO' OR 'ALL'").
    • DCO: An array of 10 elements (35 bytes each) to store company numbers and names from ARCONT.
    • UDS: A data structure for passing parameters, including:
    • KYALCO (111-113): Company selection code (ALL or CO).
    • KYCO1, KYCO2, KYCO3 (114-119): Company numbers (numeric).
    • KYJOBQ (120): Job queue flag (Y or N).
    • KYCOPY (121-122): Number of copies for the report.
    • KYCANC (129-134): Cancellation flag.
  5. Indicators: RPG indicators (e.g., *IN01, *IN09, *IN81) control program flow and screen display.

  6. Workstation File Read and Control (QSCTL Check):

  7. The program checks the QSCTL variable (likely a control flag):
    • If QSCTL is blank:
    • Sets *IN09 = '1' and *IN01 = '0'.
    • Sets QSCTL = 'R' (likely indicating a read operation).
    • Else:
    • Sets *IN09 = '0' and *IN01 = '1'.
    • Reads the display file AR931PD and sets *INLR = *ON (last record), then returns, exiting the program.
  8. This step determines whether to initialize the screen or process user input.

  9. Clear Messages and Indicators:

  10. Clears the MSG field (40 bytes) used for error messages.
  11. Resets indicators *IN51, *IN52, *IN53, *IN54, *IN81, *IN90 to *OFF to ensure a clean state for validation and display.

  12. Cancel Key Check (*INKG):

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

    • Resets *IN01 and *IN09 to *OFF.
    • Sets *INLR = *ON to indicate program termination.
    • Sets KYCANC = 'CANCEL', which aligns with the OCL script’s error check (// IF ?L'129,6'?/CANCEL GOTO END).
    • This allows the user to cancel the operation, terminating the program.
  14. Initial Setup (*IN09 Check):

  15. If *IN09 = *ON (initial program entry):
    • Sets *IN81 = *ON to control screen display.
    • Executes the ONETIM subroutine to perform one-time setup tasks.
  16. This ensures setup occurs only on the first pass.

  17. Screen Processing (*IN01 Check):

  18. If *IN01 = *ON (user input received):
    • Executes the SCREEN1 subroutine to validate user input.
  19. This handles the validation of parameters entered via the display file.

  20. Screen Display or Termination:

  21. If *IN81 = *OFF:
    • Sets *INLR = *ON to terminate the program.
  22. If *IN81 = *ON:
    • Writes to the display file AR931PD to show the screen (with fields like KYALCO, KYCO1, DCO, etc.) and loops back to the END tag for further input.
  23. This controls whether the program displays the screen or exits.

  24. ONETIM Subroutine:

  25. Purpose: Performs one-time setup, populating the DCO array with company data and setting default parameters.
  26. Steps:

    • Clears the DCO array.
    • Initializes counters: X = 1 (array index), ACLIM = 00 (limit for reading ARCONT).
    • Positions the file pointer at the start of ARCONT using SETLL.
    • Reads ARCONT records in a loop until end-of-file (*IN10 = *ON) or X = 10:
    • Skips records where ACDEL = 'D' (deleted records).
    • Stores ACCO (company number) and ACNAME (company name) in DCO(X).
    • Increments X.
    • Copies DCO elements to individual fields (DCO1 to DCO10) for display.
    • Checks GSCONT for a company number (GXCONO):
    • If GXCONO ≠ 0, sets KYALCO = 'CO ' and KYCO1 = GXCONO.
    • Else, sets KYALCO = 'ALL'.
    • Sets defaults: KYJOBQ = 'N', KYCOPY = 01.
    • Sets *IN81 = *ON to display the screen.
  27. SCREEN1 Subroutine:

  28. Purpose: Validates user input for company selection, company numbers, and job queue settings.
  29. Steps:
    • Company Selection Validation:
    • Checks if KYALCO = 'ALL' or KYALCO = 'CO '. If neither, sets error indicators (*IN81, *IN90), displays error message COM(1) ("COMPANY SELECTION MUST BE 'CO' OR 'ALL'"), and jumps to ENDS1.
    • If KYALCO = 'CO' and all company numbers (KYCO1, KYCO2, KYCO3) are 0, sets error indicators (*IN81, *IN90, *IN51), displays COM(2) ("IF CO, THEN ENTER VALID COMPANIES"), and jumps to ENDS1.
    • If KYALCO = 'ALL' and any company number is non-zero, sets error indicators (*IN81, *IN90, *IN51), displays COM(3) ("IF ALL, THEN DO NOT ENTER COMPANIES"), and jumps to ENDS1.
    • Company Number Validation (if KYALCO = 'CO'):
    • For each non-zero KYCO1, KYCO2, KYCO3, performs a CHAIN to ARCONT to verify the company number exists.
    • If any company number is invalid (*IN10 = *ON), sets error indicators (*IN81, *IN90, *IN51/IN52/IN53), displays COM(4) ("INVALID COMPANY NUMBER"), and jumps to ENDS1.
    • Job Queue Validation:
    • Checks if KYJOBQ = 'Y' or KYJOBQ = 'N'. If neither, sets error indicators (*IN81, *IN90, *IN54), displays COM(5) ("JOB QUEUE ENTRY MUST BE 'Y' OR 'N'"), and jumps to ENDS1.
    • Copy Count Validation:
    • If KYCOPY = 0, sets it to 01 to ensure at least one copy.
    • Jumps to ENDS1 to end the subroutine.

Business Rules

The program enforces the following business rules for generating the A/R Control File List:

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

  6. Job Queue Selection:

  7. The job queue flag (KYJOBQ) must be either Y (submit to job queue) or N (run interactively).
  8. This aligns with the OCL script’s conditional job submission (// IF ?L'120,1'?/Y JOBQ ?CLIB?,AR931).

  9. Copy Count:

  10. The number of report copies (KYCOPY) must be at least 1. If set to 0, it defaults to 1.

  11. Error Handling:

  12. Invalid inputs (e.g., wrong KYALCO, invalid company numbers, or incorrect KYJOBQ) trigger error messages from the COM array and prevent further processing until corrected.
  13. The cancel key (*INKG) allows the user to exit, setting KYCANC = 'CANCEL', which the OCL script checks to terminate the job.

  14. Data Validation:

  15. Only non-deleted records (ACDEL ≠ 'D') from ARCONT are used.
  16. Up to 10 companies can be displayed (DCO array), populated from ARCONT.

  17. Default Settings:

  18. If GSCONT contains a non-zero company number (GXCONO), it defaults to KYALCO = 'CO ' with KYCO1 = GXCONO. Otherwise, KYALCO = 'ALL'.
  19. KYJOBQ defaults to N, and KYCOPY defaults to 01.

Tables/Files Used

  1. AR931PD:
  2. Type: Display file (workstation file).
  3. Purpose: Handles user interaction, displaying prompts for KYALCO, KYCO1, KYCO2, KYCO3, KYJOBQ, KYCOPY, DCO (company list), and MSG (error messages).
  4. Uses the Profound UI handler for modernized display.

  5. ARCONT:

  6. Type: Input file (disk, 256 bytes, indexed).
  7. Purpose: Stores Accounts Receivable control data, including:
    • ACDEL (position 1): Delete flag ('D' for deleted).
    • ACCO (positions 2-3): Company number.
    • ACNAME (positions 4-33): Company name.
  8. Used to validate company numbers and populate the DCO array.

  9. GSCONT:

  10. Type: Input file (disk, 512 bytes, indexed).
  11. Purpose: Stores system control data, including:
    • GXDEL (position 1): Delete flag.
    • GXCONO (positions 77-78): Company number.
  12. Used to determine the default company selection (KYALCO and KYCO1).

External Programs Called

The RPGLE program does not explicitly call any external programs using CALL operations. However, the OCL script (AR931P.ocl36.txt) provides context for how AR931P fits into the workflow:

  • AR931:
  • Referenced in the OCL script (// IF ?L'120,1'?/Y JOBQ ?CLIB?,AR931 or // ELSE AR931).
  • Likely an RPG program or job that generates the actual A/R Control File List report, using parameters validated by AR931P.
  • Not called directly from the RPGLE code but is part of the job flow.

  • GSGENIEC and SCPROCP:

  • Called in the OCL script before AR931P is loaded.
  • Not referenced in the RPGLE code but part of the broader job setup.

Integration with OCL Script

The OCL script (AR931P.ocl36.txt) orchestrates the execution of AR931P: - It loads and runs AR931P with the ARCONT file. - It checks KYCANC (positions 129-134) for 'CANCEL' to terminate if the user cancels. - It uses KYJOBQ (position 120) to decide whether to queue AR931 (Y) or run it directly (N). - The ?9? parameter in the OCL script aligns with file labels and library references.

Summary

  • Process Overview: AR931P prompts the user for company selection (ALL or specific companies), company numbers, job queue settings, and report copies via a display file (AR931PD). It validates inputs against ARCONT and GSCONT, populates a company list, and sets parameters for the OCL script to control further job execution (e.g., running AR931). It handles errors with appropriate messages and allows cancellation.
  • Business Rules: Enforces valid company selection (ALL or CO), valid company numbers, correct job queue settings (Y or N), and a minimum of one report copy. Uses GSCONT for defaults and skips deleted records in ARCONT.
  • Files/Tables: AR931PD (display), ARCONT (A/R control data), GSCONT (system control data).
  • External Programs: None called directly in RPGLE, but AR931 (report generation), GSGENIEC, and SCPROCP are part of the OCL workflow.

If you need further analysis (e.g., details of AR931 or the display file format), please provide additional files or context, as some components (e.g., AR931PFM, AR931) are referenced but not fully defined here.