PAULDCLARK
Well Known Member
One of the big issues I've had with JDE is the way that the WSJ from the F986110 doesn't show a seperate wait time from a run time, which makes the F986110 table a complete waste of time when finding how long a job took, what jobs were running at the same time etc etc. I understand that 8.98 has this sort of information, but on 8.97 it doesn't, so I wrote a trigger for it (This is SQL Server Code) and it shows the start time, run time, end time and run and wait times in seconds in a new table.
It can even account for the job number being reset, as this is one of the unique keys in the file. It been tested and has been live for a month or so with no issues, and it's proved very useful in finding average times, wait times etc etc. The order of status changes is quite odd, when I ran diagnostics it went: W - S - P - P - D\E, so its based on an insert of the W, then a delete of S and a delete of P, the latter gets processed twice but that doesn't really matter.
There are two SQL scripts included, the first is the gen of the table, the other the actual trigger over the F986110.
Hope this helps!
Table Gen:
USE [JDE812]
GO
/****** Object: Table [SVB812].[F986110_JobTimes] Script Date: 04/30/2009 09:49:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [SVB812].[F986110_JobTimes](
[JCJOBNBR] [float] NOT NULL,
[JCEXEHOST] [char](40) NOT NULL,
[JCFNDFUF2] [char](30) NOT NULL,
[JCENHV] [char](10) NULL,
[JCUSER] [char](10) NULL,
[JCJOBQUE] [char](10) NULL,
[JCJOBSTS] [nchar](2) NULL,
[Submit_Date_Time] [datetime] NULL,
[Start_Date_Time] [datetime] NULL,
[End_Date_Time] [datetime] NULL,
[Wait_Time] [int] NULL,
[Run_Time] [int] NULL,
CONSTRAINT [F986110_JobTimes_PK] PRIMARY KEY NONCLUSTERED
( [JCEXEHOST] ASC,
[JCJOBNBR] ASC,
[JCFNDFUF2] ASC )
)
ON [PRIMARY]
GO
SET ANSI_PADDING OFF
The trigger:
USE [JDE812]
GO
/****** Object: Trigger [SVB812].[F985110_Timings] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE trigger [SVB812].[F986110_Timings] on [SVB812].[F986110] after insert, update, delete
as
BEGIN
SET NOCOUNT ON
/* Variable Declarations */
Declare @JCJOBSTS_Var Char (2),
@JCJOBNBR_Var Float,
@JCEXEHOST_Var Char (40),
@Submit_Date_Time_Var DateTime,
@Start_Date_Time_Var DateTime,
@Date_Now_Var DateTime
/* Set Constants */
/* Initial Insert has a W in the Job Status */
IF (SELECT COUNT(*) FROM inserted) > 0
BEGIN
SET @JCJOBSTS_Var = (Select JCJOBSTS from inserted)
SET @JCJOBNBR_Var = (Select JCJOBNBR from inserted)
SET @JCEXEHOST_Var = (Select JCEXEHOST from inserted)
SET @Date_Now_Var = (getDate())
IF @JCJOBSTS_Var = 'W'
BEGIN
insert into SVB812.F986110_JobTimes
(JCJOBNBR, JCEXEHOST, JCFNDFUF2, JCENHV, JCUSER, JCJOBQUE, JCJOBSTS, Submit_Date_Time )
select JCJOBNBR, JCEXEHOST, JCFNDFUF2, JCENHV, JCUSER, JCJOBQUE, JCJOBSTS, @Date_Now_Var from inserted;
/* This line deletes any wraparound records, i.e. if the job number has been reset */
delete from SVB812.F986110_JobTimes where (JCJOBNBR = @JCJOBNBR_Var and JCEXEHOST = @JCEXEHOST_Var and Submit_Date_Time <> @Date_Now_Var);
END
END
IF (SELECT COUNT(*) FROM deleted) > 0
BEGIN
SET @JCJOBSTS_Var = (Select JCJOBSTS from deleted)
SET @JCJOBNBR_Var = (Select JCJOBNBR from deleted)
SET @JCEXEHOST_Var = (Select JCEXEHOST from deleted)
SET @Date_Now_Var = (getDate())
/* When the job goes active, S is deleted from the Job Status */
IF @JCJOBSTS_Var = 'S'
BEGIN
SET @Submit_Date_Time_Var = (Select Submit_Date_Time from SVB812.F986110_JobTimes where (JCJOBNBR = @JCJOBNBR_Var and JCEXEHOST = @JCEXEHOST_Var))
Update SVB812.F986110_JobTimes set Start_Date_Time = @Date_Now_Var,
Wait_Time = DateDiff(ss,@Submit_Date_Time_Var, @Date_Now_Var)
where (JCJOBNBR = @JCJOBNBR_Var and JCEXEHOST = @JCEXEHOST_Var);
Update SVB812.F986110_JobTimes set JCJOBSTS = (select JCJOBSTS from inserted)
where (JCJOBNBR = @JCJOBNBR_Var and JCEXEHOST = @JCEXEHOST_Var);
END
/* When the job ends, P is deleted from the Job Status */
IF @JCJOBSTS_Var = 'P'
BEGIN
SET @Start_Date_Time_Var = (Select Start_Date_Time from SVB812.F986110_JobTimes where (JCJOBNBR = @JCJOBNBR_Var and JCEXEHOST = @JCEXEHOST_Var))
Update SVB812.F986110_JobTimes set End_Date_Time = @Date_Now_Var,
Run_Time = DateDiff(ss,@Start_Date_Time_Var, @Date_Now_Var)
where (JCJOBNBR = @JCJOBNBR_Var and JCEXEHOST = @JCEXEHOST_Var);
Update SVB812.F986110_JobTimes set JCJOBSTS = (select JCJOBSTS from inserted)
where (JCJOBNBR = @JCJOBNBR_Var and JCEXEHOST = @JCEXEHOST_Var);
END
END
END
It can even account for the job number being reset, as this is one of the unique keys in the file. It been tested and has been live for a month or so with no issues, and it's proved very useful in finding average times, wait times etc etc. The order of status changes is quite odd, when I ran diagnostics it went: W - S - P - P - D\E, so its based on an insert of the W, then a delete of S and a delete of P, the latter gets processed twice but that doesn't really matter.
There are two SQL scripts included, the first is the gen of the table, the other the actual trigger over the F986110.
Hope this helps!
Table Gen:
USE [JDE812]
GO
/****** Object: Table [SVB812].[F986110_JobTimes] Script Date: 04/30/2009 09:49:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [SVB812].[F986110_JobTimes](
[JCJOBNBR] [float] NOT NULL,
[JCEXEHOST] [char](40) NOT NULL,
[JCFNDFUF2] [char](30) NOT NULL,
[JCENHV] [char](10) NULL,
[JCUSER] [char](10) NULL,
[JCJOBQUE] [char](10) NULL,
[JCJOBSTS] [nchar](2) NULL,
[Submit_Date_Time] [datetime] NULL,
[Start_Date_Time] [datetime] NULL,
[End_Date_Time] [datetime] NULL,
[Wait_Time] [int] NULL,
[Run_Time] [int] NULL,
CONSTRAINT [F986110_JobTimes_PK] PRIMARY KEY NONCLUSTERED
( [JCEXEHOST] ASC,
[JCJOBNBR] ASC,
[JCFNDFUF2] ASC )
)
ON [PRIMARY]
GO
SET ANSI_PADDING OFF
The trigger:
USE [JDE812]
GO
/****** Object: Trigger [SVB812].[F985110_Timings] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE trigger [SVB812].[F986110_Timings] on [SVB812].[F986110] after insert, update, delete
as
BEGIN
SET NOCOUNT ON
/* Variable Declarations */
Declare @JCJOBSTS_Var Char (2),
@JCJOBNBR_Var Float,
@JCEXEHOST_Var Char (40),
@Submit_Date_Time_Var DateTime,
@Start_Date_Time_Var DateTime,
@Date_Now_Var DateTime
/* Set Constants */
/* Initial Insert has a W in the Job Status */
IF (SELECT COUNT(*) FROM inserted) > 0
BEGIN
SET @JCJOBSTS_Var = (Select JCJOBSTS from inserted)
SET @JCJOBNBR_Var = (Select JCJOBNBR from inserted)
SET @JCEXEHOST_Var = (Select JCEXEHOST from inserted)
SET @Date_Now_Var = (getDate())
IF @JCJOBSTS_Var = 'W'
BEGIN
insert into SVB812.F986110_JobTimes
(JCJOBNBR, JCEXEHOST, JCFNDFUF2, JCENHV, JCUSER, JCJOBQUE, JCJOBSTS, Submit_Date_Time )
select JCJOBNBR, JCEXEHOST, JCFNDFUF2, JCENHV, JCUSER, JCJOBQUE, JCJOBSTS, @Date_Now_Var from inserted;
/* This line deletes any wraparound records, i.e. if the job number has been reset */
delete from SVB812.F986110_JobTimes where (JCJOBNBR = @JCJOBNBR_Var and JCEXEHOST = @JCEXEHOST_Var and Submit_Date_Time <> @Date_Now_Var);
END
END
IF (SELECT COUNT(*) FROM deleted) > 0
BEGIN
SET @JCJOBSTS_Var = (Select JCJOBSTS from deleted)
SET @JCJOBNBR_Var = (Select JCJOBNBR from deleted)
SET @JCEXEHOST_Var = (Select JCEXEHOST from deleted)
SET @Date_Now_Var = (getDate())
/* When the job goes active, S is deleted from the Job Status */
IF @JCJOBSTS_Var = 'S'
BEGIN
SET @Submit_Date_Time_Var = (Select Submit_Date_Time from SVB812.F986110_JobTimes where (JCJOBNBR = @JCJOBNBR_Var and JCEXEHOST = @JCEXEHOST_Var))
Update SVB812.F986110_JobTimes set Start_Date_Time = @Date_Now_Var,
Wait_Time = DateDiff(ss,@Submit_Date_Time_Var, @Date_Now_Var)
where (JCJOBNBR = @JCJOBNBR_Var and JCEXEHOST = @JCEXEHOST_Var);
Update SVB812.F986110_JobTimes set JCJOBSTS = (select JCJOBSTS from inserted)
where (JCJOBNBR = @JCJOBNBR_Var and JCEXEHOST = @JCEXEHOST_Var);
END
/* When the job ends, P is deleted from the Job Status */
IF @JCJOBSTS_Var = 'P'
BEGIN
SET @Start_Date_Time_Var = (Select Start_Date_Time from SVB812.F986110_JobTimes where (JCJOBNBR = @JCJOBNBR_Var and JCEXEHOST = @JCEXEHOST_Var))
Update SVB812.F986110_JobTimes set End_Date_Time = @Date_Now_Var,
Run_Time = DateDiff(ss,@Start_Date_Time_Var, @Date_Now_Var)
where (JCJOBNBR = @JCJOBNBR_Var and JCEXEHOST = @JCEXEHOST_Var);
Update SVB812.F986110_JobTimes set JCJOBSTS = (select JCJOBSTS from inserted)
where (JCJOBNBR = @JCJOBNBR_Var and JCEXEHOST = @JCEXEHOST_Var);
END
END
END