OPNQRYF with numeric fields

I have a AS400 CL Program where I amd comparing three (3) fields from the DB file - two Alpha and one Numeric - to three parameters. The paramertes are in the LDA.

The fields from the file are: TLOCN; TUSID; TDATE and the comparison fields from the LDA are - &LCN; &USR; &LYMD

When I compile the program I am gettin the error (see code and error below. I have included the three lines where the parameters are declared):
 
                            DCL        VAR(&USR) TYPE(*CHAR) LEN(10)  
                            DCL        VAR(&LCN) TYPE(*CHAR) LEN(7)  
                            DCL        VAR(&LYMD) TYPE(*DEC) LEN(8 0)
   
    3701-              OVRDBF     FILE(PHYCNT) TOFILE(*LIBL/('PHYCNT' || &WH))  
    3702                            SHARE(*YES)                                
    3703-              OPNQRYF    FILE((HHLIB/('PHYCNT' || &WH))) +            
    3704                            QRYSLT('TLOCN *EQ "' *CAT &LCN *CAT '" +    
    3705                            *AND TUSID *EQ "' *CAT &USR *CAT '" *AND +  
    3706                            TDATE *EQ ' *CAT &LYMD *CAT ' ') +          
    3707                            KEYFLD((TLOCN) (TITM#))                    
 * CPD0712 30  Operand  does not have valid type for operator.                  
 * CPD0711 30  Operands in expression not same type.          

Please advise.

Gerry
gmollineauAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_b_hCommented:
Hi Gerry
The query selection string is created by concatenating character variables together. Variable &LYMD is numeric and needs to be moved to a char variable first, say &lymdC.
0
gmollineauAuthor Commented:
Ok.

But the TDATE from the file is numeric. Do I leave that as is?
0
_b_hCommented:
Yes.
Try this:
dcl &LYMDC  *char 8
chgvar &LYMDC  &LYMD
    3703-              OPNQRYF    FILE((HHLIB/('PHYCNT' || &WH))) +            
    3704                            QRYSLT('TLOCN *EQ "' *CAT &LCN *CAT '" +    
    3705                            *AND TUSID *EQ "' *CAT &USR *CAT '" *AND +  
    3706                            TDATE *EQ ' *CAT &LYMDC *CAT ' ') +          
    3707                            KEYFLD((TLOCN) (TITM#))
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gmollineauAuthor Commented:
Thanks. Works fine.

Regards
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IBM System i

From novice to tech pro — start learning today.