[Home] [Help]
PACKAGE BODY: APPS.PO_CONC_MODS_PVT
Source
1 PACKAGE BODY PO_CONC_MODS_PVT AS
2 /* $Header: PO_CONC_MODS_PVT.plb 120.2.12020000.4 2013/03/08 09:08:36 inagdeo ship $ */
3
4 d_pkg_name CONSTANT varchar2(50) :=
5 PO_LOG.get_package_base('PO_CONC_MODS_PVT');
6 -------------------------------------------------------
7 -------------- PUBLIC PROCEDURES ----------------------
8 -------------------------------------------------------
9 -----------------------------------------------------------------------
10 --Start of Comments
11 --Name: start_concmods_notif_workflow
12 --Pre-reqs: None
13 --Modifies:
14 --Function:
15 -- API to launch PO concurrent modification workflow
16 --Parameters:
17 --IN:
18 --p_draft_id
19 -- draft unique identifier
20 --p_requestor_id
21 -- employeed id of the requester
22 --p_actioner_id
23 -- employee id of the actioner
24 --p_action_requested
25 -- Action requested
26 --p_action_req_details
27 -- Action requested details
28 --p_draft_type
29 -- PAR/MOD
30 --IN OUT:
31 --OUT:
32 --Returns:
33 --Notes:
34 --Testing:
35 --End of Comments
36 ------------------------------------------------------------------------
37 PROCEDURE start_concmods_notif_workflow(
38 p_draft_id IN NUMBER,
39 p_lock_by_draft_id IN NUMBER,
40 p_requestor_id IN NUMBER,
41 p_actioner_id IN NUMBER,
42 p_action_requested IN VARCHAR2,
43 p_action_req_details IN VARCHAR2,
44 p_draft_type IN VARCHAR2) --<PAR project>
45 IS
46 d_api_name CONSTANT VARCHAR2(30) := 'start_concmods_notif_workflow';
47 d_module CONSTANT VARCHAR2(2000) := d_pkg_name || d_api_name || '.';
48 d_api_version CONSTANT NUMBER := 1.0;
49
50 l_mod_number VARCHAR2(100);
51 l_document_id po_drafts.document_id%TYPE;
52 l_seq_for_item_key VARCHAR2(100) := NULL;
53 l_itemkey VARCHAR2(100);
54 l_itemtype VARCHAR2(100);
55 l_requestor_user_name VARCHAR2(100);
56 l_requestor_display_name VARCHAR2(240);
57 l_actioner_user_name VARCHAR2(100);
58 l_actioner_display_name VARCHAR2(240);
59 l_edit_po_url VARCHAR2(1000);
60 l_doc_subtype po_document_types_all_b.document_subtype%TYPE;
61 d_position NUMBER;
62 l_view_par_url VARCHAR2(1000);
63
64 BEGIN
65
66 IF (PO_LOG.d_proc) THEN
67 PO_LOG.proc_begin(d_module);
68 PO_LOG.proc_begin(d_module, 'p_draft_id', p_draft_id);
69 PO_LOG.proc_begin(d_module, 'p_lock_by_draft_id ', p_lock_by_draft_id);
70 PO_LOG.proc_begin(d_module, 'p_requestor_id', p_requestor_id);
71 PO_LOG.proc_begin(d_module, 'p_actioner_id', p_actioner_id);
72 PO_LOG.proc_begin(d_module, 'p_action_requested',
73 p_action_requested);
74 PO_LOG.proc_begin(d_module, 'p_action_req_details', p_action_req_details);
75 END IF;
76
77 d_position := 10;
78
79 BEGIN
80 SELECT modification_number,
81 document_id
82 INTO l_mod_number,
83 l_document_id
84 FROM po_drafts
85 WHERE draft_id = p_lock_by_draft_id;
86 EXCEPTION
87 WHEN no_data_found THEN
88 RAISE;
89 END;
90
91 IF (PO_LOG.d_stmt) THEN
92 PO_LOG.stmt(d_module, d_position, 'l_mod_number', l_mod_number);
93 PO_LOG.stmt(d_module, d_position, 'l_document_id', l_document_id);
94 END IF;
95
96 d_position := 20;
97
98 SELECT TO_CHAR(PO_WF_ITEMKEY_S.NEXTVAL)
99 INTO l_seq_for_item_key
100 FROM sys.dual;
101 l_itemkey := TO_CHAR(l_document_id) || '-' || l_seq_for_item_key;
102 l_itemtype := 'POCMODNT' ;
103
104 -- <PAR project>
105 -- Launching the workflow process based on draft type
106 IF (p_draft_type = 'MOD') THEN
107 wf_engine.CreateProcess( ItemType => l_itemtype ,ItemKey => l_itemkey ,
108 process => 'NOTIFY_MOD_REQUEST_KO');
109 ELSIF (p_draft_type = 'PAR') THEN
110 wf_engine.CreateProcess( ItemType => l_itemtype ,ItemKey => l_itemkey ,
111 process => 'NOTIFY_PAR_REQUEST');
112 END IF;
113
114 -- initialize the wf attributes
115 d_position := 30;
116 -- user key
117 wf_engine.SetItemUserKey ( itemtype => l_itemtype ,itemkey => l_itemkey ,userkey =>
118 to_char(p_draft_id));
119
120 --mod number
121 wf_engine.SetItemAttrText ( itemtype => l_itemtype ,itemkey => l_itemkey ,aname =>
122 'MOD_NUMBER' ,avalue => l_mod_number);
123
124 --requestor user name
125 PO_REQAPPROVAL_INIT1.get_user_name
126 (p_requestor_id,l_requestor_user_name,l_requestor_display_name);
127
128 --actioner user name
129 PO_REQAPPROVAL_INIT1.get_user_name
130 (p_actioner_id,l_actioner_user_name,l_actioner_display_name);
131
132 IF (PO_LOG.d_stmt) THEN
133 PO_LOG.stmt(d_module, d_position,'l_requestor_user_name', l_requestor_user_name);
134 PO_LOG.stmt(d_module, d_position,'l_actioner_user_name', l_actioner_user_name);
135 END IF;
136
137 wf_engine.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname =>
138 'REQUESTOR' , avalue => l_requestor_user_name);
139
140 wf_engine.SetItemOwner (itemtype => l_itemtype, itemkey => l_itemkey, owner =>
141 l_requestor_user_name);
142
143 wf_engine.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname =>
144 'RECIPIENT' , avalue => l_actioner_user_name);
145 --action requested
146
147 wf_engine.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname =>
148 'ACTION_REQ' , avalue => p_action_requested);
149 --action requested details
150
151 wf_engine.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname =>
152 'ACTION_REQ_DETAILS' , avalue => p_action_req_details);
153 SELECT type_lookup_code INTO l_doc_subtype FROM po_headers_all WHERE po_header_id = l_document_id ;
154
155 l_edit_po_url := po_reqapproval_init1.get_mod_url(
156 p_po_header_id => l_document_id
157 ,p_draft_id => p_lock_by_draft_id
158 ,p_doc_subtype => l_doc_subtype
159 , p_mode => 'update');
160
161 wf_engine.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname =>
162 'UPDATE_MOD_URL' , avalue => l_edit_po_url);
163
164 -- <PAR Project>
165 -- Set View PAR URL
166 l_view_par_url := po_reqapproval_init1.get_mod_url(
167 p_po_header_id => l_document_id
168 ,p_draft_id => p_lock_by_draft_id
169 ,p_doc_subtype => l_doc_subtype
170 , p_mode => 'viewOnly');
171
172 wf_engine.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname =>
173 'VIEW_PAR_DETAILS' , avalue => l_view_par_url);
174
175 --start wf process
176
177 wf_engine.StartProcess( itemtype => l_itemtype, itemkey => l_itemkey );
178
179 COMMIT;
180 IF (PO_LOG.d_proc) THEN
181 PO_LOG.proc_end (d_module);
182 END IF;
183
184 EXCEPTION
185 WHEN OTHERS THEN
186 wf_core.context(d_module,'NOTIFY_MOD_REQUEST_KO',l_itemtype,l_itemkey);
187 raise_application_error(-20041, 'Failure in start_concmods_notif_workflow ', true);
188
189 END start_concmods_notif_workflow;
190
191 END PO_CONC_MODS_PVT;