OK, got it so far. PGM will contain the value for the USERID to search for. You're allowing the user the option of specifying this value when they invoke your exec, otherwise you prompt them for it. Good idea.
Tip: The variable PGM will most likely contain embedded blanks. You should make sure that you get rid of them, or prevent them to begin with. You can either change your code slightly:
PARSE UPPER ARG PGM . <= add the dot
PULL INPGM . <= add the dot
or strip them out with
STRIP or
SPACE:
PGM = STRIP(PGM) or PGM = SPACE(PGM,0)
At this point, you'll have to read the file. Presuming that this file is relatively small, you can read it into a series of stem variables:
"EXECIO * DISKR INDD (STEM IN. FINIS"
where INDD is the DD name associated with your file and IN. is the stem variable name that the EXECIO function will populate the records into. The stem variables will be automatically incremented (IN.1, IN.2, etc.) and stem variable IN.0 will contain the value for the total number of records processed.
Then, you can search the stem variables until you find a matching entry in a DO loop
DO I = 1 TO IN.0 /* Loop through the entire stem variable array */
X = POS(PGM,IN.I)
IF X <> 0 THEN
DO
SAY IN.I
LEAVE
END
END
or read a single record at a time until a match is found
DO FOREVER
"EXECIO 1 DISKR INDD"
IF RC <> 0 THEN LEAVE
PULL IN
X = POS(PGM,IN)
IF X <> 0 THEN
DO
SAY IN
LEAVE
END
END
"EXECIO 0 DISKR INDD (FINIS"