BB802C CLP
The BB802C CLP program is a control language program within the Customer Order and Invoice Inquiry system, designed to create and populate a work file (BB802W
) in the QTEMP
library based on user-specified query criteria. It is called from the main program BB802 and processes data for open orders, canceled orders, and sales history, with support for product moves. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.
Process Steps of the BB802C CLP Program¶
The program processes input parameters to determine the mode of operation, creates or clears work files, and executes queries to populate the work file with filtered data. The steps are driven by conditional logic based on the P$MODE
parameter. Here’s a breakdown of the key process steps:
- Parameter Declaration:
- Purpose: Defines input parameters and variables for file handling.
-
Actions:
- Declares parameters:
&P$MODE
(3 characters): Mode of operation ('WRK', 'ORH', 'ORD', 'SAH', 'SAD', 'CNH', 'CND').&P$DSTC
(1 character): Destination city flag ('Q' to skip ship-to processing, otherwise process).&P$PMOV
(1 character): Product move flag ('Y' for product move, 'N' otherwise).&P$FGRP
(1 character): File group ('G' or 'Z' to determine library).&QRYSLT
(1024 characters): Query selection string for filtering data.- Declares variables for file names:
&FILE01
,&FILE02
,&FILE03
(10 characters each).
-
Clear/Create Work Files:
- Purpose: Ensures the work file
BB802W
and related files are ready inQTEMP
. -
Actions (executed if
&P$MODE = 'WRK'
):- Attempts to clear the physical file
QTEMP/BB802W
usingCLRPFM
. - If the file is not found (
CPF3142
), creates it and related files by duplicating objects from the appropriate library: - If
&P$FGRP = 'G'
, duplicates fromDATA
library. - If
&P$FGRP ≠ 'G'
, duplicates fromDATADEV
library (per JK02). - Creates files:
BB802W
,BB802WL1
,BB802BQF
,BB802FQF
,BB802HQF
,BB802IQF
,BB802PQF
. - Handles errors (
CPF5813
,CPF7302
) usingMONMSG
to continue if file creation fails.
- Attempts to clear the physical file
-
Process Open Orders - Header as Primary:
- Purpose: Queries open order header data (
BBORDH
) and populatesBB802W
. -
Actions (executed if
&P$MODE = 'ORH'
):- Sets
&FILE01
to&P$FGRP + 'BBORDH'
(e.g.,GBBORDH
orZBBORDH
). - Overrides
BBORDH
to&FILE01
withSHARE(*YES)
usingOVRDBF
. - Opens a query file (
OPNQRYF
) with: - File:
&FILE01
. - Query selection:
&QRYSLT
. - Key fields:
BOCO
(company),BOCUST
(customer),BORDNO
(order number),BOINVN
(invoice number). - Overrides
BB802W
toQTEMP/BB802W
. - Calls
BB802A
to process the query results. - Closes the query file (
CLOF
) and deletes overrides (DLTOVR
).
- Sets
-
Process Open Orders - Detail as Primary:
- Purpose: Queries open order detail data (
BBORDD
) joined with header (BBORDH
) and populatesBB802W
. -
Actions (executed if
&P$MODE = 'ORD'
):- Sets
&FILE01
to&P$FGRP + 'BBORDD'
and&FILE02
to&P$FGRP + 'BBORDH'
. - Overrides
BB802BQF
to&FILE01
withSHARE(*YES)
. - Opens a query file (
OPNQRYF
) with: - Files:
&FILE01
,&FILE02
. - Format:
BB802BQF
. - Query selection:
&QRYSLT
. - Key fields:
BDCO
(company),BOCUST
(customer),BDORDN
(order number),BOINVN
(invoice number). - Join fields:
BDCO
toBOCO
,BDORDN
toBORDNO
, withJDFTVAL(*YES)
for outer join. - Overrides
BB802W
toQTEMP/BB802W
. - Calls
BB802B
to process the query results. - Closes the query file and deletes overrides.
- Sets
-
Process Sales History - Header as Primary:
- Purpose: Queries sales history header data (
SA5SHP
) and populatesBB802W
. -
Actions (executed if
&P$MODE = 'SAH'
):- Sets
&FILE01
to&P$FGRP + 'SA5SHP'
(e.g.,GSA5SHP
orZSA5SHP
). - Overrides
SA5SHP
to&FILE01
withSHARE(*YES)
. - Opens a query file (
OPNQRYF
) with: - File:
&FILE01
. - Query selection:
&QRYSLT
. - Key fields:
SHCO
(company),SHCUST
(customer),SHORD
(order number),SHINV
(invoice number). - Overrides
BB802W
toQTEMP/BB802W
. - Calls
BB802E
to process the query results. - Closes the query file and deletes overrides.
- Sets
-
Process Sales History - Detail as Primary (Standard):
- Purpose: Queries sales history detail data (
SA5FILD
) joined with header (SA5SHP
) and populatesBB802W
. -
Actions (executed if
&P$MODE = 'SAD'
and&P$PMOV ≠ 'Y'
):- Sets
&FILE01
to&P$FGRP + 'SA5FILD'
and&FILE02
to&P$FGRP + 'SA5SHP'
. - Overrides
BB802FQF
to&FILE01
withSHARE(*YES)
. - Opens a query file (
OPNQRYF
) with: - Files:
&FILE01
,&FILE02
. - Format:
BB802FQF
. - Query selection:
&QRYSLT
. - Key fields:
SACO
(company),SACUST
(customer),SAORD
(order number),SAINVN
(invoice number),SASEQ
(sequence). - Join fields:
SACO
toSHCO
,SACUST
toSHCUST
,SAORD
toSHORD
,SAINVN
toSHINV
, withJDFTVAL(*YES)
. - Overrides
BB802W
toQTEMP/BB802W
. - Calls
BB802F
to process the query results. - Closes the query file and deletes overrides.
- Sets
-
Process Sales History - Detail as Primary (Product Move):
- Purpose: Queries sales history move detail data (
SA5MOVD
) joined with header (SA5SHP
) and populatesBB802W
. -
Actions (executed if
&P$MODE = 'SAD'
and&P$PMOV = 'Y'
):- Sets
&FILE01
to&P$FGRP + 'SA5MOVD'
and&FILE02
to&P$FGRP + 'SA5SHP'
. - Overrides
BB802PQF
to&FILE01
withSHARE(*YES)
. - Opens a query file (
OPNQRYF
) with: - Files:
&FILE01
,&FILE02
. - Format:
BB802PQF
. - Query selection:
&QRYSLT
. - Key fields:
SACO
,SACUST
,SAORD
,SAINVN
,SASEQ
. - Join fields: Same as standard sales history detail, with
JDFTVAL(*YES)
. - Overrides
BB802W
toQTEMP/BB802W
. - Calls
BB802P
to process the query results. - Closes the query file and deletes overrides.
- Sets
-
Process Canceled Orders - Header as Primary:
- Purpose: Queries canceled order header data (
BBCNH
) joined with reason (BBCNOR
) and populatesBB802W
. -
Actions (executed if
&P$MODE = 'CNH'
):- Sets
&FILE01
to&P$FGRP + 'BBCNH'
and&FILE02
to&P$FGRP + 'BBCNOR'
. - Overrides
BB802HQF
to&FILE01
withSHARE(*YES)
. - Opens a query file (
OPNQRYF
) with: - Files:
&FILE01
,&FILE02
. - Format:
BB802HQF
. - Query selection:
&QRYSLT
. - Key fields:
BOCO
,BOCUST
,BORDNO
,BOINVN
. - Join fields:
BOCO
toBCCO
,BORDNO
toBCORDN
, withJDFTVAL(*YES)
. - Overrides
BB802W
toQTEMP/BB802W
. - Calls
BB802H
to process the query results. - Closes the query file and deletes overrides.
- Sets
-
Process Canceled Orders - Detail as Primary:
- Purpose: Queries canceled order detail data (
BBCND
) joined with header (BBCNH
) and reason (BBCNOR
) and populatesBB802W
. -
Actions (executed if
&P$MODE = 'CND'
):- Sets
&FILE01
to&P$FGRP + 'BBCND'
,&FILE02
to&P$FGRP + 'BBCNH'
, and&FILE03
to&P$FGRP + 'BBCNOR'
. - Overrides
BB802IQF
to&FILE01
withSHARE(*YES)
. - Opens a query file (
OPNQRYF
) with: - Files:
&FILE01
,&FILE02
,&FILE03
. - Format:
BB802IQF
. - Query selection:
&QRYSLT
. - Key fields:
BDCO
,BOCUST
,BDORDN
,BOINVN
. - Join fields:
BDCO
toBOCO
,BDORDN
toBORDNO
,BDCO
toBCCO
,BDORDN
toBCORDN
, withJDFTVAL(*YES)
. - Overrides
BB802W
toQTEMP/BB802W
. - Calls
BB802I
to process the query results. - Closes the query file and deletes overrides.
- Sets
-
Retrieve Ship-to Destination City:
- Purpose: Updates
BB802W
with ship-to destination city fromSHIPTO
. - Actions (executed if
&P$DSTC ≠ 'Q'
): - Sets
&FILE01
to&P$FGRP + 'SHIPTO'
. - Overrides
SHIPTO
to&FILE01
withSHARE(*YES)
. - Overrides
BB802W
toQTEMP/BB802W
. - Calls
BB802G
to update the work file with destination city data. - Deletes overrides.
- Purpose: Updates
-
Program Termination:
- Ends the program (
ENDPGM
).
- Ends the program (
Business Rules¶
- Work File Creation:
- The work file
BB802W
and related logical files (BB802WL1
,BB802BQF
,BB802FQF
,BB802HQF
,BB802IQF
,BB802PQF
) are created inQTEMP
to ensure isolation and temporary storage. - Files are duplicated from
DATA
(for&P$FGRP = 'G'
) orDATADEV
(for&P$FGRP ≠ 'G'
, per JK02) to support different environments. -
Files are cleared or created with constraints and triggers disabled (
CST(*NO)
,TRG(*NO)
) to optimize performance. -
Mode-Based Processing:
- The program supports seven modes (
P$MODE
):- WRK: Clears or creates work files.
- ORH: Processes open order headers (
BBORDH
). - ORD: Processes open order details (
BBORDD
) with header join. - SAH: Processes sales history headers (
SA5SHP
). - SAD: Processes sales history details (
SA5FILD
orSA5MOVD
based onP$PMOV
). - CNH: Processes canceled order headers (
BBCNH
) with reason join. - CND: Processes canceled order details (
BBCND
) with header and reason joins.
-
Each mode uses specific files and formats, with joins and key fields tailored to the data type.
-
File Group Handling:
- The
P$FGRP
parameter ('G' or 'Z') determines the library prefix for files (e.g.,GBBORDH
vs.ZBBORDH
). -
Overrides ensure the correct library is accessed based on the environment.
-
Product Move Support (JK01):
- If
P$PMOV = 'Y'
andP$MODE = 'SAD'
, usesSA5MOVD
instead ofSA5FILD
for sales history details, callingBB802P
instead ofBB802F
. -
This supports queries involving product moves, ensuring compatibility with move-specific data.
-
Query Selection:
- The
&QRYSLT
parameter contains a dynamic query selection string built by the calling program (BB802) to filter records based on user input (e.g., company, customer, order, invoice). -
The query is applied consistently across modes, with joins ensuring related data is included.
-
Ship-to Destination:
- If
P$DSTC ≠ 'Q'
, the program retrieves ship-to destination city data fromSHIPTO
to enhance the work file. -
This step is skipped if
P$DSTC = 'Q'
, optimizing performance when destination data is not needed. -
Error Handling:
- Uses
MONMSG
to handle file creation errors (CPF3142
,CPF5813
,CPF7302
), ensuring the program continues gracefully. -
Commented-out debug messages suggest logging capabilities for troubleshooting (e.g., to users
CAPO
orKRAJTEST
). -
Revision-Specific Rules:
- JB01: Changed work file creation to copy from
ARGDEV
orARGDEVTEST
(superseded by JK02). - JK01: Added support for product moves, processing
SA5MOVD
whenP$PMOV = 'Y'
. - JK02: Updated library references to
DATA
andDATADEV
, overriding work files toQTEMP
for consistency.
Tables Used¶
The program accesses the following database files, with overrides applied based on P$FGRP
:
- BB802W: Work file in
QTEMP
(primary output file). - BB802WL1: Logical work file in
QTEMP
. - BB802BQF: Logical work file for open order details in
QTEMP
. - BB802FQF: Logical work file for sales history details in
QTEMP
. - BB802HQF: Logical work file for canceled order headers in
QTEMP
. - BB802IQF: Logical work file for canceled order details in
QTEMP
. - BB802PQF: Logical work file for sales history move details in
QTEMP
. - BBORDH: Open order header file (prefixed with
G
orZ
). - BBORDD: Open order detail file (prefixed with
G
orZ
). - SA5SHP: Sales history header file (prefixed with
G
orZ
). - SA5FILD: Sales history detail file (prefixed with
G
orZ
). - SA5MOVD: Sales history move detail file (prefixed with
G
orZ
, used ifP$PMOV = 'Y'
). - BBCNH: Canceled order header file (prefixed with
G
orZ
). - BBCND: Canceled order detail file (prefixed with
G
orZ
). - BBCNOR: Canceled order reason file (prefixed with
G
orZ
). - SHIPTO: Ship-to master file (prefixed with
G
orZ
, used ifP$DSTC ≠ 'Q'
).
External Programs Called¶
The program calls the following external programs based on the mode:
- BB802A: Processes open order header data (
ORH
mode). - Parameters: None explicitly passed (relies on file overrides and open query).
- BB802B: Processes open order detail data (
ORD
mode). - Parameters: None explicitly passed.
- BB802E: Processes sales history header data (
SAH
mode). - Parameters: None explicitly passed.
- BB802F: Processes sales history detail data (
SAD
mode,P$PMOV ≠ 'Y'
). - Parameters: None explicitly passed.
- BB802P: Processes sales history move detail data (
SAD
mode,P$PMOV = 'Y'
). - Parameters: None explicitly passed.
- BB802H: Processes canceled order header data (
CNH
mode). - Parameters: None explicitly passed.
- BB802I: Processes canceled order detail data (
CND
mode). - Parameters: None explicitly passed.
- BB802G: Updates
BB802W
with ship-to destination city data (whenP$DSTC ≠ 'Q'
). - Parameters: None explicitly passed.
Additional Notes¶
- File Overrides: The program uses
OVRDBF
to dynamically map files to the correct library (DATA
orDATADEV
) and ensure shared access (SHARE(*YES)
). - Query Flexibility: The
OPNQRYF
command allows dynamic filtering via&QRYSLT
, supporting complex user-defined criteria from BB802. - Temporary Files: All work files are created in
QTEMP
to ensure session-specific data and cleanup. - Join Logic: Uses outer joins (
JDFTVAL(*YES)
) to include records even if join conditions are not met, ensuring comprehensive results. - Commented Code: Debug messages and
CPYFRMQRYF
commands are commented out, indicating they were used for testing or development.
This program is a critical component of the inquiry system, enabling dynamic data filtering and work file population to support the interactive interface of BB802.