OPNQRYF error in QRYSLT

90 pts.
Tags:
CL/400
CL/OPNQRYF
OPNQRYF
PGM 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 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:  CPF9899 received by OOQ at 112. (C D I R) 

Note: I think in OPNQRYF only I am making mistake in QRYSLT part. Can anyone help me in this regard? 

Answer Wiki

Thanks. We'll let you know when a new response is added.

Yes

OPNQRYF FILE((SARKNS/ENQP002)) OPTION(*ALL) +
QRYSLT(‘&ENQQUA *EQ ”*CAT&ENQQUA1*CAT”’)
OVRDBF FILE(ENQP002) TOFILE(SARKNS/ENQP002) +
SHARE(*YES)

Your QRYSLT sends to the query engine the string
&ENQQUA *EQ ‘*CAT&ENQQUA1*CAT’

If ENQQUA is char type you do need to send the single quotes
but you expression fails to terminate and restart the string

OPNQRYF FILE((SARKNS/ENQP002)) OPTION(*ALL) +
QRYSLT(‘&ENQQUA *EQ ”’ *CAT &ENQQUA1 *CAT ””)
OVRDBF FILE(ENQP002) TOFILE(SARKNS/ENQP002) +
SHARE(*YES)

‘&ENQQUA *EQ ”’ <– that’s a triple single quote ”’
first two will create a single quote
third will terminate the string allowing CL to take over
it now processes *CAT &ENGQUA1 *CAT which inserts the value
in &ENGQUA1 and cats to that the amazing
”” <- four quotes
which CL reads as start string-insert ‘ – terminate string
Phil

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following