I want to assign a field name to a variable so I can just call the variable to evaluate a field against another variable.
I have a file with 2 fields, FLD1, FLD2 and FLD3. Depending on the condition, I want to evaluate the field against &TSTVAR. The logic would be as folows.
------
DO WHILE LOOP
RCVF
MONMSG CPF0864 EXEC(GOTO EOF)
SELECT
WHEN condition1
IF &FLD1 EQ &TSTVAR THEN(CALL PGM1)
WHEN condition2
IF &FLD2 EQ &TSTVAR THEN(CALL PGM1)
WHEN condition2
IF &FLD3 EQ &TSTVAR THEN(CALL PGM1)
ENDSELECT
ENDDO
-----
This above would mean I have to evaluate the condition every time I read a record from the file. I would like to assign which field I want to evaluate from the start before I go through reading the entire file much like the following.
-----
SELECT
WHEN condition1
Assign the filedname FLD1 to &TSTFLD
WHEN condition2
Assign the filedname FLD2 to &TSTFLD
WHEN condition2
Assign the filedname FLD32 to &TSTFLD
ENDSELECT
DO WHILE LOOP
RCVF
MONMSG CPF0864 EXEC(GOTO EOF)
IF &TSTFLD EQ &TSTVAR THEN(CALL PGM1)
ENDDO
-----
How can I achieve that using a field name inside a variable and evaluate the corresponding field?
I have a file with 2 fields, FLD1, FLD2 and FLD3. Depending on the condition, I want to evaluate the field against &TSTVAR. The logic would be as folows.
------
DO WHILE LOOP
RCVF
MONMSG CPF0864 EXEC(GOTO EOF)
SELECT
WHEN condition1
IF &FLD1 EQ &TSTVAR THEN(CALL PGM1)
WHEN condition2
IF &FLD2 EQ &TSTVAR THEN(CALL PGM1)
WHEN condition2
IF &FLD3 EQ &TSTVAR THEN(CALL PGM1)
ENDSELECT
ENDDO
-----
This above would mean I have to evaluate the condition every time I read a record from the file. I would like to assign which field I want to evaluate from the start before I go through reading the entire file much like the following.
-----
SELECT
WHEN condition1
Assign the filedname FLD1 to &TSTFLD
WHEN condition2
Assign the filedname FLD2 to &TSTFLD
WHEN condition2
Assign the filedname FLD32 to &TSTFLD
ENDSELECT
DO WHILE LOOP
RCVF
MONMSG CPF0864 EXEC(GOTO EOF)
IF &TSTFLD EQ &TSTVAR THEN(CALL PGM1)
ENDDO
-----
How can I achieve that using a field name inside a variable and evaluate the corresponding field?
Comment