6,580 pts.
 Can anybody give me an example for OPNQRYF and call program?
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.

Software/Hardware used:
ASKED: November 3, 2008  7:43 PM
UPDATED: November 4, 2008  12:53 PM

Answer Wiki:
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
Last Wiki Answer Submitted:  November 4, 2008  12:53 pm  by  r.otto   810 pts.
All Answer Wiki Contributors:  r.otto   810 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


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