AR880 RPGLE
The provided RPGLE program, AR880.rpgle.txt, is an RPG IV program designed for a Customer Credit Limit Authorization Inquiry on an IBM AS/400 or iSeries system. It is called from the OCL program AR880.ocl36.txt and handles the interactive process of displaying customer credit information, managing order authorizations, and generating email notifications for credit status changes. Below, I’ll explain the process steps, business rules, tables used, and external programs called.
Process Steps of the RPGLE Program¶
The program is structured to handle customer credit limit inquiries, display order details, and allow users to authorize or unauthorize orders that exceed credit limits. It uses a workstation file with subfiles for user interaction and updates files to reflect authorization changes. 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 andDFTNAME(AR880)to set the default program name. TheFIXNBR(*ZONED:*INPUTPACKED)option ensures proper handling of numeric fields. - File Declarations: Defines input files (
ARCONT,ARCUST,ARCUSP,BBORCL,ARCLGR,BBCSR,BBSLSM,GSCONT), an update file (BBORCLAU), and printer files (CREMAL,SMEMAL) for output. The workstation fileAR880Duses a subfile (SFL1) for displaying order details. - Data Structures and Variables: Defines data structures for message handling, display file information, and customer/order data. Arrays and fields store customer credit details, order amounts, and messages.
-
Initial Setup:
- Checks if the control field
qsctlis blank to set indicators for screen display (*IN01,*IN09,*IN02). - If
qsctlis not blank, reads the customer selection screen (AR880S1) and sets indicators accordingly. - Initializes message handling fields and sets the default company number from
GSCONTif available.
- Checks if the control field
-
Main Logic Flow:
- Check for End of Job: If the F3 key (
*INKG) is pressed, the program sets the last record indicator (*INLR) and exits. - Customer Selection Mode:
- If
U8is off (*INU8 = *OFF), the program uses Screen 1 (AR880S1) for customer selection. If the F12 key (*IN88) is pressed, it redisplays Screen 1. - If
U8is on (*INU8 = *ON), the program bypasses Screen 1, using customer data fromAR800(stored inldacc), and proceeds directly to Screen 2.
- If
-
Screen 1 Processing (
S1Subroutine):- Retrieves customer data from
ARCONTandARCUSTusing the company/customer number (cocust). - Validates the customer exists and is not deleted (
ardel <> 'D'). - Populates Screen 2 fields with customer details (name, address, credit limit, aging buckets, etc.) from
ARCUSTandARCUSP. - Checks authorization initials (
aauin) against valid values (ARG,KP,BZ,LM,JM,JS). If invalid, displays an error message. - Calls
S2FILLto preprocess order credit limits and calculate totals. - Reads the credit limit group file (
ARCLGR) to accumulate totals for related customers. - Sets up the subfile for order display by calling
READFW.
- Retrieves customer data from
-
Subfile Processing (Screen 2):
- Clear Subfile (
SF1CLRSubroutine): Clears the subfile (SFL1) and resets the relative record number (rrn1). - Load Subfile (
SF1LODSubroutine): Loads order details (customer, order number, batch, amount, status) into the subfile fromBBORCL. - Read Forward (
READFWSubroutine): Reads orders fromBBORCLfor the selected customer or group, filtering out deleted records (bldel = 'D') and non-over-limit orders (blovcl <> 'Y'). Populates the subfile with up to 9 records per page. -
Display Subfile: Writes the subfile control record (
SFLCTL1) and displays the subfile if records exist (*IN41). Handles user input via theEXFMToperation. -
Order Authorization Processing:
- Process Subfile (
SF1PRCSubroutine): Reads subfile records to process user selections (Afor authorize,Ufor unauthorize). -
Authorize/UnAuthorize (
S2AUTHSubroutine):- Validates the selected order exists in
BBORCLAUand is not deleted (bxdel <> 'D'). - Checks if the order needs authorization (
bxovcl = 'Y'andaunau <> 'Y') or unauthorization (aunau = 'Y'andbxauin <> *BLANKS). - Validates authorization initials (
aauin) against allowed values. - If authorizing, updates
BBORCLAUwith the initials and user ID (auser) via theAUTHexception output. - If unauthorizing, clears the authorization fields in
BBORCLAUvia theUNAUexception output. - Generates email notifications via printer files
CREMAL(CSR/A/R copy) andSMEMAL(salesman copy) with order details, customer info, and credit status. - Sends error messages for invalid cases (e.g., order not found, already authorized, invalid initials).
- Validates the selected order exists in
-
Message Handling:
- Add Message (
ADDMSGSubroutine): Sends error or status messages to the program message queue usingQMHSNDPM. - Write Message (
WRTMSGSubroutine): Displays messages in the message subfile. -
Clear Message (
CLRMSGSubroutine): Clears the message subfile usingQMHRMVPM. -
Subfile Edit (
EDITSFLSubroutine): -
Validates subfile selections to ensure no invalid options are entered when a customer/order is keyed manually.
-
Output Generation:
-
Generates spool files for
CREMALandSMEMALwhen an order is authorized or unauthorized, containing details like order number, customer info, credit limit, aging buckets, and notification recipients (CSR, salesman, A/R clerk). -
Program Exit:
- Exits when the user presses F3 (
*INKG) or completes processing, setting*INLRand returning.
Business Rules¶
- Customer Selection:
- If
U8is off, users must select a customer via Screen 1 (AR880S1). - If
U8is on, customer data is passed fromAR800, bypassing Screen 1. -
The customer must exist in
ARCUSTand not be marked as deleted (ardel <> 'D'). -
Authorization Validation:
- Orders are only displayed if they exceed the credit limit (
blovcl = 'Y'). - Authorization requires valid initials (
ARG,KP,BZ,LM,JM,JS). Invalid initials trigger an error. - An order cannot be authorized if it’s already authorized (
bxauin <> *BLANKS) or doesn’t need authorization (bxovcl <> 'Y'). -
An order cannot be unauthorized if it’s not authorized (
bxauin = *BLANKS). -
Credit Limit and Aging:
- Credit limits and aging buckets (current, 1-30, 31-60, 61-90, over 90 days) are retrieved from
ARCUST. - Totals for related customers in a credit limit group (
ARCLGR) are accumulated for display. -
Available credit is calculated as
s2clmt - s2totd - s2orap. -
Order Processing:
- Orders are read from
BBORCLand updated inBBORCLAU. -
The program accumulates approved (
s2orap) and unapproved (s2onap) order amounts for display. -
Email Notifications:
- When an order is authorized or unauthorized, notifications are sent via
CREMAL(to CSR/A/R) andSMEMAL(to salesman). -
Notifications include order details, customer info, credit limit, aging buckets, and timestamps.
-
Error Handling:
- Errors (e.g., invalid customer, order not found, invalid initials) are displayed via the message subfile.
-
The program prevents invalid subfile selections when manual customer/order input is provided.
-
Modifications (per comments):
- MG02 (11/09/2017): Added email notifications via spool files for CSR and salesman when order status changes.
- MG03 (03/21/2022): Removed beep for successful changes due to user annoyance.
- MG04 (04/08/2022): Removed
JBLISTprinter file output, no longer needed.
Tables (Files) Used¶
The program uses the following files:
1. AR880D: Workstation file (display file) with subfile SFL1 for interactive user interface.
2. ARCONT: Input file for accounts receivable control data (credit limit ranges).
3. ARCUST: Input file for customer master data (name, address, credit limit, aging buckets).
4. ARCUSP: Input file for customer-specific data (contact name).
5. BBORCL: Input file for order credit limit data.
6. ARCLGR: Input file for credit limit group data (related customers).
7. BBORCLAU: Update file for order authorization data.
8. BBCSR: Input file for customer service representative data (CSR ID, name, email).
9. BBSLSM: Input file for salesman data (salesman ID, name, email).
10. GSCONT: Input file for system control data (default company number).
11. CREMAL: Printer file for CSR and A/R email notifications.
12. SMEMAL: Printer file for salesman email notifications.
External Programs Called¶
The program explicitly calls two external programs for message handling: 1. QMHSNDPM: Sends messages to the program message queue for error/status display. 2. QMHRMVPM: Removes messages from the program message queue to clear the message subfile.
Summary¶
The AR880.rpgle program is a customer credit limit authorization inquiry tool that:
- Allows users to select customers and view credit details (via Screen 1 or AR800).
- Displays orders exceeding credit limits in a subfile, allowing authorization or unauthorization.
- Validates inputs (e.g., initials) and updates order authorization data in BBORCLAU.
- Generates email notifications for CSR, A/R, and salesmen when order status changes.
- Handles errors and user interactions via a message subfile.
Tables Used: AR880D, ARCONT, ARCUST, ARCUSP, BBORCL, ARCLGR, BBORCLAU, BBCSR, BBSLSM, GSCONT, CREMAL, SMEMAL.
External Programs Called: QMHSNDPM, QMHRMVPM.