BB943V RPGLE
The provided document is an RPGLE program named BB943V
, called from the OCL procedure BB943INQ.ocl36.txt
and referenced by the BB943
program in the IBM System/36 (or AS/400 compatibility mode) environment. This program, titled "Customer Sales Agreement File Maintenance Validation," is designed to validate input data for customer sales agreements before they are added or updated in the bicuag
file by BB943
. Below, I’ll explain the process steps, business rules, tables used, and external programs called, based on the provided RPGLE source code, the OCL context, and its integration with BB943
and BB943P
.
Process Steps of the RPGLE Program¶
The BB943V
program is a validation module that ensures the integrity of data entered in the customer sales agreement maintenance process. It receives a data structure (CUAGDS
) from BB943
, validates fields against multiple files, and returns error messages and cursor positioning information if validation fails. Here’s a detailed breakdown of the process steps:
- Initialization (
*inzsr
Subroutine, Implicit): - Receive Parameters: The program accepts two parameters via the
*ENTRY
plist:CUAGDS
: A data structure containing input fields for validation, including company (CONO
), customer (CUST
), location (ALOC
), container (KCNTR
), product codes (S3PR
), purchase order (PORD
), start/end dates and times (STDT
,STTM
,ENDT
,ENTM
), and other fields (e.g.,PRCE
,OFFP
,FRCD
,PRIM
,MNQY
,MXQY
,S3LO
,S3SH
,S3CS
,S3EXPR
,P$VALIDPW
,S3POOR
).p$fgrp
: A 1-character parameter specifying the file group ('G'
or'Z'
) for file overrides.
- Set Y2K Variables: Sets
y2kcen
to 19 andy2kcmp
to 80 for date handling (perjb01
). -
Initialize Fields: Implicitly clears or initializes work fields, though not explicitly shown in the provided code.
-
Open Database Tables (
opntbl
Subroutine): - File Overrides: Based on
p$fgrp
('G'
or'Z'
), applies file overrides using theovg
orovz
arrays (e.g.,ovrdbf file(bicont) tofile(*libl/gbicont)
for'G'
group). Executes overrides usingQCMDEXC
for all files. - Open Files: Opens the following input-only files with
usropn
:BICONT
(company file, 256 bytes, keyed on position 2).ARCUST
(customer master file, 384 bytes, keyed on position 2).SHIPTO
(ship-to address file, 2048 bytes, keyed on position 2).INLOC
(location file, 512 bytes, keyed on position 2).GSTABL
(table file, 256 bytes, keyed on position 2).GSCNTR1
(container file, 512 bytes, keyed on position 2, replacedGSCNTR
perjk02
).BICUA3
(sales agreement logical file, 256 bytes, keyed on position 1, replacedBICUA2
perjk02
).BICUA9
(another sales agreement logical file, 256 bytes, keyed on position 1, replacedBICUA8
perjk02
).BBORDH
(order header file, 512 bytes, keyed on position 2).GSPROD
(product file, 512 bytes, keyed on position 8, replacedGSTABL
for product code validation perjk04
).
-
Purpose: Ensures the correct file library (
G
orZ
) is used and files are accessible for validation. -
Main Validation Logic (
$SBLK
Subroutine): - Blank Check: Likely validates that required fields in
CUAGDS
are not blank (e.g.,CONO
,CUST
, at least one product code inS3PR
). The exact logic is not shown due to truncation. -
Purpose: Performs initial checks to ensure the data structure contains valid input before proceeding to detailed validations.
-
Field Validation (
EDITS3
Subroutine): - Company Validation:
- Chains to
BICONT
usingCONO
. If not found, sets@MSG
toCOM(01)
("COMPANY NUMBER IS INVALID") and*IN90
.
- Chains to
- Customer Validation:
- Chains to
ARCUST
usingCONO
andCUST
. If not found, sets@MSG
toCOM(06)
("CUSTOMER NUMBER NOT IN CUSTOMER MASTER") and*IN90
.
- Chains to
- Location Validation:
- Chains to
INLOC
usingCONO
andALOC
. If not found, sets@MSG
toCOM(20)
("INVALID LOCATION") and*IN90
.
- Chains to
- Container Validation:
- Chains to
GSCNTR1
usingKCNTR
. If not found, sets@MSG
toCOM(33)
("INVALID CONTAINER CODE") and*IN90
. - Checks container type (
TCCNTY
) againstGSTABL
withCNTRTY
prefix. If invalid, sets@MSG
toCOM(32)
("INVALID CONTAINER TYPE") and*IN90
. - For non-fluid products (
TPFLCD ≠ 'Y'
inGSPROD
), container must be blank (perCOM(17)
, "NON-FLUID PROD/CONTAINER S/B BLANK"). - For fluid products (
TPFLCD = 'Y'
), a valid container is required (perCOM(54)
, "FLUID PROD/REQUIRES VALID CONTAINER").
- Chains to
- Product Code Validation:
- Validates each product code in
S3PR
(10 elements) againstGSPROD
. If any are invalid, sets@MSG
toCOM(51)
("INVALID PRODUCT CODE ---->") and*IN90
. - Ensures at least one valid product code is entered (
COM(09)
, "ENTER ONE VALID PRODUCT CODE, PLEASE"). - Checks for duplicate product codes (
COM(11)
, "DO NOT ENTER DUPLICATE PROD CODES").
- Validates each product code in
- Unit of Measure Validation:
- Validates
UNMS
againstGSTABL
. If invalid, sets@MSG
toCOM(08)
orCOM(50)
("INVALID UNIT OF MEASURE ENTERED") and*IN90
.
- Validates
- Purchase Order Validation:
- Validates
PORD
againstBBORDH
ifS3POOR = 'P'
or'O'
. If invalid, sets@MSG
toCOM(13)
("INVALID ORDER NUMBER ENTERED") and*IN90
. - Ensures
S3POOR
is'P'
or'O'
(COM(36)
, "MUST ENTER 'P' or 'O'").
- Validates
- Start Date/Time Validation:
- Validates
STDT
andSTTM
using a date validation module (not shown but implied, e.g.,GSDTEDIT
). If invalid, sets@MSG
toCOM(15)
("START DATE IS INVALID"),COM(16)
("START DAY IS INVALID"),COM(21)
("START TIME 'HOURS' MUST BE 00-23"), orCOM(22)
("START TIME 'MINS' MUST BE 00-59"). - Ensures
STTM
is not all zeros (COM(25)
, "START TIME CAN NOT BE ALL ZEROS").
- Validates
- End Date/Time Validation:
- Validates
ENDT
andENTM
similarly. If invalid, sets@MSG
toCOM(18)
("END DATE IS INVALID"),COM(19)
("END DAY IS INVALID"),COM(23)
("END TIME 'HOURS' MUST BE 00-23"), orCOM(24)
("END TIME 'MINS' MUST BE 00-59"). - Ensures
ENDT/ENTM
followsSTDT/STTM
(COM(35)
, "END DT/TM MUST FOLLOW START DT/TM"). - Ensures
ENTM
is not all zeros (COM(26)
, "END TIME CAN NOT BE ALL ZEROS").
- Validates
- Price Validation:
- Ensures either
PRCE
orOFFP
is non-zero (COM(14)
, "MUST HAVE 'PRICE' OR 'OFF PRICE'").
- Ensures either
- Freight Code Validation:
- Validates
FRCD
(not shown in truncated code but implied).
- Validates
- Prepaid Validation:
- Ensures
PPD
is'P'
or blank (COM(55)
, "PREPAID MUST BE 'P' OR BLANK").
- Ensures
- Invoice/Month End Validation:
- Ensures
PRIM
is'I'
or'M'
(COM(29)
, "PRICING MUST BE 'I' OR 'M'").
- Ensures
- Min/Max Quantity Validation:
- Ensures
MXQY
is not less thanMNQY
(implied, no specific error message inCOM
).
- Ensures
- All Ship-to Validation:
- If
ALSH = 'Y'
,SHIP
must be zero (COM(28)
, "IF 'Y', SHIP-TO MUST BE ZERO"). - If
ALSH = 'N'
,SHIP
must be non-zero (COM(49)
, "IF 'N', SHIP-TO MUST NOT BE ZERO"). - Validates
ALSH
as'Y'
,'N'
, or blank (COM(27)
, "SHIP-TO ANSWER MUST BE 'Y' OR 'N'").
- If
-
Security Password Validation:
- Validates
KAGPW
againstBCAGPW
inBICONT
. If invalid, sets@MSG
toCOM(34)
("INVALID SECURITY PASSWORD"). - If
STDT
is more than 3 days ago, requires a password (COM(37)
, "NEED PASSWORD FOR START DATE 3 DAYS AGO").
- Validates
-
Other Locations/Ship-to/Customer-Ship-to Validation (
endothcs
Subroutine): - Loop Through
S3CS
(Customer-Ship-to):- For each non-blank entry in
S3CS
(up to 4 elements), extracts customer (s3cscu
) and ship-to (s3cssh
). - Zero Ship-to (All Ship-tos): Chains to
ARCUST
usingCONO
ands3cscu
. If not found, sets@MSG
toCOM(56)
("INVALID 'OTHER' CUST-SHIPTO->") and*IN90
. - Non-Zero Ship-to: Chains to
SHIPTO
usingCONO
,s3cscu
, ands3cssh
. If not found, sets@MSG
toCOM(57)
("INVALID 'OTHER' CUST-SHIPTO->") and*IN90
.
- For each non-blank entry in
- Check for Duplicate Agreements:
- Constructs a key (
otkH102
) usingCONO
,s3cscu
,ALOC
,KCNTR
,UNMS
,s3cssh
,S3PX
,PORD
,MNQY
,MXQY
,STDT
,STTM
, andFRCD
. - For add operations (
ADDREC = 'Y'
): - Checks
BICUA3
usingotkH102
to ensure no duplicate agreement exists. If found, sets@MSG
toCOM(58)
("AGREEMENT EXISTS FOR OTHER S->") and*IN90
,*IN91
. - For update operations:
- Checks
BICUA9
with the end date/time (END8
,ENTM
,FRCD
). Ignores records with start dates after the current record’s end date or end dates not equal to 12/31/2079 23:59. - If no agreement is found to update, sets
@MSG
toCOM(59)
("NO AGREEMT TO UPDATE FOR OTH->") and*IN90
,*IN91
. - Per
jb01
, "copy to other" processing is not allowed for updates, so the program skips toendothcs
.
- Constructs a key (
-
Exit on Error: If any validation fails, sets
@PC
to the cursor position (e.g.,'OCSHP# '
) and jumps toendothcs
. -
Program Termination:
- Sets
*INLR
to*ON
to indicate last record processing. - Returns to the calling program (
BB943
) with theCUAGDS
data structure updated with@MSG
(error message) and@PC
(cursor position) if validation fails.
Business Rules¶
The program enforces the following business rules for validating customer sales agreement data:
- Field Presence and Format:
- Required fields (e.g.,
CONO
,CUST
, at least oneS3PR
product code) must be non-blank. S3POOR
must be'P'
(purchase order) or'O'
(order number) (COM(36)
).ALSH
must be'Y'
,'N'
, or blank (COM(27)
).PPD
must be'P'
or blank (COM(55)
).PRIM
must be'I'
(invoice) or'M'
(month-end) (COM(29)
).-
Either
PRCE
orOFFP
must be non-zero (COM(14)
). -
Key Field Validation:
- Company (
CONO
): Must exist inBICONT
(COM(01)
). - Customer (
CUST
): Must exist inARCUST
(COM(06)
). - Location (
ALOC
): Must exist inINLOC
(COM(20)
). - Container (
KCNTR
): Must exist inGSCNTR1
(COM(33)
). Blank for non-fluid products (COM(17)
), required for fluid products (COM(54)
). - Container Type (
TCCNTY
): Must exist inGSTABL
withCNTRTY
prefix (COM(32)
). - Product Codes (
S3PR
): Must exist inGSPROD
, no duplicates (COM(11)
,COM(51)
), and at least one valid code (COM(09)
). - Unit of Measure (
UNMS
): Must exist inGSTABL
(COM(08)
,COM(50)
). - Purchase Order (
PORD
): Must exist inBBORDH
ifS3POOR
is'P'
or'O'
(COM(13)
). -
Customer-Ship-to (
S3CS
): Validates customer (s3cscu
) inARCUST
(COM(56)
) and ship-to (s3cssh
) inSHIPTO
(COM(57)
). -
Date and Time Validation:
- Start Date/Time (
STDT
,STTM
): Must be valid, with hours 00–23 (COM(21)
) and minutes 00–59 (COM(22)
). Not all zeros (COM(25)
). - End Date/Time (
ENDT
,ENTM
): Must be valid, with hours 00–23 (COM(23)
) and minutes 00–59 (COM(24)
). Not all zeros (COM(26)
). Must follow start date/time (COM(35)
). -
Password for Backdated Start: If
STDT
is more than 3 days ago, a valid password (KAGPW
) is required (COM(37)
). -
Duplicate Agreement Checks:
- For add operations (
ADDREC = 'Y'
), ensures no duplicate agreement exists inBICUA3
based on key fields (CONO
,CUST
,ALOC
,KCNTR
,UNMS
,SHIP
,S3PX
,PORD
,MNQY
,MXQY
,STDT
,STTM
,FRCD
) (COM(58)
). - For update operations, checks
BICUA9
for an agreement with the specified end date/time or no end date. Ignores records with start dates after the current record’s end date or end dates not equal to 12/31/2079 23:59 (COM(59)
). -
Allows same start dates if freight codes (
FRCD
) differ (perMG04
). -
Copy to Other Restrictions (per
jb01
): - "Copy to other" processing (e.g., copying agreement to other locations, ship-tos, or customer-ship-tos) is allowed only when adding a record (
ADDREC = 'Y'
, via F6 or option 3 copy). - Copy-to-other fields (
S3LO
,S3SH
,S3CS
) are protected during updates. -
The
S3EXPR
(expire) field is only editable for option 3 (copy). IfS3EXPR = 'Y'
, the original record is expired (COM(47)
). -
Price and Quantity Fields:
PRCE
andOFFP
are expanded to 9.4 packed decimal (perJK03
).-
MNQY
andMXQY
are validated as part of the agreement key (perJK02
). -
Program Termination:
- If validation fails, sets
@MSG
with an error message and@PC
with the cursor position for the invalid field. - If validation succeeds, returns to
BB943
without errors.
Tables Used¶
The program uses the following files, as defined in the File Specification (F-spec) section:
- BICONT: Company file, input-only, 256 bytes, keyed on position 2 (fields:
BCNAME
,BCINST
,BCAGPW
for password validation). - ARCUST: Customer master file, input-only, 384 bytes, keyed on position 2 (fields:
ARNAME
,ARNM24
,ARAD1
,ARAD2
). - SHIPTO: Ship-to address file, input-only, 2048 bytes, keyed on position 2.
- INLOC: Location file, input-only, 512 bytes, keyed on position 2.
- GSTABL: Table file (for codes like unit of measure, container type), input-only, 256 bytes, keyed on position 2 (fields:
TBDEL
,TBFLCD
). - GSCNTR1: Container file (replaced
GSCNTR
perjk02
), input-only, 512 bytes, keyed on position 2 (fields:TCDEL
,TCCNTY
). - BICUA3: Sales agreement logical file (replaced
BICUA2
perjk02
), input-only, 256 bytes, keyed on position 1 (fields:BXDEL
,BXCONO
,BXCUST
,BXLOC
,BXENTM
,BXALSH
,BXSTD8
,BXEND8
,BXFRCD
,BXCNTR
,BXSHIP
,BXCNT#
,BXUNMS
). - BICUA9: Another sales agreement logical file (replaced
BICUA8
perjk02
), input-only, 256 bytes, keyed on position 1 (same fields asBICUA3
). - BBORDH: Order header file, input-only, 512 bytes, keyed on position 2 (fields:
BODEL
,BOCO
,BORDNO
,BORSEQ
,BOCUST
). - GSPROD: Product file (replaced
GSTABL
for product code validation perjk04
), input-only, 512 bytes, keyed on position 8 (fields:TPDEL
,TPDESC
,TPPRGP
,TPPRCL
,TPGRAV
,TPSGL#
,TPVCF
,TPFLCD
).
File Overrides:
- The ovg
and ovz
arrays specify overrides for file groups 'G'
and 'Z'
, mapping files to libraries (e.g., gbicont
, zbicua3
).
External Programs Called¶
The program explicitly calls one external program:
- QCMDEXC:
- Called in the
opntbl
subroutine to execute file override commands. - Parameters:
dbov##
(override command string),dbol##
(length, 80).
No other external programs are explicitly called in the provided code. However, the validation of dates and times likely involves a call to a date validation module (e.g., GSDTEDIT
, as implied in BB943
), but this is not shown due to code truncation.
Summary¶
- Process Steps:
- Initialize by receiving
CUAGDS
andp$fgrp
parameters, setting Y2K variables. - Apply file overrides and open database files (
opntbl
). - Perform initial blank checks (
$SBLK
, partially truncated). - Validate fields (
EDITS3
): company, customer, location, container, product codes, unit of measure, purchase order, dates/times, and other fields. - Validate other customer-ship-to entries (
endothcs
), checking for duplicates and update eligibility. -
Return to
BB943
with error messages (@MSG
) and cursor positions (@PC
) if validation fails, or no errors if successful. -
Business Rules:
- Validates required fields (company, customer, product codes, etc.) and their formats.
- Ensures no duplicate agreements exist for add operations and valid agreements for updates.
- Restricts "copy to other" processing to add operations (F6 or option 3) and protects related fields during updates (per
jb01
). - Allows blank containers for non-fluid products and requires containers for fluid products.
- Enforces date/time rules (valid dates, end after start, non-zero times).
- Allows same start dates if freight codes differ (per
MG04
). -
Validates passwords for backdated start dates and other security checks.
-
Tables Used:
-
BICONT
,ARCUST
,SHIPTO
,INLOC
,GSTABL
,GSCNTR1
,BICUA3
,BICUA9
,BBORDH
,GSPROD
. -
External Programs Called:
QCMDEXC
(for file overrides).
Due to the truncation of the source code (59,735 characters), some details about the $SBLK
and EDITS3
subroutines are incomplete. If you can provide the complete BB943V.rpgle
code or specific sections (e.g., full EDITS3
logic), I can refine the process steps and business rules further. Additionally, if you have related files (e.g., BB943
full source, display file bb943d
, or date validation program), I can provide more context. Let me know how you’d like to proceed!