BI907 RPGLE
The provided RPGLE program, BI907, is a core component of the Bradford Order Entry/Invoices system, designed for customer and ship-to file maintenance and inquiry. It is called by the BI907C CLP program, which sets up a temporary work file and passes parameters to BI907. This program manages a subfile-based interface to allow users to maintain or inquire about customer/ship-to product descriptions and freight terms. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.
Process Steps of the BI907 RPGLE Program¶
The BI907 program is an interactive workstation program that uses a display file (bi907d) with a subfile (sfl1) to present and manage customer/ship-to data. It operates in either maintenance (MNT) or inquiry (INQ) mode, with functionality to add, update, or delete records, and includes features like field prompting, history inquiry, and copy functionality. The process steps are as follows:
- Initialization (
*inzsrSubroutine): - Receives input parameters:
p$co(company number),p$cst(customer number),p$shp(ship-to number),p$mode(run mode:MNTorINQ), andp$fgrp(file group:ZorG). - Retrieves the local data area (
lda) to access environment information (e.g.,tstprdfor test/production indicator). - Sets the header (
c$hdr1) based on the mode: "Customer & Ship To File Maint" forMNT, or "Customer & Ship To File Inquiry" forINQ. - Sets global protection indicator (
*in71) to protect input fields in inquiry mode (INQ). - Initializes subfile control fields (
rrn1,rrnsv1), page size (pagsz1 = 12), and mode flags (c1mode,s1updt,s1f10d). - Checks if a record exists in
arcuprusing the key listkls1s1(company, customer, ship-to):- If found, sets to "Update Mode" (
*in87 = *on,s1f10d = "F10=All Mode",c1mode = "Update Mode"). - If not found, sets to "All Mode" or "Add Mode" based on
p$modeand protection settings.
- If found, sets to "Update Mode" (
-
Sets the current date and time using the
TIMEoperation, formatting it into thet#cymddata structure. -
Open Database Tables (
opntblSubroutine): - Applies file overrides based on the
p$fgrpparameter (ZorG) for filesgstabl,arcupr,bicont,gsprod,arcust,shipto, andarcuphsusing theQCMDEXCAPI. - Opens these files with the
usropnoption for input or update, and opensbi907wwithout override (as it is inQTEMP). -
Files are opened for read-only (
if) or read/write (uf) access as needed. -
Subfile Processing (
srsfl1Subroutine): - Clear Message Subfile: Calls
clrmsgto clear messages andwrtmsgto write the message control record. - Default Values: Sets the default company number (
c1cono = 10). - Position File: Calls
sf1repto position the file cursor based on input parameters. - Suppress Initial Errors: Clears error indicators and messages on the first display (
w$frst = *on). -
Main Loop (
sf1agn):- Repositions the subfile if needed (
repsfl = *on) by updating control fields (c1prod,c1cnty) and callingsf1rep. - Sets cursor position for add mode (
row1 = 10,col1 = 02,*in75 = *on) or clears it for other modes. - Displays the command line (
sflcmd1) and message subfile (msgctlormsgclr). - Checks if the subfile has records (
rrn1 > 0) to enable display (*in41). - Writes and formats the subfile control record (
sflctl1) usingexfmt. - Clears message subfile if errors are present.
- Processes user input via function keys or direct access:
- F03: Exits the program.
- F04: Prompts for field input (calls
promptfor control or subfile fields). - F05: Refreshes the subfile by clearing
r$cntyand repositioning. - F08: Copies alternate descriptions (
sf1cpy). - F09: Calls history inquiry (
histinq). - F10: Toggles between "Add Mode," "Update Mode," and "All Mode" (
c1mode,s1updt,*in87,s1f10d). - ENTER: Processes subfile changes (
sf1pro). - Updates cursor location (
row1,col1) and subfile record number (rcdnb1) for redisplay.
- Repositions the subfile if needed (
-
Field Prompting (
promptSubroutine): - Handles prompting for fields in
SFLCTL1orSFL1:- For
C1CUSTorC1SHIP: CallsLARCUSTorLCSTSHPto select customer or ship-to. - For
S1PRODorC1PROD: CallsLGSPRODto select a product. - For
S1FRCD: CallsLTABLEto select a freight code. - For
S1CNTY: CallsLTABLEto select a container type.
- For
-
Updates fields with selected values and sets
*in19for input change. -
Subfile Processing (
sf1proSubroutine): - Reads changed subfile records (
readc sfl1) ifrrn1 > 0. - Validates input (
sf1val) for fields like freight code (s1frcd), container type (s1cnty), and separate freight (s1sfrt). - Updates or adds records to
arcuprorbi907wbased on the mode (s1updt). - Writes history records to
arcuphsfor changes or deletions. -
Updates the subfile with formatted data (
sf1fmt) and applies color coding (sf1col). -
Reposition Subfile (
sf1repSubroutine): - Clears the subfile (
sf1clr) and resetsrrn1. - Loads records into the subfile (
sf1lod) based on key lists (kls1s1,kls1s2). -
Filters records by company, customer, ship-to, product, and container type.
-
Load Subfile Records (
sf1lodSubroutine): - Reads records from
arcuprorbi907wbased on key lists. - Filters records based on mode and user input (e.g.,
c1prod,c1cnty). - Formats each record (
sf1fmt) and applies color coding (sf1col). -
Writes records to the subfile, incrementing
rrn1. -
Validate Subfile Input (
sf1valSubroutine): - Validates freight code (
s1frcd) againstgstabl(table typeBBFRCD). - Validates container type (
s1cnty) againstgstabl(table typeCNTRTY). - Enforces business rules for freight codes (e.g.,
Crequiress1sfrtands1cafrto beY,N, or blank;Arequiress1sfrt = 'Y'). -
Sets error indicators and messages for invalid inputs.
-
Copy Alternate Description (
sf1cpySubroutine): - Copies product descriptions from an alternate customer/ship-to pair to the current record.
-
Updates the subfile and writes history records.
-
History Inquiry (
histinqSubroutine):- Calls
GB730Pto display historical data for the selected customer/ship-to/product.
- Calls
-
Message Handling:
- Add Message (
addmsg): Sends error messages to the program message queue usingQMHSNDPM. - Write Message Subfile (
wrtmsg): Displays the message subfile. - Clear Message Subfile (
clrmsg): Clears messages usingQMHRMVPM.
- Add Message (
-
Program Termination:
- Closes all open files.
- Sets
*inlr = *onand returns.
Business Rules¶
The BI907 program enforces the following business rules:
- Mode-Based Processing:
- In
MNTmode, users can add, update, or delete records; input fields are editable (*in71 = *off). -
In
INQmode, fields are protected (*in71 = *on), allowing only viewing of records. -
Freight Code Validation (JB01, JB02 Revisions):
- Freight code (
s1frcd) must exist ingstabl(table typeBBFRCD). - For freight code
C(freight collect):- Separate freight (
s1sfrt) and calculate freight (s1cafr) must beY,N, or blank.
- Separate freight (
- For freight code
A(non-Bradford location, e.g., Anchor):- Separate freight (
s1sfrt) must beY.
- Separate freight (
-
For freight code
CYY(freight collect with service fee, JB02):- Represents a situation where shipping is arranged by ARG but billed to the customer by the carrier, with a $100 service fee charged to the customer.
-
Container Type Validation:
-
Container type (
s1cnty) must exist ingstabl(table typeCNTRTY). -
Record Existence and Deletion:
- Prevents adding a record if it already exists or is marked as deleted.
- Allows reactivation of deleted records.
-
Records deleted or reactivated are logged in
arcuphsfor history. -
Mode Toggling:
-
Users can toggle between "Add Mode," "Update Mode," and "All Mode" using F10, controlling whether new records can be added or existing records updated.
-
File Group Flexibility:
-
Supports different file sets (
ZorG) via overrides, allowing the program to work with different data environments. -
Error Handling:
- Validates all user inputs and displays specific error messages (e.g., "Invalid Freight Code," "Must Enter At Least One Product Code in ADD Mode").
- Ensures at least one product code is entered in add mode.
Tables Used¶
The program uses the following database files, opened with the usropn option and overridden based on the file group (Z or G):
1. gstabl:
- Purpose: Stores table data for freight codes (BBFRCD) and container types (CNTRTY).
- Used in: sf1val to validate s1frcd and s1cnty.
- Override: ggstabl (G group) or zgstabl (Z group).
- Access: Input (if).
- arcupr:
- Purpose: Stores customer/ship-to cross-reference data.
- Used in:
sf1rep,sf1lod,sf1profor reading, adding, or updating records. - Override:
garcupr(G group) orzarcupr(Z group). -
Access: Update (
uf a). -
bicont:
- Purpose: Stores company information.
- Used in: Validates company number (
c1cono). - Override:
gbicont(G group) orzbicont(Z group). -
Access: Input (
if). -
gsprod:
- Purpose: Stores product information.
- Used in:
sf1fmtto retrieve product descriptions (tpdesc). - Override:
ggsprod(G group) orzgsprod(Z group). -
Access: Input (
if). -
arcust:
- Purpose: Stores customer master data.
- Used in:
sf1valto validate customer numbers. - Override:
garcust(G group) orzarcust(Z group). -
Access: Input (
if). -
shipto:
- Purpose: Stores ship-to data.
- Used in:
sf1valto validate ship-to codes. - Override:
gshipto(G group) orzshipto(Z group). -
Access: Input (
if). -
arcuphs:
- Purpose: Stores history records for customer/ship-to changes.
- Used in:
sf1proto log changes or deletions. - Override:
garcuphs(G group) orzarcuphs(Z group). -
Access: Output (
o). -
bi907w:
- Purpose: Temporary work file in
QTEMPfor processing customer/ship-to data. - Used in:
sf1pro,sf1lodfor temporary storage and processing. - Access: Update (
uf a).
External Programs Called¶
The BI907 program calls the following external programs:
1. LARCUST:
- Purpose: Prompts for customer selection.
- Called in: prompt subroutine for C1CUST.
- Parameters: o$co (company), o$cust (customer), o$fgrp (file group).
- LCSTSHP:
- Purpose: Prompts for ship-to selection.
- Called in:
promptsubroutine forC1SHIP. -
Parameters:
x$cstshp(data structure with company, search, customer, ship-to, flag, file group). -
LGSPROD:
- Purpose: Prompts for product selection.
- Called in:
promptsubroutine forS1PRODandC1PROD. -
Parameters:
o$co(company),o$prod(product),o$fgrp(file group). -
LTABLE:
- Purpose: Prompts for table codes (freight code or container type).
- Called in:
promptsubroutine forS1FRCDandS1CNTY. -
Parameters:
o$tbcd(table code),o$tbty(table type),o$flag(flag). -
GB730P:
- Purpose: Displays historical data for customer/ship-to/product.
- Called in:
histinqsubroutine. -
Parameters:
x$arcuprhist(data structure with file, file group, company, customer, ship-to, product, container type). -
QCMDEXC:
- Purpose: Executes file override commands.
- Called in:
opntblsubroutine. -
Parameters:
dbov##(override command),dbol##(command length). -
QMHSNDPM:
- Purpose: Sends messages to the program message queue.
- Called in:
addmsgsubroutine. -
Parameters:
m@id(message ID),m@msgf(message file),m@data(message data),m@l(data length),m@type(message type),m@pgmq(program queue),m@scnt(stack counter),m@key(message key),m@errc(error code). -
QMHRMVPM:
- Purpose: Removes messages from the program message queue.
- Called in:
clrmsgsubroutine. - Parameters:
m@pgmq(program queue),m@scnt(stack counter),m@rmvk(message key),m@rmv(remove option),m@errc(error code).
Summary¶
The BI907 RPGLE program is a comprehensive tool for maintaining and inquiring about customer/ship-to data within the Bradford Order Entry/Invoices system. It provides a subfile-based interface for adding, updating, or viewing records, with robust validation for freight codes, container types, and other fields. The program supports special freight scenarios (e.g., non-Bradford locations, freight collect with service fees) and logs changes to a history file. It integrates with multiple database files and external programs for prompting and history inquiry, ensuring flexibility and user interaction. The temporary work file in QTEMP (set up by BI907C) supports processing, and file overrides allow operation across different data environments (Z or G).