Skip to content

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

  1. File Definition:
  2. The F specification defines the BICUAG file:

    • 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.
  3. Input Specifications:

  4. The I specifications define the record format for the BICUAG file (record type NS 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.
    • BAPR01 to BAPR10 (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.
  5. Initialization (One-Time Setup):

  6. The C (calculation) specifications include a one-time initialization block controlled by the ONCE indicator:

    • Condition: ONCE IFEQ *ZEROS checks if the ONCE field (a 10-digit numeric variable) is zero, indicating the first execution.
    • Actions:
    • Increment ONCE by 1 to prevent re-execution.
    • Use the TIME operation to retrieve the current system date and time into TIMDAT (12 digits: likely YYMMDDHHMMSS).
    • Move the time portion (first 6 digits of TIMDAT) to SYSTIM (6 digits: HHMMSS).
    • Move the date portion (first 6 digits of TIMDAT) to SYSDAT (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.
  7. Record Processing:

  8. The program processes records from the BICUAG file (indicated by the 01 indicator for the NS 01 record type).
  9. 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.
  10. 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 EXCPT operation to update the record.

  11. Output/Update Operation:

  12. The O (output) specifications define an exception output (E) for the BICUAG file:
    • Fields BACRDT and BACRTM are written to positions 150–157 and 158–163, respectively, which correspond to BALUDT and BALUTM in the input record.
    • The B in the output specification indicates that these fields are written only if both input and output values are non-blank/non-zero.
  13. This updates the BALUDT and BALUTM fields with the values of BACRDT and BACRTM, respectively, effectively setting the last update date and time to the creation date and time for new records.

Business Rules

  1. Purpose: The program ensures that new records in the BICUAG file have their last update date (BALUDT) and time (BALUTM) fields populated with the creation date (BACRDT) and time (BACRTM) when these fields are empty.
  2. Condition for Update:
  3. 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).
  4. This ensures updates occur only for new records with valid creation timestamps.
  5. Field Mapping:
  6. BACRDTBALUDT (copy creation date to last update date).
  7. BACRTMBALUTM (copy creation time to last update time).
  8. Non-Destructive Update: Only the BALUDT and BALUTM fields are updated; other fields in the record remain unchanged.
  9. Context in Pricing Generation: As part of the PRICEGEN process, BIFX43 likely prepares pricing records in BICUAG by ensuring consistent timestamp data, which may be critical for tracking or auditing purposes in subsequent steps (e.g., by BIFX44, 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 BALUDT and BALUTM fields.
  • Label: As defined in the OCL script (?9?BICUAG), the file name is dynamic (e.g., ABICUAG if the parameter is 'A' from PRICEGEN.clp).

External Programs Called

  • None: The BIFX43 RPG program does not explicitly call any external programs or subroutines within the provided code. It operates solely on the BICUAG file 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 BIFX43 program is one step in the pricing generation workflow initiated by PRICEGEN.clp.
  • Parameter Integration: The ?9? in the OCL file label (?9?BICUAG) likely corresponds to the &P$GRP parameter (e.g., 'A') passed via &PARM9 from PRICEGEN.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 BALUDT and BALUTM. The SYSDAT and SYSTIM fields (from the TIME operation) 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!