× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: OPNQRYF - QRYSLT
  • From: "Scott Klement" <infosys@xxxxxxxxxxxx>
  • Date: 26 May 1999 10:05:42 -0500

When you call OPNQRYF, you are not sending the actual variables to
it.  Your QRYSLT parameter will be a string that is, first, created
following the code in your program, and then the completed string
is passed as a parameter to the OPNQRYF program.

In other words, you're passing the letters "&FRMDTE" to the OPNQRYF
program, instead of the value of the variable.  It actually thinks
that you want to know if your date contains the letters "&FRMDTE",
which it knows isnt possible for a date -- and yells at you that
its invalid.

I've trained several people in CL from the ground up.  I think every
single person I've trained has had this same problem understanding
OPNQRYF, so rest assured that you are not alone :)

Its a little difficult to grasp the difference, you really need to
look at it in steps, and know what you WANT to see passed to the
OPNQRYF program.  Your first example (the "THIS WORKS" example)
You're creating the exact string that you WANT to have passed
to the OPNQRYF.  (this makes a great example, by the way, because
it shows EXACTLY what you WANT to send to the OPNQRYF])

'WNPDTP1E *EQ "01.05.1999"'

Your next task, by putting a variable in this string, is to make
the variable look EXACTLY THE SAME to the OPNQRYF program as the
string above (except that the date may be different)

In your "DOESN'T WORK" example, you have: 'WNPDTP1E *EQ &FRMDTE'.
Because the whole thing is in quotes, the &FRMDTE is being passed,
as-is, to the OPNQRYF program.  OPNQRYF doesn't know that you meant
a variable there... it thinks your date is actually "&FRMDTE"]

It SHOULD be something like this:

'WNPDTP1E *EQ "' *TCAT &FRMDTE *TCAT '"'

When your CL program runs, it (before calling OPNQRYF) makes that
expression into a string.  It makes a new string in these steps:

new string:
'WNPTDP1E *EQ "'
then concatenates the value of &FRMDTE, so, if &FRMDTE was 26.05.1999:
'WNPDTP1E *EQ "26.06.1999'
then concatenates the quote.  so you'd have:
'WNPDTP1E *EQ "26.06.1999"'

And, finally, it passes THIS string to the OPNQRYF program.

Your NEXT example was:
'%TIMESTP(WNPDTP1E) *GT %TIMESTP(&FRMDTE)'

If you haven't figured this one out already, its the exact same
problem.  OPNQRYF is being passed a string containing the letters
"&FRMDTE" rather than the value of the variable &FRMDTE.

Instead, you need something like:
'%TIMESTP(WNPDTP1E) *GT %TIMESTP("' *TCAT &FRMDTE *TCAT '"'

Your CL program will then take that and make a string containing
'%TIMESTP(WNPDTP1E) *GT %TIMESTP("20.05.1999")'  and pass that to
the OPNQRYF program.

Hope that helps...

Scott Klement
Information Systems Manager
Klement's Sausage Co, Inc.


"Marc Geerkens" <marc_geerkens@hotmail.com> wrote:
> ---------------- Part 1 ----------------
> Hello,
>
> What is the difference between the following 2 examples.
>
> WNPDTP1E = database field format *DATE (*EUR)
>
> Only the first one seems to work.
>
>
> THIS WORKS :
>
> PGM
>
> OVRDBF file(PESTPR) SHARE(*YES)
>
> OPNQRYF file(pestpr) qryslt('WNPDTP1E *EQ "01.05.1999"')
>
> CLOF PESTPR
> DLTOVR *ALL
>
> ENDPGM
>
> -----------------------------------------------------------
> THIS DOESN'T WORK
>
>
> PGM
>
> DCL VAR(&FRMDTE) TYPE(*CHAR) LEN(10)
>
> CHGVAR VAR(&FRMDTE) VALUE('01.05.1995')
>
> OVRDBF FILE(PESTPR) SHARE(*YES)
>
> OPNQRYF FILE(pestpr) QRYSLT('WNPDTP1E *EQ &FRMDTE')
>
> CLOF PESTPR
> DLTOVR *ALL
>
> ENDPGM
>
> --------------------------------------------------------
>
> When you have a string (20051999) as a incoming parameter in an CL
> program. How can you use this string in an QRYSLT statement when the
> database field is a field of type *DATE (*EUR) (25.05.1999)
>
> The following example doesn't work
>
> PGM (&FRMDTE)
>
> DCL VAR(FRMDTE) TYPE(*CHAR) LEN(8)
>
> OVRDBF FILE(PESTPR) SHARE(*YES)
>
> OPNQRYF FILE(PESTPR) QRYSLT('%TIMESTP(WNPDTP1E) *GT +
>                      %TIMESTP(&FRMDTE)')
>
> CLOF PESTPR
> DLTOFR *ALL
>
> ENDPGM
>
>
>
>
> Thanks
>
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
>  * *
> * This is the RPG/400 Discussion Mailing List]  To submit a new
>   *
> * message, send your mail to "RPG400-L@midrange.com".  To unsubscrib
>   *
> * from this list send email to MAJORDOMO@midrange.com and specify
>   *
> * 'unsubscribe RPG400-L' in the body of your message.  Questions
>  should *
> * be directed to the list owner / operator: david@midrange.com
>   *
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
>  * *
>
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the RPG/400 Discussion Mailing List!  To submit a new         *
* message, send your mail to "RPG400-L@midrange.com".  To unsubscribe   *
* from this list send email to MAJORDOMO@midrange.com and specify       *
* 'unsubscribe RPG400-L' in the body of your message.  Questions should *
* be directed to the list owner / operator: david@midrange.com          *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.