Skip to content

GSDT12 RPG36

The provided document, GSDT12.rpg36.txt, is an RPG (Report Program Generator) program for the IBM System/36 environment (or AS/400 in compatibility mode), named GSDT12. It is invoked by the OCL script GSDT12.ocl36.txt, which is called by SA505C.ocl36.txt with parameter 'G' within the PRICES.ocl36.txt workflow, part of the PRICEGEN.clp pricing generation process for blended lubes. The program processes date-related data, likely prompting for or calculating a date range for the Customer Shipping Analysis Report, and updates the Local Data Area (LDA) with start and end dates (FRDT8, TODT8). Below, I will explain the process steps, business rules, tables used, and external programs called, despite the truncation in the document.

Process Steps of the RPG Program

  1. File Definitions:
  2. Input File:
    • ARCONT (Input Primary, IP, 256 bytes, indexed with 2-byte key, disk): Contract master file, mapped to ?9?ARCONT (e.g., AARCONT), shared mode.
  3. User Data Structure (UDS):

    • YY (124–125): Year (YY) for start date.
    • MM (126–127): Month (MM) for start date.
    • DD (128–129): Day (DD) for start date.
    • NWYY (130–131): Year (YY) for end date.
    • NWMM (132–133): Month (MM) for end date.
    • NWDD (134–135): Day (DD) for end date.
    • FRDT8 (175–182): Start date (CYMD, CCYYMMDD).
    • TODT8 (183–190): End date (CYMD, CCYYMMDD).
    • Y2KCEN (509–510): Century for Y2K compliance.
    • Y2KCMP (511–512): Company-specific century.
  4. Input Specifications:

  5. ARCONT (record type NS 01):
    • ACDEL (1): Delete code (indicates if the record is active or deleted).
  6. UDS Fields:

    • Input fields (YY, MM, DD, NWYY, NWMM, NWDD) likely set by user input or prior programs.
    • Output fields (FRDT8, TODT8) store calculated start and end dates in CYMD format.
  7. Calculation Specifications:

  8. Initialization:
    • TIME TIMDAT: Gets system time (TIMDAT, 12 digits, YYMMDDHHMMSS).
    • MOVELTIMDAT SYTIME: Moves time to SYTIME (6 digits, HHMMSS).
    • MOVE TIMDAT SYDATE: Moves date to SYDATE (6 digits, YYMMDD).
    • SYDATE MULT 10000.01 SYDYMD: Converts SYDATE to YMD format with century (CCYYMMDD).
    • MOVELSYDATE NWMM: Moves month to NWMM.
    • MOVE SYDATE NWYY: Moves year to NWYY.
    • Z-ADDSYDATE MDY: Moves SYDATE to MDY (6 digits, MMDDYY).
    • EXSR GETDT: Calls the GETDT subroutine to calculate dates.
  9. GETDT Subroutine:
    • Calculates the end date (TODT8) based on the start date (FRDT8 or input YY, MM, DD).
    • Logic for end date calculation:
    • If DD = 1:
      • If MM = 12: Sets NWYY = YY + 1, NWMM = 1.
      • Else: Increments MM by 1.
      • Sets DD = 1.
    • Sets NWDD based on month:
      • For months 1, 3, 5, 7, 8, 10, 12: NWDD = 31.
      • For month 2: NWDD = 29 (no leap year check shown in provided code).
      • For months 4, 6, 9, 11: NWDD = 30.
    • Formats dates:
    • MOVEL20 FRDT8: Sets century to 20 for FRDT8 (Y2K compliance).
    • MOVEL20 TODT8: Sets century to 20 for TODT8.
    • MOVELYY FRDT4: Builds FRDT4 (YYYYMM).
    • MOVE MM FRDT4: Adds month to FRDT4.
    • MOVELFRDT4 FRDT6: Builds FRDT6 (YYYYMMDD).
    • MOVE DD FRDT6: Adds day to FRDT6.
    • MOVE FRDT6 FRDT8: Finalizes FRDT8 (CCYYMMDD).
    • Similar steps for TODT8 using NWYY, NWMM, NWDD.
  10. Finalization:

    • SETON LR: Sets Last Record indicator to end processing.
  11. Output Specifications:

  12. No explicit output file writes; updates are made to the LDA (FRDT8, TODT8) for use by subsequent programs (e.g., SA505C, SA505X).

Business Rules

  1. Purpose: Calculates or validates a date range for the Customer Shipping Analysis Report, setting FRDT8 (start date) and TODT8 (end date) in the LDA, likely based on user input (YY, MM, DD) or system date, using ARCONT for company-specific context.
  2. Date Calculation:
  3. Uses system date (SYDATE) as a baseline.
  4. Calculates end date (TODT8) as the last day of the same or next month, depending on input:
    • If start day is 1, sets end date to the first day of the next month.
    • Assigns NWDD based on month (31 for January, March, May, July, August, October, December; 29 for February; 30 for April, June, September, November).
  5. Formats dates in CYMD (CCYYMMDD) with century hardcoded as 20 for Y2K compliance.
  6. Y2K Compliance:
  7. Handles century (Y2KCEN, Y2KCMP) to ensure correct date formatting.
  8. Hardcodes century as 20, indicating processing for post-2000 dates.
  9. Context: Called by SA505C.ocl36.txt with parameter 'G', initializing date parameters for filtering sales data in SA505X, SA505C, and subsequent programs.
  10. Output: Updates LDA fields FRDT8 and TODT8, used by other programs for date range filtering (e.g., KYFRDT, KYTODT in SA505C, SA505X).

Tables (Files) Used

  1. ARCONT (?9?ARCONT):
  2. Access: Input Primary (IP), shared mode.
  3. Purpose: Contract master file, likely used to validate company-specific data or provide context, though no specific fields are processed in the provided code.

External Programs Called

  • None: The GSDT12 program does not call external programs. It uses the internal GETDT subroutine for date calculations.

Additional Notes

  • Context: Invoked by GSDT12.ocl36.txt within SA505C.ocl36.txt, setting date parameters for the Customer Shipping Analysis Report workflow, part of PRICES.ocl36.txt.
  • System/36 Environment: Uses RPG II/III syntax, likely on AS/400.
  • Truncation: The document is truncated, but key sections (F, I, C) provide sufficient detail. Missing code likely includes additional validation or user prompting logic.
  • Error Handling: Minimal error handling; relies on System/36 for file errors and assumes valid input in the LDA.
  • Relation to Other Programs: Provides FRDT8 and TODT8 for SA505C, SA505X, and others, ensuring consistent date filtering across the workflow.
  • Y2K Considerations: Hardcodes century as 20, which may limit processing for dates before 2000 or after 2099.

If you have the RPG source code for SA505E, SA505J, or SA505L, or need further analysis of the pricing workflow, please provide those details! Let me know if you have additional questions or files to share.