Skip to content

BB802B RPGLE

The BB802B RPGLE program is a component of the Customer Orders and Invoicing system, designed to populate a work file (BB802W) with open order detail data from the BB802BQF file, which is a logical file joining BBORDD (order details) and BBORDH (order headers). 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 BB802B RPG Program

The program reads records from the BB802BQF file, processes them based on a level break (L1), and updates or adds corresponding records to the BB802W work file. The steps are focused 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: bdco (company), bocust (customer), bdordn (order number), and boinvn (invoice number).
  4. Main Processing Loop:

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

    • Reads BB802BQF records sequentially, with level break indicators (L1) set on fields bdco, bocust, bdordn, 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 BB802BQF data.
  9. Actions:

    • Uses the klwrk key list (bdco, bocust, bdordn, boinvn) 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 BB802BQF to BB802W:
      • w1cobdco (company)
      • w1custbocust (customer)
      • w1ord#bdordn (order number)
      • w1inv#boinvn (invoice number)
      • 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)
      • w1locbdloc (location)
      • w1prodbdprod (product)
      • w1cntrbdcntr (container)
      • w1qtybdqty (quantity, added by jk01)
      • w1umbdum (unit of measure, added by jk01)
      • w1oori'O' (order origin indicator)
      • Additional fields (per jk02):
      • 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 BB802BQF records, closing files implicitly (as BB802BQF and BB802W are defined with ip and uf respectively).

Business Rules

  1. Work File Population:
  2. The program adds records to BB802W from BB802BQF (joining BBORDD and BBORDH) for open order details, preserving the invoice number (boinvn) from the header.
  3. Only adds new records if no matching record exists in BB802W (based on bdco, bocust, bdordn, boinvn).

  4. Level Break Processing:

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

  7. Field Mapping:

  8. Maps fields from BB802BQF to BB802W, including both header (BBORDH) and detail (BBORDD) data (e.g., customer, order, ship-to, product, quantity).
  9. Includes additional fields added in revisions jk01 (quantity, unit of measure) and jk02 (taken by, rush flag, load volume, etc.) to support enhanced inquiry capabilities.

  10. File Group Handling:

  11. Relies on p$fgrp ('G' or 'Z') set by BB802C to access the correct library (GBBORDD, GBBORDH or ZBBORDD, 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 w1qty (quantity) and w1um (unit of measure) to BB802W to include order detail quantities.
  17. jk02: 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. BB802BQF: Logical file (input primary, ip), joins BBORDD (order details) and BBORDH (order headers), containing fields like bdco, bocust, bdordn, boinvn, bdloc, bdprod, etc.
  2. BB802W: Work file (update file, uf), stores processed inquiry data in QTEMP with fields like w1co, w1cust, w1ord#, w1inv#, w1qty, 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 bdco, bocust, bdordn, and boinvn.
  • Context: Called by BB802C in ORD mode (open order detail processing), where BB802BQF 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 detail data is efficiently transferred to the BB802W work file for further processing by the BB802 inquiry interface.