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 (
*inzsr
Subroutine): - Receives input parameters:
p$co
(company number),p$cst
(customer number),p$shp
(ship-to number),p$mode
(run mode:MNT
orINQ
), andp$fgrp
(file group:Z
orG
). - Retrieves the local data area (
lda
) to access environment information (e.g.,tstprd
for 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
arcupr
using 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$mode
and protection settings.
- If found, sets to "Update Mode" (
-
Sets the current date and time using the
TIME
operation, formatting it into thet#cymd
data structure. -
Open Database Tables (
opntbl
Subroutine): - Applies file overrides based on the
p$fgrp
parameter (Z
orG
) for filesgstabl
,arcupr
,bicont
,gsprod
,arcust
,shipto
, andarcuphs
using theQCMDEXC
API. - Opens these files with the
usropn
option for input or update, and opensbi907w
without override (as it is inQTEMP
). -
Files are opened for read-only (
if
) or read/write (uf
) access as needed. -
Subfile Processing (
srsfl1
Subroutine): - Clear Message Subfile: Calls
clrmsg
to clear messages andwrtmsg
to write the message control record. - Default Values: Sets the default company number (
c1cono = 10
). - Position File: Calls
sf1rep
to 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 (msgctl
ormsgclr
). - 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
prompt
for control or subfile fields). - F05: Refreshes the subfile by clearing
r$cnty
and 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 (
prompt
Subroutine): - Handles prompting for fields in
SFLCTL1
orSFL1
:- For
C1CUST
orC1SHIP
: CallsLARCUST
orLCSTSHP
to select customer or ship-to. - For
S1PROD
orC1PROD
: CallsLGSPROD
to select a product. - For
S1FRCD
: CallsLTABLE
to select a freight code. - For
S1CNTY
: CallsLTABLE
to select a container type.
- For
-
Updates fields with selected values and sets
*in19
for input change. -
Subfile Processing (
sf1pro
Subroutine): - 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
arcupr
orbi907w
based on the mode (s1updt
). - Writes history records to
arcuphs
for changes or deletions. -
Updates the subfile with formatted data (
sf1fmt
) and applies color coding (sf1col
). -
Reposition Subfile (
sf1rep
Subroutine): - 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 (
sf1lod
Subroutine): - Reads records from
arcupr
orbi907w
based 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 (
sf1val
Subroutine): - Validates freight code (
s1frcd
) againstgstabl
(table typeBBFRCD
). - Validates container type (
s1cnty
) againstgstabl
(table typeCNTRTY
). - Enforces business rules for freight codes (e.g.,
C
requiress1sfrt
ands1cafr
to beY
,N
, or blank;A
requiress1sfrt = 'Y'
). -
Sets error indicators and messages for invalid inputs.
-
Copy Alternate Description (
sf1cpy
Subroutine): - Copies product descriptions from an alternate customer/ship-to pair to the current record.
-
Updates the subfile and writes history records.
-
History Inquiry (
histinq
Subroutine):- Calls
GB730P
to 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 = *on
and returns.
Business Rules¶
The BI907
program enforces the following business rules:
- Mode-Based Processing:
- In
MNT
mode, users can add, update, or delete records; input fields are editable (*in71 = *off
). -
In
INQ
mode, 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
arcuphs
for 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 (
Z
orG
) 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
,sf1pro
for 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:
sf1fmt
to retrieve product descriptions (tpdesc
). - Override:
ggsprod
(G group) orzgsprod
(Z group). -
Access: Input (
if
). -
arcust:
- Purpose: Stores customer master data.
- Used in:
sf1val
to validate customer numbers. - Override:
garcust
(G group) orzarcust
(Z group). -
Access: Input (
if
). -
shipto:
- Purpose: Stores ship-to data.
- Used in:
sf1val
to 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:
sf1pro
to log changes or deletions. - Override:
garcuphs
(G group) orzarcuphs
(Z group). -
Access: Output (
o
). -
bi907w:
- Purpose: Temporary work file in
QTEMP
for processing customer/ship-to data. - Used in:
sf1pro
,sf1lod
for 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:
prompt
subroutine forC1SHIP
. -
Parameters:
x$cstshp
(data structure with company, search, customer, ship-to, flag, file group). -
LGSPROD:
- Purpose: Prompts for product selection.
- Called in:
prompt
subroutine forS1PROD
andC1PROD
. -
Parameters:
o$co
(company),o$prod
(product),o$fgrp
(file group). -
LTABLE:
- Purpose: Prompts for table codes (freight code or container type).
- Called in:
prompt
subroutine forS1FRCD
andS1CNTY
. -
Parameters:
o$tbcd
(table code),o$tbty
(table type),o$flag
(flag). -
GB730P:
- Purpose: Displays historical data for customer/ship-to/product.
- Called in:
histinq
subroutine. -
Parameters:
x$arcuprhist
(data structure with file, file group, company, customer, ship-to, product, container type). -
QCMDEXC:
- Purpose: Executes file override commands.
- Called in:
opntbl
subroutine. -
Parameters:
dbov##
(override command),dbol##
(command length). -
QMHSNDPM:
- Purpose: Sends messages to the program message queue.
- Called in:
addmsg
subroutine. -
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:
clrmsg
subroutine. - 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
).