Skip to content

BB802H RPGLE

The BB802H RPGLE program is a component of the Customer Orders and Invoicing system, designed to populate a work file (BB802W) with canceled order header data from the BB802HQF file, which is a logical file joining BBCNH (canceled order headers) and BBCNOR (canceled order reasons). It is called by the BB802C CLP program in CNH mode (canceled order header processing) and is noted as being cloned from BB802A with modifications for canceled orders. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.


Process Steps of the BB802H RPG Program

The program reads records from the BB802HQF file, processes them based on a level break (L1), and adds or updates corresponding records in 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: boco (company), bocust (customer), bordno (order number), and k$invn (invoice number, defined as like boinvn and initialized to zeros).
  4. Main Processing Loop:

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

    • Reads BB802HQF records sequentially, with level break indicators (L1) set on fields boco (company), bocust (customer), bordno (order number), and boinvn (invoice number).
    • 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 records to the BB802W work file based on BB802HQF 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 BB802HQF to BB802W:
      • w1coboco (company)
      • w1custbocust (customer)
      • w1ord#bordno (order number)
      • w1inv#k$invn (invoice number, set to 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)
      • w1cnrsbccnrs (cancel reason, specific to canceled orders)
      • w1oori'C' (canceled order origin indicator)
    • 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 BB802HQF records, closing files implicitly (as BB802HQF and BB802W are defined with ip and uf respectively).

Business Rules

  1. Work File Population:
  2. The program adds records to BB802W from BB802HQF (joining BBCNH and BBCNOR) for canceled 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 BB802HQF 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 fields from BB802HQF to BB802W, including key inquiry data (e.g., customer, order, ship-to, salesman, freight details) and the cancel reason (bccnrs) specific to canceled orders.
  9. Sets w1oori = 'C' to indicate the record originates from a canceled order.

  10. File Group Handling:

  11. Relies on p$fgrp ('G' or 'Z') set by BB802C to access the correct library (GBBCNH, GBBCNOR or ZBBCNH, ZBBCNOR) 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. Cloned from BB802A:

  16. The program is cloned from BB802A (which processes open order headers from BBORDH) but adapted for canceled order headers (BBCNH).
  17. Key differences include:
    • Uses BB802HQF instead of BBORDH.
    • Adds w1cnrs (cancel reason) to BB802W.
    • Sets w1oori = 'C' instead of 'O'.
  18. No additional fields from revisions (unlike BB802A, which has jk01 additions).

  19. Revision-Specific Rules:

  20. No revisions are listed, indicating the program has remained stable since its creation in 2014.

Tables Used

The program accesses the following database files:

  1. BB802HQF: Logical file (input primary, ip), joins BBCNH (canceled order headers) and BBCNOR (canceled order reasons), containing fields like boco, bocust, bordno, boinvn, bccnrs, etc.
  2. BB802W: Work file (update file, uf), stores processed inquiry data in QTEMP with fields like w1co, w1cust, w1ord#, w1inv#, w1cnrs, 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 CNH mode (canceled order header processing), where BB802HQF 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.
  • Relation to BB802A: As a clone of BB802A, it follows a similar structure but is tailored for canceled orders, with the addition of the cancel reason field (w1cnrs) and a different origin indicator (w1oori = 'C').

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