[Home] [Help]
PACKAGE BODY: APPS.FA_AFE_TRANSACTIONS_PKG
Source
1 package BODY FA_AFE_TRANSACTIONS_PKG as
2 /* $Header: FAAFETRB.pls 120.2 2005/09/19 10:02:43 skchawla noship $ */
3
4
5 -- Private type declarations
6
7 -- Private constant declarations
8
9 -- Private variable declarations
10
11 -- Function and procedure implementations
12 -- Author : SKCHAWLA
13 -- Created : 7/26/2005 5:32:12 PM
14 FUNCTION get_new_ccid(p_book_type_code varchar2,
15 p_old_expense_ccid number,
16 p_overlay_seg_val number,
17 x_new_expense_ccid out NOCOPY number,
18 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null)
19 return boolean IS
20
21 h_mesg_name VARCHAR2(30);
22 h_new_deprn_exp_acct VARCHAR2(26);
23 -- h_new_ccid NUMBER(15) := 0;
24 gen_ccid_err EXCEPTION;
25 h_cost_acct_ccid NUMBER := 0;
26
27 h_chart_of_accounts_id GL_SETS_OF_BOOKS.chart_of_accounts_id%TYPE;
28 h_flex_segment_delimiter varchar2(5);
29 h_flex_segment_number number;
30 h_num_of_segments NUMBER;
31 h_concat_array_segments FND_FLEX_EXT.SEGMENTARRAY;
32
33 h_appl_short_name varchar2(30);
34 h_message_name varchar2(30);
35 h_num number := 0;
36 h_errmsg varchar2(512);
37 h_concat_segs varchar2(2000) := '';
38 h_delimiter varchar2(1);
39
40 l_err_stage varchar2(250);
41 l_calling_fn varchar2(40) := 'FA_AFE_TRANSACTIONS_PKG.get_new_ccid';
42
43 BEGIN
44
45 l_err_stage := 'Get Chart of Accounts ID';
46 if (p_log_level_rec.statement_level) then
47 fa_debug_pkg.add(l_calling_fn,
48 '-',
49 'before ' || l_err_stage,
50 p_log_level_rec => p_log_level_rec);
51 end if;
52 Select sob.chart_of_accounts_id
53 into h_chart_of_accounts_id
54 From fa_book_controls bc, gl_sets_of_books sob
55 Where sob.set_of_books_id = bc.set_of_books_id
56 And bc.book_type_code = p_book_type_code;
57
58 l_err_stage := 'Get Account Qualifier Segment Number';
59 if (p_log_level_rec.statement_level) then
60 fa_debug_pkg.add(l_calling_fn,
61 '-',
62 'before ' || l_err_stage,
63 p_log_level_rec => p_log_level_rec);
64 end if;
65 IF (NOT FND_FLEX_APIS.GET_QUALIFIER_SEGNUM(101,
66 'GL#',
67 h_chart_of_accounts_id,
68 'FA_COST_CTR',
69 h_flex_segment_number)) THEN
70 RAISE gen_ccid_err;
71 END IF;
72
73 l_err_stage := 'Retrieve distribution segments';
74 if (p_log_level_rec.statement_level) then
75 fa_debug_pkg.add(l_calling_fn,
76 '-',
77 'before ' || l_err_stage,
78 p_log_level_rec => p_log_level_rec);
79 end if;
80 IF (NOT FND_FLEX_EXT.GET_SEGMENTS('SQLGL',
81 'GL#',
82 h_chart_of_accounts_id,
83 p_old_expense_ccid, --old_ccid,
84 h_num_of_segments,
85 h_concat_array_segments)) THEN
86
87 RAISE gen_ccid_err;
88 END IF;
89
90 -- Updating array with new account value
91 h_concat_array_segments(h_flex_segment_number) := p_overlay_seg_val;
92
93 l_err_stage := 'Retrieve new ccid with overlaid account';
94 if (p_log_level_rec.statement_level) then
95 fa_debug_pkg.add(l_calling_fn,
96 '-',
97 'before ' || l_err_stage,
98 p_log_level_rec => p_log_level_rec);
99 end if;
100 -- get_combination_id function generates new ccid if rules allows.
101 -- h_message_name := 'FND_FLEX_EXT.GET_COMBINATION_ID';
102
103 IF (NOT FND_FLEX_EXT.GET_COMBINATION_ID('SQLGL',
104 'GL#',
105 h_chart_of_accounts_id,
106 SYSDATE,
107 h_num_of_segments,
108 h_concat_array_segments,
109 x_new_expense_ccid)) THEN
110
111 -- -- dbms_output.put_line('FND_FLEX_APIS.get_segment_delimiter');
112 -- build message
113 h_delimiter := FND_FLEX_APIS.get_segment_delimiter(101,
114 'GL#',
115 h_chart_of_accounts_id);
116
117 -- fill the string for messaging with concat segs...
118 while (h_num < h_num_of_segments) loop
119 h_num := h_num + 1;
120
121 if (h_num > 1) then
122 h_concat_segs := h_concat_segs || h_delimiter;
123 end if;
124
125 h_concat_segs := h_concat_segs || h_concat_array_segments(h_num);
126
127 end loop;
128
129 h_errmsg := null;
130 h_errmsg := FND_FLEX_EXT.GET_ENCODED_MESSAGE;
131
132 FA_SRVR_MSG.ADD_MESSAGE(CALLING_FN => 'FAFLEX_PKG_WF.START_PROCESS',
133 NAME => 'FA_FLEXBUILDER_FAIL_CCID',
134 TOKEN1 => 'ACCOUNT_TYPE',
135 VALUE1 => 'DEPRN_EXP',
136 TOKEN2 => 'BOOK_TYPE_CODE',
137 VALUE2 => p_book_type_code,
138 TOKEN3 => 'DIST_ID',
139 VALUE3 => 'NEW',
140 TOKEN4 => 'CONCAT_SEGS',
141 VALUE4 => h_concat_segs,
142 p_log_level_rec => p_log_level_rec);
143
144 fnd_message.set_encoded(h_errmsg);
145 fnd_msg_pub.add;
146
147 RAISE gen_ccid_err;
148 END IF;
149
150 RETURN(TRUE);
151
152 EXCEPTION
153 WHEN gen_ccid_err THEN
154 FA_SRVR_MSG.add_message(CALLING_FN => l_calling_fn,
155 NAME => h_mesg_name,
156 p_log_level_rec => p_log_level_rec);
157 RETURN(FALSE);
158 WHEN OTHERS THEN
159 FA_SRVR_MSG.ADD_SQL_ERROR(CALLING_FN => l_calling_fn,
160 p_log_level_rec => p_log_level_rec);
161
162 RETURN(FALSE);
163
164 END get_new_ccid;
165
166 -- Purpose : To capitalize the assets
167 function process_capitalize(p_trans_int_rec FA_API_TYPES.trans_interface_rec_type,
168 p_asset_id number,
169 p_new_asset_key_ccid number,
170 p_log_level_rec IN FA_API_TYPES.log_level_rec_type)
171 return boolean is
172 Result boolean;
173 l_trans_rec FA_API_TYPES.trans_rec_type;
174 l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
175 l_asset_fin_rec FA_API_TYPES.asset_fin_rec_type;
176 l_asset_desc_rec FA_API_TYPES.asset_desc_rec_type;
177 l_asset_cat_rec FA_API_TYPES.asset_cat_rec_type;
178
179 l_CALENDAR_PERIOD_OPEN_DATE date;
180 l_return_status VARCHAR2(1);
181 l_mesg_count number := 0;
182 l_mesg_len number;
183 l_mesg varchar2(4000);
184 l_book_type_code varchar2(30);
185 cost_center_seg varchar(50);
186 cost_center_seg_index number;
187 l_group_asset_rec FA_CREATE_GROUP_ASSET_PKG.group_asset_rec_type;
188 l_ACCOUNTING_FLEX_STRUCTURE fa_book_controls.accounting_flex_structure%type;
189 l_asset_dist_tbl fa_api_types.asset_dist_tbl_type;
190 l_gl_ccid_enabled_flag varchar2(1);
191 l_log_level_rec FA_API_TYPES.log_level_rec_type := p_log_level_rec;
192 TYPE varchar30_tbl IS TABLE OF varchar2(30) INDEX BY BINARY_INTEGER;
193 l_segment varchar30_tbl;
194 l_err_stage varchar2(250);
195 l_calling_fn varchar2(40) := 'FA_AFE_TRANSACTIONS_PKG.process_capitalize';
196
197 cursor get_distributions(c_book_type_code varchar2, c_asset_id number) is
198 select *
199 from fa_distribution_history
200 where book_type_code = c_book_type_code
201 and asset_id = c_asset_id
202 and date_ineffective is null;
203
204 begin
205 l_err_stage := 'Begin FA_AFE_TRANSACTIONS_PKG.process_capitalize';
206 if (l_log_level_rec.statement_level) then
207 fa_debug_pkg.add(l_calling_fn,
208 '-',
209 'before ' || l_err_stage,
210 p_log_level_rec => l_log_level_rec);
211 end if;
212 l_book_type_code := p_trans_int_rec.book_type_code;
213 select CALENDAR_PERIOD_OPEN_DATE
214 into l_CALENDAR_PERIOD_OPEN_DATE
215 from fa_deprn_periods
216 where period_close_date is null
217 and book_type_code = l_book_type_code;
218 -- asset header info
219 l_asset_hdr_rec.asset_id := p_asset_id;
220 l_asset_hdr_rec.book_type_code := l_book_type_code;
221
222 l_asset_fin_rec.date_placed_in_service := l_CALENDAR_PERIOD_OPEN_DATE;
223 l_asset_fin_rec.dry_hole_flag := 'N';
224 l_err_stage := 'Calling capitalization API';
225 if (l_log_level_rec.statement_level) then
226 fa_debug_pkg.add(l_calling_fn,
227 '-',
228 'before ' || l_err_stage,
229 p_log_level_rec => l_log_level_rec);
230 end if;
231 FA_CIP_PUB.do_capitalization(p_api_version => 1.0,
232 p_init_msg_list => FND_API.G_FALSE,
233 p_commit => FND_API.G_FALSE,
234 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
235 x_return_status => l_return_status,
236 x_msg_count => l_mesg_count,
237 x_msg_data => l_mesg,
238 p_calling_fn => null,
239 px_trans_rec => l_trans_rec,
240 px_asset_hdr_rec => l_asset_hdr_rec,
241 px_asset_fin_rec => l_asset_fin_rec);
242
243 l_err_stage := 'Change ASset Key and Transfer Report Center';
244 if (l_log_level_rec.statement_level) then
245 fa_debug_pkg.add(l_calling_fn,
246 '-',
247 'before ' || l_err_stage,
248 p_log_level_rec => l_log_level_rec);
249 end if;
250 if (p_trans_int_rec.ASSET_KEY_NEW_HIERARCHY_VALUE is not null) then
251
252 l_asset_hdr_rec := null;
253 l_asset_hdr_rec.asset_id := p_asset_id;
254 l_asset_hdr_rec.book_type_code := l_book_type_code;
255
256 l_asset_desc_rec.asset_key_ccid := p_new_asset_key_ccid;
257 l_err_stage := 'Calling asset descriptive API';
258 if (l_log_level_rec.statement_level) then
259 fa_debug_pkg.add(l_calling_fn,
260 '-',
261 'before ' || l_err_stage,
262 p_log_level_rec => l_log_level_rec);
263 end if;
264 FA_ASSET_DESC_PUB.update_desc(p_api_version => 1.0,
265 p_init_msg_list => FND_API.G_FALSE,
266 p_commit => FND_API.G_FALSE,
267 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
268 x_return_status => l_return_status,
269 x_msg_count => l_mesg_count,
270 x_msg_data => l_mesg,
271 p_calling_fn => 'process_capitalize',
272 px_trans_rec => l_trans_rec,
273 px_asset_hdr_rec => l_asset_hdr_rec,
274 px_asset_desc_rec_new => l_asset_desc_rec,
275 px_asset_cat_rec_new => l_asset_cat_rec);
276
277 --do transfer
278
279 select ACCOUNTING_FLEX_STRUCTURE
280 into l_ACCOUNTING_FLEX_STRUCTURE
281 from fa_book_controls
282 where book_type_code = l_book_type_code;
283
284 if not
285 (FND_FLEX_APIS.get_segment_column(x_application_id => 101,
286 x_id_flex_code => 'GL#',
287 x_id_flex_num => l_ACCOUNTING_FLEX_STRUCTURE,
288 x_seg_attr_type => 'FA_COST_CTR',
289 x_app_column_name => cost_center_seg)) then
290 null;
291 end if;
292
293 cost_center_seg_index := to_number(substr(cost_center_seg, 8));
294 l_err_stage := 'Check all distributions';
295 if (l_log_level_rec.statement_level) then
296 fa_debug_pkg.add(l_calling_fn,
297 '-',
298 'before ' || l_err_stage,
299 p_log_level_rec => l_log_level_rec);
300 end if;
301 for dist_rec in get_distributions(l_book_type_code, p_asset_id) loop
302
303 select Segment1,
304 Segment2,
305 Segment3,
306 Segment4,
307 Segment5,
308 Segment6,
309 Segment7,
310 Segment8,
311 Segment9,
312 Segment10,
313 Segment11,
314 Segment12,
315 Segment13,
316 Segment14,
317 Segment15,
318 Segment16,
319 Segment17,
320 Segment18,
321 Segment19,
322 Segment20,
323 Segment21,
324 Segment22,
325 Segment23,
326 Segment24,
327 Segment25,
328 Segment26,
329 Segment27,
330 Segment28,
331 Segment29,
332 Segment30,
333 enabled_flag
334 into l_segment(1),
335 l_segment(2),
336 l_segment(3),
337 l_segment(4),
338 l_segment(5),
339 l_segment(6),
340 l_segment(7),
341 l_segment(8),
342 l_segment(9),
343 l_segment(10),
344 l_segment(11),
345 l_segment(12),
346 l_segment(13),
347 l_segment(14),
348 l_segment(15),
349 l_segment(16),
350 l_segment(17),
351 l_segment(18),
352 l_segment(19),
353 l_segment(20),
354 l_segment(21),
355 l_segment(22),
356 l_segment(23),
357 l_segment(24),
358 l_segment(25),
359 l_segment(26),
360 l_segment(27),
361 l_segment(28),
362 l_segment(29),
363 l_segment(30),
364 l_gl_ccid_enabled_flag
365 from gl_code_combinations
366 where code_combination_id = dist_rec.code_combination_id;
367 l_err_stage := 'Check distribution for the transfer';
368 if (l_log_level_rec.statement_level) then
369 fa_debug_pkg.add(l_calling_fn,
370 '-',
371 'before ' || l_err_stage,
372 p_log_level_rec => l_log_level_rec);
373 end if;
374 if (l_segment(cost_center_seg_index) =
375 p_trans_int_rec.ASSET_KEY_HIERARCHY_VALUE) then
376
377 l_asset_dist_tbl.delete;
378 l_asset_hdr_rec := null;
379 l_asset_hdr_rec.asset_id := p_asset_id;
380 l_asset_hdr_rec.book_type_code := l_book_type_code;
381
382 l_asset_dist_tbl(1).transaction_units := dist_rec.units_assigned;
383
384 l_asset_dist_tbl(1).distribution_id := dist_rec.distribution_id;
385
386 l_asset_dist_tbl(2).transaction_units := dist_rec.units_assigned;
387 l_asset_dist_tbl(2).assigned_to := dist_rec.assigned_to;
388 l_asset_dist_tbl(2).location_ccid := dist_rec.location_id;
392 '-',
389 l_err_stage := 'Get new expense account for transfer';
390 if (l_log_level_rec.statement_level) then
391 fa_debug_pkg.add(l_calling_fn,
393 'before ' || l_err_stage,
394 p_log_level_rec => l_log_level_rec);
395 end if;
396 if not get_new_ccid(l_book_type_code,
397 dist_rec.code_combination_id,
398 p_trans_int_rec.ASSET_KEY_NEW_HIERARCHY_VALUE,
399 l_asset_dist_tbl(2).expense_ccid) then
400 null;
401 end if;
402 l_err_stage := 'Perform the transfer calling transfer API';
403 if (l_log_level_rec.statement_level) then
404 fa_debug_pkg.add(l_calling_fn,
405 '-',
406 'before ' || l_err_stage,
407 p_log_level_rec => l_log_level_rec);
408 end if;
409 FA_TRANSFER_PUB.do_transfer(p_api_version => 1.0,
410 p_init_msg_list => FND_API.G_FALSE,
411 p_commit => FND_API.G_FALSE,
412 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
413 x_return_status => l_return_status,
414 x_msg_count => l_mesg_count,
415 x_msg_data => l_mesg,
416 p_calling_fn => 'process_capitalize',
417 px_trans_rec => l_trans_rec,
418 px_asset_hdr_rec => l_asset_hdr_rec,
419 px_asset_dist_tbl => l_asset_dist_tbl);
420 if (l_return_status <> FND_API.G_RET_STS_SUCCESS) then
421 null; --raise mtfr_err;
422 end if;
423
424 end if;
425
426 end loop;
427 end if;
428
429 l_group_asset_rec.asset_id := p_asset_id;
430 l_group_asset_rec.rec_mode := 'ITERFACE';
431 l_group_asset_rec.book_type_code := l_book_type_code;
432 l_err_stage := 'Calling create_group_asset';
433 if not (FA_CREATE_GROUP_ASSET_PKG.create_group_asset(l_group_asset_rec)) then
434 l_err_stage := 'create_group_asset_failed';
435 if (l_log_level_rec.statement_level) then
436 fa_debug_pkg.add(l_calling_fn,
437 '-',
438 l_err_stage,
439 p_log_level_rec => l_log_level_rec);
440 return false;
441 end if;
442 end if;
443
444 if (l_return_status = 'Y') then
445 return true;
446 else
447 return false;
448 end if;
449
450 return(Result);
451 exception
452 when others then
453 return false;
454 end process_capitalize;
455
456 function process_dry_hole(p_trans_int_rec FA_API_TYPES.trans_interface_rec_type,
457 p_asset_id number,
458 p_new_asset_key_ccid number,
459 p_log_level_rec IN FA_API_TYPES.log_level_rec_type)
460 return boolean is
461 Result boolean;
462 l_trans_rec FA_API_TYPES.trans_rec_type;
463 l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
464 l_asset_fin_rec FA_API_TYPES.asset_fin_rec_type;
465 l_asset_desc_rec FA_API_TYPES.asset_desc_rec_type;
466 l_asset_cat_rec FA_API_TYPES.asset_cat_rec_type;
467
468 l_CALENDAR_PERIOD_OPEN_DATE date;
472 l_mesg varchar2(4000);
469 l_return_status VARCHAR2(1);
470 l_mesg_count number := 0;
471 l_mesg_len number;
473 l_book_type_code varchar2(30);
474 cost_center_seg varchar(50);
475 cost_center_seg_index number;
476 l_group_asset_rec FA_CREATE_GROUP_ASSET_PKG.group_asset_rec_type;
477 l_ACCOUNTING_FLEX_STRUCTURE fa_book_controls.accounting_flex_structure%type;
478 l_asset_dist_tbl fa_api_types.asset_dist_tbl_type;
479 l_gl_ccid_enabled_flag varchar2(1);
480 l_log_level_rec FA_API_TYPES.log_level_rec_type := p_log_level_rec;
481 TYPE varchar30_tbl IS TABLE OF varchar2(30) INDEX BY BINARY_INTEGER;
482 l_segment varchar30_tbl;
483 l_err_stage varchar2(250);
484 l_calling_fn varchar2(40) := 'FA_AFE_TRANSACTIONS_PKG.process_dry_hole';
485 cursor get_distributions(c_book_type_code varchar2, c_asset_id number) is
486 select *
487 from fa_distribution_history
488 where book_type_code = c_book_type_code
489 and asset_id = c_asset_id
490 and date_ineffective is null;
491 begin
492 l_err_stage := 'Begin FA_AFE_TRANSACTIONS_PKG.process_capitalize';
493 if (l_log_level_rec.statement_level) then
494 fa_debug_pkg.add(l_calling_fn,
495 '-',
496 'before ' || l_err_stage,
497 p_log_level_rec => l_log_level_rec);
498 end if;
499 l_book_type_code := p_trans_int_rec.book_type_code;
500 select CALENDAR_PERIOD_OPEN_DATE
501 into l_CALENDAR_PERIOD_OPEN_DATE
502 from fa_deprn_periods
503 where period_close_date is null
504 and book_type_code = l_book_type_code;
505 -- asset header info
506 l_asset_hdr_rec.asset_id := p_asset_id;
507 l_asset_hdr_rec.book_type_code := l_book_type_code;
508
509 l_asset_fin_rec.date_placed_in_service := l_CALENDAR_PERIOD_OPEN_DATE;
510 l_asset_fin_rec.dry_hole_flag := 'Y';
511 l_err_stage := 'Calling capitalization API';
512 if (l_log_level_rec.statement_level) then
513 fa_debug_pkg.add(l_calling_fn,
514 '-',
515 'before ' || l_err_stage,
516 p_log_level_rec => l_log_level_rec);
517 end if;
518 FA_CIP_PUB.do_capitalization(p_api_version => 1.0,
519 p_init_msg_list => FND_API.G_FALSE,
520 p_commit => FND_API.G_FALSE,
521 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
522 x_return_status => l_return_status,
523 x_msg_count => l_mesg_count,
524 x_msg_data => l_mesg,
525 p_calling_fn => null,
526 px_trans_rec => l_trans_rec,
527 px_asset_hdr_rec => l_asset_hdr_rec,
528 px_asset_fin_rec => l_asset_fin_rec);
529
530 l_err_stage := 'Change ASset Key and Transfer Report Center';
531 if (l_log_level_rec.statement_level) then
532 fa_debug_pkg.add(l_calling_fn,
533 '-',
534 'before ' || l_err_stage,
535 p_log_level_rec => l_log_level_rec);
536 end if;
537 if (p_trans_int_rec.ASSET_KEY_NEW_HIERARCHY_VALUE is not null) then
538
539 l_asset_hdr_rec := null;
540 l_asset_hdr_rec.asset_id := p_asset_id;
541 l_asset_hdr_rec.book_type_code := l_book_type_code;
542
543 l_asset_desc_rec.asset_key_ccid := p_new_asset_key_ccid;
544 l_err_stage := 'Calling asset descriptive API';
545 if (l_log_level_rec.statement_level) then
546 fa_debug_pkg.add(l_calling_fn,
547 '-',
548 'before ' || l_err_stage,
549 p_log_level_rec => l_log_level_rec);
550 end if;
551 FA_ASSET_DESC_PUB.update_desc(p_api_version => 1.0,
552 p_init_msg_list => FND_API.G_FALSE,
553 p_commit => FND_API.G_FALSE,
554 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
555 x_return_status => l_return_status,
556 x_msg_count => l_mesg_count,
557 x_msg_data => l_mesg,
558 p_calling_fn => 'process_capitalize',
559 px_trans_rec => l_trans_rec,
560 px_asset_hdr_rec => l_asset_hdr_rec,
561 px_asset_desc_rec_new => l_asset_desc_rec,
562 px_asset_cat_rec_new => l_asset_cat_rec);
563
564 --do transfer
565
566 select ACCOUNTING_FLEX_STRUCTURE
567 into l_ACCOUNTING_FLEX_STRUCTURE
568 from fa_book_controls
569 where book_type_code = l_book_type_code;
570
571 if not
572 (FND_FLEX_APIS.get_segment_column(x_application_id => 101,
573 x_id_flex_code => 'GL#',
574 x_id_flex_num => l_ACCOUNTING_FLEX_STRUCTURE,
575 x_seg_attr_type => 'FA_COST_CTR',
576 x_app_column_name => cost_center_seg)) then
577 null;
578 end if;
579
580 cost_center_seg_index := to_number(substr(cost_center_seg, 8));
584 '-',
581 l_err_stage := 'Check all distributions';
582 if (l_log_level_rec.statement_level) then
583 fa_debug_pkg.add(l_calling_fn,
585 'before ' || l_err_stage,
586 p_log_level_rec => l_log_level_rec);
587 end if;
588 for dist_rec in get_distributions(l_book_type_code, p_asset_id) loop
589
590 select Segment1,
591 Segment2,
592 Segment3,
593 Segment4,
594 Segment5,
595 Segment6,
596 Segment7,
597 Segment8,
598 Segment9,
599 Segment10,
600 Segment11,
601 Segment12,
602 Segment13,
603 Segment14,
604 Segment15,
605 Segment16,
606 Segment17,
607 Segment18,
608 Segment19,
609 Segment20,
610 Segment21,
611 Segment22,
612 Segment23,
613 Segment24,
614 Segment25,
615 Segment26,
616 Segment27,
617 Segment28,
618 Segment29,
619 Segment30,
620 enabled_flag
621 into l_segment(1),
622 l_segment(2),
623 l_segment(3),
624 l_segment(4),
625 l_segment(5),
626 l_segment(6),
627 l_segment(7),
628 l_segment(8),
629 l_segment(9),
630 l_segment(10),
631 l_segment(11),
632 l_segment(12),
633 l_segment(13),
634 l_segment(14),
635 l_segment(15),
636 l_segment(16),
637 l_segment(17),
638 l_segment(18),
639 l_segment(19),
640 l_segment(20),
641 l_segment(21),
642 l_segment(22),
643 l_segment(23),
644 l_segment(24),
645 l_segment(25),
646 l_segment(26),
647 l_segment(27),
648 l_segment(28),
649 l_segment(29),
650 l_segment(30),
651 l_gl_ccid_enabled_flag
652 from gl_code_combinations
653 where code_combination_id = dist_rec.code_combination_id;
654 l_err_stage := 'Check distribution for the transfer';
655 if (l_log_level_rec.statement_level) then
656 fa_debug_pkg.add(l_calling_fn,
657 '-',
658 'before ' || l_err_stage,
659 p_log_level_rec => l_log_level_rec);
660 end if;
661 if (l_segment(cost_center_seg_index) =
662 p_trans_int_rec.ASSET_KEY_HIERARCHY_VALUE) then
663
664 l_asset_dist_tbl.delete;
665 l_asset_hdr_rec := null;
666 l_asset_hdr_rec.asset_id := p_asset_id;
667 l_asset_hdr_rec.book_type_code := l_book_type_code;
668
669 l_asset_dist_tbl(1).transaction_units := dist_rec.units_assigned;
670
671 l_asset_dist_tbl(1).distribution_id := dist_rec.distribution_id;
672
673 l_asset_dist_tbl(2).transaction_units := dist_rec.units_assigned;
674 l_asset_dist_tbl(2).assigned_to := dist_rec.assigned_to;
675 l_asset_dist_tbl(2).location_ccid := dist_rec.location_id;
676 l_err_stage := 'Get new expense account for transfer';
677 if (l_log_level_rec.statement_level) then
678 fa_debug_pkg.add(l_calling_fn,
679 '-',
680 'before ' || l_err_stage,
681 p_log_level_rec => l_log_level_rec);
682 end if;
683 if not get_new_ccid(l_book_type_code,
684 dist_rec.code_combination_id,
685 p_trans_int_rec.ASSET_KEY_NEW_HIERARCHY_VALUE,
686 l_asset_dist_tbl(2).expense_ccid) then
687 null;
688 end if;
689 l_err_stage := 'Perform the transfer calling transfer API';
690 if (l_log_level_rec.statement_level) then
691 fa_debug_pkg.add(l_calling_fn,
692 '-',
693 'before ' || l_err_stage,
694 p_log_level_rec => l_log_level_rec);
695 end if;
696 FA_TRANSFER_PUB.do_transfer(p_api_version => 1.0,
697 p_init_msg_list => FND_API.G_FALSE,
698 p_commit => FND_API.G_FALSE,
699 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
700 x_return_status => l_return_status,
701 x_msg_count => l_mesg_count,
702 x_msg_data => l_mesg,
703 p_calling_fn => 'process_capitalize',
704 px_trans_rec => l_trans_rec,
705 px_asset_hdr_rec => l_asset_hdr_rec,
706 px_asset_dist_tbl => l_asset_dist_tbl);
707 if (l_return_status <> FND_API.G_RET_STS_SUCCESS) then
708 null; --raise mtfr_err;
709 end if;
710
711 end if;
712
713 end loop;
714 end if;
715
716 l_group_asset_rec.asset_id := p_asset_id;
717 l_group_asset_rec.rec_mode := 'ITERFACE';
718 l_group_asset_rec.book_type_code := l_book_type_code;
719 l_err_stage := 'Calling create_group_asset';
720 if not (FA_CREATE_GROUP_ASSET_PKG.create_group_asset(l_group_asset_rec)) then
721 l_err_stage := 'create_group_asset_failed';
722 if (l_log_level_rec.statement_level) then
723 fa_debug_pkg.add(l_calling_fn,
724 '-',
725 l_err_stage,
726 p_log_level_rec => l_log_level_rec);
727 return false;
728 end if;
729 end if;
730
731 if (l_return_status = 'Y') then
732 return true;
733 else
734 return false;
735 end if;
736
737 return(Result);
738 exception
739 when others then
740 return false;
741 end process_dry_hole;
742
743 function process_expense(p_trans_int_rec FA_API_TYPES.trans_interface_rec_type,
744 p_asset_id number,
745 p_log_level_rec IN FA_API_TYPES.log_level_rec_type)
746 return boolean is
747 Result boolean;
748 l_book_type_code varchar2(30);
749 l_trans_rec FA_API_TYPES.trans_rec_type;
750 l_dist_trans_rec FA_API_TYPES.trans_rec_type;
751 l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
752 l_asset_retire_rec FA_API_TYPES.asset_retire_rec_type;
753 l_asset_dist_tbl FA_API_TYPES.asset_dist_tbl_type;
754 l_subcomp_tbl FA_API_TYPES.subcomp_tbl_type;
755 l_inv_tbl FA_API_TYPES.inv_tbl_type;
756
757 l_api_version number := 1;
758 l_init_msg_list varchar2(1) := FND_API.G_FALSE;
759 l_commit varchar2(1) := FND_API.G_FALSE;
760 l_validation_level number := FND_API.G_VALID_LEVEL_FULL;
761
762 l_return_status VARCHAR2(1);
763 l_mesg_count number := 0;
764 l_mesg_len number;
765 l_mesg varchar2(4000);
766
767 l_log_level_rec FA_API_TYPES.log_level_rec_type := p_log_level_rec;
768
769 l_err_stage varchar2(250);
770 l_calling_fn varchar2(40) := 'FA_AFE_TRANSACTIONS_PKG.process_expense';
771 begin
772 l_book_type_code := p_trans_int_rec.book_type_code;
773
774 l_asset_hdr_rec.asset_id := p_asset_id;
775 l_asset_hdr_rec.book_type_code := l_book_type_code;
776 select cost
777 into l_asset_retire_rec.cost_retired
778 from fa_books
779 where book_type_code = l_book_type_code
780 and asset_id = p_asset_id
781 and transaction_header_id_out is null;
782
783 FA_RETIREMENT_PUB.do_retirement(p_api_version => l_api_version,
784 p_init_msg_list => l_init_msg_list,
785 p_commit => l_commit,
786 p_validation_level => l_validation_level,
787 p_calling_fn => l_calling_fn,
788 x_return_status => l_return_status,
789 x_msg_count => l_mesg_count,
790 x_msg_data => l_mesg,
791 px_trans_rec => l_trans_rec,
792 px_dist_trans_rec => l_dist_trans_rec,
793 px_asset_hdr_rec => l_asset_hdr_rec,
794 px_asset_retire_rec => l_asset_retire_rec,
795 p_asset_dist_tbl => l_asset_dist_tbl,
796 p_subcomp_tbl => l_subcomp_tbl,
797 p_inv_tbl => l_inv_tbl);
798
799 return(Result);
800 exception
801 when others then
802 return false;
803 end process_expense;
804
805 end FA_AFE_TRANSACTIONS_PKG;