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:
- Initialization (
*inzsr
Subroutine): - Purpose: Sets up the program environment and initializes variables.
-
Actions:
- Receives the input parameter:
p$fgrp
(1 character, file group: 'G' or 'Z'). - Defines a key list (
klwrk
) for accessing the work fileBB802W
, using fields:boco
(company),bocust
(customer),bordno
(order number), andk$invn
(invoice number, defined as likeboinvn
and initialized to zeros).
- Receives the input parameter:
-
Main Processing Loop:
- Purpose: Reads
BB802HQF
records and processes them based on a level break. -
Actions:
- Reads
BB802HQF
records sequentially, with level break indicators (L1
) set on fieldsboco
(company),bocust
(customer),bordno
(order number), andboinvn
(invoice number). - When the level break indicator
*inl1
is on, executes theupdwrkf
subroutine to process the record.
- Reads
-
Update Work File (
updwrkf
Subroutine): - Purpose: Adds records to the
BB802W
work file based onBB802HQF
data. -
Actions:
- Uses the
klwrk
key list (boco
,bocust
,bordno
,k$invn
) to check if a matching record exists inBB802W
usingSETLL
(sets*in99
if no match). - If no matching record exists (
*in99 = *off
), chains toBB802W
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
toBB802W
:w1co
←boco
(company)w1cust
←bocust
(customer)w1ord#
←bordno
(order number)w1inv#
←k$invn
(invoice number, set to zeros)w1ship
←boship
(ship-to code)w1pord
←bopord
(purchase order)w1slmn
←boslmn
(salesman)w1crid
←bortg1
(carrier ID)w1carn
←bocar
(carrier name)w1sdat
←borqd8
(request date)w1frcd
←bofrcd
(freight code)w1sfrt
←bosfrt
(ship freight)w1cafr
←bocafr
(carrier freight)w1cacd
←bocacd
(carrier code)w1cnrs
←bccnrs
(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).
- Uses the
-
Program Termination:
- Purpose: Completes processing and exits.
- Actions:
- Ends the program after processing all
BB802HQF
records, closing files implicitly (asBB802HQF
andBB802W
are defined withip
anduf
respectively).
- Ends the program after processing all
Business Rules¶
- Work File Population:
- The program adds records to
BB802W
fromBB802HQF
(joiningBBCNH
andBBCNOR
) for canceled order headers, using a fixed invoice number of zeros (k$invn = *zeros
) to align with the query structure set by BB802C. -
Only adds new records if no matching record exists in
BB802W
(based onboco
,bocust
,bordno
,k$invn
). -
Level Break Processing:
- Processes
BB802HQF
records on a level break (L1
) defined byboco
(company),bocust
(customer),bordno
(order number), andboinvn
(invoice number). -
Ensures records are processed only when the level break occurs, optimizing performance.
-
Field Mapping:
- Maps fields from
BB802HQF
toBB802W
, including key inquiry data (e.g., customer, order, ship-to, salesman, freight details) and the cancel reason (bccnrs
) specific to canceled orders. -
Sets
w1oori = 'C'
to indicate the record originates from a canceled order. -
File Group Handling:
-
Relies on
p$fgrp
('G' or 'Z') set by BB802C to access the correct library (GBBCNH
,GBBCNOR
orZBBCNH
,ZBBCNOR
) via overrides in the CLP. -
Data Integrity:
- Uses
SETLL
andCHAIN
to ensure no duplicate records are written toBB802W
. -
Clears the record format before writing to prevent residual data.
-
Cloned from BB802A:
- The program is cloned from BB802A (which processes open order headers from
BBORDH
) but adapted for canceled order headers (BBCNH
). - Key differences include:
- Uses
BB802HQF
instead ofBBORDH
. - Adds
w1cnrs
(cancel reason) toBB802W
. - Sets
w1oori = 'C'
instead of'O'
.
- Uses
-
No additional fields from revisions (unlike BB802A, which has jk01 additions).
-
Revision-Specific Rules:
- No revisions are listed, indicating the program has remained stable since its creation in 2014.
Tables Used¶
The program accesses the following database files:
- BB802HQF: Logical file (input primary,
ip
), joinsBBCNH
(canceled order headers) andBBCNOR
(canceled order reasons), containing fields likeboco
,bocust
,bordno
,boinvn
,bccnrs
, etc. - BB802W: Work file (update file,
uf
), stores processed inquiry data inQTEMP
with fields likew1co
,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
andCHAIN
operations). - Field Prefixes: Uses
w1
prefix forBB802W
fields, aligning with the work file structure. - Key List: The
klwrk
key list ensures unique identification of records inBB802W
usingboco
,bocust
,bordno
, andk$invn
. - Context: Called by BB802C in
CNH
mode (canceled order header processing), whereBB802HQF
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.