--PLSQL Code to Run Workflow Backend
--Create sequence XXJG_WF_S ;
--Create sequence XXJG_WF_S ;
DECLARE
p_x_item_type VARCHAR2(100);
P_X_PROC_INT_NAME VARCHAR2(100);
P_X_ATTRIBUTE1 VARCHAR2(100) ;
x_itemkey number;
P_USER_NAME VARCHAR2(100) ;
BEGIN
P_x_item_type :='XXJGWF'; --Item Internal Name -- It can be 8 Charater
P_X_PROC_INT_NAME := 'XXJG_FIRST_PRC'; --Process Name
P_USER_NAME :='OPERATIONS' ;
SELECT XXJG_WF_S.NEXTVAL INTO x_itemkey FROM DUAL;
-- API used to create a Process.
wf_engine.createprocess ( itemtype => p_x_item_type ,itemkey => x_itemkey ,
process => p_x_proc_int_name);
-- API used to set the userkey for the Workflow.
wf_engine.setitemuserkey ( itemtype => p_x_item_type ,itemkey => x_itemkey ,
userkey => x_itemkey);
-- -- API used to set the Attribute value in a Workflow.
--WF_ENGINE.SETITEMATTRTEXT ( ITEMTYPE => P_X_ITEM_TYPE ,itemkey => x_itemkey,
-- aname => 'XXPONUM' ,avalue => 'PO-ABC-199');
-- API used to set the Item Owner for the Workflow.
wf_engine.setitemowner ( itemtype => p_x_item_type ,ITEMKEY => X_ITEMKEY ,owner => P_USER_NAME);
-- API used to Start Process, here Main Process.
wf_engine.startprocess (p_x_item_type, x_itemkey);
dbms_output.put_line( 'workflow completed successfully');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line( 'Exception Raised while Calling the Workflow... ' || SQLCODE || ' - ' || SQLERRM);
END;