[Home] [Help]
PACKAGE BODY: APPS.RCV_DEBIT_MEMO_NOTIF
Source
1 PACKAGE BODY RCV_DEBIT_MEMO_NOTIF AS
2 /* $Header: RCVWFDMB.pls 120.1.12010000.2 2010/03/03 12:23:34 zrahiman ship $ */
3
4 -- Read the profile option that enables/disables the debug log
5 g_po_wf_debug VARCHAR2(1) := NVL(FND_PROFILE.VALUE('PO_SET_DEBUG_WORKFLOW_ON'),'N');
6
7 /*=======================================================================+
8 | FILENAME
9 | RCVWPA1B.pls
10 |
11 | DESCRIPTION
12 | PL/SQL body for package: RCV_DEBIT_MEMO_NOTIF
13 |
14 | NOTES dreddy Created 3/30/2000
15 |
16 *=======================================================================*/
17
18 --
19 -- get the receipt_info
20 -- call the workflow
21 --
22 PROCEDURE dm_workflow_call(x_transaction_id number)is
23 l_seq varchar2(80);
24 EmployeeId number;
25 ReceiptNum varchar2(20);
26 PONumber po_headers_all.clm_document_number%type; -- Bug 9342280
27 x_ship_id number;
28 x_po_header_id number;
29 Quantity number;
30 ItemKey varchar2(80);
31 ItemType varchar2(80);
32 WorkflowProcess varchar2(80);
33 x_progress varchar2(30);
34
35 BEGIN
36
37 /* 4698050 - debit memo failure notiifacations should goto buyer rather than to
38 receiver. commenting the below selection of employee_id from rcv_transactions
39 and getting the same from po_headers as below.
40 */
41 x_progress := '010';
42
43 select shipment_header_id,
44 -- employee_id, -- Bugfix #4698050
45 quantity,
46 po_header_id
47 into x_ship_id,
48 -- EmployeeId, -- BUgFix 4698050
49 Quantity,
50 x_po_header_id
51 from rcv_transactions
52 where transaction_id = x_transaction_id ;
53
54 x_progress := '020';
55
56 select receipt_num
57 into ReceiptNum
58 from rcv_shipment_headers
59 where shipment_header_id = x_ship_id;
60
61 x_progress := '030';
62
63 /* Bug 9342280 Modified the from clause below from po_headers to
64 po_headers_trx_v to accomodate CLM PO Number changes */
65
66 select segment1,agent_id -- BugFix 4698050
67 into PONumber,EmployeeId -- BugFix 4698050
68 from po_headers_trx_v
69 where po_header_id = x_po_header_id;
70
71 x_progress := '040';
72
73 select to_char(PO_WF_ITEMKEY_S.NEXTVAL) into l_seq from sys.dual;
74 ItemKey := ReceiptNum || '-' || l_seq;
75 ItemType := 'RCVDMEMO' ;
76 WorkflowProcess := 'RCV_DEBIT_MEMO';
77
78 -- call the WF
79
80 Start_WF_Process ( ItemType => ItemType,
81 ItemKey => ItemKey,
82 WorkflowProcess => WorkflowProcess,
83 ReceiptNum => ReceiptNum,
84 EmployeeId => EmployeeId ,
85 Quantity => Quantity,
86 PONumber => PONumber );
87 EXCEPTION
88 WHEN OTHERS THEN
89
90 x_progress := '050';
91
92 po_message_s.sql_error('In Exception of dm_workflow_call()', x_progress, sqlcode);
93
94 RAISE;
95
96 END dm_workflow_call;
97
98
99 -- Start_WF_Process
100 -- Generates the itemkey, sets up the Item Attributes,
101 -- then starts the workflow process.
102 --
103 PROCEDURE Start_WF_Process ( ItemType VARCHAR2,
104 ItemKey VARCHAR2,
105 WorkflowProcess VARCHAR2,
106 ReceiptNum VARCHAR2,
107 EmployeeId NUMBER,
108 Quantity NUMBER,
109 PONumber VARCHAR2 ) is
110
111 x_progress varchar2(300);
112 x_wf_created number;
113 p_orig_system varchar2(20);
114 x_username varchar2(100);
115 x_user_display_name varchar2(240);
116 l_message1 varchar2(2000);
117 l_message2 varchar2(2000);
118 l_message3 varchar2(2000);
119 l_message4 varchar2(2000);
120 l_message varchar2(2000);
121
122 BEGIN
123
124
125 IF ( ItemType is NOT NULL ) AND
126 ( ItemKey is NOT NULL) AND
127 ( ReceiptNum is NOT NULL ) THEN
128
129 -- check to see if process has already been created
130 -- if it has, don't create process again.
131 begin
132 select count(*)
133 into x_wf_created
134 from wf_items
135 where item_type = ItemType
136 and item_key = ItemKey;
137
138 end;
139
140 commit;
141
142 if x_wf_created = 0 then
143 wf_engine.CreateProcess( ItemType => ItemType,
144 ItemKey => ItemKey,
145 process => WorkflowProcess );
146 end if;
147
148 -- get the user id
149 p_orig_system:= 'PER';
150 WF_DIRECTORY.GetUserName(p_orig_system,
151 EmployeeId,
152 x_username,
153 x_user_display_name);
154
155 -- get the message to be sent
156
157 l_message := fnd_message.get_string('PO', 'RCV_WF_NOTIF_DEBIT_MEMO');
158 l_message1 := fnd_message.get_string('PO', 'RCV_WF_DM_MSG1');
159 l_message2 := fnd_message.get_string('PO', 'RCV_WF_DM_MSG2');
160 l_message3 := fnd_message.get_string('PO', 'RCV_WF_DM_MSG3');
161 l_message4 := fnd_message.get_string('PO', 'RCV_WF_DM_MSG4');
162
163 -- Initialize workflow item attributes
164
165
166 --
167 wf_engine.SetItemAttrText ( itemtype => itemType,
168 itemkey => itemkey,
169 aname => 'USER_NAME' ,
170 avalue => x_username);
171
172 --
173 wf_engine.SetItemAttrText ( itemtype => itemType,
174 itemkey => itemkey,
175 aname => 'USER_DISPLAY_NAME' ,
176 avalue => x_user_display_name);
177
178 --
179 wf_engine.SetItemAttrText ( itemtype => itemtype,
180 itemkey => itemkey,
181 aname => 'RECEIPT_NUM',
182 avalue => ReceiptNum);
183
184 --
185 wf_engine.SetItemAttrText ( itemtype => itemtype,
186 itemkey => itemkey,
187 aname => 'QUANTITY',
188 avalue => Quantity);
189
190 --
191 wf_engine.SetItemAttrText ( itemtype => itemtype,
192 itemkey => itemkey,
193 aname => 'PO_NUMBER',
194 avalue => PONumber);
195 --
196
197 wf_engine.SetItemAttrText(itemtype => itemtype,
198 itemkey => itemkey,
199 aname => 'RCV_DM_NOTIF_MSG',
200 avalue => l_message);
201
202 --
203 wf_engine.SetItemAttrText(itemtype => itemtype,
204 itemkey => itemkey,
205 aname => 'RCV_DM_MSG1',
206 avalue => l_message1);
207 --
208 wf_engine.SetItemAttrText(itemtype => itemtype,
209 itemkey => itemkey,
210 aname => 'RCV_DM_MSG2',
211 avalue => l_message2);
212
213 --
214 wf_engine.SetItemAttrText(itemtype => itemtype,
215 itemkey => itemkey,
216 aname => 'RCV_DM_MSG3',
217 avalue => l_message3);
218
219 --
220 wf_engine.SetItemAttrText(itemtype => itemtype,
221 itemkey => itemkey,
222 aname => 'RCV_DM_MSG4',
223 avalue => l_message4);
224 --
225
226 wf_engine.StartProcess(itemtype => itemtype,
227 itemkey => itemkey );
228
229 END IF;
230
231 EXCEPTION
232 WHEN OTHERS THEN
233
234 x_progress := 'RCV_DEBIT_MEMO_NOTIF.Start_WF_Process: In Exception handler';
235 IF (g_po_wf_debug = 'Y') THEN
236 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
237 END IF;
238
239 po_message_s.sql_error('In Exception of Start_WF_Process()', x_progress, sqlcode);
240
241 RAISE;
242
243 END Start_WF_Process;
244
245 END RCV_DEBIT_MEMO_NOTIF;