Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8635

Re: Getting CR to display fields from stored procedure

$
0
0

Dell it basically is used to filter the data...  below is a snippet of the code (@plansdate is the input parameter into the proc).  I get the difference between the @plansdate and current date (getdate) and depending on what that difference is, I run different queries.  However, as you can see it always returns the same columns from the same table (SAPItemCode, item_desc, uom_code, etc.), the only difference is the where clause.  So I need Crystal reports to give me access to those columsn so I can display it on the report.

 

I could always make these two queries, separate stored procs ( with no input parameters) and then add multiple procs to my report.  Then through section formulas I could decide which data to display, but that just seems rather tedious and complex to me.  If I could get CR to realize that (SAPItemCode, item_desc, uom_code, TodayUsage, FutureUsage, etc.) will always be returned, then allow me to place those fields on my report, it would make it alot easier than having 2 or more different stored procs on this report

 

 

   DECLARE @datedifference INT

        SET @datedifference = DATEDIFF(DAY, GETDATE(), @plansdate)

    /********************************************************************

    get data for current day's ingred usage from cssr

    *********************************************************************/

 

 

        IF @datedifference = 0

            BEGIN

 

 

 

 

                SELECT  C.SAPItemCode, C.item_desc, C.uom_code, C.TodayUsage,

                        C.FutureUsage, C.TodayUsageNotSent, C.FutureUsage1,

                        C.FutureUsage2, C.FutureUsage3

                FROM    Oceanside.cssr.CSSR AS C

                WHERE   c.SAPItemCode IN (

                        SELECT DISTINCT

                                TIU.SAPItemCode_rm

                        FROM    Backlogs.dbo.TodayIngredUsage AS TIU )

            END

 

 

    /********************************************************************

    get data for tomorrow's ingred usage from cssr

    *********************************************************************/

 

 

        IF @datedifference = 1

            BEGIN

 

 

 

 

                SELECT  C.SAPItemCode, C.item_desc, C.uom_code, C.TodayUsage,

                        C.FutureUsage, C.TodayUsageNotSent, C.FutureUsage1,

                        C.FutureUsage2, C.FutureUsage3

                FROM    Oceanside.cssr.CSSR AS C

                WHERE   c.SAPItemCode IN (

                        SELECT DISTINCT

                                FIU1.SAPItemCode_rm

                        FROM    Backlogs.dbo.FutureIngredUsage1 AS FIU1 )

            END


Viewing all articles
Browse latest Browse all 8635

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>