Yes you can, but you will need to use a trigger to do so. Standard Eralis Job uses the job type from the master job rather than the subjob.
The following trigger can be used on a SQL Server Platform / Database:
CREATE TRIGGER ENPRISE_CUSTOM_SETGLCODESBYSUBJOBTYPE
ON ENPRISE_JOBCOST_JOBLINES
FOR INSERT
AS
BEGIN
UPDATE L
SET L.SALESGLCODE = T.DEFAULTSALESCODE,
L.COSGLCODE = T.DEFAULTCOSCODE
FROM ENPRISE_JOBCOST_JOBLINES L
INNER JOIN INSERTED I ON I.SEQNO = L.SEQNO
INNER JOIN ENPRISE_JOBCOST_SUBJOB S ON S.SUBJOBID = I.SUBJOBID
INNER JOIN ENPRISE_JOBCOST_JOBTYPE T ON T.SEQNO = S.JOBTYPE
WHERE I.STATUS IN (1, 2, 3, 5)
AND I.LINETYPE <> 'Q'
END
The following trigger can be used on a HANA Platform / Database Schema:
CREATE TRIGGER ENPRISE_CUSTOM_SETGLCODESBYSUBJOBTYPE
BEFORE INSERT ON ENPRISE_JOBCOST_JOBLINES
REFERENCING NEW ROW inserted
FOR EACH ROW
BEGIN
IF ((:inserted.STATUS = 1 OR :inserted.STATUS = 2 OR :inserted.STATUS = 3 OR :inserted.STATUS = 5) AND :inserted.LINETYPE <> 'Q') THEN
DECLARE default_sales_code NVARCHAR(15);
DECLARE default_cos_code NVARCHAR(15);
SELECT T.DEFAULTSALESCODE, T.DEFAULTCOSCODE INTO default_sales_code, default_cos_code
FROM ENPRISE_JOBCOST_SUBJOB S
INNER JOIN ENPRISE_JOBCOST_JOBTYPE T ON T.SEQNO = S.JOBTYPE
WHERE S.SUBJOBID = :inserted.SUBJOBID;
inserted.SALESGLCODE = default_sales_code;
inserted.COSGLCODE = default_cos_code;
END IF;
END;
Please note: The trigger will only update new lines that are inserted after the trigger has been applied and will not affect or update the existing job lines.
Comments
0 comments
Please sign in to leave a comment.