Setting up a stored procedure critical number drilldown
You can set up a drilldown for a critical number based on a stored procedure either by creating one new or by copying an existing one and then modifying it.
This example shows Customer Order Past Due:
CREATE PROCEDURE WBCanCoitemPastDueDetailsSp (
@AsOfDate DateType
, @DrillNum WBDrillNumType
, @KPINum WBKPINumType
, @Id nvarchar(500)
, @Parm1 WBSourceNameType
, @Parm2 WBSourceNameType
, @Parm3 WBSourceNameType
, @Parm4 WBSourceNameType
, @Parm5 WBSourceNameType
, @Parm6 WBSourceNameType
, @Parm7 WBSourceNameType
, @Parm8 WBSourceNameType
, @Parm9 WBSourceNameType
, @Parm10 WBSourceNameType
, @Parm11 WBSourceNameType
, @Parm12 WBSourceNameType
, @Parm13 WBSourceNameType
, @Parm14 WBSourceNameType
, @Parm15 WBSourceNameType
, @Parm16 WBSourceNameType
, @Parm17 WBSourceNameType
, @Parm18 WBSourceNameType
, @Parm19 WBSourceNameType
, @Parm20 WBSourceNameType
, @Parm21 WBSourceNameType
, @Parm22 WBSourceNameType
, @Parm23 WBSourceNameType
, @Parm24 WBSourceNameType
, @Parm25 WBSourceNameType
, @Parm26 WBSourceNameType
, @Parm27 WBSourceNameType
, @Parm28 WBSourceNameType
, @Parm29 WBSourceNameType
, @Parm30 WBSourceNameType
, @Parm31 WBSourceNameType
, @Parm32 WBSourceNameType
, @Parm33 WBSourceNameType
, @Parm34 WBSourceNameType
, @Parm35 WBSourceNameType
, @Parm36 WBSourceNameType
, @Parm37 WBSourceNameType
, @Parm38 WBSourceNameType
, @Parm39 WBSourceNameType
, @Parm40 WBSourceNameType
, @Parm41 WBSourceNameType
, @Parm42 WBSourceNameType
, @Parm43 WBSourceNameType
, @Parm44 WBSourceNameType
, @Parm45 WBSourceNameType
, @Parm46 WBSourceNameType
, @Parm47 WBSourceNameType
, @Parm48 WBSourceNameType
, @Parm49 WBSourceNameType
, @Parm50 WBSourceNameType
) AS
DECLARE @Severity INT
, @CoNum CoNumType
, @CustNum CustNumType
, @ParmsSite SiteType
, @CoStatList LongListType
, @CoitemStatList LongListType
, @CredHold ListYesNoType
, @LateDays INT
, @LineFilter CoLineType
, @ItemFilter ItemType
, @ProdCodeFilter ProductCodeType
, @WhseFilter WhseType
, @StatFilter CoitemStatusType
, @SessionID RowPointerType
SET @Severity = 0
SET @LateDays = 0
SET @SessionId = dbo.SessionIdSp()
SET @CustNum = dbo.ExpandKyByType('CustNumType', @Parm1) SET @CoNum = dbo.ExpandKyByType('CoNumType', @Parm2) SET @LineFilter = NULLIF(@Parm3, '') SET @ItemFilter = NULLIF(@Parm4, '') SET @ProdCodeFilter = NULLIF(@Parm5, '') SET @WhseFilter = NULLIF(@Parm6, '') SET @StatFilter = NULLIF(@Parm7, '')
IF @CoNum IS NULL AND @LineFilter IS NOT NULL
SET @LineFilter = NULL
SELECT @ParmsSite = site
FROM parms
SET @CoStatList = ISNULL(dbo.WBGetDrillParm(@DrillNum, @KPINum, 'COStatusList'), 'POS')
SET @CoitemStatList = ISNULL(dbo.WBGetDrillParm(@DrillNum, @KPINum, 'COITEMStatusList'), 'PO')
SET @CredHold = ISNULL(dbo.WBGetDrillParm(@DrillNum, @KPINum, 'CredHold'), 0)
SET @LateDays = ISNULL(dbo.WBGetDrillParm(@DrillNum, @KPINum, 'LateDaysTolerance'), 0)
INSERT INTO WBTmpDrilldowns(
RefRowPointer
, DATE01
, CHAR01
, INTE01
, CHAR02
, CHAR03
, SessionID
)
SELECT
coitem.RowPointer
, coitem.due_date
, co.co_num
, coitem.co_line
, co.cust_num
, custaddr.name
, @SessionID
FROM coitem
INNER JOIN co
ON co.co_num = coitem.co_num
LEFT OUTER JOIN custaddr
ON custaddr.cust_num = co.cust_num
AND custaddr.cust_seq = co.cust_seq
LEFT OUTER JOIN item itm
ON itm.item = coitem.item
WHERE co.cust_num = ISNULL(NULLIF(@CustNum,''), co.cust_num)
AND co.co_num = ISNULL(NULLIF(@CoNum,''), co.co_num)
AND charindex(coitem.stat, @CoitemStatList) > 0
AND qty_ordered > qty_shipped
AND ISNULL(due_date, '1900-01-01') = dateadd(dd,="" @latedays,="" @asofdate)="" and="" ship_site="@ParmsSite" charindex(co.stat,="" @costatlist)="" 0
AND co.credit_hold = @CredHold
AND (@LineFilter IS NULL OR coitem.co_line = @LineFilter)
AND (@ItemFilter IS NULL OR coitem.item = @ItemFilter)
AND (@ProdCodeFilter IS NULL OR itm.product_code = @ProdCodeFilter)
AND (@WhseFilter IS NULL OR co.whse = @WhseFilter)
AND (@StatFilter IS NULL OR co.stat = @StatFilter)
RETURN @Severity