Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

conditional data selection formula 1

Status
Not open for further replies.

crystalvictim

Programmer
Dec 4, 2002
92
DE
Hi everybody,

we're using crystal reports 8.5 professional (sap edition) and have recently encountered a strange problem.

The situation is as follows:
we have reports (mostly based on sap tables) which shall usually cover a certain period of time (e.g. lastfullmonth) and are therefore scheduled on our crystal enterprise server (8.5). But sometimes it may be neccessary to change this selection period. So what we did was introduce a parameter field (date range) which has a default value (01/01/2001) and create a conditional selection formula (if... then... else...) which checks the value of this parameter. If the default is used, the selection is set to cover the period lastfullmonth and otherwise the parameter's minimum/maximum are used.

The formula looks like this:
if ({?Datumsbereich}=date("01.01.2001")) then
(
{EKKO.LIFNR}='0010267876' and
{EKKO.BUKRS}='0001' and
{EKKO.MANDT}='400' and
{EKKO.BSART}='B2' and
{EKKO.BEDAT}>=date("01.06.2003") and
{EKKO.BEDAT}<=date(&quot;25.06.2003&quot;)
)
else
(
{EKKO.LIFNR}='0010267876' and
{EKKO.BUKRS}='0001' and
{EKKO.MANDT}='400' and
{EKKO.BSART}='B2' and
{EKKO.BEDAT}>=Minimum({?Datumsbereich}) and
{EKKO.BEDAT}<=Maximum({?Datumsbereich});
);

So using this formula would lead to a dump, no matter what value the parameter has, while using just the first part (if-branch) works as expected.

It has been working - and we still have reports where it does - but since some days we're no longer able to create new reports using this technique. Whenever using the if-then-else construct, the report will dump with a timeout (i.e. it's querying the SAP-system for more than 5 minutes). This even happens if we use the same selection formula for then if- AND for the else-branch.
When using the selection formula without any &quot;if&quot;, it works just fine, no timeout at all....

Does anyone have an idea oder has experienced something similar?
 
sorry, i made a mistake posting the formula: the first line has to be:

if (minimum({?Datumsbereich})=date(&quot;01.01.2001&quot;)) then






 
Because you are wrapping all your selection criteria in the IF then else statement nothing is being passed to the server try re-writing as

{EKKO.LIFNR}='0010267876' and
{EKKO.BUKRS}='0001' and
{EKKO.MANDT}='400' and
{EKKO.BSART}='B2' and
(
if minimum({?Datumsbereich})=date(&quot;01.01.2001&quot;) then
( {EKKO.BEDAT}>=date(&quot;01.06.2003&quot;) and
{EKKO.BEDAT}<=date(&quot;25.06.2003&quot;)
)
else
(
{EKKO.BEDAT}>=Minimum({?Datumsbereich}) and
{EKKO.BEDAT}<=Maximum({?Datumsbereich}))
)
Now only the date selection will be run locally all other selection will be on server.

Ian Waterman
UK Crystal Consultant
 
Ian,

great it works :)
So everything wrapped in a If then else statement will be processed locally - and will therefore be processed after receiving data from the server. And as there was no selection criteria for getting data from the server in my original formula, crystal tried to bring all data from the table. and that, of course, has to result in a timeout.
Did i get this right?

Thank you very much again for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top