Skip to content

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:

  1. Initialization (*inzsr Subroutine):
  2. 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.
  3. Field Setup: Initializes key fields (dsco, dstcust, dstshp) with input parameters (p$co, p$tcust, p$tshp) for use in key lists.
  4. 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).
  5. Data Structures: Defines external data structures (wkds01, wkds02, wkds03, wkds04) for shipto, arcupr, cuadr, and bbshsa1 to store and manipulate record data.
  6. Test Data: Includes commented-out test values for parameters (e.g., p$co = '10', p$fcust = '006700', etc.).
  7. Environment: Uses the program status data structure (psds##) to access user, date, and time information.

  8. Open Database Tables (opntbl Subroutine):

  9. Applies file overrides for shipto, arcuprrd, arcupr, cuadrrd, cuadr, bbshsa1rd, and bbshsa based on p$fgrp ('G' for g* files, 'Z' for z* files) using the QCMDEXC API.
  10. Opens input files (arcuprrd, cuadrrd, bbshsa1rd) and input/output files (shipto, arcupr, cuadr, bbshsa) with usropn.

  11. Write New Ship-to Records (WriteShipto Subroutine):

  12. Copy to shipto:
    • Chains to the source shipto record using klFrmShipto (p$co, p$fcust, p$fshp).
    • If found (*in99 = *off), stores the record in svds (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 to wkds01 and updates csship (target ship-to) and cscust (target customer).
    • Clears specific fields (cscsid, csadr1, csadr2, csadr3, csadr4, cszip5, cszip9, csstat, csmils, csctst, cscszp, cslong, cslatt).
    • Writes the new record to shipto.
  13. Copy to arcupr:
    • Sets the lower limit (setll) for arcuprrd using klFrmShipto.
    • 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 to wkds02 and updates cpship (target ship-to) and cpcust (target customer).
    • Writes the new record to arcupr.
  14. Copy to cuadr:
    • Sets the lower limit for cuadrrd using klFrmShipto.
    • 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 to wkds03 and updates cdship (target ship-to) and cdcust (target customer).
    • Writes the new record to cuadr.
  15. Copy to bbshsa:

    • Sets the lower limit for bbshsa1rd using klFrmShipto.
    • 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 to wkds04 and updates baship (target ship-to), bacust (target customer), and bahkey (key11).
    • Writes the new record to bbshsa.
  16. Program Termination:

  17. Closes all files (close *all).
  18. Sets *inlr = *on and returns.

Business Rules

  1. Copy Functionality:
  2. 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).
  3. Copies records from shipto, arcupr, cuadr, and bbshsa1 to their respective target files, updating customer and ship-to fields.

  4. Validation:

  5. Verifies the source ship-to exists in shipto using klFrmShipto.
  6. Ensures the target ship-to does not exist in shipto before writing (*in99 = *on for KlToShipto).
  7. No explicit error messages are defined in the code, but the program assumes prior validation (e.g., in BI890P) prevents invalid inputs.

  8. Data Handling:

  9. Clears specific fields (cscsid, csadr1, csadr2, csadr3, csadr4, cszip5, cszip9, csstat, csmils, csctst, cscszp, cslong, cslatt) in the new shipto record to ensure only essential data is copied.
  10. Copies all related records from arcuprrd, cuadrrd, and bbshsa1rd without modification, except for updating customer and ship-to fields.

  11. File Overrides:

  12. Uses p$fgrp to determine file overrides ('G' for g* files, 'Z' for z* files).
  13. Ensures shared access is disabled (share(*no)) to prevent conflicts during writes.

  14. Non-Interactive:

  15. The program is non-interactive, with no display file or user interface (unlike BI890P or BB800E).
  16. 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!