Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Help please Post Reply Post New Topic
Author Message
loismustdie
Newbie
Newbie


Joined: 19 Jun 2009
Online Status: Offline
Posts: 2
Quote loismustdie Replybullet Topic: Help please
     Posted: 19 Jun 2009 at 4:18am
Hi guys,

I'm just after a little bit of help with a report I am writing for work. I'm a relative newbie when it comes to Crystal Reports. I'm using CR XI. Here is my problem...
 
I am trying to write a report that lists how much usage we have used on certain stock, whilst ignoring any reverse transactions.
 
Whenever an item is issued, the transaction itself gets a Unique Transaction Number. If (for whatever reason) the transaction is reversed and added back into stock, our system gives the reversal its own transaction number and also writes the original transaction number to a field called 'originaltransactionid'. So for example...
 
Qty      Description    Type                 Transactionid     Originaltransactionid
 
20        M6 Nuts         Standard          12345
50        M6 Nuts         Standard          67890
20        M6 Nuts         Reversal           98765                12345
 
where the 3rd line is the reversal of transactionid 12345.
I would like the report to disregard any of the REV items (which is easy) but also to disregard the original transaction based on the 'originaltransactionid' number stored in the reversal transaction (so on my example above, only the 2nd line would show up on my report and only 50 nuts would be deducted from stock).

Thanks in advance for your help.


Edited by loismustdie - 19 Jun 2009 at 4:19am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 19 Jun 2009 at 6:37am
This is best done in a stored proc on the database.  The one way that I can think of that should work is to create a subreport, this would be placed in the report header.  Nothing is going to be displayed from the report, but you need crystal to read through data.  in the subreport you would have a formula that would go in the detail section of the subreport:
shared stringvar reversed
if not isnull({originaltransactionid}) then reversed := reversed + "|" + {originaltransactionid} +"|";
 
in the main report, in the details section of Section Expert in the suppression formula:
shared stringvar reversed;
instr(reversed, "|" + {Transactionid} + "|") > 0 or {Type} = "Reversal"
 
 
that should do it, it will suppress both.  Unfortunately, if you want to do any aggregate functions, you are going to have to create shared variables for that as well...maybe a running total DBlank is good at those.
 
HTH
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Jun 2009 at 7:40am
Why not add the table to the report twice, left outer join it on table1.Transactionid >table2.originaltransactionid and then add in a select statement isnull(table2.transactionid) and that should give you only records that were not reversed...
IP IP Logged
loismustdie
Newbie
Newbie


Joined: 19 Jun 2009
Online Status: Offline
Posts: 2
Quote loismustdie Replybullet Posted: 19 Jun 2009 at 8:53am
Originally posted by DBlank

Why not add the table to the report twice, left outer join it on table1.Transactionid >table2.originaltransactionid and then add in a select statement isnull(table2.transactionid) and that should give you only records that were not reversed...
 
Done it. Thank you all very much for your help. Much appreciated.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 19 Jun 2009 at 11:23am
I was thinking of something like that, but couldn't wrap my head around it.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum