Skip to content

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:

  1. Initialization (*inzsr Subroutine, Implicit):
  2. 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.
  3. Set Y2K Variables: Sets y2kcen to 19 and y2kcmp to 80 for date handling (per jb01).
  4. Initialize Fields: Implicitly clears or initializes work fields, though not explicitly shown in the provided code.

  5. Open Database Tables (opntbl Subroutine):

  6. File Overrides: Based on p$fgrp ('G' or 'Z'), applies file overrides using the ovg or ovz arrays (e.g., ovrdbf file(bicont) tofile(*libl/gbicont) for 'G' group). Executes overrides using QCMDEXC for all files.
  7. 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, replaced GSCNTR per jk02).
    • BICUA3 (sales agreement logical file, 256 bytes, keyed on position 1, replaced BICUA2 per jk02).
    • BICUA9 (another sales agreement logical file, 256 bytes, keyed on position 1, replaced BICUA8 per jk02).
    • BBORDH (order header file, 512 bytes, keyed on position 2).
    • GSPROD (product file, 512 bytes, keyed on position 8, replaced GSTABL for product code validation per jk04).
  8. Purpose: Ensures the correct file library (G or Z) is used and files are accessible for validation.

  9. Main Validation Logic ($SBLK Subroutine):

  10. Blank Check: Likely validates that required fields in CUAGDS are not blank (e.g., CONO, CUST, at least one product code in S3PR). The exact logic is not shown due to truncation.
  11. Purpose: Performs initial checks to ensure the data structure contains valid input before proceeding to detailed validations.

  12. Field Validation (EDITS3 Subroutine):

  13. Company Validation:
    • Chains to BICONT using CONO. If not found, sets @MSG to COM(01) ("COMPANY NUMBER IS INVALID") and *IN90.
  14. Customer Validation:
    • Chains to ARCUST using CONO and CUST. If not found, sets @MSG to COM(06) ("CUSTOMER NUMBER NOT IN CUSTOMER MASTER") and *IN90.
  15. Location Validation:
    • Chains to INLOC using CONO and ALOC. If not found, sets @MSG to COM(20) ("INVALID LOCATION") and *IN90.
  16. Container Validation:
    • Chains to GSCNTR1 using KCNTR. If not found, sets @MSG to COM(33) ("INVALID CONTAINER CODE") and *IN90.
    • Checks container type (TCCNTY) against GSTABL with CNTRTY prefix. If invalid, sets @MSG to COM(32) ("INVALID CONTAINER TYPE") and *IN90.
    • For non-fluid products (TPFLCD ≠ 'Y' in GSPROD), container must be blank (per COM(17), "NON-FLUID PROD/CONTAINER S/B BLANK").
    • For fluid products (TPFLCD = 'Y'), a valid container is required (per COM(54), "FLUID PROD/REQUIRES VALID CONTAINER").
  17. Product Code Validation:
    • Validates each product code in S3PR (10 elements) against GSPROD. If any are invalid, sets @MSG to COM(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").
  18. Unit of Measure Validation:
    • Validates UNMS against GSTABL. If invalid, sets @MSG to COM(08) or COM(50) ("INVALID UNIT OF MEASURE ENTERED") and *IN90.
  19. Purchase Order Validation:
    • Validates PORD against BBORDH if S3POOR = 'P' or 'O'. If invalid, sets @MSG to COM(13) ("INVALID ORDER NUMBER ENTERED") and *IN90.
    • Ensures S3POOR is 'P' or 'O' (COM(36), "MUST ENTER 'P' or 'O'").
  20. Start Date/Time Validation:
    • Validates STDT and STTM using a date validation module (not shown but implied, e.g., GSDTEDIT). If invalid, sets @MSG to COM(15) ("START DATE IS INVALID"), COM(16) ("START DAY IS INVALID"), COM(21) ("START TIME 'HOURS' MUST BE 00-23"), or COM(22) ("START TIME 'MINS' MUST BE 00-59").
    • Ensures STTM is not all zeros (COM(25), "START TIME CAN NOT BE ALL ZEROS").
  21. End Date/Time Validation:
    • Validates ENDT and ENTM similarly. If invalid, sets @MSG to COM(18) ("END DATE IS INVALID"), COM(19) ("END DAY IS INVALID"), COM(23) ("END TIME 'HOURS' MUST BE 00-23"), or COM(24) ("END TIME 'MINS' MUST BE 00-59").
    • Ensures ENDT/ENTM follows STDT/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").
  22. Price Validation:
    • Ensures either PRCE or OFFP is non-zero (COM(14), "MUST HAVE 'PRICE' OR 'OFF PRICE'").
  23. Freight Code Validation:
    • Validates FRCD (not shown in truncated code but implied).
  24. Prepaid Validation:
    • Ensures PPD is 'P' or blank (COM(55), "PREPAID MUST BE 'P' OR BLANK").
  25. Invoice/Month End Validation:
    • Ensures PRIM is 'I' or 'M' (COM(29), "PRICING MUST BE 'I' OR 'M'").
  26. Min/Max Quantity Validation:
    • Ensures MXQY is not less than MNQY (implied, no specific error message in COM).
  27. 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'").
  28. Security Password Validation:

    • Validates KAGPW against BCAGPW in BICONT. If invalid, sets @MSG to COM(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").
  29. Other Locations/Ship-to/Customer-Ship-to Validation (endothcs Subroutine):

  30. 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 using CONO and s3cscu. If not found, sets @MSG to COM(56) ("INVALID 'OTHER' CUST-SHIPTO->") and *IN90.
    • Non-Zero Ship-to: Chains to SHIPTO using CONO, s3cscu, and s3cssh. If not found, sets @MSG to COM(57) ("INVALID 'OTHER' CUST-SHIPTO->") and *IN90.
  31. Check for Duplicate Agreements:
    • Constructs a key (otkH102) using CONO, s3cscu, ALOC, KCNTR, UNMS, s3cssh, S3PX, PORD, MNQY, MXQY, STDT, STTM, and FRCD.
    • For add operations (ADDREC = 'Y'):
    • Checks BICUA3 using otkH102 to ensure no duplicate agreement exists. If found, sets @MSG to COM(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 to COM(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 to endothcs.
  32. Exit on Error: If any validation fails, sets @PC to the cursor position (e.g., 'OCSHP# ') and jumps to endothcs.

  33. Program Termination:

  34. Sets *INLR to *ON to indicate last record processing.
  35. Returns to the calling program (BB943) with the CUAGDS 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:

  1. Field Presence and Format:
  2. Required fields (e.g., CONO, CUST, at least one S3PR product code) must be non-blank.
  3. S3POOR must be 'P' (purchase order) or 'O' (order number) (COM(36)).
  4. ALSH must be 'Y', 'N', or blank (COM(27)).
  5. PPD must be 'P' or blank (COM(55)).
  6. PRIM must be 'I' (invoice) or 'M' (month-end) (COM(29)).
  7. Either PRCE or OFFP must be non-zero (COM(14)).

  8. Key Field Validation:

  9. Company (CONO): Must exist in BICONT (COM(01)).
  10. Customer (CUST): Must exist in ARCUST (COM(06)).
  11. Location (ALOC): Must exist in INLOC (COM(20)).
  12. Container (KCNTR): Must exist in GSCNTR1 (COM(33)). Blank for non-fluid products (COM(17)), required for fluid products (COM(54)).
  13. Container Type (TCCNTY): Must exist in GSTABL with CNTRTY prefix (COM(32)).
  14. Product Codes (S3PR): Must exist in GSPROD, no duplicates (COM(11), COM(51)), and at least one valid code (COM(09)).
  15. Unit of Measure (UNMS): Must exist in GSTABL (COM(08), COM(50)).
  16. Purchase Order (PORD): Must exist in BBORDH if S3POOR is 'P' or 'O' (COM(13)).
  17. Customer-Ship-to (S3CS): Validates customer (s3cscu) in ARCUST (COM(56)) and ship-to (s3cssh) in SHIPTO (COM(57)).

  18. Date and Time Validation:

  19. 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)).
  20. 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)).
  21. Password for Backdated Start: If STDT is more than 3 days ago, a valid password (KAGPW) is required (COM(37)).

  22. Duplicate Agreement Checks:

  23. For add operations (ADDREC = 'Y'), ensures no duplicate agreement exists in BICUA3 based on key fields (CONO, CUST, ALOC, KCNTR, UNMS, SHIP, S3PX, PORD, MNQY, MXQY, STDT, STTM, FRCD) (COM(58)).
  24. 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)).
  25. Allows same start dates if freight codes (FRCD) differ (per MG04).

  26. Copy to Other Restrictions (per jb01):

  27. "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).
  28. Copy-to-other fields (S3LO, S3SH, S3CS) are protected during updates.
  29. The S3EXPR (expire) field is only editable for option 3 (copy). If S3EXPR = 'Y', the original record is expired (COM(47)).

  30. Price and Quantity Fields:

  31. PRCE and OFFP are expanded to 9.4 packed decimal (per JK03).
  32. MNQY and MXQY are validated as part of the agreement key (per JK02).

  33. Program Termination:

  34. If validation fails, sets @MSG with an error message and @PC with the cursor position for the invalid field.
  35. 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:

  1. BICONT: Company file, input-only, 256 bytes, keyed on position 2 (fields: BCNAME, BCINST, BCAGPW for password validation).
  2. ARCUST: Customer master file, input-only, 384 bytes, keyed on position 2 (fields: ARNAME, ARNM24, ARAD1, ARAD2).
  3. SHIPTO: Ship-to address file, input-only, 2048 bytes, keyed on position 2.
  4. INLOC: Location file, input-only, 512 bytes, keyed on position 2.
  5. GSTABL: Table file (for codes like unit of measure, container type), input-only, 256 bytes, keyed on position 2 (fields: TBDEL, TBFLCD).
  6. GSCNTR1: Container file (replaced GSCNTR per jk02), input-only, 512 bytes, keyed on position 2 (fields: TCDEL, TCCNTY).
  7. BICUA3: Sales agreement logical file (replaced BICUA2 per jk02), input-only, 256 bytes, keyed on position 1 (fields: BXDEL, BXCONO, BXCUST, BXLOC, BXENTM, BXALSH, BXSTD8, BXEND8, BXFRCD, BXCNTR, BXSHIP, BXCNT#, BXUNMS).
  8. BICUA9: Another sales agreement logical file (replaced BICUA8 per jk02), input-only, 256 bytes, keyed on position 1 (same fields as BICUA3).
  9. BBORDH: Order header file, input-only, 512 bytes, keyed on position 2 (fields: BODEL, BOCO, BORDNO, BORSEQ, BOCUST).
  10. GSPROD: Product file (replaced GSTABL for product code validation per jk04), 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:

  1. QCMDEXC:
  2. Called in the opntbl subroutine to execute file override commands.
  3. 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 and p$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!