90 pts.
 OPNQRYF
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

Answer Wiki:
/// sorry - Mr Phil made mistake. ////////// Yes, there is still a mistake in the QRYSLT '&ENQQUA *EQ ''' *CAT &ENQQUA1 *CAT '''' Now transmits &ENQQUA *EQ 'YOURVAL' and the error is... the first character -- your field in the database is not named &ENQQUA it is named ENQQUA only in the CL land would we refer to it as &ENQQUA. The OpnQry Select is built in the CL land but runs in the database engine. Sooooooooo the select should be: 'ENQQUA *EQ ''' *CAT &ENQQUA1 *CAT'''' Sorry. Phil
Last Wiki Answer Submitted:  March 19, 2009  1:40 pm  by  philpl1jb   44,150 pts.
All Answer Wiki Contributors:  philpl1jb   44,150 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

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.

 830 pts.

 

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.

 3,115 pts.

 

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.

 5,525 pts.