Skip to content

BB802A RPGLE

The BB802A RPGLE program is a component of the Customer Orders and Invoicing system, designed to populate a work file (BB802W) with open order header data from the BBORDH 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 BB802A RPG Program

The program reads records from the BBORDH file, processes them based on a level break (L1), and updates or adds corresponding records to the BB802W work file. The steps are straightforward, focusing on data transfer with minimal 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: boco (company), bocust (customer), bordno (order number), and k$invn (invoice number, initialized to zeros).
    • Defines k$invn as a field like boinvn (invoice number from BBORDH) and sets it to zeros.
  4. Main Processing Loop:

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

    • Reads BBORDH records sequentially, with level break indicators (L1) set on fields boco, bocust, bordno, and boinvn.
    • 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 BBORDH data.
  9. Actions:

    • Uses the klwrk key list (boco, bocust, bordno, k$invn) to check if a matching record exists in BB802W using SETLL (sets *in99 if no match).
    • If no matching record exists (*in99 = *off), chains to BB802W to verify existence (*in99 = *on if not found).
    • If the record does not exist (*in99 = *on):
    • Clears the BB802W record format (bb802wpf).
    • Maps fields from BBORDH to BB802W:
      • w1coboco (company)
      • w1custbocust (customer)
      • w1ord#bordno (order number)
      • w1inv#k$invn (invoice number, zeros)
      • w1shipboship (ship-to code)
      • w1pordbopord (purchase order)
      • w1slmnboslmn (salesman)
      • w1cridbortg1 (carrier ID)
      • w1carnbocar (carrier name)
      • w1sdatborqd8 (request date)
      • w1frcdbofrcd (freight code)
      • w1sfrtbosfrt (ship freight)
      • w1cafrbocafr (carrier freight)
      • w1cacdbocacd (carrier code)
      • w1oori'O' (order origin indicator)
      • Additional fields (per jk01):
      • w1tkbybotkby (taken by)
      • w1rushborush (rush order flag)
      • w1gpbybogpby (group by)
      • w1racdboracd (reason code)
      • w1mulobomulo (multi-order flag)
      • w1mlcdbomlcd (multi-code)
      • w1tolobotolo (total order)
      • w1lodaboloda (load date)
      • w1lovobolovo (load volume)
    • Writes the new record to BB802W (write bb802wpf).
    • If a matching record exists (*in99 = *off), no update is performed (implicitly skips to the next record).
  10. Program Termination:

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

Business Rules

  1. Work File Population:
  2. The program adds records to BB802W from BBORDH for open order headers, using a fixed invoice number of zeros (k$invn = *zeros) to align with the query structure set by BB802C.
  3. Only adds new records if no matching record exists in BB802W (based on boco, bocust, bordno, k$invn).

  4. Level Break Processing:

  5. Processes BBORDH records on a level break (L1) defined by boco (company), bocust (customer), bordno (order number), and boinvn (invoice number).
  6. Ensures records are processed only when the level break occurs, optimizing performance.

  7. Field Mapping:

  8. Maps specific fields from BBORDH to BB802W, preserving key order and inquiry data (e.g., customer, order, ship-to, salesman, freight details).
  9. Includes additional fields added in revision jk01 to support enhanced inquiry capabilities (e.g., rush order, load date, total order).

  10. File Group Handling:

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

  12. Data Integrity:

  13. Uses SETLL and CHAIN to ensure no duplicate records are written to BB802W.
  14. Clears the record format before writing to prevent residual data.

  15. Revision-Specific Rules:

  16. jk01: Added fields to BB802W (w1tkby, w1rush, w1gpby, w1racd, w1mulo, w1mlcd, w1tolo, w1loda, w1lovo) to capture additional order header data (e.g., taken by, rush flag, load volume).

Tables Used

The program accesses the following database files:

  1. BBORDH: Open order header file (input primary, ip), contains order header data (e.g., boco, bocust, bordno, boinvn, boship, etc.).
  2. BB802W: Work file (update file, uf), stores processed inquiry data in QTEMP with fields like w1co, w1cust, w1ord#, w1inv#, 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 (SETLL and CHAIN operations).
  • 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 boco, bocust, bordno, and k$invn.
  • Context: Called by BB802C in ORH mode (open order header processing), where BBORDH 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.

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