Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Inventory of parts Post Reply Post New Topic
Author Message
Glen IT
Newbie
Newbie


Joined: 06 Dec 2012
Online Status: Offline
Posts: 9
Quote Glen IT Replybullet Topic: Inventory of parts
     Posted: 06 Dec 2012 at 10:39pm
Hi
We have created a report to pull through data of parts on our system.  The report can select these parts based on a date range and works fine.  It can also show the first date next to the part within the date range we select.  This is working fine.  However, we are now stuck.  We need to display the parts that were added to the system within the date range and not the parts that were created or updated before we run the query (e.g. part could have been created before date range but updated during date range selection).  Basically we want an inventory of parts, to include only parts that have been created on the system within that date period.  Example below of what we are seeking to achieve.
 
Part 1   Date 20/4/2011
Part 1   Date 30/5/2012
Part 2   Date 4/5/2011
Part 3   Date 9/4/2012
Part 3   Date 9/8/2012
If we run a report and select the date range of 1/1/2012 - 30/9/2012, the report will display the following because we have got the first date within the selection period to display:
Part 1   Date 30/5/2012
Part 3   Date 9/4/2012
However, we need to get the report to not display the part if there is a date next to the part before the selection date.
The report should only display:
Part 3   Date 9/4/2012  because this part was first added to the system on the date the report is set to run and not Part 1 because it was created or updated before the date selection.
 
Hope I have explained what we are seeking to achieve with this report.  Any help or guidance in the right direction is appreciated.  Thanks
 
Update:  We are using v 2008


Edited by Glen IT - 06 Dec 2012 at 10:56pm
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 07 Dec 2012 at 4:45am

The easy way to do this (if you have good SQL skills!) would be to write a command (SQL Select statement) that does this filtering for you.  When you use a command instead of tables, you need to create any parameters, such as your date params, in the Command Editor, NOT in the report!  You then use the params in the where clause of the SQL.

 
Another way to do this would be to do the following:
 
1.  Add a second copy of the table that contains the dates to the report.  In the Database Expert, when you add a table that is already in the report, Crystal will give a warning and then add the table with "_1" on the end of the name.  So, in your case you might have Inventory and Inventory_1.
 
2.  Link from the part number in Inventory to the part number in Inventory_1.  Make the link a Left Outer join.
 
3.  Edit your selection criteria - you'll need to edit the formula instead of just selecting fields and values. Assuming a parameter called {?Start Date}, you'll add something like the following:
 
And ( IsNull({Inventory_1.DateField}) or {Inventory_1.DateField} < {?Start Date})
And IsNull({Inventory_1.PartNumber})
 
The first part of this limits the date range in the second copy of Inventory to dates prior to the start date of the range for the report.  The second part says that you only want records in the Inventory table that don't have a corresponding record in the earlier date range.
 
-Dell
IP IP Logged
Glen IT
Newbie
Newbie


Joined: 06 Dec 2012
Online Status: Offline
Posts: 9
Quote Glen IT Replybullet Posted: 11 Dec 2012 at 4:58am
Hi
Thanks for advise.  Option 2 didn't work (but i will play around it with a bit and update you).  Not too good with the SQL expressions!  if you got any other advise, thanks in advance. 
Sorry for late reply
IP IP Logged
Glen IT
Newbie
Newbie


Joined: 06 Dec 2012
Online Status: Offline
Posts: 9
Quote Glen IT Replybullet Posted: 18 Jan 2013 at 5:09am
Hi All
 
Still need advice on this one.  Thanks


Edited by Glen IT - 18 Jan 2013 at 5:09am
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 18 Jan 2013 at 5:35am
So how is it not working?  In other words, what do you see on the report vs. what you expect to see.
 
-Dell
IP IP Logged
Glen IT
Newbie
Newbie


Joined: 06 Dec 2012
Online Status: Offline
Posts: 9
Quote Glen IT Replybullet Posted: 21 Jan 2013 at 10:13pm
Hi
 
I have tried your suggestion and played about with it but it still isnt separating the parts according to what i need (as explained in the original post).  So it will still pull through a part within the date range, even though the part has been created prior to date range.  Which it should only show a part if it was created within the specific date range, because the purpose is to get a report on parts that were first added during the date range and exclude any parts that were added to the system before the date range.  The reason these parts might show during the specific date range is because they have been updated during the range but not added. 
Thanks again, i do appreciate any suggestions or guidance.


Edited by Glen IT - 21 Jan 2013 at 10:14pm
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 22 Jan 2013 at 3:26am
Please copy and paste the whole formula from the Select Expert.  I'd like to see if there's an issue there.
 
Thanks!
 
-Dell
IP IP Logged
Glen IT
Newbie
Newbie


Joined: 06 Dec 2012
Online Status: Offline
Posts: 9
Quote Glen IT Replybullet Posted: 22 Jan 2013 at 3:51am
( IsNull({PartTran1_1.SysDate}) or {PartTran1_1.SysDate} < {?StartDate}) and
{PartTran1.Plant} = {?Plant} and
IsNull({PartTran1_1.PartNum}) and
{PartTran1.Company} = {?Company} and
{PartTran1.TranType} = {?TransType} and
Isnull({PartTran1.PartNum}) and
(not HasValue({?Part}) OR {PartTran1.PartNum} = {?Part}) and
{PartTran1.SysDate} < {?StartDate}

Edited by Glen IT - 22 Jan 2013 at 3:51am
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