DCLF FILE(LIBRARY/DISPLAY)
START:
SNDRCVF RCDFMT(REC) WAIT(*YES)
IF COND(&IN03 *EQ '1') THEN(DO)
GOTO CMDLBL(END)
ENDDO
IF COND(&ENQQUA1 *EQ ' ') THEN(DO)
GOTO CMDLBL(START)
ENDDO
IF COND(&ENQQUA1 *NE *BLANKS) THEN(DO)
OPNQRYF FILE((SARKNS/ENQP002)) OPTION(*ALL) +
QRYSLT('&ENQQUA *EQ ''' *CAT &ENQQUA1 *CAT'''')
OVRDBF FILE(ENQP002) TOFILE(SARKNS/ENQP002) +
SHARE(*YES)
CPYFRMQRYF FROMOPNID(ENQP002) TOFILE(SARKNS/ENQP00222) +
MBROPT(*REPLACE)
ENDDO
DLTOVR FILE(ENQP002)
CLOF OPNID(ENQP002)
END:
ENDPGM
I HAD DONE A MISTAKE WHILE IN QRYSLT , I WAS CORRECTED BY Mr. PHIL.
HERE &ENQQUA IS A FIELD FROM PHYSICAL FILE (LIBRARY/ENQP002) AND
&ENQQUA1 IS A FIELD FROM DISPLAY FILE (LIBRARY/DISPLAY).
BOTH THE FIELDS ATTRIBUTES ARE SAME (SIZE & DATA TYPE)
WHEN I AM CALLING THIS PROGRAMME I AM GETTING THE FOLLOWING MESSAGE:
STILL I AM GETTING SAME ERROR
CPF9899 received by OOQ at 112. (C D I R)
NOTE:
I THINK IN OPNQRYF ONLY I AM DOING MISTAKE IN QRYSLT PART.
CAN ANY ONE HELP ME IN THIS REGARDS?
THANKS IN ADVANCE.
Software/Hardware used:
ASKED:
March 19, 2009 6:37 AM
UPDATED:
March 23, 2009 5:37 PM
Message CPF9899 only says an error occured in a command. You need to dig deeper into your job log to determine what the error is and what may have caused. it.
Pressing F10 in the command entry screen displays all messages. To get to the command entry screen, CALL QCMD. You can also use the DSPJOB command or SYSREQ, option 3 to get the Display Job menu, then use option 10 to see your job log. From here, F10 to display all message and F18 to go to the end. Read from the bottom up to get to the message describing the error.
You can make your life easier with OPNQRYF by defining a CL variable for the QRYSLT parm. Something like this
DCL &QRYSLT *CHAR 1024
CHGVAR &QRYSLT VALUE(‘your select statememt’)
OPNQRYF QRYSLT(&QRYSLT) etc
The advantage to this is it simplifes the quotes. It also lets to do a SNDMSG with the &QRYSLT variable before the OPNQRYF actually runs so you can see what the variable builds up as. The OPNQRYF errors often are caused by confused quotes, and the error doesn’t always give much help.
There is another advantage to Graybeard’s suggestion. After entering your select statment you can quickly get a general idea if your quotes are correct by checking for upper and lower case characters after pressing F4.
For example, ChgVar &QrySelect (‘fieldA *gt’ *bcat &num1 *bcat ‘*and fieldB *eq ”X” ‘) should be returned as (”fieldA *gt’ *BCAT &NUM1 *BCAT ‘*and fieldB *eq ”X” ‘) Notice how everything outsite your quorte is capitalized.
This is not a 100% validation but at least gives a quick idea if the elements of the select statement will be treated as literals or variables.