Skip to content

AR200P RPGLE

The provided document, AR200P.rpgle.txt, is an RPGLE (RPG IV) program used in an IBM AS/400 or iSeries environment, called from the OCL script AR201P.ocl36.txt. It handles the journal date prompt for accounts receivable (A/R) transaction posting, interacting with a workstation display file to collect and validate user input. Below, I’ll explain the process steps, business rules, tables used, and external programs called.

Process Steps of the RPG Program (AR200P)

The program AR200P is designed to prompt the user for a journal date, validate it, and confirm the input before allowing A/R transaction posting to proceed. Here’s a step-by-step breakdown of the process:

  1. Program Initialization:
  2. The program defines a workstation display file AR200PD (renamed from SCREEN during conversion) as a CF (combined file) with a handler for a graphical interface (PROFOUNDUI(HANDLER)).
  3. Data structures and variables are initialized, including kyjrdt (journal date), y2kcen (century), y2kcmp (comparison year), and msg (error message array).
  4. The program uses an information data structure (@infds) to capture screen status, such as function keys (@vkey).

  5. Main Loop (Screen Processing):

  6. The program enters a DO loop (dow @sfnex <> 'EJ') that continues until the exit condition (EJ) is met, indicating the user has completed or canceled the process.
  7. The loop processes user interactions with two screen formats: AR200PS1 (for entering the journal date) and AR200PS2 (for confirming the date).

  8. Screen Selection Logic:

  9. The program uses a CASEQ structure to determine which screen to process based on @sfid (screen format identifier):

    • @sfid = *blank: Calls subroutine $sblk (initial blank screen setup).
    • @sfid = 'S1': Calls subroutine $s1 (processes journal date input screen).
    • @sfid = 'S2': Calls subroutine $s2 (processes confirmation screen).
  10. Initial Screen Setup ($sblk):

  11. Clears variables (kyjrdt, kyyn, msgout) to initialize the process.
  12. Sets @sfnex to 'S1', indicating the next screen to display is AR200PS1 (journal date input).

  13. Display and Read Screen ($xcpt and Main Loop):

  14. The $xcpt subroutine displays the next screen based on @sfnex:
    • If @sfnex = 'S1', writes AR200PS1.
    • If @sfnex = 'S2', writes AR200PS2.
    • Increments @ccnt (screen counter) and sets indicator *in98 if the same screen is redisplayed (error condition).
  15. The main loop reads the screen:

    • For AR200PS1, reads the journal date (jrdate) and sets @sfid = 'S1'.
    • For AR200PS2, reads the confirmation flag (yn) and sets @sfid = 'S2'.
  16. Process Screen AR200PS1 ($s1):

  17. Checks the function key (@vkey):
    • If 0 (Enter key), calls $s1ent to validate the journal date.
    • If 2 (command key, e.g., F3), calls $s1ck to handle exit.
  18. $s1ent (Enter key processing):
    • Moves kyjrdt to mmddyy and calls @dtedt to validate the date.
    • If date is invalid (*in79 = *on), displays error message (msgout = 'INVALID DATE') and redisplays AR200PS1 (*in50 = *on).
    • If valid, clears indicators (clrind), sets @sfnex = 'S2', and moves to the confirmation screen.
  19. $s1ck (Command key processing):

    • If F3 (*inkg = *on), sets exit indicators (*inu1, *inlr) and @sfnex = 'EJ' to terminate the program.
  20. Process Screen AR200PS2 ($s2):

  21. Checks the function key (@vkey):
    • If 0 (Enter key), calls $s2ent to process confirmation.
    • If 2 (command key), calls $s2ck to handle navigation or exit.
  22. $s2ent (Enter key processing):
    • If kyyn <> 'Y', clears fields (clrfld) and returns to AR200PS1 (@sfnex = 'S1').
    • If kyyn = 'Y', sets @sfnex = 'EJ' to exit the program, indicating confirmation.
  23. $s2ck (Command key processing):

    • If F3 (*inkg = *on), sets exit indicators and @sfnex = 'EJ'.
    • If another command key (e.g., F12, ka), returns to AR200PS1 (@sfnex = 'S1').
  24. Date Validation (@dtedt):

  25. Validates the journal date (mmddyy) in MMDDYY format:

    • Breaks down the date into month ($month), day ($day), and year ($yr).
    • Validates month (1–12).
    • For February, checks leap year:
    • Non-zero year: Divides year by 4 (multiply by 0.25) to check leap year.
    • Century year: Combines century (y2kcen) and year, divides by 400 (multiply by 0.0025).
    • Leap year allows up to 29 days; non-leap year allows 28.
    • For other months, checks 30 or 31 days based on month (e.g., April, June, September, November = 30; others = 31).
    • Sets *in79 if the date is invalid.
  26. Clear Fields and Indicators:

  27. clrfld: Resets kyjrdt, kyyn, and msgout, and sets @sfnex = 'S1' for redisplay.
  28. clrind: Clears error and display indicators (*in50, *in81*in86, *in59).

  29. Program Termination:

    • When @sfnex = 'EJ', the program exits the main loop, sets *inlr = *on (last record indicator), and terminates, returning control to the calling OCL script.

Business Rules

  1. Journal Date Validation:
  2. The user must enter a valid journal date in MMDDYY format.
  3. The date is validated for:
    • Valid month (1–12).
    • Valid day based on month (30 or 31 days) and leap year for February (28 or 29 days).
    • Leap year logic accounts for century (Y2K compliance using y2kcen and y2kcmp).
  4. Invalid dates trigger an error message (INVALID DATE) and prompt redisplay.

  5. Two-Step Input Process:

  6. Screen AR200PS1 collects the journal date.
  7. Screen AR200PS2 requires confirmation (yn = 'Y') to proceed.
  8. If confirmation is not Y, the user is returned to AR200PS1.

  9. Exit Conditions:

  10. Pressing F3 (*inkg) on either screen exits the program, setting *inu1 and *inlr.
  11. Other command keys (e.g., F12, ka) on AR200PS2 return to AR200PS1.

  12. Error Handling:

  13. Invalid dates set *in79 and display an error message.
  14. Indicators (*in50, *in81*in86, *in59) control error display and screen behavior.

Tables Used

The program uses no database files (physical or logical files) directly. Instead, it interacts with: - Workstation Display File: AR200PD (originally SCREEN), defined as a CF (combined file) with formats AR200PS1 and AR200PS2. This file handles user input/output via the screen. - Compile-Time Data: A single message array (msg) with one entry (INVALID DATE) defined in the CTDATA section.

No traditional database tables (e.g., A/R master file or journal file) are referenced, suggesting this program’s sole purpose is to collect and validate the journal date, passing it to subsequent programs (e.g., AR201) for actual transaction posting.

External Programs Called

The program does not explicitly call external programs using CALL operations. All processing is internal, with subroutines handling specific tasks: - $sblk: Initializes the blank screen. - $s1, $s1ent, $s1ck: Process the journal date input screen. - $s2, $s2ent, $s2ck: Process the confirmation screen. - $xcpt: Manages screen display. - clrind, clrfld: Clear indicators and fields. - @dtedt: Validates the journal date.

The program is called by the OCL script (AR201P.ocl36.txt) and likely passes the validated journal date (kyjrdt) to subsequent programs (e.g., AR201) via parameters or data areas.

Notes

  • Y2K Compliance: The program includes logic for century handling (y2kcen, y2kcmp) to ensure proper date validation, reflecting its conversion date (04/11/23) and Y2K considerations.
  • Conversion Notes: The T4 prefixes indicate a TARGET/400 source conversion, with 33 added lines, 8 modified lines, and 279 total lines processed. Changes include modernized syntax (e.g., EVAL instead of MOVE, READ instead of READ SCREEN).
  • Screen Formats:
  • AR200PS1: Captures jrdate (journal date, positions 3–8) and displays msgout (error message, position 41).
  • AR200PS2: Displays jrdate (position 6), captures yn (confirmation, position 7), and displays msgout (position 42).
  • Parameters: The program receives the journal date as a parameter (likely ?9? from the OCL) and stores it in kyjrdt (data area, positions 100–105).

If you have additional details (e.g., the source for AR201 or related database files), I can provide further analysis. Let me know if you need clarification or additional information!