Run time error when OPNQRY is executed

pts.
Tags:
APGLDT
APINDVT
AS/400 error messages
AS/400 Runtime Errors
OPNQRY
I'm getting a run time error when OPNQRY is executed. APGLDT field is numeric and & POST is *CHAR value retrieved from dtaara. Similar is the case with APINVDT. I tried without %DIGITS also and it still doesn't work. OPNQRYF FILE((*LIBL/APH *FIRST *ONLY)) + QRYSLT('%DIGITS(APGLDT) *EQ "' *CAT &POST + *CAT '" *AND %DIGITS(APINVDT) *EQ "' *CAT + &DOCD *CAT '"')

Answer Wiki

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

OK here’s a shot.
because APGLDT is numeric you don’t need the ” ” around the data to be compared
&POST is of char type but as long as it looks like a number when the string is built
it should work fine.

OPNQRYF FILE((*LIBL/APH *FIRST *ONLY)) +
QRYSLT(‘APGLDT *EQ ‘ *CAT &POST +
*CAT ‘ *AND APINVDT *EQ ‘ *CAT +
&DOCD)

Again, I would code it like this
DCL &QRYSLT *CHAR 150

chgvar &QRYSLT (‘APGLDT *EQ ‘ *CAT &POST +
*CAT ‘ *AND APINVDT *EQ ‘ *CAT &DOCD)

sndmsg &QRYSLT tousr(myprofile)

OPNQRYF FILE((*LIBL/APH *FIRST *ONLY)) +
QRYSLT(&QRYSLT)

that way you can get a readable image of what’s being sent to the Query Engine

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