IN805BC CLP
The IN805BC.clp.txt document is a CLP (Control Language Program) written for an IBM System/36 or AS/400 (now IBM i) environment, called from the BB101.ocl36.txt OCL program. Its purpose is to build work files (INWZHW and INWZ10W) in the QTEMP library to accumulate totals for tanks in the work file IN805W. The program was written by Jimmy Krajacic on 03/14/2018 and revised on 08/30/21 (revision JK01) to update library references and copy files to QTEMP. Below is a detailed explanation of the process steps, business rules, tables (files) used, and any external programs called.
Process Steps of the CLP Program¶
The IN805BC CLP program creates and populates temporary work files (INWZHW and INWZ10W) in the QTEMP library by copying data from source files based on input parameters. The steps are as follows:
- Program Initialization:
- The program accepts two parameters:
&P$FGRP(1 character): File group identifier (e.g., 'G' or other values).&P$CO#(2 characters): Company number.
-
Declares variables:
&WRKFIL1(10 characters): Name of the first source file, constructed as&P$FGRP + 'INWZH'.&WRKFIL2(10 characters): Name of the second source file, constructed as&P$FGRP + 'INWZ' + &P$CO#.
-
Construct File Names:
- Concatenates
&P$FGRPwith'INWZH'to form&WRKFIL1(e.g., 'GINWZH' for&P$FGRP='G'). -
Concatenates
&P$FGRP,'INWZ', and&P$CO#to form&WRKFIL2(e.g., 'GINWZ01' for&P$FGRP='G'and&P$CO#='01'). -
Clear or Create Work File
INWZHW: - Attempts to clear the physical file
QTEMP/INWZHWusingCLRPFM. -
If the file does not exist (
CPF3142message), executes aDOblock:- If
&P$FGRP = 'G': - Creates a duplicate object of
INWZHWfrom theDATAlibrary toQTEMPusingCRTDUPOBJ, with constraints (CST(*NO)) and triggers (TRG(*NO)) disabled. - Monitors for errors
CPF5813(template file locked) andCPF7302(constraint error). - If
&P$FGRP ≠ 'G': - Creates a duplicate object of
INWZHWfrom theDATADEVlibrary toQTEMPwith the same settings. - Monitors for the same errors.
- If
-
Clear or Create Work File
INWZ10W: - Attempts to clear the physical file
QTEMP/INWZ10WusingCLRPFM. -
If the file does not exist (
CPF3142message), executes aDOblock:- If
&P$FGRP = 'G': - Creates a duplicate object of
INWZ10Wfrom theDATAlibrary toQTEMPwith constraints and triggers disabled. - Monitors for errors
CPF5813andCPF7302. - If
&P$FGRP ≠ 'G': - Creates a duplicate object of
INWZ10Wfrom theDATADEVlibrary toQTEMPwith the same settings. - Monitors for the same errors.
- If
-
Copy Data to Work Files:
- Copies data from the source file
&WRKFIL1(e.g.,GINWZH) toQTEMP/INWZHWusingCPYFwith:MBROPT(*REPLACE): Replaces existing data in the target file.FMTOPT(*NOCHK): Bypasses format checking for faster copying.- Monitors for error
CPF2817(copy failed, e.g., if source file is empty or does not exist).
-
Copies data from the source file
&WRKFIL2(e.g.,GINWZ01) toQTEMP/INWZ10WusingCPYFwith the same options and error monitoring. -
Program Termination:
- The program ends with
ENDPGMafter completing the file creation and data copy operations.
Business Rules¶
The program enforces the following business rules:
- Dynamic File Naming:
- Source file names are dynamically constructed using
&P$FGRPand&P$CO#to ensure the correct files are accessed (e.g.,GINWZH,GINWZ01). -
This allows the program to handle different file groups and company-specific data.
-
Library Selection Based on File Group:
- If
&P$FGRP = 'G', source files are copied from theDATAlibrary (production environment). -
If
&P$FGRP ≠ 'G', source files are copied from theDATADEVlibrary (development or test environment, per revision JK01). -
Temporary Work Files:
- Work files (
INWZHW,INWZ10W) are created in theQTEMPlibrary, which is temporary and unique to the job, ensuring isolation and cleanup upon job completion. -
If the files do not exist, they are created by duplicating objects from the appropriate library (
DATAorDATADEV). -
Error Handling:
- The program handles missing files (
CPF3142) by creating them dynamically. - It monitors for file copy errors (
CPF2817) and object creation errors (CPF5813,CPF7302) to ensure robust execution without abending. -
Constraints and triggers are disabled (
CST(*NO),TRG(*NO)) to simplify file creation and avoid conflicts. -
Data Replacement:
- The
CPYFcommand usesMBROPT(*REPLACE)to overwrite any existing data inINWZHWandINWZ10W, ensuring the work files contain the latest data. FMTOPT(*NOCHK)bypasses format validation, assuming the source and target file formats are compatible.
Tables (Files) Used¶
The program interacts with the following files:
- INWZHW (in
QTEMP): - Temporary work file created or cleared to store data copied from
&WRKFIL1(e.g.,GINWZH). - Source library:
DATA(if&P$FGRP = 'G') orDATADEV(if&P$FGRP ≠ 'G'). - INWZ10W (in
QTEMP): - Temporary work file created or cleared to store data copied from
&WRKFIL2(e.g.,GINWZ01). - Source library:
DATA(if&P$FGRP = 'G') orDATADEV(if&P$FGRP ≠ 'G'). - &WRKFIL1 (e.g.,
GINWZH): - Source file in
DATAorDATADEV, dynamically named using&P$FGRP + 'INWZH'. - &WRKFIL2 (e.g.,
GINWZ01): - Source file in
DATAorDATADEV, dynamically named using&P$FGRP + 'INWZ' + &P$CO#.
External Programs Called¶
The IN805BC CLP program does not call any external programs. It relies entirely on CL commands (CHGVAR, CLRPFM, CRTDUPOBJ, CPYF) for its operations.
Summary¶
The IN805BC CLP program, called from the BB101.ocl36.txt OCL program, builds temporary work files (INWZHW and INWZ10W) in the QTEMP library to accumulate tank totals for the IN805W work file. It constructs source file names using input parameters &P$FGRP and &P$CO#, clears or creates the target files, and copies data from source files in the DATA (production) or DATADEV (development) library based on the file group. Business rules ensure dynamic file naming, appropriate library selection, error handling, and data replacement in temporary files. The program interacts with four files (INWZHW, INWZ10W, and their source files) and does not call external programs, relying on internal CL commands for all processing.