AR915 RPGLE
The RPGLE program AR915 is a customer form type contacts maintenance and inquiry program within the Customer Master Information system. It is called from the main program AR915P (as seen in the previous document) to handle the creation, updating, or displaying of individual customer form type contact records. The program supports both maintenance (MNT) and inquiry (INQ) modes, providing a user interface to manage contact details such as form type, contact name, email, and various flags. Below is a detailed explanation of the process steps, business rules, database tables used, and external programs called.
Process Steps of the AR915 Program¶
The AR915 program follows a structured flow to manage a single customer form type contact record through a display file interface. The process steps are organized by the main subroutines:
- Program Initialization (
*inzsr): - Purpose: Initializes variables, defines key lists, and processes input parameters.
-
Actions:
- Defines the parameter list for receiving input parameters:
p$cono(company),p$seq#(sequence number),p$cust(customer),p$mode(run mode: 'MNT' or 'INQ'),p$fgrp(file group: 'Z' or 'G'), andp$flag(return flag). - Moves input parameters to display file fields (
f$cono,f$seq#) and initializes output parameters (o$fgrp,o$mode,o$flag). - Defines key lists (
klcufm,klcust,klfrmtyp) for database operations. - Initializes work fields, message handling fields, and date validation parameters.
- Sets up the display file fields and headers based on the mode (
MNTorINQ).
- Defines the parameter list for receiving input parameters:
-
Open Database Tables (
opntbl): - Purpose: Opens the required database files with appropriate overrides based on the file group (
p$fgrp). -
Actions:
- Checks if
p$fgrpis 'G' or 'Z' to apply the correct file overrides (ovgorovz) using theQCMDEXCcommand. - Opens files
arcust,gstabl,arcufm, andbicontwith user-controlled open (usropn).
- Checks if
-
Retrieve Data for Passed Parameters (
rtvdta): - Purpose: Retrieves data for the provided company, sequence number, and customer to populate the display file fields.
-
Actions:
- Chains to
arcufmusingklcufm(company, sequence number) to retrieve the contact record; if not found (*in99), clears the record and setsfmcusttop$cust. - Sets
w$existsto indicate whether the record exists. - Chains to
bicontto validate the company code (f$cono); clearsbcnameif not found. - Chains to
arcustto validate the customer code (fmcust); clearsarnameif not found. - Sets the display header (
c$hdr1) and protection indicator (*in70) based onp$mode('MNT' for maintenance, 'INQ' for inquiry).
- Chains to
-
Process Panel Formats (
srfmt): - Purpose: Manages the main loop for displaying and processing the panel format (
fmt01). -
Actions:
- Clears the screen (
clrscr). - Initializes the panel format (
f01mov) and sets the format name toFMT01. - Enters a loop (
fmtagn) that: - Displays the message subfile if needed (
wrtmsg) or clears the screen. - Displays the
fmt01format usingexfmtand clears error indicators (*in50-*in69). - Processes user input via
f01sr. - Clears the message subfile (
clrmsg) if displayed. - Continues until
fmtagnis turned off (e.g., via F12 or inquiry mode completion).
- Clears the screen (
-
Process Format (
f01sr): - Purpose: Handles user input for the
fmt01format based on function keys or ENTER. -
Actions:
- Processes function keys:
- F04: Calls the
promptsubroutine for field prompting. - F10: Resets the cursor position (
row,col) to home. - F12: Exits the program by setting
fmtagnto off. - In inquiry mode (
p$mode = 'INQ'), determines the next format (f01nxt) and exits. - For ENTER, validates input (
f01edt) and, if no errors (*in50 = *off), updates the database (upddbf) in maintenance mode and determines the next format (f01nxt).
-
Determine Next Format (
f01nxt): - Purpose: Decides whether to continue or exit the panel loop.
-
Actions:
- If no input change occurred (
*in19 = *off), setsfmtagnto off to exit the loop. - Note: The subroutine is prepared to handle a second format (
FMT02), but it is commented out, so the program only usesFMT01.
- If no input change occurred (
-
Edit Format Input (
f01edt): - Purpose: Validates user input fields in maintenance mode.
-
Actions:
- Validates form type code (
fmfmty) by chaining togstablusingklfrmtyp; if valid and not deleted, setsf$fmtyto the description; else, adds error messageERR0010and sets*in50,*in51. - Checks if contact name (
fmcntc) is non-blank; if blank, adds error messageERR0012and sets*in50,*in52. - Validates send original flag (
fmfmyn), reprint flag (fmrpyn), mail flag (fmmlyn), and back terms flag (fmbkyn); each must be 'Y' or 'N', else adds error messageERR0014and sets*in50,*in55-*in58as appropriate. - Validates email address (
fmemla): - As of the 08/30/22 revision (JK01), fax number validation is removed.
- If
fmemlais non-blank, callsVALMAILIDto validate the email; if invalid (p$valid = 'N'), adds error messageERR0000withcom(02)("Invalid Email Address Entered") and sets*in50,*in53. - Allows blank email if
fmfmyn = 'N'(no original sent). - In inquiry mode (
p$mode = 'INQ'), clears error indicators and messages.
- Validates form type code (
-
Initialize Format Field Values (
f01mov): - Purpose: Initializes the
fmt01format fields and clears any prior errors. -
Actions:
- Calls
f01edtto validate fields. - If errors exist (
*in50), clears error indicators and messages (clrmsg).
- Calls
-
Format Protection Schemes (
f01pro): - Purpose: Sets field protection indicators based on the mode.
-
Actions:
- Clears protection indicators (
*in70-*in74). - In inquiry mode (
p$mode != 'MNT'), sets*in70-*in73to protect fields. - Note: Protection for existing records (
w$exists) is commented out, so key fields are not protected based on record existence.
- Clears protection indicators (
-
Update Database Files (
upddbf):- Purpose: Updates or creates a record in
arcufmin maintenance mode. - Actions:
- If
f$seq#is zero, retrieves the next sequence number (rtvnxtseq). - Saves the current
arcufmrecord fields tosvds. - Chains to
arcufmusingklcufm:- If found (
*in80 = *off), updates the record if changes exist (svds != wkds01) and setsp$flag = '1'. - If not found, creates a new record with
f$conoandf$seq#, writes toarcufm, and setsp$flag = '1'.
- If found (
- Sets
w$existsto indicate the record now exists.
- Purpose: Updates or creates a record in
-
Retrieve Next Sequence Number (
rtvnxtseq):- Purpose: Generates the next sequence number for a new
arcufmrecord. - Actions:
- Chains to
bicontto get the current sequence number (bcseqn). - Increments
f$seq#until a unique value is found by checkingarcufmwithklcufm. - Increments
bcseqninbicontand updates the record.
- Purpose: Generates the next sequence number for a new
-
Field Prompting (
prompt):- Purpose: Provides lookup functionality for the form type field.
- Actions:
- If the cursor is on
FMFMTYand input is not protected (*in70), callsLGSTABLto prompt for a form type code. - Updates
fmfmtywith the selected value if non-blank. - Sets
*in19to indicate a panel format change.
-
Message Handling (
addmsg,wrtmsg,clrmsg):- Purpose: Manages error and confirmation messages displayed in the message subfile.
- Actions:
addmsg: Sends messages to the program message queue usingQMHSNDPMwith message ID, file, data, and type.wrtmsg: Writes the message subfile control (msgctl) with*in49on.clrmsg: Clears the message subfile usingQMHRMVPMand restores the current record format and page number.
-
Program Termination:
- Purpose: Closes files and exits.
- Actions:
- Closes all open files (
close *all). - Sets
*inlrto*onand returns control to the calling program (AR915P).
Business Rules¶
The program enforces the following business rules during input validation and processing:
1. Form Type Code (fmfmty):
- Must exist in the gstabl file with type FRMTYP and not be marked deleted (tbdel != 'D').
- If invalid, displays error ERR0010 and sets error indicators.
- Contact Name (
fmcntc): - Must be non-blank.
-
If blank, displays error
ERR0012and sets error indicators. -
Email Address (
fmemla): - As of the 08/30/22 revision, fax number validation is removed, and email is the primary contact method.
- If non-blank, must be valid as determined by the
VALMAILIDprogram (p$valid = 'Y'). - If invalid, displays error
ERR0000with message "Invalid Email Address Entered". -
Can be blank if
fmfmyn = 'N'(no original sent); otherwise, a non-blank email is required iffmfmynis 'Y' or blank. -
Flags (
fmfmyn,fmrpyn,fmmlyn,fmbkyn): - Each flag (send original, reprint, mail, back terms) must be 'Y' or 'N'.
-
If invalid, displays error
ERR0014and sets corresponding error indicators (*in55-*in58). -
Mode-Based Behavior:
- In maintenance mode (
p$mode = 'MNT'), fields are editable, and updates are written toarcufm. - In inquiry mode (
p$mode = 'INQ'), fields are protected (*in70-*in73), errors are cleared, and no database updates occur. -
The display header changes based on the mode: "Customer Form Type Contacts Maintenance" for
MNT, "Customer Form Type Contacts Inquiry" forINQ. -
Sequence Number Generation:
- For new records (
f$seq# = 0), the next sequence number is retrieved frombicont(bcseqn) and incremented until a unique value is found inarcufm. -
The
bicontrecord is updated with the new sequence number. -
Database Updates:
- In maintenance mode, updates or creates records in
arcufmonly if input validation passes. -
Sets
p$flag = '1'to indicate a successful update or creation. -
Field Prompting:
- The form type code (
fmfmty) can be prompted via F04, callingLGSTABLto select a valid value.
Database Tables Used¶
The program uses the following database files, all opened with usropn:
1. arcust:
- Purpose: Customer master file for validating customer codes.
- Usage: Chained to using klcust (company, customer) to retrieve arname (customer name).
- Access: Input only, keyed (k disk).
- Override: garcust (for 'G' file group) or zarcust (for 'Z' file group).
- gstabl:
- Purpose: General table file for validating form type codes.
- Usage: Chained to using
klfrmtyp(typeFRMTYP, codefmfmty) to retrievetbdesc(description). - Access: Input only, keyed (
k disk). -
Override:
ggstabl(for 'G') orzgstabl(for 'Z'). -
arcufm:
- Purpose: Primary file for customer form type contact records.
- Usage: Chained to for retrieving records (
klcufm), updated, or written to in maintenance mode. - Access: Update and add, keyed (
uf a e k disk). -
Override:
garcufm(for 'G') orzarcufm(for 'Z'). -
bicont:
- Purpose: Company master file for validating company codes and managing sequence numbers.
- Usage: Chained to for validating
f$conoand retrievingbcname; updated to incrementbcseqnfor new records. - Access: Update, keyed (
uf e k disk). -
Override:
gbicont(for 'G') orzbicont(for 'Z'). -
ar915d:
- Purpose: Display file for the user interface.
- Usage: Contains the
fmt01format and message subfile control (msgctl) for interactive display and input. - Access: Work station file (
cf e workstn).
External Programs Called¶
The program interacts with the following external programs:
1. LGSTABL:
- Called in subroutine prompt.
- Parameters: k$ft (table type, set to FRMTYP), k$fmty (form type code), o$fgrp (file group).
- Purpose: Provides a lookup window for selecting a valid form type code.
- VALMAILID:
- Called in subroutine
f01edt(added in 08/30/22 revision). - Parameters:
p$email(email address, 100 characters),p$valid(validity flag, 'Y' or 'N'). -
Purpose: Validates the email address entered in
fmemla. -
QCMDEXC:
- Called in subroutine
opntbl. - Parameters:
dbov##(override command),dbol##(command length). -
Purpose: Executes file override commands for
arcust,gstabl,arcufm, andbicont. -
QMHSNDPM:
- Called in subroutine
addmsg. - Parameters:
m@id(message ID),m@msgf(message file),m@data(message data),m@l(message length),m@type(message type),m@pgmq(program message queue),m@scnt(stack counter),m@key(message key),m@errc(error code). -
Purpose: Sends messages to the program message queue.
-
QMHRMVPM:
- Called in subroutine
clrmsg. - Parameters:
m@pgmq(program message queue),m@scnt(stack counter),m@rmvk(message key),m@rmv(remove option),m@errc(error code). - Purpose: Removes messages from the program message queue.
Summary¶
The AR915 program, called by AR915P, provides a detailed interface for maintaining or inquiring about customer form type contact records. It supports creating new records, updating existing ones, and displaying details in a single-panel format (fmt01). The program enforces strict validation rules for form type, contact name, email, and flags, with email validation introduced in the 08/30/22 revision. It uses four database files (arcust, gstabl, arcufm, bicont) with dynamic overrides and interacts with external programs for field prompting and email validation. The program ensures data integrity through comprehensive input validation and provides user feedback via a message subfile.