BI890P RPGLE
The BI890P.rpgle.txt
is an RPGLE (RPG IV) program named BI890P
, designed as a "Ship-to Master Inquiry Prompt" for the Customer Orders and Invoicing system on an IBM AS/400 (iSeries) platform. It provides an interactive interface to query and manage ship-to master records, utilizing a subfile (SFL) to display records and handle user interactions. Below, I will explain the process steps, business rules, tables used, and external programs called, based on the provided RPGLE source code.
Process Steps¶
The program follows a structured flow to manage the inquiry process for ship-to master records. The steps are organized into subroutines, executed in a specific sequence:
- Initialization (
*inzsr
Subroutine): - Parameters: Receives two input parameters:
p$fgrp
(1 character): File group identifier ('G' or 'Z') to determine file overrides.p$mode
(3 characters): Mode of operation ('INQ' for inquiry or 'MNT' for maintenance).
- Local Data Area (LDA): Retrieves data from the LDA (fields
l$co
,l$cust
,l$ship
,l$fkey
) for company, customer, ship-to, and function key values. - File Overrides: Applies database file overrides based on
p$fgrp
('G' forgarcust
,gbicont
,gshipto
or 'Z' forzarcust
,zbicont
,zshipto
) using theopntbl
subroutine. - Field Setup: Initializes work fields, subfile control fields (e.g.,
rrn1
,pagsz1
), and date/time fields using the program status data structure (psds##
). - Key Lists: Defines key lists (
kls1s1
,kls1s2
,kls1r1
,klcust
,klcust2
,klshipto
) for file access. -
Mode Check: If
p$mode
is 'MNT', sets indicator*in78
to enable maintenance options. -
Open Database Tables (
opntbl
Subroutine): - Executes file overrides for
arcust
,bicont
, andshipto
based onp$fgrp
using theQCMDEXC
API. -
Opens the
arcust
,bicont
, andshipto
files withusropn
for input-only access. -
Process Subfile (
srsfl1
Subroutine): - Subfile Setup: Initializes the subfile mode (
sfmod1
) to '1' (folded) and clears the message subfile (clrmsg
). - Main Loop (
sf1agn
):- Displays the command line (
sflcmd1
) and message subfile if errors exist (wrtmsg
). - Checks if subfile records exist (
rrn1 > 0
) to set*in41
(SFLDSP). - Sets folded/unfolded mode based on
sfmod1
(*in45
). - Displays the subfile control format (
sflctl1
) usingexfmt
. - Clears message subfile and format indicators after display.
- Determines cursor location (
csrloc
) and sets the subfile record number (rcdnb1
) based onpagrrn
.
- Displays the command line (
-
User Input Handling:
- F03 (Exit): Sets
l$fkey
to 'F03', writes to LDA, and exits the loop. - F04 (Prompt): Calls the
prompt
subroutine to assist with field input (e.g., company or customer lookup). - F05 (Refresh): Triggers subfile repositioning (
repsfl
). - User Positioning: If company (
c$co
), customer (c$cust
), or ship-to (c$ship
) changes, repositions the subfile (sf1rep
). - Direct Access: If
d1opt
ord1ship
is specified, processes direct access (sf1dir
). - Page Down: Loads additional subfile records (
sf1lod
). - Enter Key: Processes subfile selections (
sf1prc
). - F10: Clears cursor position (
row1
,col1
).
- F03 (Exit): Sets
-
Subfile Processing (
sf1prc
Subroutine): - Reads subfile records (
readc sfl1
) ifrrn1 > 0
. -
Processes each record change (
sf1chg
) if a record is read (*in81 = *off
). -
Subfile Record Change (
sf1chg
Subroutine): - Handles subfile options (
s1opt
):- Option 2 (Update): In maintenance mode (
*in78
), setss$ship
and callssf1s02
. - Option 3 (Copy): In maintenance mode, sets
s$ship
and callssf1s03
. - Option 5 (Display): In inquiry mode, sets
s$ship
and callssf1s05
.
- Option 2 (Update): In maintenance mode (
-
Clears the selection field (
s1opt
) and updates the subfile record after applying color coding (sf1color
). -
Subfile Repositioning (
sf1rep
Subroutine): - Clears the subfile (
sf1clr
) and validates control fields (sf1cte
). - If no errors (
*in50 = *off
), positions theshipto
file usingkls1s1
and loads subfile records (sf1lod
). -
Retains control fields (
r$co
,r$cust
,r$ship
) for repositioning and clearsc$ship
. -
Control Field Validation (
sf1cte
Subroutine): - Validates company number (
c$co
) againstbicont
. If invalid or zero, sets error 'ERR0010' and indicators*in50
,*in51
. -
Validates customer number (
c$cust
) againstarcust
. If invalid or zero, sets error 'ERR0010' and indicators*in50
,*in52
. -
Subfile Loading (
sf1lod
Subroutine): - Sets the relative record number (
rrn1
) to the last saved value (rrnsv1
). - Loads up to
pagsz1
(32) records into the subfile:- Reads the next
shipto
record (reade shipto
). - If no records are found (
*in43 = *on
andrrn1 = 0
), adds a "No Results" record (com(01)
). - Formats each record (
sf1fmt
) and writes to the subfile.
- Reads the next
-
Updates
rrnsv1
with the last record number. -
Subfile Formatting (
sf1fmt
Subroutine): - Clears the subfile record and populates fields (
s1ship
,s1name
,s1ctst
,s1adr1
,s1adr2
,s1adr3
,s1stat
,s1cszp
) fromshipto
data. -
Applies color coding (
sf1color
). -
Color Coding (
sf1color
Subroutine):- Sets
*in77
if the record is flagged for deletion (s1del = 'D'
).
- Sets
-
Direct Access (
sf1dir
Subroutine):- Validates direct input (
d1opt
,d1ship
): - For option 1 (Create) in maintenance mode, ensures
c$co
,c$cust
, andd1ship
are non-zero; otherwise, sets error 'ERR0103'. - Checks if the ship-to exists (
setll shipto
). - For option 2 (Update), errors if the ship-to does not exist ('ERR0102').
- For option 1 (Create), errors if the ship-to already exists ('ERR0101').
- If no errors, processes options (calls
sf1s01
,sf1s02
,sf1s03
, orsf1s05
).
- Validates direct input (
-
Option Processing:
- Create (
sf1s01
): Sets LDA fields (l$co
,l$cust
,l$ship
), clearsl$fkey
, writes to LDA, and exits the loop. - Update (
sf1s02
): Same assf1s01
. - Copy (
sf1s03
): Callssf1cpy
to handle copying a ship-to record. - Display (
sf1s05
): Sets LDA fields and exits the loop.
- Create (
-
Copy Processing (
sf1cpy
Subroutine):- Initializes window fields (
c$tcnm
,w$tcst
,w$tshp
) and enters a loop (winagn
). - Displays the copy window (
sflcpy1
) and processes input: - F04: Calls
prompt
. - F12: Exits the window.
- F22: No action defined.
- Validates input (
sf1cpyedt
). - If no errors, calls
BI8903
with parameters (c$co
,c$cust
,s$ship
,w$tcst
,w$tshp
,p$fgrp
), updates LDA, and exits both window and main loops.
- Initializes window fields (
-
Copy Input Validation (
sf1cpyedt
Subroutine):- Validates target customer (
w$tcst
) againstarcust
. If invalid, sets error 'ERR0010'. - Ensures target ship-to (
w$tshp
) is non-zero; otherwise, sets error 'ERR0000' with messagecom(02)
. - Checks if the target ship-to exists (
chain shipto
). If it does, sets error 'ERR0000' with messagecom(03)
.
- Validates target customer (
-
Field Prompting (
prompt
Subroutine):- For
SFLCTL1
format: - If
C$CO
, callsLBICONT
to prompt for company. - If
C$CUST
, callsLARCUST
to prompt for customer. - For
SFLCPY1
format: - If
W$TCST
, callsLARCUST
and updatesc$tcnm
.
- For
-
Message Handling:
- Add Message (
addmsg
): Sends error messages to the program message queue usingQMHSNDPM
. - Write Message (
wrtmsg
): Displays the message subfile (msgctl
). - Clear Message (
clrmsg
): Clears the message subfile usingQMHRMVPM
.
- Add Message (
-
Program Termination:
- Closes all files (
close *all
). - Sets
*inlr = *on
and returns.
- Closes all files (
Business Rules¶
- Access Control:
- The program operates in two modes: Inquiry (
INQ
) and Maintenance (MNT
). -
Maintenance mode (
*in78 = *on
) enables options 1 (Create), 2 (Update), and 3 (Copy). Inquiry mode enables option 5 (Display). -
Validation:
- Company (
c$co
) must exist inbicont
or an error ('ERR0010') is displayed. - Customer (
c$cust
,w$tcst
) must exist inarcust
or an error ('ERR0010') is displayed. - For Create (
d1opt = 1
), the ship-to (d1ship
) must not exist (ERR0101
) and must be non-zero (ERR0103
). - For Update (
d1opt = 2
), the ship-to must exist (ERR0102
). -
For Copy, the target ship-to (
w$tshp
) must be non-zero (ERR0000
,com(02)
) and must not exist (ERR0000
,com(03)
). -
Subfile Management:
- The subfile displays up to 32 records per page (
pagsz1
). - If no records are found, a "No Results" message (
com(01)
) is displayed. -
Deleted records (
s1del = 'D'
) are color-coded (*in77
). -
Navigation and Input:
- Users can reposition the subfile by entering company, customer, or ship-to values.
- Function keys:
- F03: Exit the program.
- F04: Prompt for company or customer selection.
- F05: Refresh the subfile.
- F10: Position cursor to the control record.
- F12: Cancel copy window.
- Page Down: Load the next page of records.
-
Direct access (
d1opt
,d1ship
) allows quick navigation to specific records. -
Copy Functionality:
- Copying a ship-to record requires a valid target customer and a non-existing target ship-to number.
-
The
BI8903
program is called to perform the copy operation. -
Error Handling:
- Errors are displayed in a message subfile (
msgctl
) with codes like 'ERR0010', 'ERR0101', 'ERR0102', 'ERR0103', and 'ERR0000'. - Messages are cleared after each display cycle unless errors persist.
Tables (Files) Used¶
The program uses the following database files (tables) with input-only access (if
and usropn
):
1. arcust: Customer master file (contains customer data, e.g., arname
).
2. bicont: Contract or company master file (contains company data, e.g., bcname
).
3. shipto: Ship-to master file (contains ship-to data, e.g., `csship梗
System: hip,
csname,
csctst,
csadr1,
csadr2,
csadr3,
csstat,
cscszp).
4. **bi890pd**: Display file (workstation file with subfile
sfl1and control formats like
sflctl1,
sflcmd1,
sflcpy1,
msgctl,
msgclr,
wdwovr`).
External Programs Called¶
The program calls the following external programs:
1. QCMDEXC: System API to execute file override commands (ovrdbf
) for arcust
, bicont
, and shipto
.
2. QMHSNDPM: System API to send error messages to the program message queue.
3. QMHRMVPM: System API to clear messages from the program message queue.
4. LBICONT: Called during prompting (F04
) for company selection, passing c$co
and p$fgrp
.
5. LARCUST: Called during prompting (F04
) for customer selection, passing c$co
, c$cust
or w$tcst
, and p$fgrp
.
6. BI8903: Called during copy processing (sf1cpy
), passing c$co
, c$cust
, s$ship
, w$tcst
, w$tshp
, and p$fgrp
.
Summary¶
The BI890P
program is an interactive inquiry and maintenance tool for ship-to master records, using a subfile to display data and handle user interactions. It supports:
- Inquiry and maintenance modes, with validation for company, customer, and ship-to data.
- Subfile navigation, error handling, and color-coded displays for deleted records.
- Copy functionality via a window, calling BI8903
for record creation.
- Prompting for company and customer selection via LBICONT
and LARCUST
.
- File overrides based on the file group ('G' or 'Z').
The program integrates with arcust
, bicont
, and shipto
files, ensuring robust data access and validation. It uses system APIs for command execution and message handling, and external programs for specific tasks like prompting and copying records.
If you need further details or analysis of specific subroutines or business logic, please let me know!