BIFX43 RPG36
The provided document, BIFX43.rpg36.txt, is an RPG (Report Program Generator) program for the IBM System/36 environment, named BIFX43. This program is invoked by the OCL script BIFX43.ocl36.txt (previously analyzed) and is part of the pricing generation process initiated by PRICEGEN.clp. The program’s primary purpose is to update the "Last Updated Date and Time" fields (BALUDT and BALUTM) with the "Creation Date and Time" (BACRDT and BACRTM) for new records in the BICUAG file when these fields are empty. Below, I will explain the process steps, business rules, tables used, and external programs called.
Process Steps of the RPG Program¶
- File Definition:
-
The
Fspecification defines theBICUAGfile:- Access: Update mode (
UP) and fixed-length records of 256 bytes. - Type: Disk file, likely a physical file.
- Usage: The file is used for both input and output, as indicated by the update mode and the
O(output) specification.
- Access: Update mode (
-
Input Specifications:
-
The
Ispecifications define the record format for theBICUAGfile (record typeNS 01). The fields are mapped to specific positions in the 256-byte record, including:BADEL(1): Delete code.BACONO(2–3): Company.BACUST(4–9): Customer number.BALOC(10–12): Location.BAPR01toBAPR10(13–52): Product codes 1 to 10.BASTDT(53–59): Start date (YMD format).BASTTM(60–63): Start time (HM format).BAENDT(64–70): End date (YMD format).BAENTM(71–74): End time (HM format).BAPRCE(75–80.4): Price (4 decimal places).BAOFFP(81–86.4): Off-price (4 decimal places).BAMNGL(87–93): Minimum gallons/month.BAMXGL(94–100): Maximum gallons/month.BAPPD(101): Prepaid sale indicator (P or blank).BAALSH(102): Apply to all ship-to (Y, N, or blank).BAPRIM(106): Pricing at invoice or end of month (I, M, or blank).BASTD8(118–125): Start date (CYMD format).BAEND8(126–133): End date (CYMD format).BADELV(134): Delivery indicator (Y, N, or blank).BAFRCD(135): Freight code (C, P, A, or blank).BACRDT(136–143): Creation date (CYMD format).BACRTM(144–149): Creation time (HMS format).BALUDT(150–157): Last update date (CYMD format).BALUTM(158–163): Last update time (HMS format).BACNTR(164–166): Container code.BASHIP(167–169): Ship-to number.BACNT#(170–180): Contract number.BAUNMS(181–183): Unit of measure.
-
Initialization (One-Time Setup):
-
The
C(calculation) specifications include a one-time initialization block controlled by theONCEindicator:- Condition:
ONCE IFEQ *ZEROSchecks if theONCEfield (a 10-digit numeric variable) is zero, indicating the first execution. - Actions:
- Increment
ONCEby 1 to prevent re-execution. - Use the
TIMEoperation to retrieve the current system date and time intoTIMDAT(12 digits: likely YYMMDDHHMMSS). - Move the time portion (first 6 digits of
TIMDAT) toSYSTIM(6 digits: HHMMSS). - Move the date portion (first 6 digits of
TIMDAT) toSYSDAT(6 digits: YYMMDD). - This block captures the system date and time for potential use, though these fields (
SYSTIM,SYSDAT) are not directly used in the provided code.
- Condition:
-
Record Processing:
- The program processes records from the
BICUAGfile (indicated by the01indicator for theNS 01record type). - For each record, it checks the following conditions:
BALUDT IFEQ *ZEROS: The last update date is blank/zero.BALUTM IFEQ *ZEROS: The last update time is blank/zero.BACRDT IFNE *ZEROS: The creation date is not blank/zero.BACRTM IFNE *ZEROS: The creation time is not blank/zero.
-
If all conditions are true (i.e., the record is new with a valid creation date/time but no last update date/time), the program executes an
EXCPToperation to update the record. -
Output/Update Operation:
- The
O(output) specifications define an exception output (E) for theBICUAGfile:- Fields
BACRDTandBACRTMare written to positions 150–157 and 158–163, respectively, which correspond toBALUDTandBALUTMin the input record. - The
Bin the output specification indicates that these fields are written only if both input and output values are non-blank/non-zero.
- Fields
- This updates the
BALUDTandBALUTMfields with the values ofBACRDTandBACRTM, respectively, effectively setting the last update date and time to the creation date and time for new records.
Business Rules¶
- Purpose: The program ensures that new records in the
BICUAGfile have their last update date (BALUDT) and time (BALUTM) fields populated with the creation date (BACRDT) and time (BACRTM) when these fields are empty. - Condition for Update:
- The record must have:
BALUDT= blank/zero (no last update date).BALUTM= blank/zero (no last update time).BACRDT≠ blank/zero (valid creation date).BACRTM≠ blank/zero (valid creation time).
- This ensures updates occur only for new records with valid creation timestamps.
- Field Mapping:
BACRDT→BALUDT(copy creation date to last update date).BACRTM→BALUTM(copy creation time to last update time).- Non-Destructive Update: Only the
BALUDTandBALUTMfields are updated; other fields in the record remain unchanged. - Context in Pricing Generation: As part of the
PRICEGENprocess,BIFX43likely prepares pricing records inBICUAGby ensuring consistent timestamp data, which may be critical for tracking or auditing purposes in subsequent steps (e.g., byBIFX44,BI944B, etc.).
Tables (Files) Used¶
- BICUAG: The only file explicitly used in the program.
- Access: Update mode (
UP). - Purpose: Read records, check conditions, and update
BALUDTandBALUTMfields. - Label: As defined in the OCL script (
?9?BICUAG), the file name is dynamic (e.g.,ABICUAGif the parameter is'A'fromPRICEGEN.clp).
External Programs Called¶
- None: The
BIFX43RPG program does not explicitly call any external programs or subroutines within the provided code. It operates solely on theBICUAGfile and performs internal logic.
Additional Notes¶
- System/36 Context: The program runs in a System/36 environment (or AS/400 in compatibility mode), as indicated by the OCL script and RPG II/III syntax. The
BIFX43program is one step in the pricing generation workflow initiated byPRICEGEN.clp. - Parameter Integration: The
?9?in the OCL file label (?9?BICUAG) likely corresponds to the&P$GRPparameter (e.g.,'A') passed via&PARM9fromPRICEGEN.clp, ensuring the correct file (e.g.,ABICUAG) is processed. - Data Integrity: The program ensures data consistency by populating missing last update timestamps, which may be required for downstream processes or reporting.
- Limitations: The program only updates
BALUDTandBALUTM. TheSYSDATandSYSTIMfields (from theTIMEoperation) are not used, suggesting the initialization block may be a remnant of a template or unused functionality. - Error Handling: The program lacks explicit error handling (e.g., for file access issues or invalid data), relying on the System/36 environment or the calling CLP (
PRICEGEN.clp) to manage errors.
If you have additional RPG or OCL source files for the other procedures (BIFX44, BI944B, BI942E, PRICES) or need further analysis of how BIFX43 integrates with the pricing generation process, please provide those details!