Skip to content

VSCDS1R RPG

The VSCDS1R.rpg.txt is an RPG program (likely RPG III or RPG/36, given the System/36 context) called from the BB502.ocl36.txt OCL program and referenced in the BB502.rpg36.txt program (in the RLOOK subroutine). It is a utility module designed to retrieve carrier information from the VSCARR file and display it interactively via a workstation subfile for user selection. Below, I’ll explain the process steps, business rules, tables used, and external programs called based on the provided RPG source code.


Process Steps of the RPG Program

The VSCDS1R program retrieves carrier details (code, description, and carrier ID) based on a provided carrier code or user search input, using a workstation file (VSCDS1RDCF) with a subfile (SFLC) for interactive display. It returns the selected carrier details to the calling program. Here’s a step-by-step breakdown of the process:

  1. Program Initialization:
  2. The program defines the VSCDS1RDCF workstation file for interactive screen processing, with a subfile (SFLC) keyed by RRNC (relative record number).
  3. The VSCARR file (92 bytes, indexed, read-only, key length 1 byte) is defined to store carrier data.
  4. A data structure (@VSCD) is defined for input and output:
    • @RTCOD (10 characters): Carrier code (input/output).
    • @RTDSC (33 characters): Carrier description (output).
    • @RTCAI (6 characters): Carrier ID (output).
  5. Input specifications (I) map fields from VSCARR:

    • VCCODE (positions 1–10): Carrier code.
    • VCDESC (positions 11–43): Carrier description.
    • VCCAID (positions 44–49): Carrier ID.
    • VCFORC (position 50): Force flag (not used in the code).
  6. Parameter Input:

  7. The program accepts the @VSCD data structure via the *ENTRY PLIST, containing the input carrier code (@RTCOD) and expecting to return @RTCOD, @RTDSC, and @RTCAI.

  8. Initial Carrier Code Lookup:

  9. The program moves the input carrier code (@RTCOD) to SCRCOM (a 10-character screen field).
  10. If SCRCOM is not blank, it performs a CHAIN operation on VSCARR using SCRCOM as the key:

    • If a record is found (indicator 83 off), it moves VCCODE to @RTCOD and sets NEXT to '$EOJ' to exit.
    • If no record is found (indicator 83 on), it clears @RTCOD and proceeds to the main loop.
  11. Main Processing Loop:

  12. The program enters a DO loop controlled by the NEXT variable (10 characters, packed) until NEXT = '$EOJ':

    • If NEXT = '$XCUTC', it calls the $XCUTC subroutine (execute carrier subfile).
    • If NEXT = '$SERCH', it calls the $SERCH subroutine (search and populate subfile).
    • Otherwise, it calls the $ENTRY subroutine (display entry screen).
  13. Entry Processing ($ENTRY Subroutine):

  14. Displays the main screen (SCRE) using EXFMT.
  15. Checks user input:

    • If F3 is pressed (*IN03 = *ON), sets NEXT to '$EOJ' to exit.
    • If the search string (STRING) is blank, it sets indicators (*IN30–*IN35) to 000010, writes the subfile control (CTLC), clears the subfile (RRNC), and sets NEXT to '$SERCH' to initiate a search.
  16. Search and Populate Subfile ($SERCH Subroutine):

  17. Sets the file pointer to the beginning of VSCARR using SETLL *LOVAL.
  18. Checks if the search string (STRING) is blank (using CHEKR to compare with spaces).
  19. Reads VSCARR records in a loop until end-of-file (*IN80 = *ON):
    • Scans each record’s description (VCDESC) for the search string (STRING).
    • If a match is found (indicator 81 on), calls the $WRITE subroutine to add the record to the subfile.
  20. After the loop:

    • If records were added to the subfile (RRNC ≠ 0), sets NEXT to '$XCUTC' to display the subfile.
    • If no records were added (RRNC = 0), sets indicator 70 (error) and NEXT to '$ENTRY' to redisplay the entry screen.
  21. Write to Subfile ($WRITE Subroutine):

  22. Increments the subfile record number (RRNC) and writes the current VSCARR record to the subfile (SFLC).

  23. Execute Carrier Subfile ($XCUTC Subroutine):

  24. Sets indicators (*IN30–*IN35) to 110001, writes the subfile control (SCRC), and displays the subfile (CTLC) using EXFMT.
  25. If F12 is pressed (*IN12 = *ON), clears indicator 83 and sets NEXT to '$ENTRY' to return to the entry screen.
  26. If a carrier is selected (SCRCOM not blank), chains to VSCARR:

    • If found (indicator 82 off), moves VCCODE to @RTCOD, VCDESC to @RTDSC, clears SCRCOM, sets *IN12 to '1', and sets NEXT to '$EOJ' to exit.
    • If not found, no action is taken (remains in the subfile display).
  27. Program Termination:

  28. When NEXT = '$EOJ', the program sets the LR (Last Record) indicator and returns the @VSCD data structure with the selected carrier’s code (@RTCOD), description (@RTDSC), and ID (@RTCAI).

Business Rules

The program enforces the following business rules, inferred from the code and context:

  1. Carrier Code Validation:
  2. If a carrier code (@RTCOD) is provided, the program validates it against VSCARR. If valid, it returns the corresponding code and description immediately.
  3. If the code is invalid or blank, it allows the user to search for a carrier interactively.

  4. Interactive Carrier Selection:

  5. The program provides a subfile interface to display carrier records matching a user-entered search string (STRING) in the carrier description (VCDESC).
  6. Users can exit with F3 (*IN03) or cancel with F12 (*IN12) to return to the entry screen.

  7. Subfile Population:

  8. Only records with a description matching the search string are added to the subfile.
  9. If no matches are found, an error indicator (*IN70) is set, and the entry screen is redisplayed.

  10. Output Consistency:

  11. The program returns a blank @RTCOD if no valid carrier is found or selected.
  12. When a carrier is selected, it returns the carrier code (VCCODE), description (VCDESC), and carrier ID (VCCAID) in the @VSCD data structure.

  13. Integration with Shipment Processing:

  14. The program is called by BB502 (in the RLOOK subroutine) to validate and retrieve carrier details for shipment processing, ensuring accurate carrier information for orders.

  15. Error Handling:

  16. The program handles invalid inputs gracefully by redisplaying the entry screen or returning blanks for unfound carriers.
  17. No explicit error messages are displayed, but indicator 70 signals no matching carriers.

Tables (Files) Used

The program uses two files, as defined in the F (File) specifications:

  1. VSCDS1RDCF: Workstation file for interactive screen processing, containing a subfile (SFLC) keyed by RRNC (relative record number). Used to display and select carrier records.
  2. VSCARR: Carrier master file (92 bytes, indexed, read-only, key length 1 byte). Contains fields:
  3. VCCODE (carrier code).
  4. VCDESC (carrier description).
  5. VCCAID (carrier ID).
  6. VCFORC (force flag, not used in the code).

External Programs Called

The program does not call any external programs. It is a self-contained utility that performs file lookups and interactive screen processing internally.


Summary

The VSCDS1R RPG program is a utility called from the BB502 OCL program to retrieve and validate carrier information from the VSCARR file. It supports direct lookup by carrier code (@RTCOD) or interactive selection via a subfile interface, allowing users to search by description (STRING). The program returns the selected carrier’s code, description, and ID in the @VSCD data structure. It enforces rules for valid carrier lookup, subfile population, and user navigation (F3/F12), using two files (VSCDS1RDCF, VSCARR) and no external programs.

If you need further details on specific logic, integration with BB502, or additional analysis (e.g., X posts or web searches), let me know!