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
BB802Wand related files are ready inQTEMP. -
Actions (executed if
&P$MODE = 'WRK'):- Attempts to clear the physical file
QTEMP/BB802WusingCLRPFM. - If the file is not found (
CPF3142), creates it and related files by duplicating objects from the appropriate library: - If
&P$FGRP = 'G', duplicates fromDATAlibrary. - If
&P$FGRP ≠ 'G', duplicates fromDATADEVlibrary (per JK02). - Creates files:
BB802W,BB802WL1,BB802BQF,BB802FQF,BB802HQF,BB802IQF,BB802PQF. - Handles errors (
CPF5813,CPF7302) usingMONMSGto 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
&FILE01to&P$FGRP + 'BBORDH'(e.g.,GBBORDHorZBBORDH). - Overrides
BBORDHto&FILE01withSHARE(*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
BB802WtoQTEMP/BB802W. - Calls
BB802Ato 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
&FILE01to&P$FGRP + 'BBORDD'and&FILE02to&P$FGRP + 'BBORDH'. - Overrides
BB802BQFto&FILE01withSHARE(*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:
BDCOtoBOCO,BDORDNtoBORDNO, withJDFTVAL(*YES)for outer join. - Overrides
BB802WtoQTEMP/BB802W. - Calls
BB802Bto 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
&FILE01to&P$FGRP + 'SA5SHP'(e.g.,GSA5SHPorZSA5SHP). - Overrides
SA5SHPto&FILE01withSHARE(*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
BB802WtoQTEMP/BB802W. - Calls
BB802Eto 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
&FILE01to&P$FGRP + 'SA5FILD'and&FILE02to&P$FGRP + 'SA5SHP'. - Overrides
BB802FQFto&FILE01withSHARE(*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:
SACOtoSHCO,SACUSTtoSHCUST,SAORDtoSHORD,SAINVNtoSHINV, withJDFTVAL(*YES). - Overrides
BB802WtoQTEMP/BB802W. - Calls
BB802Fto 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
&FILE01to&P$FGRP + 'SA5MOVD'and&FILE02to&P$FGRP + 'SA5SHP'. - Overrides
BB802PQFto&FILE01withSHARE(*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
BB802WtoQTEMP/BB802W. - Calls
BB802Pto 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
&FILE01to&P$FGRP + 'BBCNH'and&FILE02to&P$FGRP + 'BBCNOR'. - Overrides
BB802HQFto&FILE01withSHARE(*YES). - Opens a query file (
OPNQRYF) with: - Files:
&FILE01,&FILE02. - Format:
BB802HQF. - Query selection:
&QRYSLT. - Key fields:
BOCO,BOCUST,BORDNO,BOINVN. - Join fields:
BOCOtoBCCO,BORDNOtoBCORDN, withJDFTVAL(*YES). - Overrides
BB802WtoQTEMP/BB802W. - Calls
BB802Hto 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
&FILE01to&P$FGRP + 'BBCND',&FILE02to&P$FGRP + 'BBCNH', and&FILE03to&P$FGRP + 'BBCNOR'. - Overrides
BB802IQFto&FILE01withSHARE(*YES). - Opens a query file (
OPNQRYF) with: - Files:
&FILE01,&FILE02,&FILE03. - Format:
BB802IQF. - Query selection:
&QRYSLT. - Key fields:
BDCO,BOCUST,BDORDN,BOINVN. - Join fields:
BDCOtoBOCO,BDORDNtoBORDNO,BDCOtoBCCO,BDORDNtoBCORDN, withJDFTVAL(*YES). - Overrides
BB802WtoQTEMP/BB802W. - Calls
BB802Ito process the query results. - Closes the query file and deletes overrides.
- Sets
-
Retrieve Ship-to Destination City:
- Purpose: Updates
BB802Wwith ship-to destination city fromSHIPTO. - Actions (executed if
&P$DSTC ≠ 'Q'): - Sets
&FILE01to&P$FGRP + 'SHIPTO'. - Overrides
SHIPTOto&FILE01withSHARE(*YES). - Overrides
BB802WtoQTEMP/BB802W. - Calls
BB802Gto 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
BB802Wand related logical files (BB802WL1,BB802BQF,BB802FQF,BB802HQF,BB802IQF,BB802PQF) are created inQTEMPto 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 (
SA5FILDorSA5MOVDbased 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$FGRPparameter ('G' or 'Z') determines the library prefix for files (e.g.,GBBORDHvs.ZBBORDH). -
Overrides ensure the correct library is accessed based on the environment.
-
Product Move Support (JK01):
- If
P$PMOV = 'Y'andP$MODE = 'SAD', usesSA5MOVDinstead ofSA5FILDfor sales history details, callingBB802Pinstead ofBB802F. -
This supports queries involving product moves, ensuring compatibility with move-specific data.
-
Query Selection:
- The
&QRYSLTparameter 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 fromSHIPTOto enhance the work file. -
This step is skipped if
P$DSTC = 'Q', optimizing performance when destination data is not needed. -
Error Handling:
- Uses
MONMSGto 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
CAPOorKRAJTEST). -
Revision-Specific Rules:
- JB01: Changed work file creation to copy from
ARGDEVorARGDEVTEST(superseded by JK02). - JK01: Added support for product moves, processing
SA5MOVDwhenP$PMOV = 'Y'. - JK02: Updated library references to
DATAandDATADEV, overriding work files toQTEMPfor 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
GorZ). - BBORDD: Open order detail file (prefixed with
GorZ). - SA5SHP: Sales history header file (prefixed with
GorZ). - SA5FILD: Sales history detail file (prefixed with
GorZ). - SA5MOVD: Sales history move detail file (prefixed with
GorZ, used ifP$PMOV = 'Y'). - BBCNH: Canceled order header file (prefixed with
GorZ). - BBCND: Canceled order detail file (prefixed with
GorZ). - BBCNOR: Canceled order reason file (prefixed with
GorZ). - SHIPTO: Ship-to master file (prefixed with
GorZ, used ifP$DSTC ≠ 'Q').
External Programs Called¶
The program calls the following external programs based on the mode:
- BB802A: Processes open order header data (
ORHmode). - Parameters: None explicitly passed (relies on file overrides and open query).
- BB802B: Processes open order detail data (
ORDmode). - Parameters: None explicitly passed.
- BB802E: Processes sales history header data (
SAHmode). - Parameters: None explicitly passed.
- BB802F: Processes sales history detail data (
SADmode,P$PMOV ≠ 'Y'). - Parameters: None explicitly passed.
- BB802P: Processes sales history move detail data (
SADmode,P$PMOV = 'Y'). - Parameters: None explicitly passed.
- BB802H: Processes canceled order header data (
CNHmode). - Parameters: None explicitly passed.
- BB802I: Processes canceled order detail data (
CNDmode). - Parameters: None explicitly passed.
- BB802G: Updates
BB802Wwith ship-to destination city data (whenP$DSTC ≠ 'Q'). - Parameters: None explicitly passed.
Additional Notes¶
- File Overrides: The program uses
OVRDBFto dynamically map files to the correct library (DATAorDATADEV) and ensure shared access (SHARE(*YES)). - Query Flexibility: The
OPNQRYFcommand allows dynamic filtering via&QRYSLT, supporting complex user-defined criteria from BB802. - Temporary Files: All work files are created in
QTEMPto 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
CPYFRMQRYFcommands 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.