Skip to content

GS973 RPG36

Process Steps of the RPG Program GS973

This RPG III program (for IBM System/36) performs interactive maintenance on product-container master records. It uses a workstation display file (SCREEN) with two screen formats: S1 (input/validation screen for company, product, and container) and S2 (review/update screen showing descriptions, last sold date, and status). The program runs in a loop until exit, handling user input, validations, data retrieval from files, and updates. It initializes the current date (in YYYYMMDD format) for potential updates to the "last sold date" field.

The high-level process flow is as follows:

  1. Initialization and Main Loop Setup:
  2. The program enters a main loop (DOWNE 'EJ') that continues until an exit condition (e.g., command key for end job) is met.
  3. It checks the current screen ID (@SFID) and branches to the appropriate subroutine: $SBLK (for initial blank screen), $S1 (for S1 screen processing), or $S2 (for S2 screen processing).
  4. After processing, it calls $XCPT to display the next screen, then reads user input from the SCREEN file (with LR indicator for last record if needed).
  5. Command keys (e.g., via @VKEY from INFDS) trigger specific actions like enter (0) or command key processing (2).

  6. Initial Blank Screen Handling ($SBLK):

  7. Clears fields: company (CO), product (PROD), container (CNTR).
  8. Sets indicator 99 (likely for conditioning fields or highlights).
  9. Prepares the current date in YYYYMMDD format (using TIME opcode and calculations) for potential use in updates.
  10. Sets @SFNEX and @SFID to 'S1' to transition to the input screen.

  11. S1 Screen Processing ($S1):

  12. Handles input from S1 screen (company, product, container).
  13. Branches based on @VKEY: to $S1ENT for ENTER key (validations and data retrieval) or $S1CK for command keys.

  14. S1 Validations and Data Retrieval ($S1ENT):

  15. Validates company (CO): Must not be zero/blank; chains to INCONT file to confirm existence (error if not found: "COMPANY NOT IN CONTROL FILE").
  16. Validates product (PROD): Must not be blank (error: "PRODUCT CANNOT BE BLANK").
  17. Container (CNTR): Validation for blank is commented out, so it appears optional.
  18. Chains to PRCNTR using SCKEY (composite key: likely CO + PROD + CNTR) to retrieve record.
    • Error if not found: "INVALID COMBINATION ENTERED".
    • If found, checks deletion flag (PNDEL='D'): Error "THIS RECORD MARKED AS DELETED".
    • Checks inactive flag (PNDEL='I'): Error "THIS RECORD MARKED AS INACTIVE".
  19. Retrieves product description: Chains to GSPROD using PRDKEY (CO + PROD), moves TPDESC to PRDESC.
  20. Retrieves container description: Chains to GSCNTR using CNTR, moves TCDESC to CNDESC.
  21. If all valid, sets @SFNEX to 'S2' to transition to review screen.

  22. S1 Command Key Handling ($S1CK):

  23. KG (likely F3 or exit key): Sets @SFNEX to 'EJ' to end the loop and job.

  24. S2 Screen Processing ($S2):

  25. Handles input from S2 screen (displays retrieved data plus status input).
  26. Branches based on @VKEY: to $S2ENT for ENTER key (update processing) or $S2CK for command keys.

  27. S2 Update Processing ($S2ENT):

  28. Re-chains to PRCNTR to confirm record.
  29. If status (STAT) is 'A' (accept), sets indicator 51 and outputs update to PRCNTR: Updates last sold date (PNLSD8) to current date and status (PNSTAT) to 'A'.
  30. Calls CLRFLD to blank out fields (STAT, etc.) and reset to S1 screen.
  31. If not 'A', no update occurs, and it resets to S1.

  32. S2 Command Key Handling ($S2CK):

  33. KA (likely reset/clear key): Clears all fields (CO, PROD, CNTR, STAT, PRDESC, CNDESC) and resets to S1 screen.
  34. KG: Sets @SFNEX to 'EJ' to exit.

  35. Screen Display and Indicator Management ($XCPT):

  36. Increments screen counter (@CCNT).
  37. If @SFNEX matches @SFID, sets indicator 98 (likely for refresh).
  38. Outputs the appropriate screen format: @S1 or @S2, including fields like CO, PROD, CNTR, messages, descriptions, last sold date (formatted as MM/DD/YY), and status.
  39. Calls CLRIND to reset error indicators (90-83) and blank messages.

  40. Field Clearing and Reset (CLRFLD and CLRIND):

    • CLRFLD: Blanks STAT, sets 99, resets to S1.
    • CLRIND: Turns off error indicators, blanks MSG1/MSG2.
  41. Error Handling:

    • Errors set indicators (e.g., 90 for company, 81 for general, 82 for product/combination) and display messages (MSG1/MSG2).
    • Program stays on the current screen for corrections.
  42. Loop Exit:

    • When @SFNEX='EJ', the main loop ends, and the program terminates (implicit end via LR).

Business Rules

  • Required Fields: Company (CO) must be non-zero and exist in the company control file (INCONT). Product (PROD) must not be blank. Container (CNTR) is effectively optional (blank check commented out).
  • Validation of Combination: The company + product + container must exist in PRCNTR and not be marked deleted ('D') or inactive ('I').
  • Data Retrieval: Product and container descriptions are fetched from GSPROD and GSCNTR only if the combination is valid.
  • Status Update: On S2, status (PNSTAT) can be set to 'A' (accept) or possibly 'O' (override, inferred from field comment). If 'A', the last sold date (PNLSD8) is updated to the current system date, enforcing a business rule that acceptance records the sale date.
  • No Adds/Deletes: The program supports updates only (to status and last sold date in PRCNTR). No new records are added, and deletions are checked but not performed here.
  • Date Handling: Current date is always computed at startup and used for updates (format: YYYYMMDD internally, MM/DD/YY on screen).
  • Error Messaging: Specific messages for blanks, invalid combinations, non-existent company, deleted/inactive records. Messages are displayed on screen without halting.
  • User Interface Rules: Screens are chained (S1 to S2 on valid input, back to S1 after update). Command keys allow reset (KA) or exit (KG). Indicators control field protection/highlighting (e.g., 99 for blanks, 51 for conditional output).
  • Shared Access: Files are opened in shared mode (from OCL), allowing concurrent use, but no explicit locking in RPG code.

Tables Used

The program uses the following files (tables) for input, validation, and updates. All are disk files with keyed access:

File Name Type Key Length Record Length Purpose/Description Fields Accessed (Key Examples)
SCREEN Workstation (Display) N/A 1000 Interactive screens S1 (input/validation) and S2 (review/update). CO (company), PROD (product), CNTR (container), STAT (status), PRDESC (product desc), CNDESC (container desc), PNLSD8 (last sold date), MSG1/MSG2 (errors).
PRCNTR Update (UF) 9 bytes 51 Product-container master; main file for maintenance. Checked for existence, deletion/inactive status; updated with status and last sold date. Key: Likely IAKEY (company + product + container). Fields: PNDEL (delete flag), PNCONO (company), PNPROD (product), PNCNTR (container), PNLSD8 (last sold date), PNSTAT (status: 'A' accept, 'O' override).
GSPROD Input (IF) 6 bytes 512 Product master; read-only for descriptions and details. Key: PRDKEY (company + product). Fields: TPDEL (delete), TPCONO (company), TPPROD (product), TPDESC (description).
GSCNTR Input (IF) 3 bytes 512 Container master; read-only for descriptions. Key: CNTR (container code). Fields: TCDEL (delete), TCCNTR (container), TCDESC (description).
INCONT Input (IC) 2 bytes 512 Company control file; validates company existence. Key: CO (company number). No specific fields read beyond existence check.

External Programs Called

  • None. The program uses only internal subroutines (e.g., $S1, $S2, $XCPT) and does not contain CALL opcodes or references to external programs/procedures. All logic is self-contained within GS973.