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:
- Program Initialization:
- 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 toAR931P.
- File Definitions:
FAR931PD CF E WORKSTN HANDLER('PROFOUNDUI(HANDLER)'): Defines the display fileAR931PD(likely replacing the originalCREEN) for user interaction, using the Profound UI handler for modernized UI support.FARCONT IF F 256 2AIDISK KEYLOC(2): Defines the input fileARCONT(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 fileGSCONT, likely a general system control file, with a record length of 512 bytes and a key at position 2.
- 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 fromARCONT.UDS: A data structure for passing parameters, including:KYALCO(111-113): Company selection code (ALLorCO).KYCO1,KYCO2,KYCO3(114-119): Company numbers (numeric).KYJOBQ(120): Job queue flag (YorN).KYCOPY(121-122): Number of copies for the report.KYCANC(129-134): Cancellation flag.
-
Indicators: RPG indicators (e.g.,
*IN01,*IN09,*IN81) control program flow and screen display. -
Workstation File Read and Control (
QSCTLCheck): - The program checks the
QSCTLvariable (likely a control flag):- If
QSCTLis 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
AR931PDand sets*INLR = *ON(last record), then returns, exiting the program.
- If
-
This step determines whether to initialize the screen or process user input.
-
Clear Messages and Indicators:
- Clears the
MSGfield (40 bytes) used for error messages. -
Resets indicators
*IN51,*IN52,*IN53,*IN54,*IN81,*IN90to*OFFto ensure a clean state for validation and display. -
Cancel Key Check (
*INKG): -
If the cancel function key (
*INKG = *ON) is pressed:- Resets
*IN01and*IN09to*OFF. - Sets
*INLR = *ONto 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.
- Resets
-
Initial Setup (
*IN09Check): - If
*IN09 = *ON(initial program entry):- Sets
*IN81 = *ONto control screen display. - Executes the
ONETIMsubroutine to perform one-time setup tasks.
- Sets
-
This ensures setup occurs only on the first pass.
-
Screen Processing (
*IN01Check): - If
*IN01 = *ON(user input received):- Executes the
SCREEN1subroutine to validate user input.
- Executes the
-
This handles the validation of parameters entered via the display file.
-
Screen Display or Termination:
- If
*IN81 = *OFF:- Sets
*INLR = *ONto terminate the program.
- Sets
- If
*IN81 = *ON:- Writes to the display file
AR931PDto show the screen (with fields likeKYALCO,KYCO1,DCO, etc.) and loops back to theENDtag for further input.
- Writes to the display file
-
This controls whether the program displays the screen or exits.
-
ONETIM Subroutine:
- Purpose: Performs one-time setup, populating the
DCOarray with company data and setting default parameters. -
Steps:
- Clears the
DCOarray. - Initializes counters:
X = 1(array index),ACLIM = 00(limit for readingARCONT). - Positions the file pointer at the start of
ARCONTusingSETLL. - Reads
ARCONTrecords in a loop until end-of-file (*IN10 = *ON) orX = 10: - Skips records where
ACDEL = 'D'(deleted records). - Stores
ACCO(company number) andACNAME(company name) inDCO(X). - Increments
X. - Copies
DCOelements to individual fields (DCO1toDCO10) for display. - Checks
GSCONTfor a company number (GXCONO): - If
GXCONO ≠ 0, setsKYALCO = 'CO 'andKYCO1 = GXCONO. - Else, sets
KYALCO = 'ALL'. - Sets defaults:
KYJOBQ = 'N',KYCOPY = 01. - Sets
*IN81 = *ONto display the screen.
- Clears the
-
SCREEN1 Subroutine:
- Purpose: Validates user input for company selection, company numbers, and job queue settings.
- Steps:
- Company Selection Validation:
- Checks if
KYALCO = 'ALL'orKYALCO = 'CO '. If neither, sets error indicators (*IN81,*IN90), displays error messageCOM(1)("COMPANY SELECTION MUST BE 'CO' OR 'ALL'"), and jumps toENDS1. - If
KYALCO = 'CO'and all company numbers (KYCO1,KYCO2,KYCO3) are0, sets error indicators (*IN81,*IN90,*IN51), displaysCOM(2)("IF CO, THEN ENTER VALID COMPANIES"), and jumps toENDS1. - If
KYALCO = 'ALL'and any company number is non-zero, sets error indicators (*IN81,*IN90,*IN51), displaysCOM(3)("IF ALL, THEN DO NOT ENTER COMPANIES"), and jumps toENDS1. - Company Number Validation (if
KYALCO = 'CO'): - For each non-zero
KYCO1,KYCO2,KYCO3, performs aCHAINtoARCONTto verify the company number exists. - If any company number is invalid (
*IN10 = *ON), sets error indicators (*IN81,*IN90,*IN51/IN52/IN53), displaysCOM(4)("INVALID COMPANY NUMBER"), and jumps toENDS1. - Job Queue Validation:
- Checks if
KYJOBQ = 'Y'orKYJOBQ = 'N'. If neither, sets error indicators (*IN81,*IN90,*IN54), displaysCOM(5)("JOB QUEUE ENTRY MUST BE 'Y' OR 'N'"), and jumps toENDS1. - Copy Count Validation:
- If
KYCOPY = 0, sets it to01to ensure at least one copy. - Jumps to
ENDS1to end the subroutine.
Business Rules¶
The program enforces the following business rules for generating the A/R Control File List:
- Company Selection:
- The user must select either
ALL(process all companies) orCO(specific companies) viaKYALCO. - If
KYALCO = 'CO', at least one valid company number (KYCO1,KYCO2, orKYCO3) must be provided. - If
KYALCO = 'ALL', no company numbers should be entered. -
Company numbers must exist in the
ARCONTfile and not be marked as deleted (ACDEL ≠ 'D'). -
Job Queue Selection:
- The job queue flag (
KYJOBQ) must be eitherY(submit to job queue) orN(run interactively). -
This aligns with the OCL script’s conditional job submission (
// IF ?L'120,1'?/Y JOBQ ?CLIB?,AR931). -
Copy Count:
-
The number of report copies (
KYCOPY) must be at least 1. If set to 0, it defaults to 1. -
Error Handling:
- Invalid inputs (e.g., wrong
KYALCO, invalid company numbers, or incorrectKYJOBQ) trigger error messages from theCOMarray and prevent further processing until corrected. -
The cancel key (
*INKG) allows the user to exit, settingKYCANC = 'CANCEL', which the OCL script checks to terminate the job. -
Data Validation:
- Only non-deleted records (
ACDEL ≠ 'D') fromARCONTare used. -
Up to 10 companies can be displayed (
DCOarray), populated fromARCONT. -
Default Settings:
- If
GSCONTcontains a non-zero company number (GXCONO), it defaults toKYALCO = 'CO 'withKYCO1 = GXCONO. Otherwise,KYALCO = 'ALL'. KYJOBQdefaults toN, andKYCOPYdefaults to01.
Tables/Files Used¶
- AR931PD:
- Type: Display file (workstation file).
- Purpose: Handles user interaction, displaying prompts for
KYALCO,KYCO1,KYCO2,KYCO3,KYJOBQ,KYCOPY,DCO(company list), andMSG(error messages). -
Uses the Profound UI handler for modernized display.
-
ARCONT:
- Type: Input file (disk, 256 bytes, indexed).
- 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.
-
Used to validate company numbers and populate the
DCOarray. -
GSCONT:
- Type: Input file (disk, 512 bytes, indexed).
- Purpose: Stores system control data, including:
GXDEL(position 1): Delete flag.GXCONO(positions 77-78): Company number.
- Used to determine the default company selection (
KYALCOandKYCO1).
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?,AR931or// 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
AR931Pis 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:
AR931Pprompts the user for company selection (ALLor specific companies), company numbers, job queue settings, and report copies via a display file (AR931PD). It validates inputs againstARCONTandGSCONT, populates a company list, and sets parameters for the OCL script to control further job execution (e.g., runningAR931). It handles errors with appropriate messages and allows cancellation. - Business Rules: Enforces valid company selection (
ALLorCO), valid company numbers, correct job queue settings (YorN), and a minimum of one report copy. UsesGSCONTfor defaults and skips deleted records inARCONT. - 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, andSCPROCPare 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.