[Home] [Help]
PACKAGE BODY: APPS.IEX_WRITEOFFOBJ_PUB
Source
1 PACKAGE BODY IEX_WRITEOFFOBJ_PUB as
2 /* $Header: iexpwrob.pls 120.10.12010000.2 2009/02/18 14:52:59 ehuh ship $ */
3 -- Start of Comments
4 -- Package name :IEX_WRITEOFFOBJ_PUB
5 -- Purpose : 1) Procedure to populate OKL_TRX_ADJST_B and OKL_TXL_ADJSTS_LNS_B
6 -- : 2) Procedure to call OKL_WRAPPER OKL_CREATE_ADJ_PVT
7 -- : to create an adjustment
8 -- : 3) Procedure to check approval before creating a writeoff.
9 -- : 4) Procedure to update iex_writeoff_objects after creating
10
11 G_FILE_NAME VARCHAR2(12) ;
12 PG_DEBUG NUMBER ;
13 wf_yes varchar2(1) ;
14 wf_no varchar2(1) ;
15
16 PROCEDURE AddfailMsg ( p_object IN VARCHAR2, p_operation IN VARCHAR2 ) IS
17
18 BEGIN
19 fnd_message.set_name('IEX', 'IEX_FAILED_OPERATION');
20 fnd_message.set_token('OBJECT', p_object);
21 fnd_message.set_token('UPDATE', p_operation);
22 fnd_msg_pub.add;
23
24 END AddfailMsg;
25
26 PROCEDURE Get_Messages ( p_message_count IN NUMBER, x_message OUT nocopy VARCHAR2) IS
27
28 l_msg_list VARCHAR2(32627) := '';
29 l_temp_msg VARCHAR2(32627);
30 l_appl_short_name VARCHAR2(50) ;
31 l_message_name VARCHAR2(50) ;
32 l_id NUMBER;
33 l_message_num NUMBER;
34 l_msg_count NUMBER;
35 l_msg_data VARCHAR2(32627);
36 l_new_line VARCHAR2(10) := FND_GLOBAL.NEWLINE;
37
38 Cursor Get_Appl_Id (x_short_name VARCHAR2) IS
39 SELECT application_id
40 FROM fnd_application_vl
41 WHERE application_short_name = x_short_name;
42
43 Cursor Get_Message_Num (x_msg VARCHAR2, x_id NUMBER, x_lang_id NUMBER) IS
44 SELECT msg.message_number
45 FROM fnd_new_messages msg, fnd_languages_vl lng
46 WHERE msg.message_name = x_msg
47 and msg.application_id = x_id
48 and lng.LANGUAGE_CODE = msg.language_code
49 and lng.language_id = x_lang_id;
50
51 BEGIN
52 iex_debug_pub.logmessage ( 'in get message routine');
53 FOR l_count in 1..p_message_count LOOP
54
55 l_temp_msg := fnd_msg_pub.get(fnd_msg_pub.g_next, fnd_api.g_true);
56 fnd_message.parse_encoded(l_temp_msg, l_appl_short_name, l_message_name);
57 OPEN Get_Appl_Id (l_appl_short_name);
58 FETCH Get_Appl_Id into l_id;
59 CLOSE Get_Appl_Id;
60
61 l_message_num := NULL;
62
63 IF l_id is not NULL THEN
64 OPEN Get_Message_Num (l_message_name, l_id, to_number(NVL(FND_PROFILE.Value('LANGUAGE'), '0')));
65 FETCH Get_Message_Num into l_message_num;
66 CLOSE Get_Message_Num;
67 END IF;
68
69 l_temp_msg := fnd_msg_pub.get(fnd_msg_pub.g_previous, fnd_api.g_true);
70
71 IF NVL(l_message_num, 0) <> 0 then
72 l_temp_msg := 'APP-' || to_char(l_message_num) || ': ';
73 ELSE
74 l_temp_msg := NULL;
75 END IF;
76
77 IF l_count = 1 then
78 l_msg_list := l_msg_list || l_temp_msg || fnd_msg_pub.get(fnd_msg_pub.g_first, fnd_api.g_false);
79 ELSE
80 l_msg_list := l_msg_list || l_temp_msg || fnd_msg_pub.get(fnd_msg_pub.g_next, fnd_api.g_false);
81 END IF;
82
83 l_msg_list := l_msg_list || '';
84 iex_debug_pub.logmessage ( 'l_msg_lis'||l_msg_list);
85 END LOOP;
86
87 x_message := l_msg_list;
88 iex_debug_pub.logmessage ( ' x_message ' ||x_message);
89 EXCEPTION
90 WHEN OTHERS THEN
91 x_message:=l_msg_list;
92 END Get_Messages;
93
94
95 PROCEDURE Get_Messages1 ( p_message_count IN NUMBER, x_message OUT nocopy VARCHAR2) IS
96
97 l_msg_list VARCHAR2(32627) := '';
98 l_temp_msg VARCHAR2(32627);
99 l_appl_short_name VARCHAR2(50) ;
100 l_message_name VARCHAR2(50) ;
101 l_id NUMBER;
102 l_message_num NUMBER;
103 l_msg_count NUMBER;
104 l_msg_data VARCHAR2(32627);
105 l_new_line VARCHAR2(10) := FND_GLOBAL.NEWLINE;
106
107 BEGIN
108 iex_debug_pub.logmessage ( 'in get message routine');
109 FOR i IN 1..p_message_count
110 LOOP
111 fnd_msg_pub.get(p_data => l_msg_data,
112 p_msg_index_out => l_msg_count,
113 p_encoded => fnd_api.g_false,
114 p_msg_index => fnd_msg_pub.g_next);
115 IF i = 1 THEN
116 l_msg_list := l_msg_data;
117 ELSE
118 l_msg_list := l_msg_list || l_new_line || l_msg_data;
119 END IF;
120 END LOOP;
121 x_message:=l_msg_list;
122 iex_debug_pub.logmessage ( ' x_message ' ||x_message);
123 EXCEPTION
124 WHEN OTHERS THEN
125 x_message:=l_msg_list;
126 END Get_Messages1;
127
128 PROCEDURE invoke_writeoff_wf(
129 p_WRITEOFF_ID IN NUMBER
130 ,p_writeoff_type IN VARCHAR2
131 ,p_request_id IN NUMBER
132 ,p_object_id IN VARCHAR2
133 ,x_return_status OUT NOCOPY VARCHAR2
134 ,x_msg_count OUT NOCOPY NUMBER
135 ,x_msg_data OUT NOCOPY VARCHAR2 ) IS
136
137 l_parameter_list wf_parameter_list_t;
138 l_key VARCHAR2(240);
139 l_seq NUMBER;
140 l_event_name varchar2(240) ;
141 l_init_msg_list VARCHAR2(1);
142 l_return_status VARCHAR2(1);
143 l_msg_count NUMBER ;
144 l_msg_data VARCHAR2(32627);
145 l_message VARCHAR2(32627);
146 l_api_name VARCHAR2(50) ;
147 l_api_name_full VARCHAR2(150);
148 l_notification_agent varchar2(100);
149 l_case_owner varchar2(100);
150 l_case_number varchar2(240);
151
152 TYPE c_getinvoiceCurTyp IS REF CURSOR;
153 c_getinvoices c_getinvoiceCurTyp;
154
155 l_object_id VARCHAR2(32627) ;
156 l_currency_code VARCHAR2(10);
157 l_amount NUMBER;
158
159 cursor c_get_agent is
160 SELECT name from wf_roles
161 where orig_system = 'FND_RESP'
162 and orig_system_id = '23366';
163
164 cursor c_get_ar_invoices(p_object_id IN VARCHAR2) is
165 select to_char(payment_schedule_id), invoice_currency_code, amount_due_remaining
166 from ar_payment_schedules
167 where customer_trx_id = p_object_id;
168 --where payment_schedule_id =p_object_id;
169
170 cursor c_get_cont_invoices(p_object_id IN VARCHAR2,p_request_id IN NUMBER) is
171 select chr.contract_number, sum(iwob.adjustment_amount), chr.currency_code
172 from iex_writeoff_objects iwob, okc_k_headers_b chr
173 where chr.id = p_object_id
174 and iwob.contract_id = chr.id
175 and iwob.request_id = p_request_id
176 group by chr.contract_number,chr.currency_code ;
177
178 BEGIN
179
180 SAVEPOINT invoke_writeoff_wf;
181 l_event_name := 'oracle.apps.iex.wrf.approvewriteoff';
182 l_api_name := 'invoke_writeoff_wf';
183 l_api_name_full := g_pkg_name || '.'||l_api_name;
184 x_return_status := FND_API.G_RET_STS_SUCCESS;
185
186 AddfailMsg(p_object => 'BEFORE CALLING WORKFLOW ', p_operation => 'CREATE');
187
188 l_key := l_event_name ||'-'||p_request_id;
189
190 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
191 iex_debug_pub.logmessage ('Event Key ' ||l_key ||'writeoff_type' ||p_writeoff_type||
192 'object_id'||p_object_id|| 'request_id'||p_request_id);
193 END IF;
194
195 l_amount :=0;
196
197 if p_writeoff_type ='AR_INVOICE' THEN
198 OPEN c_get_ar_invoices(p_object_id);
199 FETCH c_get_ar_invoices INTO l_object_id, l_currency_code, l_amount;
200 CLOSE c_get_ar_invoices ;
201 else
202 OPEN c_get_cont_invoices(p_object_id,p_request_id);
203 FETCH c_get_cont_invoices INTO l_object_id, l_amount, l_currency_code;
204 CLOSE c_get_cont_invoices;
205
206 if (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
207 iex_debug_pub.logmessage ('in contracts' ||'writeoff_type' ||p_writeoff_type||
208 'object_id'||p_object_id|| 'request_id'||p_request_id);
209 end if;
210 end if;
211
212 OPEN c_get_agent ;
213 FETCH c_get_agent INTO l_notification_agent;
214 CLOSE c_get_Agent;
215
216 IF l_notification_agent IS NULL THEN l_notification_agent := 'SYSADMIN';
217 END IF;
218
219 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
220 iex_debug_pub.logmessage ('l_case_number ' ||l_case_number || 'l_case_owner' || l_case_owner
221 ||'<-----L_AMOUNT----->' ||l_amount);
222 END IF;
223
224 wf_event.AddParameterToList('AMOUNT', to_char(l_amount), l_parameter_list);
225 --wf_event.AddParameterToList('CASE_OWNER', l_case_owner, l_parameter_list);
226 --wf_event.AddParameterToList('CASE_NUMBER', l_case_number, l_parameter_list);
227 wf_event.AddParameterToList('NOTIFY_AGENT', l_notification_agent, l_parameter_list);
228 wf_event.AddParameterToList('REQUEST_ID', p_request_ID, l_parameter_list);
229 wf_event.AddParameterToList('WRITEOFF_ID', p_writeoff_ID, l_parameter_list);
230 wf_event.AddParameterToList('OBJECT_ID', l_object_ID, l_parameter_list);
231 wf_event.AddParameterToList('WRITEOFF_TYPE', p_writeoff_type, l_parameter_list);
232 wf_event.AddParameterToList('CURRENCY_CODE', l_currency_code, l_parameter_list);
233
234 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
235 iex_debug_pub.logmessage ('before launching workflow');
236 END IF;
237
238 wf_event.raise(p_event_name => l_event_name
239 ,p_event_key => l_key
240 ,p_parameters => l_parameter_list);
241 COMMIT ;
242 l_parameter_list.DELETE;
243
244 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
245 iex_debug_pub.logmessage ('Successfully launched writeoff workflow');
246 END IF;
247
248 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count, p_data => x_msg_data);
249 EXCEPTION
250 WHEN OTHERS THEN
251 ROLLBACK TO invoke_writeoff_wf;
252 x_return_status := Fnd_Api.G_RET_STS_UNEXP_ERROR;
253 x_msg_count := l_msg_count ;
254 x_msg_data := l_msg_data ;
255 Fnd_Msg_Pub.ADD_EXC_MSG('IEX_WRITEOFFOBJ_PUB','invoke_writeoff_wf');
256 Fnd_Msg_Pub.count_and_get( p_count => x_msg_count
257 ,p_data => x_msg_data);
258 End invoke_writeoff_wf;
259
260
261 PROCEDURE invoke_asset_mgr_wf(
262 p_object_id IN varchar2
263 ,p_request_id IN varchar2
264 ,x_return_status OUT NOCOPY VARCHAR2
265 ,x_msg_count OUT NOCOPY NUMBER
266 ,x_msg_data OUT NOCOPY VARCHAR2 ) IS
267
268 l_parameter_list wf_parameter_list_t;
269 l_key VARCHAR2(240);
270 l_seq NUMBER;
271 l_event_name varchar2(240) ;
272 l_init_msg_list VARCHAR2(1);
273 l_return_status VARCHAR2(1);
274 l_msg_count NUMBER ;
275 l_msg_data VARCHAR2(32627);
276 l_message VARCHAR2(32627);
277 l_api_name VARCHAR2(50) ;
278 l_api_name_full VARCHAR2(150);
279 l_notification_agent varchar2(100);
280 l_case_owner varchar2(100);
281 l_contract_number varchar2(120);
282
283 cursor c_get_agent is
284 SELECT name from wf_roles
285 where orig_system = 'FND_RESP'
286 and orig_system_id = '23449';
287
288 cursor c_get_case_owner(p_object_id IN VARCHAR2) IS
289 select rs.source_name, chr.contract_number
290 from iex_cases_all_b icas,
291 jtf_rs_resource_extns rs,
292 iex_case_objects ico,
293 okc_k_headers_b chr
294 where ico.cas_id = icas.cas_id
295 and icas.owner_resource_id = rs.resource_id(+)
296 and chr.id = ico.object_id
297 and chr.id = to_number(p_object_id);
298
299 BEGIN
300 SAVEPOINT invoke_asset_mgr_wf;
301 l_event_name := 'oracle.apps.iex.wrf.terminatenotification';
302 l_api_name := 'invoke_asset_mgr_wf';
303 l_api_name_full := g_pkg_name || '.'||l_api_name;
304 x_return_status := FND_API.G_RET_STS_SUCCESS;
305
306 AddfailMsg(p_object => 'BEFORE CALLING WORKFLOW ', p_operation => 'CREATE');
307
308 l_key := l_event_name ||'-'||p_request_id;
309
310 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
311 iex_debug_pub.logmessage ('Event Key ' ||l_key);
312 END IF;
313
314 OPEN c_get_case_owner(p_object_id);
315 FETCH c_get_case_owner INTO l_case_owner, l_contract_number;
316 CLOSE c_get_case_owner;
317
318 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
319 iex_debug_pub.logmessage ('l_contract_number ' ||l_contract_number
320 || 'l_case_owner' || l_case_owner);
321 END IF;
322
323 OPEN c_get_agent ;
324 FETCH c_get_agent INTO l_notification_agent;
325 CLOSE c_get_Agent;
326
327 IF l_notification_agent IS NULL THEN
328 l_notification_agent := 'SYSADMIN';
329 END IF;
330
331 wf_event.AddParameterToList('NOTIFY_AGENT', l_notification_agent, l_parameter_list);
332 wf_event.AddParameterToList('CASE_OWNER', l_case_owner, l_parameter_list);
333 wf_event.AddParameterToList('CONTRACT_NUMBER', l_contract_number, l_parameter_list);
334
335 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
336 iex_debug_pub.logmessage ('before launching workflow');
337 END IF;
338
339 wf_event.raise(p_event_name => l_event_name
340 ,p_event_key => l_key
341 ,p_parameters => l_parameter_list);
342
343 COMMIT ;
344 l_parameter_list.DELETE;
345
346 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
347 iex_debug_pub.logmessage ('Successfully launched asset mgr workflow');
348 END IF;
349
350 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count, p_data => x_msg_data);
351 EXCEPTION
352 WHEN OTHERS THEN
353 ROLLBACK TO invoke_asset_mgr_wf;
354 x_return_status := Fnd_Api.G_RET_STS_UNEXP_ERROR;
355 x_msg_count := l_msg_count ;
356 x_msg_data := l_msg_data ;
357 Fnd_Msg_Pub.ADD_EXC_MSG('IEX_WRITEOFFOBJ_PUB','invoke_asset_mgr_wf');
358 Fnd_Msg_Pub.count_and_get(p_count => x_msg_count
359 ,p_data => x_msg_data);
360 End invoke_asset_mgr_wf;
361
362
363 PROCEDURE create_writeoffs(
364 P_Api_Version_Number IN NUMBER
365 ,p_init_msg_list IN VARCHAR2
366 ,p_commit IN VARCHAR2
367 ,p_writeoff_object_rec IN writeoff_obj_rec_type := g_miss_writeoff_obj_rec_type
368 ,p_writeoff_type IN VARCHAR2
369 ,p_object_id IN VARCHAR2
370 ,p_invoice_line_id IN NUMBER
371 ,x_return_status OUT NOCOPY VARCHAR2
372 ,x_msg_count OUT NOCOPY NUMBER
373 ,x_msg_data OUT NOCOPY VARCHAR2
374 ,x_adjustment_id OUT NOCOPY NUMBER) IS
375
376 l_api_name CONSTANT VARCHAR2(50) := 'CREATE_WRITEOFFS';
377 l_api_name_full CONSTANT VARCHAR2(150):= g_pkg_name || '.' || l_api_name;
378 l_api_version_number CONSTANT NUMBER := 2.0;
379 l_writeoff_object_id IEX_writeoff_objects.writeoff_object_id%TYPE;
380 x_adj_id IEX_writeoff_objects.receviables_adjustment_id%TYPE;
381 l_return_status VARCHAR2(1);
382 l_msg_count NUMBER ;
383 l_msg_data VARCHAR2(32627);
384 l_message VARCHAR2(32627);
385
386 l_object_version_number IEX_writeoff_objects.writeoff_object_id%TYPE;
387 l_adjv_rec adjv_rec_type;
388 x_adjv_rec adjv_rec_type;
389 l_ajlv_rec ajlv_rec_type;
390 x_ajlv_rec ajlv_rec_type;
391 l_writeoff_obj_rec writeoff_obj_rec_type ;
392 l_writeoff_rec writeoff_rec_type ;
393 l_code_combination_id ar_adjustments.code_combination_ID%TYPE;
394 l_contract_number okc_k_headers_b.contract_number%TYPE;
395 l_product okl_products_v.name%TYPE;
396 l_stream okl_strm_type_b.code%TYPE;
397
398 cursor c_get_obj_ver(p_WRITEOFF_ID IN NUMBER) is
399 select object_version_number
400 from iex_writeoffs
401 where WRITEOFF_ID =p_WRITEOFF_ID;
402
403 BEGIN
404
405 l_writeoff_obj_rec := p_writeoff_object_rec;
406 SAVEPOINT CREATE_WRITEOFFS;
407
408 IF NOT FND_API.Compatible_API_Call ( l_api_version_number, p_api_version_number, l_api_name, G_PKG_NAME) then
409 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
410 END IF;
411
412 FND_MSG_PUB.initialize;
413 x_return_status := FND_API.G_RET_STS_SUCCESS;
414
415 l_writeoff_obj_rec.writeoff_status := 'W';
416 l_writeoff_obj_rec.writeoff_type := p_writeoff_type;
417 l_writeoff_obj_rec.writeoff_type_id := p_object_id;
418
419 IEX_WRITEOFF_OBJECTS_PUB.create_writeoff_objects(
420 P_Api_Version_Number =>p_Api_Version_Number
421 ,P_Init_Msg_List =>P_Init_Msg_List
422 ,P_Commit =>p_commit
423 ,P_writeoff_obj_rec =>l_writeoff_obj_rec
424 ,X_writeoff_object_id =>l_writeoff_object_id
425 ,x_return_status =>l_return_status
426 ,x_msg_count =>l_msg_count
427 ,x_msg_data =>l_msg_data);
428
429 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
430 iex_debug_pub.logmessage ('writeoff creation object ID '||
431 l_writeoff_object_id || 'status ' ||l_return_status);
432 END IF;
433
434 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
435 IEX_WRITEOFFOBJ_PUB.Get_Messages1 (l_msg_count,l_message);
436 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
437 iex_debug_pub.logmessage('Error' ||l_message);
438 END IF;
439 raise FND_API.G_EXC_ERROR;
440
441 ELSE
442 FND_MSG_PUB.initialize;
443 END IF;
444
445 AddfailMsg( p_object => 'Writeoffs ', p_operation => 'UPDATE' );
446
447 OPEN c_get_obj_ver(l_writeoff_obj_rec.writeoff_id);
448 FETCH c_get_obj_ver INTO l_writeoff_rec.object_version_number;
449 CLOSE c_get_obj_ver;
450
451 l_writeoff_rec.disposition_code := 'W';
452 --l_writeoff_rec.disposition_date := SYSDATE;
453 l_writeoff_rec.writeoff_id:=l_writeoff_obj_rec.writeoff_id;
454
455 IEX_WRITEOFFS_PVT.Update_writeoffs(
456 P_Api_Version_Number =>l_api_version_number
457 ,P_Init_Msg_List =>'F'
458 ,P_Commit =>'T'
459 ,P_writeoffs_Rec =>l_writeoff_rec
460 ,x_return_status => l_return_status
461 ,x_msg_count => l_msg_count
462 ,x_msg_data => l_msg_data
463 ,xo_object_version_number =>l_object_version_number
464 );
465
466 IF x_return_status <> FND_API.G_RET_STS_SUCCESS then
467 IEX_WRITEOFFOBJ_PUB.Get_Messages1 (l_msg_count,l_message);
468 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
469 iex_debug_pub.logmessage('Error' ||l_message);
470 END IF;
471 raise FND_API.G_EXC_ERROR;
472 ELSE
473 FND_MSG_PUB.initialize;
474 if (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
475 iex_debug_pub.logmessage ('obj of iex_writeoff' ||l_object_version_number
476 ||'l_writeoff_rec.writeoff_id' || l_writeoff_obj_rec.writeoff_id);
477 end if;
478 END IF;
479
480 IF FND_API.to_Boolean( p_commit ) THEN
481 COMMIT WORK;
482 END IF;
483
484 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count, p_data => x_msg_data);
485
486 EXCEPTION
487 WHEN FND_API.G_EXC_ERROR THEN
488 ROLLBACK TO CREATE_WRITEOFFS;
489 x_return_status := FND_API.G_RET_STS_ERROR ;
490 x_msg_count := l_msg_count ;
491 x_msg_data := l_msg_data ;
492 FND_MSG_PUB.Count_And_Get( p_count => x_msg_count,
493 p_data => x_msg_data);
494 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
495 ROLLBACK TO CREATE_WRITEOFFS;
496 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
497 x_msg_count := l_msg_count ;
498 x_msg_data := l_msg_data ;
499 FND_MSG_PUB.Count_And_Get( p_count => x_msg_count,
500 p_data => x_msg_data);
501 WHEN OTHERS THEN
502 ROLLBACK TO CREATE_WRITEOFFS;
503 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
504 x_msg_count := l_msg_count ;
505 x_msg_data := l_msg_data ;
506 FND_MSG_PUB.ADD_EXC_MSG(G_PKG_NAME,l_api_name);
507 FND_MSG_PUB.Count_And_Get( p_count => x_msg_count,
508 p_data => x_msg_data);
509
510 END create_writeoffs;
511
512 /** Intialize record defintion to avoid direct server side access of variables
513 */
514 FUNCTION INIT_WRITEOFFOBJ_REC
515 RETURN IEX_WRITEOFFOBJ_PUB.writeoff_obj_rec_type
516 IS
517 l_return_rec IEX_WRITEOFFOBJ_PUB.writeoff_obj_rec_type ;
518 BEGIN
519 RETURN l_return_rec;
520 END INIT_WRITEOFFOBJ_REC;
521
522
523 /**
524 called from the workflow to approve writeoffs
525 **/
526 PROCEDURE approve_writeoffs (itemtype in varchar2,
527 itemkey in varchar2,
528 actid in number,
529 funcmode in varchar2,
530 result out nocopy varchar2) IS
531
532 l_api_version NUMBER := 1;
533 l_init_msg_list VARCHAR2(1);
534 l_return_status VARCHAR2(1);
535 l_msg_count NUMBER ;
536 l_msg_data VARCHAR2(32627);
537 l_message VARCHAR2(32627);
538
539 l_WRITEOFF_ID VARCHAR2(32627);
540 l_REQUEST_ID VARCHAR2(32627);
541 l_OBJECT_ID VARCHAR2(32627);
542 l_OBJECT_TYPE VARCHAR2(100);
543
544 cursor c_get_obj_ver(p_WRITEOFF_ID IN NUMBER) is
545 select object_version_number,writeoff_reason
546 from iex_writeoffs
547 where WRITEOFF_ID =p_WRITEOFF_ID;
548
549
550 --bug 8258156 add ar_payment_schedules_all to get org id
551 cursor c_get_writeoff_objects(p_WRITEOFF_ID IN NUMBER, p_request_id IN NUMBER) is
552 select writeoff_object_id, object_version_number, transaction_id,
553 adjustment_amount, contract_id, org_id
554 from iex_writeoff_objects io,ar_payment_schedules_all ap
555 where WRITEOFF_ID = p_WRITEOFF_ID
556 and writeoff_status ='W'
557 and transaction_id = payment_schedule_id(+)
558 and io.request_id = p_request_id;
559
560 l_api_name CONSTANT VARCHAR2(50) := 'APPROVE_WRITEOFFS';
561 l_api_name_full CONSTANT VARCHAR2(150):= g_pkg_name || '.' || l_api_name;
562 l_api_version_number CONSTANT NUMBER := 2.0;
563 l_writeoff_object_id IEX_writeoff_objects.writeoff_object_id%TYPE;
564 x_adj_id IEX_writeoff_objects.receviables_adjustment_id%TYPE;
565 l_object_version_number IEX_writeoff_objects.object_version_number%TYPE;
566
567 l_adjv_rec adjv_rec_type;
568 x_adjv_rec adjv_rec_type;
569 l_ajlv_rec ajlv_rec_type;
570 x_ajlv_rec ajlv_rec_type;
571 l_writeoff_obj_rec writeoff_obj_rec_type ;
572 l_writeoff_rec writeoff_rec_type ;
573 l_adj_reason_code iex_writeoffs.writeoff_reason%TYPE;
574 l_ctr NUMBER;
575
576 l_code_combination_id ar_adjustments.code_combination_ID%TYPE;
577 l_contract_number okc_k_headers_b.contract_number%TYPE;
578
579 BEGIN
580
581 if funcmode <> 'RUN' then
582 result := wf_engine.eng_null;
583 return;
584 end if;
585
586 l_WRITEOFF_ID:= wf_engine.GetItemAttrText(itemtype => itemtype,
587 itemkey => itemkey,
588 aname => 'WRITEOFF_ID');
589 l_REQUEST_ID:= wf_engine.GetItemAttrText(itemtype => itemtype,
590 itemkey => itemkey,
591 aname => 'REQUEST_ID');
592 l_object_id := wf_engine.GetItemAttrText(itemtype => itemtype,
593 itemkey => itemkey,
594 aname => 'OBJECT_ID');
595 l_object_type := wf_engine.GetItemAttrText(itemtype => itemtype,
596 itemkey => itemkey,
597 aname => 'WRITEOFF_TYPE');
598 /** 1) insert into okl_trx_ar_adjst_b and tl
599 ** 2) insert into okl_txl_adjst_lns_b and tl
600 ** 3) call okl_adjst_create_pvt to create adjsutment
601 ** 4) update iex_writeoff_objects with the adjustment ID
602 ** 5) update iex_writeoffs disposition code to APPROVED
603 ** 6) if writeoff type is CONTRACT then send asset mgr a termination notification */
604
605 OPEN c_get_obj_ver(l_WRITEOFF_ID);
606 FETCH c_get_obj_ver INTO l_writeoff_rec.object_version_number, l_adj_reason_code;
607 CLOSE c_get_obj_ver;
608
609 -- do not process if objects are part of a different
610 --transaction . this will not happen since the views already remove
611 --the transaction if it is part of any other request
612 l_ctr :=0;
613
614 For i in c_get_writeoff_objects (l_writeoff_id,L_REQUEST_ID) LOOP
615
616 l_ctr := 1;
617 l_writeoff_obj_rec.WRITEOFF_OBJECT_ID :=i.writeoff_object_id;
618 l_writeoff_obj_rec.OBJECT_VERSION_NUMBER :=i.object_version_number;
619
620 --START jsanju bug 4637174 replace 3 calls with one call
621 /*
622 --populate the record type to be passed(l_adjv_rec)
623 --l_adjv_rec.adjustment_reason_code:= l_adj_reason_code;
624 l_adjv_rec.adjustment_reason_code:= 'WRITE OFF';
625 l_adjv_rec.apply_date :=sysdate;
626 l_adjv_rec.gl_date := sysdate;
627 l_adjv_rec.trx_status_code :='WORKING';
628
629 -- call okl_trx_ar_adjsts_pub.insert_trx_ar_adjsts
630 --set error message,so this will be prefixed before the
631 --actual message, so it makes more sense than displaying an
632 -- OKL message.
633
634 AddfailMsg(
635 p_object => 'RECORD IN OKL_TRX_AR_ADJST_B ',
636 p_operation => 'CREATE' );
637
638 okl_trx_ar_adjsts_pub.insert_trx_ar_adjsts(
639 p_api_version =>1.0
640 ,p_init_msg_list =>'F'
641 ,x_return_status =>l_return_status
642 ,x_msg_count =>l_msg_count
643 ,x_msg_data =>l_msg_data
644 ,p_adjv_rec =>l_adjv_rec
645 ,x_adjv_rec =>x_adjv_rec);
646
647 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
648 iex_debug_pub.logmessage ('okl_trx_ar_adjsts status ' ||l_return_status);
649 iex_debug_pub.logmessage ('okl_trx_ar_adjsts adj_id ' || x_adjv_rec.id);
650 END IF;
651
652 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
653 IEX_WRITEOFFOBJ_PUB.Get_Messages1 (l_msg_count,l_message);
654 -- IF PG_DEBUG <11 THEN
655 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
656 iex_debug_pub.logmessage('Error' ||l_message);
657 END IF;
658 wf_engine.SetItemAttrText(itemtype => itemtype,
659 itemkey => itemkey,
660 aname => 'ERROR_MESSAGE',
661 avalue => l_message);
662 --raise FND_API.G_EXC_ERROR;
663 result := wf_engine.eng_completed ||':'||wf_no;
664 return;
665
666 ELSE
667 FND_MSG_PUB.initialize;
668 END IF;
669
670 --else insert of okl_trx_ar_adjsts_b is successful we can go to
671 --the third step of populating the okl_txl_adjsts_lns_b tables
672
673 --populate the record type to be passed(l_ajlv_rec)
674
675 -- call okl_txl_adjsts_lns_pub.insert_txl_adjsts_lns
676
677 l_ajlv_rec.adj_id :=x_adjv_rec.id;
678 l_ajlv_rec.psl_id :=i.transaction_id;
679 l_ajlv_rec.amount :=i.adjustment_amount;
680
681 --not sure what to pass????
682 -- l_ajlv_rec.CODE_COMBINATION_ID := 17001;
683
684 --08/13/03
685 --check for code combination before creating
686 --writeoff objects
687 OPEN c_get_code_comb(i.transaction_id);
688 FETCH c_get_code_comb INTO l_CODE_COMBINATION_ID;
689 CLOSE c_get_code_comb;
690
691 IF l_CODE_COMBINATION_ID IS NULL THEN
692 -- IF PG_DEBUG < 11 THEN
693 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
694 iex_debug_pub.logmessage ('Error in retreiving Code combination ');
695 END IF;
696
697 select contract_number into l_contract_number
698 from okc_k_headers_b
699 where id=i.contract_id;
700
701 fnd_message.set_name('IEX', 'IEX_WRITEOFFOBJ_CODE_COMB');
702 fnd_message.set_token('CONTRACT_NUMBER', l_contract_number);
703 fnd_msg_pub.add;
704 IEX_WRITEOFFOBJ_PUB.Get_Messages1 (l_msg_count,l_message);
705 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
706 iex_debug_pub.logmessage('Error' ||l_message);
707 END IF;
708 wf_engine.SetItemAttrText(itemtype => itemtype,
709 itemkey => itemkey,
710 aname => 'ERROR_MESSAGE',
711 avalue => l_message);
712 result := wf_engine.eng_completed ||':'||wf_no;
713 return;
714
715 END IF;
716
717 l_ajlv_rec.CODE_COMBINATION_ID := l_CODE_COMBINATION_ID;
718 l_code_combination_id := null;
719
720 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
721 iex_debug_pub.logmessage ('Code combination' ||l_ajlv_rec.CODE_COMBINATION_ID );
722 END IF;
723
724 --set error message,so this will be prefixed before the
725 --actual message, so it makes more sense than displaying an
726 -- OKL message.
727 AddfailMsg( p_object => 'RECORD IN OKL_TXL_ADJSTS_LNS_B ',
728 p_operation => 'CREATE' );
729
730 okl_txl_adjsts_lns_pub.insert_txl_adjsts_lns(
731 p_api_version =>1.0
732 ,p_init_msg_list =>'F'
733 ,x_return_status =>l_return_status
734 ,x_msg_count =>l_msg_count
735 ,x_msg_data =>l_msg_data
736 ,p_ajlv_rec =>l_ajlv_rec
737 ,x_ajlv_rec =>x_ajlv_rec);
738
739
740 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
741 IEX_WRITEOFFOBJ_PUB.Get_Messages1 (l_msg_count,l_message);
742 -- IF PG_DEBUG <11 THEN
743 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
744 iex_debug_pub.logmessage('Error' ||l_message);
745 END IF;
746 wf_engine.SetItemAttrText(itemtype => itemtype,
747 itemkey => itemkey,
748 aname => 'ERROR_MESSAGE',
749 avalue => l_message);
750 --raise FND_API.G_EXC_ERROR;
751 result := wf_engine.eng_completed ||':'||wf_no;
752 return;
753 ELSE
754 -- IF PG_DEBUG <11 THEN
755 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
756 iex_debug_pub.logmessage ('okl_txl_adjsts_lns status '
757 ||l_return_status || ' Id ' ||
758 x_ajlv_rec.id);
759 END IF;
760 FND_MSG_PUB.initialize;
761 END IF;
762
763 --else insert of okl_txl_adjsts_lns_b is successful we can go to
764 --the fourth step of calling okl_create_adjst_pvt
765 */
766 --END jsanju for bug 4637174 replace 3 calls with one call.
767
768 --set error message,so this will be prefixed before the
769 --actual message, so it makes more sense than displaying an
770 -- OKL message.
771
772 AddfailMsg( p_object => 'Adjustments ', p_operation => 'CREATE' );
773
774 -- IF PG_DEBUG <11 THEN
775 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
776 iex_debug_pub.logmessage ('Before calling Okl Api' ||'transaction id ' || i.transaction_id);
777 END IF;
778
779 -- Begin bug 8258156
780 -- mo_global.set_policy_context('S',7746);
781 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
782 iex_debug_pub.logmessage ('Before calling Okl Api Org ID = ' || i.org_id);
783 END IF;
784
785 mo_global.set_policy_context('S',i.org_id);
786 -- End bug 8258156
787
788 okl_create_adjst_pub.iex_create_adjustments_pub (
789 p_api_version => 1
790 ,p_init_msg_list => 'F'
791 ,p_commit_flag => 'F'
792 ,p_psl_id => i.transaction_id
793 ,p_chk_approval_limits => 'F'
794 ,x_new_adj_id => x_adj_id
795 ,x_return_status => l_return_status
796 ,x_msg_count => l_msg_count
797 ,x_msg_data => l_msg_data);
798
799 -- IF PG_DEBUG <11 THEN
800 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
801 iex_debug_pub.logmessage ('After calling Okl Api and status'||l_return_status);
802 END IF;
803
804 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
805 IEX_WRITEOFFOBJ_PUB.Get_Messages1 (l_msg_count,l_message);
806 -- IF PG_DEBUG <11 THEN
807 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
808 iex_debug_pub.logmessage('Error' ||l_message);
809 END IF;
810 wf_engine.SetItemAttrText(itemtype => itemtype,
811 itemkey => itemkey,
812 aname => 'ERROR_MESSAGE',
813 avalue => l_message);
814 --raise FND_API.G_EXC_ERROR;
815 result := wf_engine.eng_completed ||':'||wf_no;
816 return;
817 ELSE
818 FND_MSG_PUB.initialize;
819 if (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
820 IEx_debug_pub.logmessage ('After caling OKL Adj API and adj_id ' || x_adj_id);
821 end if;
822 END IF;
823
824 --else adjustment created and update iex_writeoff_objects
825 --with the adjustment ID
826 --populate the writeoff_obect rec
827
828 if x_adj_id IS NOT NULL then
829 l_writeoff_obj_rec.RECEVIABLES_ADJUSTMENT_ID :=x_adj_id;
830 l_writeoff_obj_rec.writeoff_status :='A';
831 else
832 -- IF PG_DEBUG < 11 THEN
833 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
834 iex_debug_pub.logmessage('Adjust ment ID is null ');
835 END IF;
836
837 AddfailMsg(p_object => 'Adjustments ',
838 p_operation => 'CREATE' );
839 --raise FND_API.G_EXC_ERROR;
840 result := wf_engine.eng_completed ||':'||wf_no;
841 return;
842 end if;
843
844 --update iex_writeoff_objects
845 --prefix this message before writeoff record is updated
846 AddfailMsg( p_object => 'Writeoff Object ',
847 p_operation => 'UPDATE' );
848
849 IEX_WRITEOFF_OBJECTS_PUB.update_writeoff_objects(
850 P_Api_Version_Number =>l_Api_Version_Number
851 ,P_Init_Msg_List =>'F'
852 ,P_Commit =>'F'
853 ,P_writeoff_obj_rec =>l_writeoff_obj_rec
854 ,xo_object_version_number =>l_object_version_number
855 ,x_return_status =>l_return_status
856 ,x_msg_count =>l_msg_count
857 ,x_msg_data =>l_msg_data);
858
859 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
860 IEX_WRITEOFFOBJ_PUB.Get_Messages1 (l_msg_count,l_message);
861 -- IF PG_DEBUG <11 THEN
862 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
863 iex_debug_pub.logmessage('Error' ||l_message);
864 END IF;
865 wf_engine.SetItemAttrText(itemtype => itemtype,
866 itemkey => itemkey,
867 aname => 'ERROR_MESSAGE',
868 avalue => l_message);
869 --raise FND_API.G_EXC_ERROR;
870 result := wf_engine.eng_completed ||':'||wf_no;
871 return;
872 ELSE
873 FND_MSG_PUB.initialize;
874 -- IF PG_DEBUG <11 THEN
875 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
876 iex_debug_pub.logmessage('Finished updating iex_writeoffobjects');
877 END IF;
878
879 END IF;
880
881 END LOOP;
882
883 if l_ctr =1 THEN
884 --update iex_writeoffs
885 --prefix this message before writeoff record is updated
886 AddfailMsg( p_object => 'Writeoffs ', p_operation => 'UPDATE' );
887
888 -- update iex_writeoff's dispostion_code;
889 l_writeoff_rec.disposition_code := 'A';
890 -- l_writeoff_rec.disposition_date := SYSDATE;
891 l_writeoff_rec.writeoff_id := l_writeoff_id;
892
893 IEX_WRITEOFFS_PVT.Update_writeoffs(
894 P_Api_Version_Number => l_api_version_number
895 ,P_Init_Msg_List => 'F'
896 ,P_Commit => 'F'
897 ,P_writeoffs_Rec => l_writeoff_rec
898 ,x_return_status => l_return_status
899 ,x_msg_count => l_msg_count
900 ,x_msg_data => l_msg_data
901 ,xo_object_version_number =>l_object_version_number);
902
903 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
904 IEX_WRITEOFFOBJ_PUB.Get_Messages1 (l_msg_count,l_message);
905 -- IF PG_DEBUG <11 THEN
906 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
907 iex_debug_pub.logmessage('Error' ||l_message);
908 END IF;
909 wf_engine.SetItemAttrText(itemtype => itemtype,
910 itemkey => itemkey,
911 aname => 'ERROR_MESSAGE',
912 avalue => l_message);
913 --raise FND_API.G_EXC_ERROR;
914 result := wf_engine.eng_completed ||':'||wf_no;
915 return;
916 ELSE
917 FND_MSG_PUB.initialize;
918 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
919 iex_debug_pub.logmessage ('obj of iex_writeoff' ||l_object_version_number
920 ||'l_writeoff_rec.writeoff_id' || l_writeoff_obj_rec.writeoff_id||
921 'in approve writeoff procedure');
922 END IF;
923
924 END IF;
925
926 /** if writeoff type is CONTRACT then send asset mgr a
927 termination notification
928 */
929 If l_object_type ='CONTRACT' THEN
930 if (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
931 iex_debug_pub.logmessage('l_object_id ' || l_object_id|| 'l_request_id '|| l_request_id );
932 end if;
933 -- iex_test_pub.logmessage('l_object_id ' || l_object_id||
934 -- 'l_request_id '|| l_request_id );
935 invoke_asset_mgr_wf(p_object_id => l_object_id
936 ,p_request_id => l_request_id
937 ,x_return_status => l_return_status
938 ,x_msg_count => l_msg_count
939 ,x_msg_data => l_msg_data );
940
941 IF ( l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
942 Get_Messages1 (l_msg_count,l_message);
943 -- IF PG_DEBUG < 11 THEN
944 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
945 iex_debug_pub.logmessage('Error after calling asset mgr WF' ||l_message);
946 END IF;
947
948 wf_engine.SetItemAttrText(itemtype => itemtype,
949 itemkey => itemkey,
950 aname => 'ERROR_MESSAGE',
951 avalue => l_message);
952 --raise FND_API.G_EXC_ERROR;
953 result := wf_engine.eng_completed ||':'||wf_no;
954 return;
955 ELSE
956 FND_MSG_PUB.initialize;
957 END IF;
958 END IF; --object_type
959 END if ;--if l_ctr;
960
961 result := wf_engine.eng_completed ||':'||wf_yes;
962
963 EXCEPTION
964 WHEN FND_API.G_EXC_ERROR THEN
965 --resultout := wf_engine.eng_completed ||':'||wf_no;
966 -- IF PG_DEBUG < 11 THEN
967 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
968 iex_debug_pub.logmessage('Error ' ||l_message);
969 END IF;
970
971 wf_core.context('IEX_WRITEOFFOBJ_PUB',
972 'approve_writeoffs',
973 itemtype,
974 itemkey,
975 to_char(actid),
976 funcmode);
977 raise;
978
979 when others then
980 --resultout := wf_engine.eng_completed ||':'||wf_no;
981 -- IF PG_DEBUG < 11 THEN
982 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
983 iex_debug_pub.logmessage('Error WHEN OTHERE' ||sqlerrm);
984 END IF;
985 wf_core.context('IEX_WRITEOFFOBJ_PUB',
986 'approve_writeoffs',
987 itemtype,
988 itemkey,
989 to_char(actid),
990 funcmode);
991 raise;
992
993 END approve_writeoffs;
994
995 /**
996 called from the workflow to reject writeoff record
997 update disposition_code
998 **/
999 PROCEDURE reject_writeoffs (itemtype in varchar2,
1000 itemkey in varchar2,
1001 actid in number,
1002 funcmode in varchar2,
1003 result out nocopy varchar2) IS
1004 l_api_version NUMBER := 1;
1005 l_init_msg_list VARCHAR2(1);
1006 l_return_status VARCHAR2(1);
1007 l_msg_count NUMBER ;
1008 l_msg_data VARCHAR2(32627);
1009 l_message VARCHAR2(32627);
1010
1011
1012 l_WRITEOFF_ID VARCHAR2(32627);
1013 l_REQUEST_ID VARCHAR2(32627);
1014
1015 cursor c_get_obj_ver(p_WRITEOFF_ID IN NUMBER) is
1016 select object_version_number
1017 from iex_writeoffs
1018 where WRITEOFF_ID =p_WRITEOFF_ID;
1019
1020
1021 l_api_name CONSTANT VARCHAR2(50) := 'REJECT_WRITEOFFS';
1022 l_api_name_full CONSTANT VARCHAR2(150):= g_pkg_name || '.' || l_api_name;
1023 l_api_version_number CONSTANT NUMBER := 2.0;
1024 l_object_version_number
1025 IEX_writeoff_objects.writeoff_object_id%TYPE;
1026
1027 l_writeoff_rec writeoff_rec_type ;
1028 l_writeoff_obj_rec writeoff_obj_rec_type ;
1029
1030 cursor c_get_writeoff_objects(p_WRITEOFF_ID IN NUMBER,
1031 p_REQUEST_ID IN NUMBER) is
1032 select writeoff_object_id,
1033 object_version_number
1034 from iex_writeoff_objects
1035 where WRITEOFF_ID =p_WRITEOFF_ID
1036 and writeoff_status ='W'
1037 and request_id =p_request_id;
1038
1039
1040 BEGIN
1041
1042 if funcmode <> 'RUN' then
1043 result := wf_engine.eng_null;
1044 return;
1045 end if;
1046 iex_debug_pub.logmessage ( 'JSANJU---inside reject writeoff');
1047 l_WRITEOFF_ID:= wf_engine.GetItemAttrText(itemtype => itemtype,
1048 itemkey => itemkey,
1049 aname => 'WRITEOFF_ID');
1050
1051
1052 l_REQUEST_ID:= wf_engine.GetItemAttrText(itemtype => itemtype,
1053 itemkey => itemkey,
1054 aname => 'REQUEST_ID');
1055
1056 OPEN c_get_obj_ver(l_WRITEOFF_ID);
1057 FETCH c_get_obj_ver INTO l_writeoff_rec.object_version_number;
1058 CLOSE c_get_obj_ver;
1059
1060
1061 --update iex_writeoff_objects
1062 --prefix this message before writeoff record is updated
1063 AddfailMsg( p_object => 'Writeoff Object ',
1064 p_operation => 'UPDATE' );
1065
1066 FOR i in c_get_writeoff_objects (l_writeoff_id,L_REQUEST_ID)
1067 LOOP
1068 l_writeoff_obj_rec.writeoff_object_id :=i.writeoff_object_id;
1069 l_writeoff_obj_rec.writeoff_status :='R';
1070 l_writeoff_obj_rec.object_version_number :=i.object_version_number;
1071
1072 IEX_WRITEOFF_OBJECTS_PUB.update_writeoff_objects(
1073 P_Api_Version_Number =>l_Api_Version_Number
1074 ,P_Init_Msg_List =>'F'
1075 ,P_Commit =>'F'
1076 ,P_writeoff_obj_rec =>l_writeoff_obj_rec
1077 ,xo_object_version_number =>l_object_version_number
1078 ,x_return_status =>l_return_status
1079 ,x_msg_count =>l_msg_count
1080 ,x_msg_data =>l_msg_data);
1081
1082 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
1083 IEX_WRITEOFFOBJ_PUB.Get_Messages1 (l_msg_count,l_message);
1084 -- IF PG_DEBUG <11 THEN
1085 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
1086 iex_debug_pub.logmessage('Error' ||l_message);
1087 END IF;
1088 wf_engine.SetItemAttrText(itemtype => itemtype,
1089 itemkey => itemkey,
1090 aname => 'ERROR_MESSAGE',
1091 avalue => l_message);
1092 --raise FND_API.G_EXC_ERROR;
1093 result := wf_engine.eng_completed ||':'||wf_no;
1094 return;
1095 ELSE
1096 FND_MSG_PUB.initialize;
1097 END IF;
1098
1099 END LOOP;
1100
1101 --update iex_writeoff_objects
1102 --prefix this message before writeoff record is updated
1103 AddfailMsg( p_object => 'Writeoffs ',
1104 p_operation => 'UPDATE' );
1105
1106 -- update iex_writeoff's dispostion_code;
1107 l_writeoff_rec.disposition_code := 'R';
1108 --l_writeoff_rec.disposition_date := SYSDATE;
1109 l_writeoff_rec.writeoff_id := l_writeoff_id;
1110
1111 IEX_WRITEOFFS_PVT.Update_writeoffs(
1112 P_Api_Version_Number =>l_api_version_number
1113 ,P_Init_Msg_List =>'F'
1114 ,P_Commit =>'F'
1115 ,P_writeoffs_Rec =>l_writeoff_rec
1116 ,x_return_status => l_return_status
1117 ,x_msg_count => l_msg_count
1118 ,x_msg_data => l_msg_data
1119 ,xo_object_version_number => l_object_version_number);
1120
1121 IF l_return_status <> FND_API.G_RET_STS_SUCCESS then
1122 IEX_WRITEOFFOBJ_PUB.Get_Messages1 (l_msg_count,l_message);
1123 -- IF PG_DEBUG <11 THEN
1124 IF (FND_LOG.LEVEL_EVENT >= PG_DEBUG) THEN
1125 iex_debug_pub.logmessage('Error' ||l_message||itemkey||itemtype);
1126 END IF;
1127
1128 wf_engine.SetItemAttrText(itemtype => itemtype,
1129 itemkey => itemkey,
1130 aname => 'ERROR_MESSAGE',
1131 avalue => l_message);
1132 --raise FND_API.G_EXC_ERROR;
1133 result := wf_engine.eng_completed ||':'||wf_no;
1134 return;
1135
1136 ELSE
1137 FND_MSG_PUB.initialize;
1138 END IF;
1139
1140 result := wf_engine.eng_completed ||':'||wf_yes;
1141
1142 EXCEPTION
1143 WHEN FND_API.G_EXC_ERROR THEN
1144 --resultout := wf_engine.eng_completed ||':'||wf_no;
1145 wf_core.context('IEX_WRITEOFFOBJ_PUB',
1146 'reject_writeoffs',
1147 itemtype,
1148 itemkey,
1149 to_char(actid),
1150 funcmode);
1151 raise;
1152
1153 when others then
1154 --resultout := wf_engine.eng_completed ||':'||wf_no;
1155 wf_core.context('IEX_WRITEOFFOBJ_PUB',
1156 'reject_writeoffs',
1157 itemtype,
1158 itemkey,
1159 to_char(actid),
1160 funcmode);
1161 raise;
1162
1163 END reject_writeoffs;
1164
1165 BEGIN
1166
1167 G_FILE_NAME := 'iexpwrob.pls';
1168 PG_DEBUG := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
1169 wf_yes := 'Y';
1170 wf_no :='N';
1171 END IEX_WRITEOFFOBJ_PUB;
1172
1173
1174