Skip to content

BB802E RPGLE

The BB802E RPGLE program is a component of the Customer Orders and Invoicing system, designed to populate a work file (BB802W) with sales history header data from the SA5SHP file. It is called by the BB802C CLP program, which sets up the query environment and file overrides. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.


Process Steps of the BB802E RPG Program

The program reads records from the SA5SHP file, processes them based on a level break (L1), and updates or adds corresponding records to the BB802W work file. The steps focus on data transfer with no user interaction. Here’s a breakdown of the key process steps:

  1. Initialization (*inzsr Subroutine):
  2. Purpose: Sets up the program environment and initializes variables.
  3. Actions:

    • Receives the input parameter: p$fgrp (1 character, file group: 'G' or 'Z').
    • Defines a key list (klwrk) for accessing the work file BB802W, using fields: shco (company), shcust (customer), shord (order number), and shinv (invoice number).
  4. Main Processing Loop:

  5. Purpose: Reads SA5SHP records and processes them based on a level break.
  6. Actions:

    • Reads SA5SHP records sequentially, with level break indicators (L1) set on fields shco, shcust, shord, and shinv.
    • When the level break indicator *inl1 is on, executes the updwrkf subroutine to process the record.
  7. Update Work File (updwrkf Subroutine):

  8. Purpose: Adds or updates records in the BB802W work file based on SA5SHP data.
  9. Actions:

    • Uses the klwrk key list (shco, shcust, shord, shinv) to check if a matching record exists in BB802W using CHAIN (sets *in99 if no match).
    • If no matching record exists (*in99 = *on):
    • Clears the BB802W record format (bb802wpf).
    • Maps fields from SA5SHP to BB802W:
      • w1coshco (company)
      • w1custshcust (customer)
      • w1ord#shord (order number)
      • w1inv#shinv (invoice number)
      • w1shipshship (ship-to code)
      • w1pordshpord (purchase order)
      • w1slmnshslmn (salesman)
      • w1cridshrtg1 (carrier ID)
      • w1carnshcarn (carrier name)
      • w1sdatshsmd8 (ship date)
      • w1frcdshfrcd (freight code)
      • w1sfrtshsfrt (ship freight)
      • w1cafrshcafr (carrier freight)
      • w1cacdshcacd (carrier code)
      • w1trk#shtrk# (tracking number)
      • w1oori'I' (invoice origin indicator)
      • Additional fields:
      • w1orprsaorpr (order process, added by JK01)
      • w1tkbyshtkby (taken by, added by JK02)
      • w1rushsarush (rush order flag, added by JK02)
      • w1gpbyshgpby (group by, added by JK02)
      • w1racdshracd (reason code, added by JK02)
      • w1muloshmulo (multi-order flag, added by JK02)
      • w1mlcdshmlcd (multi-code, added by JK02)
      • w1toloshtolo (total order, added by JK02)
      • w1lodashloda (load date, added by JK02)
      • w1lovoshlovo (load volume, added by JK02)
      • w1indtshimdy (invoice date, added by JK02)
      • w1invashitot (invoice amount, added by JK02)
      • w1fccdshfccd (freight charge code, added by JK02)
    • Writes the new record to BB802W (write bb802wpf).
    • If a matching record exists (*in99 = *off):
    • Updates the existing record with w1oori = 'B' (indicating both order and invoice data).
    • Updates the BB802W record (update bb802wpf).
  10. Program Termination:

  11. Purpose: Completes processing and exits.
  12. Actions:
    • Ends the program after processing all SA5SHP records, closing files implicitly (as SA5SHP and BB802W are defined with ip and uf respectively).

Business Rules

  1. Work File Population:
  2. The program adds or updates records in BB802W from SA5SHP for sales history headers, using the invoice number (shinv) as a key component.
  3. If no matching record exists in BB802W, a new record is created with w1oori = 'I' (indicating invoice origin).
  4. If a matching record exists, it is updated with w1oori = 'B' to indicate combined order and invoice data.

  5. Level Break Processing:

  6. Processes SA5SHP records on a level break (L1) defined by shco (company), shcust (customer), shord (order number), and shinv (invoice number).
  7. Ensures records are processed only when the level break occurs, optimizing performance.

  8. Field Mapping:

  9. Maps fields from SA5SHP to BB802W, including key inquiry data (e.g., customer, order, invoice, ship-to, salesman, freight details).
  10. Includes additional fields added in revisions JK01 (w1orpr) and JK02 (w1tkby, w1rush, w1gpby, etc.) to support enhanced inquiry capabilities (e.g., invoice date, invoice amount, freight charge code).

  11. File Group Handling:

  12. Relies on p$fgrp ('G' or 'Z') set by BB802C to access the correct library (GSA5SHP or ZSA5SHP) via overrides in the CLP.

  13. Data Integrity:

  14. Uses CHAIN to check for existing records in BB802W, ensuring no duplicates are created unnecessarily.
  15. Clears the record format before writing new records to prevent residual data.
  16. Updates existing records to reflect combined data (w1oori = 'B') when applicable.

  17. Revision-Specific Rules:

  18. JK01: Added w1orpr (order process) to BB802W to capture order processing status.
  19. JK02: Added fields to BB802W (w1tkby, w1rush, w1gpby, w1racd, w1mulo, w1mlcd, w1tolo, w1loda, w1lovo, w1indt, w1inva, w1fccd) to capture additional sales history data (e.g., taken by, invoice date, invoice amount).

Tables Used

The program accesses the following database files:

  1. SA5SHP: Sales history header file (input primary, ip), contains sales header data (e.g., shco, shcust, shord, shinv, shship, etc.).
  2. BB802W: Work file (update file, uf), stores processed inquiry data in QTEMP with fields like w1co, w1cust, w1ord#, w1inv#, w1orpr, etc.

External Programs Called

The program does not call any external programs. It operates independently, relying on file I/O operations and the environment set up by BB802C (e.g., file overrides and open query).


Additional Notes

  • Indicator Usage: Uses *inl1 for level break processing and *in99 for file access control (CHAIN operation).
  • Field Prefixes: Uses w1 prefix for BB802W fields, aligning with the work file structure.
  • Key List: The klwrk key list ensures unique identification of records in BB802W using shco, shcust, shord, and shinv.
  • Context: Called by BB802C in SAH mode (sales history header processing), where SA5SHP is queried with a selection string (QRYSLT) to filter records.
  • Efficiency: The program uses a simple, non-interactive approach, focusing on data transfer to the work file, with no user interface or message handling.
  • Update Logic: Unlike similar programs (e.g., BB802A, BB802B), it updates existing records with w1oori = 'B' to indicate combined data, reflecting the integration of sales history with other inquiry data.

This program is a critical backend component of the inquiry system, ensuring that sales history header data is efficiently transferred to the BB802W work file for further processing by the BB802 inquiry interface.