I am trying to use OPNQRYF in a CL program to select some records from a given file. The query selection string is defined in the OPNQRYF statement. But during execution, message CPF9899 was thrown with the cause that QRYSLT is empty. I had re-compiled the programs for several times and the problem was still there. Then I tried to define the query selection in a character variable first, then assigned it to QRYSLT. This times it worked. How did this happen? I have some other OPNQRYF statements in the same program with QRYSLT defined within, and they worked out fine. Is there anything else that might interfere with OPNQRYF?
This one does not work:
OPNQRYF FILE(&SLIB/CKFESCP) QRYSLT('DWSYST *EQ "' *CAT &KVAL *TCAT '"')
And this one does:
DCL VAR(&QRYSLT) TYPE(*CHAR) LEN(200)
.
.
.
CHGVAR VAR(&QRYSLT) VALUE('DWSYST *EQ "' *CAT &KVAL *TCAT '"')
OPNQRYF FILE(&SLIB/CKFESCP) QRYSLT(&QRYSLT)