0 pts.
 opnqryf
i am a new programmer. my question is can you move a field that is being put into a dspf to a query using the cl program that is also calling the dspf without using rpg. i have been unsuccessful so far

Software/Hardware used:
ASKED: October 19, 2005  12:37 PM
UPDATED: November 5, 2010  7:39 AM

Answer Wiki:
Can you supply a sample of the CL code you are using?
Last Wiki Answer Submitted:  October 19, 2005  12:50 pm  by  WaltZ400   645 pts.
All Answer Wiki Contributors:  WaltZ400   645 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


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


 

TOFMT(*YYMD) TOSEP(*NONE)
MONMSG MSGID(CPF0555) EXEC(DO)
CHGVAR VAR(&IN39) VALUE(’1′)
GOTO CMDLBL(START)
ENDDO

CHGVAR VAR(&DATEBG) VALUE(&BDATE)
CHGVAR VAR(&DATEED) VALUE(&EDATE)

CHGVAR VAR(&DTEBEG) VALUE(&DATEBG)
CHGVAR VAR(&DTEEND) VALUE(&DATEED)

RUNQRY QRY(CWQUERY/query)

OOP: OVRDBF FILE(fileFINAL) TOFILE(QTEMP/file) +
SHARE(*YES)
OPNQRYF FILE((QTEMP/File)) OPTION(*ALL)
QRYSLT(‘(ODITM *EQ +
*AND (ODINVN *NE 0) *AND (&DATEBG +*LE ODITE *LE &DATEED)’)

 0 pts.

 

The QRYSLT parameter on the OPNQRYF command does not work well if you include program variables. The best thing to do is create a variable named &QRYSLT which is character and large enough to hold your selection criteria.

Because you only provided a snippet of code, I am going to assume some things.
1. &DATEBG and &DATEED are character representations of a date and the date field you are comparing to is also.
2. You are comparing field ODITM to a character value as well although your code doesn’t show it. I am going to call this variable &ITEM for this example.

Set the &QRYSLT variable using the CHGVAR command like so:

CHGVAR VAR(&QRYSLT) VALUE(‘ODITM *EQ “‘ *CAT &ITEM +
*TCAT ‘” *AND (ODINVN *NE 0) *AND ODITE +
*EQ %RANGE(“‘ *CAT &DATEBG *TCAT ‘” “‘ +
*CAT &DATEED *TCAT ‘”)’)

Note the double quotes are surrounding the character variables in the &QRYSLT so when it is translated it will look like this:

ODITM *EQ “item” *AND (ODINVN *NE 0) *AND ODITE *EQ %RANGE(“mmddyy” “mmddyy”)

where ‘item’ and ‘mmddyy’ represents the actual values passed.

Then when you execute the OPNQRYF you would use
OPNQRYF QRYSLT(&QRYSLT) plus all other parms you have for file name, open type etc.

Hope this helps.

 645 pts.

 

The QRYSLT parameter on the OPNQRYF command does not work well if you include program variables.

The QRYSLT parameter works fine with program variables. In the example, though, program variables aren’t being used.

The example shows that the variable names are inside of the quotes. That causes them not to be names any more. They’re just contants in the middle of the string.

The variables need to be outside of any quotes. For example:

QRYSLT(’(ODITM *EQ ''somevalue'' +
*AND (ODINVN *NE 0) *AND (''' *cat &DATEBG *cat +
''' *LE ODITE *AND ODITE *LE ''' *cat &DATEED *cat ''')’) 

Without seeing the definitions, it’s not possible to know if embedded quotes needed to be supplied around the two date variables. Nor is it possible to know if the logic of the QRYSLT() expression is rational.

Tom

 110,135 pts.