Crystal Report v9 - Complex conditions in displaying

darrennsz

New member
Local time
Today, 17:27
Joined
May 30, 2009
Messages
2
Hi All Experts

I'm very troubled in displaying a reports that will show first record for an item. The report is to show all items that is gonna be label as dead

The table will look like below :

Item Type qty
xxx1 Stocktake 5
xxx1 sales 6
xxx1 sales 7
xxx2 sales 0
xxx2 Dead 0
xxx2 Sales 0
xxx3 reconc 1
xxx3 sales 1
xxx4 sales 0
xxx4 sales 0

Output should be:
xxx1 Stocktake 5
xxx3 sales 1
xxx4 sales 0

My output :
xxx1 Stocktake 5
xxx2 Sales 0
xxx3 sales 1
xxx4 sales 0


The report should only display the first record of an item. However, it should not display the first record if the subsequent records have a type 'Dead' in it.

I manage to display the first record without much difficulty. but it will still display first record if the second or third record have a type 'Dead' in it which I do not want this to happen.

What I am doing now is :
Following another thread i did this :

@freset

shared numbervar RecNo:=0;

place this in the group header.

take another formula
@fRecPerGroup
shared numbervar RecNo:=RecNo+1;

place it in the Detail secion

Under detail section :
shared numbervar RecNo;

if RecNo=1 and not({InTrans.Trans_Datetime} in DateTime (2004, 04, 01, 00, 00, 00) to DateTime (2009, 05, 29, 23, 59, 59))and not({InTrans.DESCRIPTION} startswith "STOCKTAKE")then
False
else if RecNo=1 and {InTrans.Trans_Datetime} in DateTime (2004, 04, 01, 00, 00, 00) to DateTime (2009, 05, 29, 23, 59, 59)and {InTrans.DESCRIPTION} startswith "STOCKTAKE" then
false
else if RecNo>1 then
true;

What the above code is doing is if it item transaction falls in 2004-2009 it will display it. For other records with other transaction type will only shows if it falls before 2004. Problem now is i tried many ways to add conditions if the item has a record with type 'dead' dun display any of that item. But i didn't made it. It omits the rest of the records without checking further after the first record meets the condition.

Can someone help me to modifies the above code ?

Ya help is highly appreciated. TQ

Regards
Darrennsz
 
Hi
I probably did not totally understood your porblem but,the only one thing i understood is that if at all there is a "Type" Dead for a
particular item(Group) you would like to suppress the record.
since you are already using the Shared variable instead of checking the record count check if there is a type "Dead"

Since the detail section is responsible to scan through each record
take a share variable in the Detail section

@fcheckDead
shared stringvar fType:=fType + ","+{Ftype}-->type field.

The above shared variable will concatinate the Types for ex like say for
xxx2 sales 0
xxx2 Dead 0
xxx2 Sales 0
fType will be Sales,Dead,Sales.

finally
you can use the above formula to check for the "Dead" string.


place all the fields in the group footer
go to section expert click suppress then add the below formula.
(if the string found then instring will return a value else it will return zero
shared stringvar fType;
INSTR(fType,"Dead")>0 or check Strcomp(fType,"Dead")=0 (you can use instr or Strcomp eiter of the one if available)

this will suppress the section.
hope this works for you.
 
Hi Srinvb

I'm so sorry but I do not quite understand some parts of your solution.

@fcheckDead
shared stringvar fType:=fType + ","+{Ftype}-->type field.

Which of these is a table field in this formula ? Will your solution suppress all the transactions of a particular item if one of the record have a type 'dead' in it ?

E.g.
xxx2 sales 0
xxx2 Dead 0
xxx2 Sales 0

Output :
None... xxx2 should not be in the report since record 2 is type 'dead'.


Currently all my fields are placed at the detail section, and according to your guide should I move them to the footer section ?

Sorry for the confusing conditions. The report actually checks the database for those that are going to be labelled as dead stock but not those that are already 'dead'. And we identify those bout to be label as dead if the last transaction is before april 2004 and with a type 'sales'. However if the last transaction is not type 'sales' but 'stocktake' and after april 2004 then it will shows the record. And finally to check for and remove all items that have a transaction with type = 'dead'.

Because of my previously specified condition those with type 'dead' has already been excluded out of the report, so even if I try to add another conditions to check for type 'dead', it almost never works..

E.g.
xxx2 sales 0
xxx2 Dead 0
xxx2 Sales 0

My output :
xxx2 sales 0
(Because of this my report will never read the dead type since its being suppressed beforehand by the first condition.)



Regards
Darrennsz
 
Last edited:
Hi I have checked the following code
In my previuos reply i put the {Ftype} this is your database field which should be having "Dead" and fType is the formula(shared var)

As mentioned earlier follow same procedure ,create a group on Item no ...etc
put the following code in the detail section i.e Section Expert -->suppress
and add the following code
shared stringvar fstring;
{Items.ItemDesc})="Dead" --Suppresses the current record.
OR
(NEXT({Items.ItemCOde})={Items.ItemCOde} AND NEXT({Items.ItemDesc})="Dead") --checks for the next record with same id and if found then suppress the record.
OR
(Previous({Items.ItemCOde})={Items.ItemCOde} AND Previous({Items.ItemDesc})="Dead")
OR
InStr (1,fType,"Dead" )> 0

the fType is a shared variable which has the description concatenated ,as i mentioned earlier in my reply.

i tried this example and it suppresses the whole record for the item.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom