AR415P RPGLE
The provided document, AR415P.rpgle.txt, is an RPGLE (RPG IV) program on the IBM i (AS/400) platform, called by the OCL program AR415.ocl36.txt. The program appears to handle the initial screen processing for the Customer Credit Report, allowing the user to select a company code (co) and validating it against the BICONT and GSCONT files. Below, I’ll explain the process steps, business rules, tables used, and any external programs called.
Process Steps of the AR415P RPGLE Program¶
The AR415P program is a workstation-based interactive program that displays a screen to capture a company code, validates it, and sets up conditions for the subsequent report generation. Here’s a step-by-step breakdown of the process:
- Program Initialization:
- The program uses the
DFTACTGRP(*NO)directive, indicating it runs in a named activation group, andDFTNAME(AR415P)sets the default program name. - The
FIXNBR(*ZONED:*INPUTPACKED)option ensures zoned decimal and packed decimal fields are handled correctly during input. - Files are defined:
AR415PD(workstation file, likely a display file for screen interaction, using the Profound UI handler).BICONT(input file, 256 bytes, keyed at position 2).GSCONT(input file, 512 bytes, keyed at position 2).
-
Data structures and variables are defined:
msgarray for error messages.@infdsfor workstation file information (e.g., function key status).udsdata structure withco(company code, 2-digit numeric) andkycanc(cancel key status, 6 characters).- Input specifications for
BICONT(fieldbcdelat position 1) andGSCONT(fieldsGXDELat position 1,GXCONOat positions 77–78).
-
Main Processing Loop (
dow @sfnex <> 'EJ') - The program enters a
DOloop that continues until@sfnex(screen exit flag) equals'EJ'(end job). - The loop processes the screen based on the
@sfid(screen format ID) value:- If
@sfidis blank, execute subroutine$sblk(initial blank screen). - If
@sfidis'S1', execute subroutine$s1(process screen input).
- If
- The
$xcptsubroutine is called to handle screen display. - The program reads the
AR415S1format (fromAR415PDdisplay file) with indicators50(error) orLR(last record), depending on whether it’s the first screen (@ccnt = 1) or subsequent iterations. -
The loop ends when
@sfnex = 'EJ'(set in$s1entor$s1ck), triggering theendittag and setting*INLRto*ONto end the program. -
Subroutine
$sblk: Initial Blank Screen - Executed when
@sfidis blank (first time only). - Sets indicator
*IN99to*ONto display the blank screen. - Retrieves the company code (
GXCONO) from theGSCONTfile using aCHAINoperation (keyed on'00').- If found (
*IN95 = *OFF) andGXCONOis non-zero, setsco = GXCONO.
- If found (
-
Sets
@sfnexand@sfidto'S1'to display theAR415S1screen format next. -
Subroutine
$s1: Process Screen Input - Handles input from the
AR415S1screen format. -
Checks the function key pressed (via
@vkeyin@infds):- If
@vkey = 0(Enter key), calls$s1entto validate the entered company code. - If
@vkey = 2(Command key, likely F3 or Cancel), calls$s1ckto handle cancellation.
- If
-
Subroutine
$s1ent: Validate Company Code - Validates the
cofield entered by the user:- If
co = 0, sets error messagemsg(1)(“INVALID COMPANY”) and indicator*IN90to*ON, then jumps toends1eto redisplay the screen. - Performs a
CHAINtoBICONTusingcoas the key: - If not found (
*IN96 = *ON), sets error messagemsg(1)(“INVALID COMPANY”) and*IN90to*ON. - If found but
bcdel = 'D'(deleted company), sets error messagemsg(2)(“COMPANY HAS BEEN DELETED”) and*IN90to*ON. - If validation passes (valid, non-deleted company), sets
@sfnex = 'EJ'to exit the program.
- If
-
The
ends1elabel ensures the screen is redisplayed with error messages if validation fails. -
Subroutine
$s1ck: Handle Command Key - Processes command key actions (e.g., F3 for Cancel).
- If
*INKG(F3 key) is*ON, sets@sfnex = 'EJ'to exit the program andkycanc = 'CANCEL'to indicate cancellation. -
Ends with the
ends1clabel. -
Subroutine
$xcpt: Display Screen - Increments
@ccnt(screen counter). - If
@sfnex = @sfid, sets*IN98to*ONto indicate the same screen is being redisplayed. - If
@sfnex = 'S1', writes theAR415S1format to the display file to show the screen. -
Calls
clrindto clear indicators and error messages. -
Subroutine
clrind: Clear Indicators - Resets indicators
*IN90,*IN81,*IN82,*IN12,*IN13,*IN14, and*IN15to*OFF. -
Clears the
msg1field to ensure no residual error messages are displayed. -
Program Termination:
- When
@sfnex = 'EJ', the program jumps to theendittag, sets*INLR = *ON, and terminates.
Business Rules¶
The program enforces the following business rules:
1. Company Code Validation:
- The user must enter a valid company code (co) that exists in the BICONT file.
- The company code must not be zero (invalid company).
- The company must not be marked as deleted (bcdel <> 'D' in BICONT).
2. Default Company Code:
- If available, the program retrieves a default company code (GXCONO) from the GSCONT file (key '00') for the initial screen.
3. Error Handling:
- Displays “INVALID COMPANY” if the entered co is zero or not found in BICONT.
- Displays “COMPANY HAS BEEN DELETED” if the company exists but is marked deleted.
- Errors cause the screen to be redisplayed with the appropriate message.
4. Cancellation:
- The user can cancel the program using a command key (F3, *INKG), setting kycanc = 'CANCEL' and exiting the program.
5. Screen Flow:
- Starts with a blank screen, then displays the AR415S1 format for company code input.
- Exits only when a valid company code is entered or the user cancels.
Tables (Files) Used¶
The program uses the following files:
1. AR415PD (cf, workstation file):
- A display file for screen interaction, using the AR415S1 format to capture the company code and display error messages.
- Managed by the Profound UI handler for modernized UI.
2. BICONT (if, input file):
- A 256-byte file, keyed at position 2, containing company data.
- Field: bcdel (position 1, 1 byte, indicates if the company is deleted with 'D').
3. GSCONT (if, input file):
- A 512-byte file, keyed at position 2, containing control data.
- Fields: GXDEL (position 1, 1 byte), GXCONO (positions 77–78, 2-digit numeric company code).
External Programs Called¶
The AR415P program does not explicitly call any external programs. It is an interactive program that processes user input and validates data using file I/O operations. The Profound UI handler (PROFOUNDUI(HANDLER)) is used for the workstation file, but this is a runtime component, not a separate program.
Summary¶
Process Steps:
- Initializes the program and displays a blank screen.
- Retrieves a default company code from GSCONT.
- Displays the AR415S1 screen for user input.
- Validates the entered company code against BICONT, checking for existence and deletion status.
- Handles errors by redisplaying the screen with messages or exits on valid input/cancellation.
- Terminates when a valid company code is entered or the user cancels.
Business Rules:
- Ensures a non-zero, non-deleted company code is entered.
- Provides default company code from GSCONT.
- Supports cancellation via F3.
- Displays error messages for invalid or deleted companies.
Files Used: AR415PD (display), BICONT (company data), GSCONT (control data).
External Programs: None.