AR050P RPGLE
The provided document is an RPGLE program named AR050P.rpgle.txt, which is part of a cash receipts entry prompt system for an IBM System/36 or AS/400 environment. This program, converted from RPG II to RPGLE (as indicated by the TARGET/400 conversion comments), is called by the AR050P.ocl36 OCL script previously discussed. Below, I’ll explain the process steps, business rules, tables (files) used, and external programs called.
Process Steps of the AR050P RPGLE Program¶
The AR050P program is designed to handle the entry and validation of cash receipts data, including General Ledger (GL) account assignments for debit, credit, and discount accounts. It interacts with a workstation display file and several disk files to manage user input and validate GL accounts. Here’s a step-by-step breakdown of the process:
- Program Initialization:
- Header Specifications: The program uses
DFTACTGRP(*NO)to run in a named activation group andfixnbr(*zoned:*inputpacked)to handle numeric data formats. The default program name is set toAR050P. -
Initialization Subroutine (
*inzsr):- Initializes
glco(GL company number) andglacct(GL account number) to zero.
- Initializes
-
Workstation File Processing:
- The program reads the workstation file
ar050pd(display file) to handle user input. - Logic for
qsctl(control field):- If
qsctlis blank: - Sets indicator
*in09to1(indicating first-time processing). - Sets indicator
*in01to0. - Sets
qsctltoR(read mode). - Otherwise:
- Sets
*in09to0. - Sets
*in01to1. - Reads the
ar050pfmformat from the display file. - If the last record is read (
lrindicator), the program terminates (return).
- If
-
Clears indicator
*in21(used for screen redisplay). -
Main Processing Loop (
kgDo Loop): - Sets indicator
*inu1(likely a control indicator for user interaction). - Attempts to chain (retrieve) a record from the
crgldffile using key'00000'. - Writes or updates the
crgldffile (gldfltexception output). - Sets
*inlr(last record indicator) and exits to theendtag. -
If the chain fails, proceeds to further processing.
-
Conditional Subroutine Execution:
- If
*in01is on (subsequent screen read), executes thes1edtsubroutine (screen edit). -
If
*in09is on (first-time processing), executes theonetimsubroutine (initial setup). -
Screen Edit Subroutine (
s1edt): - Input Validation:
- Clears
*in50(error indicator) andmsgout(error message field). - Validates the
selectfield (user selection, expected to be 1 or 2): - If
selectis not 1 or 2, sets*in21and*in50, displays error messagemsg(1)("SELECTION INVALID"), and jumps toendedt.
- Clears
- Default Company Values:
- Copies
drco(debit company) tocrco(credit company) anddsco(discount company). - Chains to
arcontusingdrcoto retrieve default GL accounts: - If
drgl(debit GL account) is zero, sets it toaccsgl(cash GL account fromarcont). - If
crgl(credit GL account) is zero andcrcoequalsdrco, setscrgltoacargl(AR GL account fromarcont). - If
dsgl(discount GL account) is zero anddscoequalsdrco, setsdsgltoacdsgl(discount GL account fromarcont).
- Copies
- Executes the
subrglsubroutine to validate GL accounts. - If
*in50is on (error during GL validation), jumps toendedt. - Screen Redisplay Check:
- Compares saved GL accounts (
svdrgl,svcrgl,svdsgl) with current values (drgl,crgl,dsgl). - If any differ (
*in99off), updatescrgldfwith new values and jumps toendedt. - Updates saved values (
svdrgl,svcrgl,svdsgl) with current GL accounts.
- Compares saved GL accounts (
-
Sets
*in21to trigger screen redisplay. -
One-Time Setup Subroutine (
onetim): - Sets
selectto 1 andz5(a counter or temporary field) to zero. - Sets
*in21for screen display. - Attempts to chain to
crgldfwith key'00000':- If successful (
*in90off), loads existing values fromcrgldfintodrco,drgl,crco,crgl,dsco,dsgl, and their saved counterparts. - If unsuccessful, chains to
arcontwith key'01'to load default values: - Sets
drgltoaccsglif zero. - Sets
crgltoacarglif zero. - Sets
dsgltoacdsglif zero. - Sets
drco,crco,dscoto01if zero.
- If successful (
-
Executes
subrglto validate GL accounts. -
GL Account Validation Subroutine (
subrgl): - Validates debit, credit, and discount GL accounts against the
glmastfile:- For
drgl: - Constructs
glkeyusingdrcoanddrglwithgltype = 'C'. - Chains to
glmastusingglkey. - Checks if the account is not found (
*in38on) or marked as deleted (gldel = 'D') or inactive (gldel = 'I'). - If valid, sets
drdesctogldesc(account description). - If invalid, sets
*in21and*in50, displaysmsg(2)("INVALID DR G/L ACCOUNT"), and jumps toendgl. - For
crgl: - Similar process using
crcoandcrgl, with error messagemsg(3)("INVALID CR G/L ACCOUNT") and indicator*in39. - For
dsgl: - Similar process using
dscoanddsgl, with error messagemsg(4)("INVALID DISCOUNT ACCT") and indicator*in43.
- For
-
If all validations pass, the subroutine completes without errors.
-
Output to Files:
- Display File (
ar050pfm):- If
*in21is on, writes thear050pfmformat to the screen, displaying fields likeselect,drco,drgl,drdesc,crco,crgl,crdesc,dsco,dsgl,dsdesc, andmsgout(error message).
- If
-
Disk File (
crgldf):- If
*in90is on (no existing record), adds a new record tocrgldfwith fieldsz5,drco,drgl,crco,crgl,dsco,dsgl. - If
*in90is off (existing record), updates the record with the same fields.
- If
-
Program Termination:
- If
*in21is off, sets*inLRto terminate the program. - The program loops back to read the next user input unless terminated.
Business Rules¶
The program enforces the following business rules for cash receipts entry:
- Selection Validation:
-
The
selectfield must be either 1 or 2. Any other value triggers an error ("SELECTION INVALID") and redisplays the screen. -
Default GL Account Assignment:
- If
drgl,crgl, ordsglare zero, the program retrieves default values from thearcontfile:drgldefaults toaccsgl(cash GL account).crgldefaults toacargl(AR GL account) ifcrcomatchesdrco.dsgldefaults toacdsgl(discount GL account) ifdscomatchesdrco.
-
Company numbers (
drco,crco,dsco) default to01if zero during first-time processing. -
GL Account Validation:
- All GL accounts (
drgl,crgl,dsgl) must exist in theglmastfile and not be marked as deleted (gldel = 'D') or inactive (gldel = 'I'). -
If any account is invalid, an error message is displayed ("INVALID DR/CR/DISCOUNT G/L ACCOUNT"), and the screen is redisplayed for correction.
-
First-Time vs. Subsequent Processing:
- On first-time execution (
*in09on), the program loads default values fromarcontor existing values fromcrgldf. -
On subsequent executions (
*in01on), it validates user-entered values and updatescrgldfif GL accounts change. -
Screen Redisplay:
-
The screen is redisplayed if:
- An invalid selection or GL account is entered.
- GL accounts change from their saved values (
svdrgl,svcrgl,svdsgl).
-
Data Persistence:
- Validated GL account data is saved to the
crgldffile, either as a new record or an update. -
Account descriptions (
drdesc,crdesc,dsdesc) are retrieved fromglmastfor display. -
Inactive GL Accounts (per JB01 comment, 08/24/2016):
- Inactive GL accounts (
gldel = 'I') are treated the same as deleted accounts (gldel = 'D'), triggering an error and preventing their use.
Tables (Files) Used¶
The program interacts with the following files:
1. ar050pd:
- Type: Workstation (display) file.
- Format: ar050pfm.
- Usage: Input/output for user interaction, displaying fields like select, drco, drgl, drdesc, crco, crgl, crdesc, dsco, dsgl, dsdesc, and msgout.
- Handler: Uses PROFOUNDUI(HANDLER) for modern UI integration.
- arcont:
- Type: Input file (
if), disk-based. - Record Length: 256 bytes.
- Key: 2-byte company number (keyloc(2)).
- Fields Used:
acargl(positions 38-45): Accounts Receivable GL account number.acdsgl(positions 54-61): Discount GL account number.accsgl(positions 62-69): Cash GL account number.
-
Usage: Provides default GL account numbers for cash receipts.
-
glmast:
- Type: Input file (
if), disk-based. - Record Length: 256 bytes.
- Key: 11-byte key (company number + account number + type, keyloc(2)).
- Fields Used:
gldel(position 1): Deletion/inactive flag ('D'for deleted,'I'for inactive).gldesc(positions 13-37): GL account description.
-
Usage: Validates GL accounts and retrieves descriptions.
-
crgldf:
- Type: Update file (
uf a), disk-based, allows additions. - Record Length: 48 bytes.
- Key: 5-byte key (keyloc(2)).
- Fields Used:
cgdrco(positions 7-8): Debit company number.cgdrgl(positions 9-16): Debit GL account number.cgcrco(positions 17-18): Credit company number.cgcrgl(positions 19-26): Credit GL account number.cgdsco(positions 27-28): Discount company number.cgdsgl(positions 29-36): Discount GL account number.
- Usage: Stores validated GL account assignments for cash receipts.
External Programs Called¶
The AR050P RPGLE program does not explicitly call any external programs. It is a standalone program that handles user input, validates data, and updates files within its own logic. It is invoked by the AR050P.ocl36 script, which may call other programs (AR050, AR100, AR105, AR110, GSGENIEC, SCPROCP), but AR050P itself does not initiate calls to other programs.
Summary¶
The AR050P RPGLE program is a cash receipts entry prompt that:
- Facilitates user input via a workstation display file (ar050pd).
- Validates user-entered or default GL accounts (debit, credit, discount) against the glmast file, ensuring they are not deleted or inactive.
- Retrieves default GL accounts from arcont for first-time processing or when fields are zero.
- Saves validated data to crgldf and updates the display with account descriptions or error messages.
- Enforces business rules such as valid selection values, GL account validation, and default company assignments.
- Handles first-time and subsequent processing differently, with screen redisplay for errors or changes.
The program is tightly integrated with the OCL script, which manages the broader cash receipts workflow, while AR050P focuses on user interaction and GL account validation.