J
John Sitka
I'm not sure this is the best way to ask for direction but
hopefully someone will see the issue if they have worked on it before.
I'm very new to knowing the data definition of Project so don't throw up.
Basically I'm just trying to distribute a task outline code accross a
reporting result set.
The INSERT....EXEC's that make up the UNIONS draw from an ERP calcualtion
My issue is with derived table "J" which happens
just after the LEFT JOIN and before the UNIONS
Seems a lot of work to distribute an outline code 'name' accross enterprise
tasks. So much so that I'm on the verge of changing them to custom fields
but I was excited by the analysis posibillities but then found out task
outlines aren't
part of the default cubes.
So if anyone has a code snippent that attacks Task outline codes
so I can see the table relationship, much appreciated.
ALTER PROC ab_PWA_reportingattempt4
(
@sonom varchar(6),
@opernosm varchar(2000),
@leftdatem smalldatetime,
@rightdatem smalldatetime
--@project_namem varchar(255) NOT used yet
)
AS
DECLARE @project_name varchar(255)
DECLARE @project_id int
SET @project_name = 'KIT04.Published'
SELECT @project_id = (SELECT PROJ_ID FROM MSP_PROJECTS WHERE PROJ_NAME =
@project_name)
--Build the RTG contribution
CREATE TABLE #RTGtable
(
RTGso varchar(255),
RTGwc varchar(255),
RTGop varchar(255),
RTGhrs Numeric(16,5)
)
INSERT INTO #RTGtable (RTGso,RTGwc,RTGop,RTGhrs)
EXEC ProjectServer0554.dbo.ab_quotedhours_1
@sono = @sonom,
@opernos = @opernosm
--Build the TC Contribution
CREATE TABLE #TCtable
(
TCso varchar(6),
TCjo varchar(10),
TCwc varchar(6),
TCop int,
TChrs Numeric(16,5)
)
INSERT INTO #TCtable (TCso,TCjo,TCwc,TCop,TChrs)
EXEC ProjectServer0554.dbo.ab_timecardhours_1
@sono = @sonom,
@opernos = @opernosm ,
@leftdate = @leftdatem,
@rightdate = @rightdatem
-- SELECT OUR DISPLAY SET
SELECT I.TASK_NAME as Task,J.oce_name as [Job Type],I.pro_ACTUALWORK as
[Actual Work] ,I.ecf_OWE as [Original
Estimate],I.variance,I.quotedhours,I.timecardhours
FROM
(
SELECT CASE WHEN (GROUPING(G.TASK_NAME) = 1) THEN 'X_ALL'
ELSE G.TASK_NAME END as TASK_NAME, SUM(G.pro_ACTUALWORK) as pro_ACTUALWORK,
SUM(G.ecf_OWE) as ecf_OWE, SUM(G.variance)as variance,
null as quotedhours,null as timecardhours
FROM
(
SELECT TASK_NAME, CAST(E.TASK_ACT_WORK/60000 as money) as pro_ACTUALWORK,
CAST(F.TaskEnterpriseDuration1/600.00 as money) as ecf_OWE,
CAST(F.TaskEnterpriseDuration1/600.00 as money) -
CAST(E.TASK_ACT_WORK/60000 as money) as variance
FROM
(
SELECT TASK_ACT_WORK, TASK_UID, PROJ_ID, TASK_NAME --,*
FROM MSP_TASKS WHERE Proj_ID = @project_id
)
E
INNER JOIN
(
SELECT TaskEnterpriseDuration1, ENT_ProjectUniqueID, ENT_TaskUniqueID
FROM MSP_VIEW_PROJ_TASKS_ENT WHERE ENT_ProjectUniqueID = @project_id
)
F
ON E.PROJ_ID = F.ENT_ProjectUniqueID AND E.TASK_UID = F.ENT_TaskUniqueID
WHERE F.TaskEnterpriseDuration1 <> 0
AND TASK_NAME LIKE @sonom+'%'
)
G
GROUP BY G.TASK_NAME WITH ROLLUP
)
I
LEFT JOIN
(
SELECT EE.TASK_NAME, GG.oce_name
FROM
(
SELECT TASK_UID, PROJ_ID, TASK_NAME
FROM MSP_TASKS WHERE Proj_ID = @project_id
)
EE
INNER JOIN
(
SELECT ENT_ProjectUniqueID,ENT_TaskUniqueID,TaskEnterpriseOutlineCode1ID
FROM MSP_VIEW_PROJ_TASKS_ENT WHERE ENT_ProjectUniqueID = @project_id
)
FF
ON EE.PROJ_ID = FF.ENT_ProjectUniqueID AND EE.TASK_UID =
FF.ENT_TaskUniqueID
LEFT JOIN
(
SELECT DISTINCT CODE_UID, CAST(OC_NAME as varchar(1))as oce_name FROM
MSP_OUTLINE_CODES
WHERE OC_FIELD_ID =188744419 AND PROJ_ID = 48 --not sure about this yet 48
= Enterprise global
)
GG
ON FF.TaskEnterpriseOutlineCode1ID = GG.CODE_UID
)
J
ON I.TASK_NAME=J.TASK_NAME
UNION
SELECT 'X_Routing_'+RTRIM(RTGwc)+'-'+CAST(RTGop as
varchar(6)),null,null,null,null,K.RTGhrs,null FROM
#RTGtable K
UNION
SELECT 'X_Timecard_'+RTRIM(TCwc)+'-'+CAST(TCop as
varchar(6)),null,null,null,null,null,L.TChrs FROM
#TCtable L
DROP TABLE #RTGtable
DROP TABLE #TCtable
hopefully someone will see the issue if they have worked on it before.
I'm very new to knowing the data definition of Project so don't throw up.
Basically I'm just trying to distribute a task outline code accross a
reporting result set.
The INSERT....EXEC's that make up the UNIONS draw from an ERP calcualtion
My issue is with derived table "J" which happens
just after the LEFT JOIN and before the UNIONS
Seems a lot of work to distribute an outline code 'name' accross enterprise
tasks. So much so that I'm on the verge of changing them to custom fields
but I was excited by the analysis posibillities but then found out task
outlines aren't
part of the default cubes.
So if anyone has a code snippent that attacks Task outline codes
so I can see the table relationship, much appreciated.
ALTER PROC ab_PWA_reportingattempt4
(
@sonom varchar(6),
@opernosm varchar(2000),
@leftdatem smalldatetime,
@rightdatem smalldatetime
--@project_namem varchar(255) NOT used yet
)
AS
DECLARE @project_name varchar(255)
DECLARE @project_id int
SET @project_name = 'KIT04.Published'
SELECT @project_id = (SELECT PROJ_ID FROM MSP_PROJECTS WHERE PROJ_NAME =
@project_name)
--Build the RTG contribution
CREATE TABLE #RTGtable
(
RTGso varchar(255),
RTGwc varchar(255),
RTGop varchar(255),
RTGhrs Numeric(16,5)
)
INSERT INTO #RTGtable (RTGso,RTGwc,RTGop,RTGhrs)
EXEC ProjectServer0554.dbo.ab_quotedhours_1
@sono = @sonom,
@opernos = @opernosm
--Build the TC Contribution
CREATE TABLE #TCtable
(
TCso varchar(6),
TCjo varchar(10),
TCwc varchar(6),
TCop int,
TChrs Numeric(16,5)
)
INSERT INTO #TCtable (TCso,TCjo,TCwc,TCop,TChrs)
EXEC ProjectServer0554.dbo.ab_timecardhours_1
@sono = @sonom,
@opernos = @opernosm ,
@leftdate = @leftdatem,
@rightdate = @rightdatem
-- SELECT OUR DISPLAY SET
SELECT I.TASK_NAME as Task,J.oce_name as [Job Type],I.pro_ACTUALWORK as
[Actual Work] ,I.ecf_OWE as [Original
Estimate],I.variance,I.quotedhours,I.timecardhours
FROM
(
SELECT CASE WHEN (GROUPING(G.TASK_NAME) = 1) THEN 'X_ALL'
ELSE G.TASK_NAME END as TASK_NAME, SUM(G.pro_ACTUALWORK) as pro_ACTUALWORK,
SUM(G.ecf_OWE) as ecf_OWE, SUM(G.variance)as variance,
null as quotedhours,null as timecardhours
FROM
(
SELECT TASK_NAME, CAST(E.TASK_ACT_WORK/60000 as money) as pro_ACTUALWORK,
CAST(F.TaskEnterpriseDuration1/600.00 as money) as ecf_OWE,
CAST(F.TaskEnterpriseDuration1/600.00 as money) -
CAST(E.TASK_ACT_WORK/60000 as money) as variance
FROM
(
SELECT TASK_ACT_WORK, TASK_UID, PROJ_ID, TASK_NAME --,*
FROM MSP_TASKS WHERE Proj_ID = @project_id
)
E
INNER JOIN
(
SELECT TaskEnterpriseDuration1, ENT_ProjectUniqueID, ENT_TaskUniqueID
FROM MSP_VIEW_PROJ_TASKS_ENT WHERE ENT_ProjectUniqueID = @project_id
)
F
ON E.PROJ_ID = F.ENT_ProjectUniqueID AND E.TASK_UID = F.ENT_TaskUniqueID
WHERE F.TaskEnterpriseDuration1 <> 0
AND TASK_NAME LIKE @sonom+'%'
)
G
GROUP BY G.TASK_NAME WITH ROLLUP
)
I
LEFT JOIN
(
SELECT EE.TASK_NAME, GG.oce_name
FROM
(
SELECT TASK_UID, PROJ_ID, TASK_NAME
FROM MSP_TASKS WHERE Proj_ID = @project_id
)
EE
INNER JOIN
(
SELECT ENT_ProjectUniqueID,ENT_TaskUniqueID,TaskEnterpriseOutlineCode1ID
FROM MSP_VIEW_PROJ_TASKS_ENT WHERE ENT_ProjectUniqueID = @project_id
)
FF
ON EE.PROJ_ID = FF.ENT_ProjectUniqueID AND EE.TASK_UID =
FF.ENT_TaskUniqueID
LEFT JOIN
(
SELECT DISTINCT CODE_UID, CAST(OC_NAME as varchar(1))as oce_name FROM
MSP_OUTLINE_CODES
WHERE OC_FIELD_ID =188744419 AND PROJ_ID = 48 --not sure about this yet 48
= Enterprise global
)
GG
ON FF.TaskEnterpriseOutlineCode1ID = GG.CODE_UID
)
J
ON I.TASK_NAME=J.TASK_NAME
UNION
SELECT 'X_Routing_'+RTRIM(RTGwc)+'-'+CAST(RTGop as
varchar(6)),null,null,null,null,K.RTGhrs,null FROM
#RTGtable K
UNION
SELECT 'X_Timecard_'+RTRIM(TCwc)+'-'+CAST(TCop as
varchar(6)),null,null,null,null,null,L.TChrs FROM
#TCtable L
DROP TABLE #RTGtable
DROP TABLE #TCtable