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
VSCDS1RDCF
workstation file for interactive screen processing, with a subfile (SFLC
) keyed byRRNC
(relative record number). - The
VSCARR
file (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
@VSCD
data 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
SCRCOM
is not blank, it performs aCHAIN
operation onVSCARR
usingSCRCOM
as the key:- If a record is found (indicator
83
off), it movesVCCODE
to@RTCOD
and setsNEXT
to'$EOJ'
to exit. - If no record is found (indicator
83
on), it clears@RTCOD
and proceeds to the main loop.
- If a record is found (indicator
-
Main Processing Loop:
-
The program enters a
DO
loop controlled by theNEXT
variable (10 characters, packed) untilNEXT = '$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).
- If
-
Entry Processing (
$ENTRY
Subroutine): - Displays the main screen (
SCRE
) usingEXFMT
. -
Checks user input:
- If F3 is pressed (
*IN03 = *ON
), setsNEXT
to'$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 setsNEXT
to'$SERCH'
to initiate a search.
- If F3 is pressed (
-
Search and Populate Subfile (
$SERCH
Subroutine): - Sets the file pointer to the beginning of
VSCARR
usingSETLL *LOVAL
. - Checks if the search string (
STRING
) is blank (usingCHEKR
to compare with spaces). - 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.
- Scans each record’s description (
-
After the loop:
- If records were added to the subfile (
RRNC ≠ 0
), setsNEXT
to'$XCUTC'
to display the subfile. - If no records were added (
RRNC = 0
), sets indicator70
(error) andNEXT
to'$ENTRY'
to redisplay the entry screen.
- If records were added to the subfile (
-
Write to Subfile (
$WRITE
Subroutine): -
Increments the subfile record number (
RRNC
) and writes the currentVSCARR
record to the subfile (SFLC
). -
Execute Carrier Subfile (
$XCUTC
Subroutine): - Sets indicators (
*IN30–*IN35
) to110001
, writes the subfile control (SCRC
), and displays the subfile (CTLC
) usingEXFMT
. - If F12 is pressed (
*IN12 = *ON
), clears indicator83
and setsNEXT
to'$ENTRY'
to return to the entry screen. -
If a carrier is selected (
SCRCOM
not blank), chains toVSCARR
:- If found (indicator
82
off), movesVCCODE
to@RTCOD
,VCDESC
to@RTDSC
, clearsSCRCOM
, sets*IN12
to'1'
, and setsNEXT
to'$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@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:
- 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
@RTCOD
if 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@VSCD
data structure. -
Integration with Shipment Processing:
-
The program is called by
BB502
(in theRLOOK
subroutine) 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
70
signals 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!