Can anybody give me an example for OPNQRYF and call program?

6,875 pts.
Tags:
AS/400 administration
Open Query File
OPNQRYF
Can anybody give me an example for OPNQRYF and call program with detail? ( i.e. how a call program is retrieving the data to the OPNQRYF program) Moderator note: This is a reader submitted question to our inbox.
ASKED: November 3, 2008  7:43 PM
UPDATED: November 4, 2008  12:53 PM

Answer Wiki

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

Hi Brent ,

This is how we do it:

<pre>
/* Define select variable */
DCL VAR(&QRYSLT) TYPE(*CHAR) LEN(99)

/* Compose the QuerySelect */
CHGVAR VAR(&QRYSLT) VALUE(‘FieldA *EQ ”’ *CAT +
&VariableB *CAT ”’ *AND FieldC = ”1” *AND FieldD = ”0”’)

/* Set an override. This is necessary for the OPNQRYF to work correctly */
OVRDBF FILE(FileA) OVRSCOPE(*JOB) SHARE(*YES)

/* Apply the OPNQRYF to select only those records that comply with to select clause */
OPNQRYF FILE((FileA)) OPTION(*ALL) QRYSLT(&QRYSLT) OPNSCOPE(*JOB)

/* Call the program */
CALL PGM(ProgramB) PARM(&PARM)

/* Close the file OPNQRYF */
CLOF OPNID(FileA)

/* Delete the override */
DLTOVR FILE(FileA) LVL(*JOB)
</pre>

The queryselect must be composed in a variable otherwise it won’t work.

HTH,
Rudolf

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