Probably it's to hot:
Class MyVOForm
...
METHOD Print_AboRechnung_univ(cPNO := "" AS STRING) // cPNo is the id of a record to include
//calling a RP report
....
oReport:FilterExpression := i"Person.PNo = '{cPno}' "
...
So far, fine.
Now, i want instead to fill the FilterExpression with a series of cPnos.
I get these from a helper func which returns an array of string values, i.e. PNos.
How do i code this?
[RP2.40] Filter
[RP2.40] Filter
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Re: [RP2.40] Filter
Hi Karl,
What would the filter expression look like in this case, which array items would you use in them? All or some of them and how?
Would you need to do something like this:
I think it's a bit of overkill to use interpolated strings for such complex expressions, maybe it would be more intuitive to use String.Format() instead, something like
What would the filter expression look like in this case, which array items would you use in them? All or some of them and how?
Would you need to do something like this:
Code: Select all
LOCAL aPnos AS ARRAY
FilterExpression := i"Person.PNo = '{aPnos[1]}' .AND. Person.FNo = '{aPnos[3]}' .AND. Person.CNo = '{aPnos[5]}'"
Code: Select all
FilterExpression := String.Format("Person.PNo = '{0}' .AND. Person.FNo = '{1}' .AND. Person.CNo = '{2}' ", aPnos[1], aPnos[3], aPnos[5])
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Re: [RP2.40] Filter
Chris,
the content gets filled at runtime by a helper func collecting the values, storing them into the array.
As of now, the returned array may look like e.g.:
If there's a smarter way to achieve this, i'd glad to hear about this...
EDIT: simpler spoken: i call from the app a report and have to provide the filterexpression. The report has a "base" filter, like "all records holding a membership". To this condition i have to add a list of record-ids, produced at runtime, which fullfill another condition.
the content gets filled at runtime by a helper func collecting the values, storing them into the array.
As of now, the returned array may look like e.g.:
Code: Select all
aIncludedPNos{"0123","0256","0758"}
EDIT: simpler spoken: i call from the app a report and have to provide the filterexpression. The report has a "base" filter, like "all records holding a membership". To this condition i have to add a list of record-ids, produced at runtime, which fullfill another condition.
Last edited by FFF on Tue Sep 10, 2024 3:02 pm, edited 1 time in total.
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Re: [RP2.40] Filter
Hi Karl,
And what would the filter expression look like exactly? As plain string I mean.
And what would the filter expression look like exactly? As plain string I mean.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Re: [RP2.40] Filter
ATM, there's e.g.
.Abo is bool, indicating, the person holds an abonnement.
Now there are persons, for which .Abo is false, but they pay for other persons' abonnement.
So i collect the PNos of these "childs", to include the parent record into the filter.
Code: Select all
oReport:FilterExpression := i"(Person.Abo .and. (Empty(Person.Masterno) .or. Person.Pno ='0008') .and. Person.Kat > '0' .and. Person.Kat < '3' .and. Person.Pno != '0237' .and. (Empty(Person.Abo_Bis) .or. (DToS(Person.Abo_Bis) > '20240701'))" //WORKS
Now there are persons, for which .Abo is false, but they pay for other persons' abonnement.
So i collect the PNos of these "childs", to include the parent record into the filter.
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Re: [RP2.40] Filter
Hi Karl,
How about
"AScan( { "123","456", "789" } , Person.Pno) != 0 .and. ...."
to see if a pno is inside the array?
Of course you will need to construct the string array expression with code.
How about
"AScan( { "123","456", "789" } , Person.Pno) != 0 .and. ...."
to see if a pno is inside the array?
Of course you will need to construct the string array expression with code.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Re: [RP2.40] Filter
I sent to the report for testing:
At runtime i get: The following error was encountered while validating Section Expressions:
Invalid Filter expression: AScan(a, Person.Pno) != 0
Why?
Code: Select all
Var a := GetChildPNos() // {"0498", "0565"}
oReport:FilterExpression := i"(AScan(a, Person.Pno) != 0)"
Invalid Filter expression: AScan(a, Person.Pno) != 0
Why?
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Re: [RP2.40] Filter
Karl,
'a' is a local variable. This variable is not accessible in a macro.
To solve this you can:
- make 'a' a global variable
- make 'a' a dynamic variable (public or private). You will have to enable support for memory variables in the compiler options for this.
Robert
'a' is a local variable. This variable is not accessible in a macro.
To solve this you can:
- make 'a' a global variable
- make 'a' a dynamic variable (public or private). You will have to enable support for memory variables in the compiler options for this.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Re: [RP2.40] Filter
Hi Robert,
thx, that did the trick - there are already some globals in the codebase, so this was the easiest way out.
But as you see in the "real" expression some postings below, i also have to regard things in the filter like "Person.Kat" etc. -
Edited, stupidity at keyboard...
tbc
thx, that did the trick - there are already some globals in the codebase, so this was the easiest way out.
Code: Select all
oReport:FilterExpression := i"AScan(a, Person.Pno) != 0" // works fine.
Edited, stupidity at keyboard...
tbc
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)