BI8903 RPGLE
The BI8903.rpgle.txt
is an RPGLE (RPG IV) program named BI8903
, designed for the Brandford Order Entry / Invoices system on an IBM AS/400 (iSeries) platform. It is responsible for copying ship-to records from one customer/ship-to combination to another, updating multiple related files. 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 copy ship-to records and their associated data, organized into subroutines executed sequentially:
- Initialization (
*inzsr
Subroutine): - Parameters: Receives six input parameters:
p$co
(2 digits): Company number.p$fcust
(6 digits): Source customer number (copy from).p$fshp
(3 digits): Source ship-to number (copy from).p$tcust
(6 digits): Target customer number (copy to).p$tshp
(3 digits): Target ship-to number (copy to).p$fgrp
(1 character): File group identifier ('G' or 'Z') for file overrides.
- Field Setup: Initializes key fields (
dsco
,dstcust
,dstshp
) with input parameters (p$co
,p$tcust
,p$tshp
) for use in key lists. - Key Lists: Defines two key lists:
klFrmShipto
: For accessing source records (p$co
,p$fcust
,p$fshp
).KlToShipto
: For checking target records (p$co
,p$tcust
,p$tshp
).
- Data Structures: Defines external data structures (
wkds01
,wkds02
,wkds03
,wkds04
) forshipto
,arcupr
,cuadr
, andbbshsa1
to store and manipulate record data. - Test Data: Includes commented-out test values for parameters (e.g.,
p$co = '10'
,p$fcust = '006700'
, etc.). -
Environment: Uses the program status data structure (
psds##
) to access user, date, and time information. -
Open Database Tables (
opntbl
Subroutine): - Applies file overrides for
shipto
,arcuprrd
,arcupr
,cuadrrd
,cuadr
,bbshsa1rd
, andbbshsa
based onp$fgrp
('G' forg*
files, 'Z' forz*
files) using theQCMDEXC
API. -
Opens input files (
arcuprrd
,cuadrrd
,bbshsa1rd
) and input/output files (shipto
,arcupr
,cuadr
,bbshsa
) withusropn
. -
Write New Ship-to Records (
WriteShipto
Subroutine): - Copy to
shipto
:- Chains to the source
shipto
record usingklFrmShipto
(p$co
,p$fcust
,p$fshp
). - If found (
*in99 = *off
), stores the record insvds
(save data structure). - Checks if the target ship-to exists using
KlToShipto
(p$co
,p$tcust
,p$tshp
). - If the target does not exist (
*in99 = *on
): - Clears the
shiptopf
record format. - Moves
svds
towkds01
and updatescsship
(target ship-to) andcscust
(target customer). - Clears specific fields (
cscsid
,csadr1
,csadr2
,csadr3
,csadr4
,cszip5
,cszip9
,csstat
,csmils
,csctst
,cscszp
,cslong
,cslatt
). - Writes the new record to
shipto
.
- Chains to the source
- Copy to
arcupr
:- Sets the lower limit (
setll
) forarcuprrd
usingklFrmShipto
. - Reads all matching records (
reade
) until end of file (*in99 = *on
). - For each record found:
- Stores the record in
svds
. - Clears the
arcuprpf
record format. - Moves
svds
towkds02
and updatescpship
(target ship-to) andcpcust
(target customer). - Writes the new record to
arcupr
.
- Sets the lower limit (
- Copy to
cuadr
:- Sets the lower limit for
cuadrrd
usingklFrmShipto
. - Reads all matching records (
reade
) until end of file. - For each record found:
- Stores the record in
svds
. - Clears the
cuadrpf
record format. - Moves
svds
towkds03
and updatescdship
(target ship-to) andcdcust
(target customer). - Writes the new record to
cuadr
.
- Sets the lower limit for
-
Copy to
bbshsa
:- Sets the lower limit for
bbshsa1rd
usingklFrmShipto
. - Reads all matching records (
reade
) until end of file. - For each record found:
- Stores the record in
svds
. - Clears the
bbshsapf
record format. - Moves
svds
towkds04
and updatesbaship
(target ship-to),bacust
(target customer), andbahkey
(key11). - Writes the new record to
bbshsa
.
- Sets the lower limit for
-
Program Termination:
- Closes all files (
close *all
). - Sets
*inlr = *on
and returns.
Business Rules¶
- Copy Functionality:
- Copies ship-to data from a source customer/ship-to (
p$fcust
,p$fshp
) to a target customer/ship-to (p$tcust
,p$tshp
) within the same company (p$co
). -
Copies records from
shipto
,arcupr
,cuadr
, andbbshsa1
to their respective target files, updating customer and ship-to fields. -
Validation:
- Verifies the source ship-to exists in
shipto
usingklFrmShipto
. - Ensures the target ship-to does not exist in
shipto
before writing (*in99 = *on
forKlToShipto
). -
No explicit error messages are defined in the code, but the program assumes prior validation (e.g., in
BI890P
) prevents invalid inputs. -
Data Handling:
- Clears specific fields (
cscsid
,csadr1
,csadr2
,csadr3
,csadr4
,cszip5
,cszip9
,csstat
,csmils
,csctst
,cscszp
,cslong
,cslatt
) in the newshipto
record to ensure only essential data is copied. -
Copies all related records from
arcuprrd
,cuadrrd
, andbbshsa1rd
without modification, except for updating customer and ship-to fields. -
File Overrides:
- Uses
p$fgrp
to determine file overrides ('G' forg*
files, 'Z' forz*
files). -
Ensures shared access is disabled (
share(*no)
) to prevent conflicts during writes. -
Non-Interactive:
- The program is non-interactive, with no display file or user interface (unlike
BI890P
orBB800E
). - It processes data programmatically based on input parameters.
Tables (Files) Used¶
The program uses the following database files (tables):
- Input Files (with usropn
and if
for read-only access, renamed record formats):
1. arcuprrd: Customer pricing read file (arcuprpf
renamed to arcuprpr
).
2. cuadrrd: Customer address read file (cuadrpf
renamed to cuadrpr
).
3. bbshsa1rd: Ship-to accessorial/marks read file (bbshsapf
renamed to bbshsapr
).
- Input/Output File (with usropn
and uf a
for update/add):
4. shipto: Ship-to master file (supports both reading and writing).
- Output Files (with usropn
and o
for write-only):
5. arcupr: Customer pricing file (writes new pricing records).
6. cuadr: Customer address file (writes new address records).
7. bbshsa: Ship-to accessorial/marks file (writes new accessorial records).
External Programs Called¶
The program calls one external program:
1. QCMDEXC: System API to execute file override commands (ovrdbf
) for shipto
, arcuprrd
, arcupr
, cuadrrd
, cuadr
, bbshsa1rd
, and bbshsa
.
Summary¶
The BI8903
program is a non-interactive utility that copies ship-to records and related data from a source customer/ship-to to a target customer/ship-to within the same company. It:
- Copies records from shipto
, arcuprrd
, cuadrrd
, and bbshsa1rd
to shipto
, arcupr
, cuadr
, and bbshsa
, updating customer and ship-to fields.
- Clears specific shipto
fields to ensure clean data.
- Uses file overrides based on p$fgrp
('G' or 'Z') and ensures no shared access.
- Relies on prior validation (e.g., from BI890P
) to ensure valid inputs.
- Operates without a user interface, focusing on backend data processing.
The program integrates with seven files and uses the QCMDEXC
API for file overrides, ensuring efficient data copying for ship-to management in the Brandford Order Entry / Invoices system.
If you need further details or have additional context (e.g., related programs like BI9002
), please let me know!