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:
- Program Initialization:
- The program defines the
VSCDS1RDCFworkstation file for interactive screen processing, with a subfile (SFLC) keyed byRRNC(relative record number). - The
VSCARRfile (92 bytes, indexed, read-only, key length 1 byte) is defined to store carrier data. - 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).
-
Input specifications (
I) map fields fromVSCARR: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).
-
Parameter Input:
-
The program accepts the
@VSCDdata structure via the*ENTRY PLIST, containing the input carrier code (@RTCOD) and expecting to return@RTCOD,@RTDSC, and@RTCAI. -
Initial Carrier Code Lookup:
- The program moves the input carrier code (
@RTCOD) toSCRCOM(a 10-character screen field). -
If
SCRCOMis not blank, it performs aCHAINoperation onVSCARRusingSCRCOMas the key:- If a record is found (indicator
83off), it movesVCCODEto@RTCODand setsNEXTto'$EOJ'to exit. - If no record is found (indicator
83on), it clears@RTCODand proceeds to the main loop.
- If a record is found (indicator
-
Main Processing Loop:
-
The program enters a
DOloop controlled by theNEXTvariable (10 characters, packed) untilNEXT = '$EOJ':- If
NEXT = '$XCUTC', it calls the$XCUTCsubroutine (execute carrier subfile). - If
NEXT = '$SERCH', it calls the$SERCHsubroutine (search and populate subfile). - Otherwise, it calls the
$ENTRYsubroutine (display entry screen).
- If
-
Entry Processing (
$ENTRYSubroutine): - Displays the main screen (
SCRE) usingEXFMT. -
Checks user input:
- If F3 is pressed (
*IN03 = *ON), setsNEXTto'$EOJ'to exit. - If the search string (
STRING) is blank, it sets indicators (*IN30–*IN35) to000010, writes the subfile control (CTLC), clears the subfile (RRNC), and setsNEXTto'$SERCH'to initiate a search.
- If F3 is pressed (
-
Search and Populate Subfile (
$SERCHSubroutine): - Sets the file pointer to the beginning of
VSCARRusingSETLL *LOVAL. - Checks if the search string (
STRING) is blank (usingCHEKRto compare with spaces). - Reads
VSCARRrecords 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
81on), calls the$WRITEsubroutine to add the record to the subfile.
- Scans each record’s description (
-
After the loop:
- If records were added to the subfile (
RRNC ≠ 0), setsNEXTto'$XCUTC'to display the subfile. - If no records were added (
RRNC = 0), sets indicator70(error) andNEXTto'$ENTRY'to redisplay the entry screen.
- If records were added to the subfile (
-
Write to Subfile (
$WRITESubroutine): -
Increments the subfile record number (
RRNC) and writes the currentVSCARRrecord to the subfile (SFLC). -
Execute Carrier Subfile (
$XCUTCSubroutine): - Sets indicators (
*IN30–*IN35) to110001, writes the subfile control (SCRC), and displays the subfile (CTLC) usingEXFMT. - If F12 is pressed (
*IN12 = *ON), clears indicator83and setsNEXTto'$ENTRY'to return to the entry screen. -
If a carrier is selected (
SCRCOMnot blank), chains toVSCARR:- If found (indicator
82off), movesVCCODEto@RTCOD,VCDESCto@RTDSC, clearsSCRCOM, sets*IN12to'1', and setsNEXTto'$EOJ'to exit. - If not found, no action is taken (remains in the subfile display).
- If found (indicator
-
Program Termination:
- When
NEXT = '$EOJ', the program sets theLR(Last Record) indicator and returns the@VSCDdata 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:
- Carrier Code Validation:
- If a carrier code (
@RTCOD) is provided, the program validates it againstVSCARR. If valid, it returns the corresponding code and description immediately. -
If the code is invalid or blank, it allows the user to search for a carrier interactively.
-
Interactive Carrier Selection:
- The program provides a subfile interface to display carrier records matching a user-entered search string (
STRING) in the carrier description (VCDESC). -
Users can exit with F3 (
*IN03) or cancel with F12 (*IN12) to return to the entry screen. -
Subfile Population:
- Only records with a description matching the search string are added to the subfile.
-
If no matches are found, an error indicator (
*IN70) is set, and the entry screen is redisplayed. -
Output Consistency:
- The program returns a blank
@RTCODif no valid carrier is found or selected. -
When a carrier is selected, it returns the carrier code (
VCCODE), description (VCDESC), and carrier ID (VCCAID) in the@VSCDdata structure. -
Integration with Shipment Processing:
-
The program is called by
BB502(in theRLOOKsubroutine) to validate and retrieve carrier details for shipment processing, ensuring accurate carrier information for orders. -
Error Handling:
- The program handles invalid inputs gracefully by redisplaying the entry screen or returning blanks for unfound carriers.
- No explicit error messages are displayed, but indicator
70signals no matching carriers.
Tables (Files) Used¶
The program uses two files, as defined in the F (File) specifications:
- VSCDS1RDCF: Workstation file for interactive screen processing, containing a subfile (
SFLC) keyed byRRNC(relative record number). Used to display and select carrier records. - VSCARR: Carrier master file (92 bytes, indexed, read-only, key length 1 byte). Contains fields:
VCCODE(carrier code).VCDESC(carrier description).VCCAID(carrier ID).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!