05 September 2008

Oracle: Raising Oracle Business Event.

Sample stored procedure to raise business event,

CREATE OR REPLACE PROCEDURE APPS.xxul_quote_event_create (
p_errcode OUT NUMBER,
p_errbuff OUT VARCHAR2,
p_qte_header_rec IN aso_quote_pub.qte_header_rec_type
)
IS
PRAGMA AUTONOMOUS_TRANSACTION;
/* Declaring the variables*/
l_chr_event_key VARCHAR2 (240) ;
l_parameter_list wf_parameter_list_t;
l_event_name VARCHAR2 (100) := '';
l_err VARCHAR2 (200);
v_user_id NUMBER := 0;
v_resp_id NUMBER := 0;
v_resp_appl_id NUMBER := 0;
v_org_id NUMBER := 0;
BEGIN
SELECT fnd_profile.VALUE ('ORG_ID')
INTO v_org_id
FROM DUAL;

fnd_client_info.set_org_context (v_org_id);
l_chr_event_key := hz_event_pkg.item_key (l_event_name);

SELECT fnd_profile.VALUE ('USER_ID')
INTO v_user_id
FROM DUAL;

SELECT fnd_profile.VALUE ('RESP_ID')
INTO v_resp_id
FROM DUAL;

SELECT fnd_profile.VALUE ('RESP_APPL_ID')
INTO v_resp_appl_id
FROM DUAL;

apps.fnd_global.apps_initialize (v_user_id, v_resp_id, v_resp_appl_id);
wf_event.addparametertolist (p_name => 'USER_ID',
p_value => v_user_id,
p_parameterlist => l_parameter_list
);
wf_event.addparametertolist (p_name => 'RESP_ID',
p_value => v_resp_id,
p_parameterlist => l_parameter_list
);
wf_event.addparametertolist (p_name => 'RESP_APPL_ID',
p_value => v_resp_appl_id,
p_parameterlist => l_parameter_list
);
wf_event.addparametertolist (p_name => 'QUOTE_HEADER_ID',
p_value => p_qte_header_rec.quote_header_id,
p_parameterlist => l_parameter_list
);
wf_event.RAISE (p_event_name => l_event_name,
p_event_key => l_chr_event_key,
p_parameters => l_parameter_list
);
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (fnd_file.LOG,
'Error while raising business event' || SQLERRM
);
DBMS_OUTPUT.put_line (l_err);
END;
/

http://download-uk.oracle.com/docs/cd/B10501_01/workflow.920/a95265/instal69.htm

No comments: