Skip to content

BB9433 RPGLE

The provided document is an RPGLE program named BB9433, 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 "Copy/Update Sales Agreements," is designed to copy or update customer sales agreement records in the bicuag file, including handling expiration of original records and logging to the history file (bicuagh). 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, BB943P, and BB943V.


Process Steps of the RPGLE Program

The BB9433 program is a backend module that processes the addition or updating of customer sales agreement records, including copying agreements to other locations, ship-tos, or customer-ship-to combinations, and managing expiration of original records. It receives a comprehensive parameter list from BB943 and operates in either add or update mode. Due to the truncation of the source code (7,596 characters), some logic is incomplete, but I’ll reconstruct the process steps based on the available code and context.

  1. Initialization (*inzsr Subroutine):
  2. Receive Parameters: The program accepts three parameters via the *ENTRY plist:
    • parmlist: A data structure containing fields for the sales agreement, including:
    • p$cono (company number).
    • p$cust (customer number).
    • p$loc (location).
    • p$cntr (container code).
    • p$unms (unit of measure).
    • p$alsh (all ship-tos flag, 'Y' or 'N').
    • p$ship (ship-to number).
    • p$pr01p$pr10 (product codes, up to 10).
    • p$pord (bill-to purchase order).
    • p$expr (expire flag, 'Y' for expiring original record).
    • p$prce (price, 9.4 packed, per jk05).
    • p$offp (off-price, 9.4 packed, per jk05).
    • p$frcd (freight code).
    • p$delv (delivery code).
    • p$ppd (prepaid flag, 'P' or blank).
    • p$prim (pricing type, 'I' or 'M').
    • p$mnqy (minimum quantity).
    • p$mxqy (maximum quantity).
    • p$locs (array of other locations, 30 bytes).
    • p$shp (array of other ship-tos, 30 bytes).
    • p$cshp (array of other customer-ship-to combinations, 36 bytes).
    • p$seqn (sequence number).
    • p$std8 (start date, CCYYMMDD).
    • p$sttm (start time).
    • p$end8 (end date, CCYYMMDD).
    • p$entm (end time).
    • p$addupd (add or update flag).
    • p$dateflag (date flag, 2 bytes).
    • o@cono, o@cust, o@loc, o@cntr, o@unms, o@ship, o@pr01o@pr10, o@pord, o@std8, o@sttm, o@mnqy, o@mxqy (original key fields for expiring records).
    • p$cntn (contract number, per jk04).
    • p$poor (PO/order code, per jk04).
    • p$fgrp: File group ('G' or 'Z') for file overrides.
    • p$flag: Return flag (1 character, e.g., '1' for success, '0' for failure).
  3. Set System Information: Retrieves system data via the psda## program status data structure (e.g., pgmq## for program name, jbuser for user, jbdt## for job date).
  4. Set Current Date/Time: Uses the TIME operation to populate t#time and converts it to t#cymd (CCYYMMDD) and t#hms (HHMMSS) for history record timestamps.
  5. Move Arrays: Transfers p$locs, p$shp, and p$cshp to work arrays loc, shp, and cshp for processing other locations, ship-tos, and customer-ship-to combinations.
  6. Open Database Tables: Calls opntbl to apply file overrides and open files.
  7. Define Key Lists:

    • klcuag: For accessing bicuag with p$cono and p$seqn.
    • newkey: For new records with p$cono and w$sq (work sequence number).
    • klcua3: For checking existing agreements in bicua3 with original key fields (o@cono, w$cust, w$loc, o@cntr, o@unms, w$ship, o@pr01o@pr10, o@pord, o@mnqy, o@mxqy, o@std8, o@sttm, p$frcd).
  8. Open Database Tables (opntbl Subroutine):

  9. File Overrides: Applies overrides based on p$fgrp ('G' or 'Z') using ovg or ovz arrays (e.g., ovrdbf file(bicuag) tofile(*libl/gbicuag) for 'G'). Executes overrides with QCMDEXC.
  10. Open Files: Opens the following files with usropn:
    • bicont (company file, update/input, keyed).
    • bicuag (sales agreement file, update/add/input, keyed).
    • bicua3 (sales agreement logical file, update/input, keyed, renamed record format bicuagpf to bicuagf3, per jk03).
    • bicuagh (sales agreement history file, output-only, keyed).
  11. Purpose: Ensures access to the correct file library (G or Z) for data operations.

  12. Process Other Locations (loc Array):

  13. Check loc Array: If chkloc (overlay of loc array) is not blank, sets *IN60 to *ON to indicate data in the location array.
  14. Loop Through loc: For each non-blank entry in loc (up to 10 elements):
    • Sets w@loc to the current location (loc(z)).
    • Sets w@cust to p$cust and w@ship to p$ship.
    • Calls writercd to write or update a sales agreement record for the location.
  15. Clear Indicator: Resets *IN60 to *OFF after processing.

  16. Process Other Ship-tos (shp Array):

  17. Check shp Array: If chkshp (overlay of shp array) is not blank, sets *IN61 to *ON.
  18. Loop Through shp: For each non-blank entry in shp (up to 10 elements):
    • Sets w@ship to the current ship-to (shp(y)).
    • Sets w@cust to p$cust and w@loc to p$loc.
    • Calls writercd to write or update a sales agreement record for the ship-to.
  19. Clear Indicator: Resets *IN61 to *OFF after processing.

  20. Process Other Customer-Ship-to Combinations (cshp Array):

  21. Check cshp Array: If chkcshp (overlay of cshp array) is not blank, sets *IN62 to *ON.
  22. Loop Through cshp: For each non-blank entry in cshp (up to 4 elements):
    • Extracts customer (dscust) and ship-to (dsship) from dscstshp.
    • Sets w@cust to dscust, w@ship to dsship, and w@loc to p$loc.
    • Calls writercd to write or update a sales agreement record for the customer-ship-to combination.
  23. Clear Indicator: Resets *IN62 to *OFF after processing.

  24. Write/Update Record (writercd Subroutine):

  25. Populate bicuag Fields: Maps input parameters to bicuag record fields:
    • bacono = p$cono, bacust = p$cust, baloc = w@loc, bacntr = p$cntr, baunms = p$unms, baship = w@ship.
    • Product codes: bapr01bapr10 = p$pr01p$pr10.
    • Dates: bastd8 = p$std8, bastdt = p$std8 (with flag '1'), basttm = p$sttm, baend8 = p$end8, baendt = p$end8 (with flag '1'), baentm = p$entm.
    • Other fields: bapord = p$pord, baalsh = p$alsh, baprce = p$prce, baoffp = p$offp, bafrcd = p$frcd, badelv = p$delv, bappd = p$ppd, baprim = p$prim, bamnqy = p$mnqy, bamxqy = p$mxqy, bacntn = p$cntn, bapoor = p$poor.
  26. Write/Update Logic (Truncated):

    • Likely checks if the record exists using klcuag or newkey and updates (UPDATE) or writes (WRITE) to bicuag.
    • If p$expr = 'Y', expires the original record using klcua3 by setting its end date/time and writing to bicuagh (per jk04).
    • Uses wkcuag (external data structure) and svcuag (256-byte save data structure) to hold record data during processing.
  27. Write to History File (writehist Subroutine):

  28. Clear History Record: Clears the bicuaghpf record format.
  29. Populate History Fields: Maps bicuag fields to bicuagh fields (e.g., hhcono = bacono, hhdel = badel per jk02, hhcust = bacust, etc.).
  30. Add Audit Fields:
    • Sets hhchd8 = t#cymd (current date) and hhchtm = t#hms (current time).
    • Sets hhuser = jbuser8 (user ID, 8 characters).
  31. Write Record: Writes to bicuagh using WRITE bicuaghpf.

  32. Program Termination (Truncated):

  33. Likely closes all files (close *all) and sets *inlr = *on to terminate.
  34. Returns p$flag to indicate success ('1') or failure ('0') to BB943.

Business Rules

The program enforces the following business rules for copying or updating sales agreements:

  1. Add vs. Update Mode:
  2. Controlled by p$addupd:
    • 'A' (add): Creates new records in bicuag for the primary key and any additional locations (p$locs), ship-tos (p$shp), or customer-ship-to combinations (p$cshp).
    • 'U' (update): Updates existing records based on p$seqn.
  3. Indicators *IN60, *IN61, and *IN62 track whether loc, shp, or cshp arrays contain data.

  4. Copy to Other Locations/Ship-tos/Customer-Ship-tos:

  5. Processes p$locs (other locations), p$shp (other ship-tos), and p$cshp (other customer-ship-to combinations) to create multiple agreement records with varying baloc, baship, or bacust/baship combinations.
  6. Ensures no duplicate agreements exist (validated by BB943V before calling BB9433).

  7. Expiration Handling (per jk04):

  8. If p$expr = 'Y', expires the original record (identified by o@cono, o@cust, o@loc, o@cntr, o@unms, o@ship, o@pr01o@pr10, o@pord, o@std8, o@sttm, o@mnqy, o@mxqy) only if:
    • Its expiration date (baend8) is greater than the new record’s start date (p$std8) or is zero.
  9. Writes expired records to bicuagh with audit fields (hhchd8, hhchtm, hhuser).

  10. Duplicate Start Dates (per jk01):

  11. Allows identical start dates (p$std8, p$sttm) if freight codes (p$frcd) differ.

  12. Price and Quantity Fields (per jk05):

  13. p$prce and p$offp are stored as 9.4 packed decimal in baprce and baoffp.
  14. p$mnqy and p$mxqy are stored in bamnqy and bamxqy (added per jk03).

  15. Contract Number and PO/Order Code (per jk04):

  16. Stores p$cntn in bacntn (contract number).
  17. Stores p$poor in bapoor (PO or order code).

  18. History Logging:

  19. Writes expired or modified records to bicuagh with current date/time (hhchd8, hhchtm) and user (hhuser).
  20. Transfers deletion flag (badel to hhdel, per jk02).

  21. Validation:

  22. Relies on BB943V for input validation before processing. Ensures fields like p$cono, p$cust, p$loc, p$cntr, p$pr01p$pr10, etc., are valid.

Tables Used

The program uses the following files, as defined in the File Specification (F-spec) section:

  1. bicuag: Primary sales agreement file, update/add/input, keyed.
  2. bicont: Company file, update/input, keyed.
  3. bicua3: Sales agreement logical file (replaced bicua2 per jk03), update/input, keyed, with renamed record format (bicuagpf to bicuagf3).
  4. bicuagh: Sales agreement history file, output-only, keyed.

File Overrides: - The ovg and ovz arrays specify overrides for file groups 'G' and 'Z', mapping files to libraries (e.g., gbicuag, zbicuagh).


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, 80 bytes), dbol## (length, 15.5).

Implied Program: - GSDTCLC1: Implied by the pldtclc1 PLIST for date addition/subtraction, used for date calculations (e.g., expiration date adjustments). Parameters: p#dat1, p#dat2, p#fmt, p#diff, p#err.


Summary

  • Process Steps:
  • Initialize by receiving parmlist, p$fgrp, and p$flag, setting date/time, and moving arrays (loc, shp, cshp).
  • Apply file overrides and open files (opntbl).
  • Process loc array to create/update agreements for other locations (*IN60).
  • Process shp array for other ship-tos (*IN61).
  • Process cshp array for other customer-ship-to combinations (*IN62).
  • Write/update records in bicuag using writercd, mapping parameters to file fields.
  • Write expired records to bicuagh with audit fields (writehist).
  • Terminate, returning p$flag (success/failure).

  • Business Rules:

  • Supports add ('A') and update ('U') modes via p$addupd.
  • Copies agreements to other locations, ship-tos, or customer-ship-to combinations.
  • Expires original records if p$expr = 'Y' and expiration conditions are met (per jk04).
  • Allows identical start dates if freight codes differ (per jk01).
  • Logs expired/modified records to bicuagh with audit fields.
  • Uses expanded price fields (baprce, baoffp, per jk05) and quantity fields (bamnqy, bamxqy, per jk03).
  • Stores contract number (bacntn) and PO/order code (bapoor, per jk04).

  • Tables Used:

  • bicuag, bicont, bicua3, bicuagh.

  • External Programs Called:

  • QCMDEXC (for file overrides).
  • GSDTCLC1 (implied for date calculations).

Due to the truncation of the source code, details of the main processing loop and parts of the writercd subroutine are incomplete. If you can provide the complete BB9433.rpgle code or specific sections (e.g., full writercd 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 GSDTCLC1), I can provide more context. Let me know how you’d like to proceed!