[Home] [Help]
PACKAGE BODY: APPS.FA_CHK_BALSEG_PKG
Source
1 PACKAGE BODY FA_CHK_BALSEG_PKG as
2 /* $Header: faxbaseb.pls 120.5 2009/03/27 01:25:07 bridgway ship $ */
3
4 procedure check_balancing_segments(
5 book in varchar2,
6 asset_id in number,
7 success out nocopy boolean,
8 calling_fn in varchar2,
9 p_log_level_rec in fa_api_types.log_level_rec_type)
10 is
11
12 h_structure_num number;
13 h_ccid number;
14 n_segs number;
15 all_segments fnd_flex_ext.SegmentArray;
16 balancing_segnum number;
17 h_ret_val boolean;
18 get_segments_success boolean;
19 balseg_mismatch_error exception;
20
21 /*fix for bug no.3794548.changing BalsegvalType type from varchar(15) to varchar(30)*/
22 TYPE BalsegvalType IS TABLE of VARCHAR2(30)
23 INDEX BY BINARY_INTEGER;
24 h_bal_seg_val BalSegValType;
25 no_rows BINARY_INTEGER:=0;
26 i BINARY_INTEGER:=0;
27 j BINARY_INTEGER:=0;
28 H_DEBUG BOOLEAN :=FALSE;
29 error_mesg varchar2(250);
30
31 cursor SEL_DIST_CCID(c_book varchar2,c_asset_id number) IS
32 SELECT code_combination_id
33 FROM fa_distribution_history FAD
34 WHERE book_type_code=c_book
35 AND asset_id=c_asset_id
36 AND transaction_header_id_out is null;
37 BEGIN
38 success:=FALSE;
39 select accounting_flex_structure
40 into h_structure_num
41 from fa_book_controls
42 where book_type_code = book;
43
44 h_ret_val := fnd_flex_apis.get_qualifier_segnum (
45 appl_id => 101,
46 key_flex_code => 'GL#',
47 structure_number => h_structure_num,
48 flex_qual_name => 'GL_BALANCING',
49 segment_number => balancing_segnum);
50
51 if (h_ret_val = FALSE)
52 then
53 null;
54 end if;
55
56 open SEL_DIST_CCID(book,asset_id);
57 LOOP
58 fetch SEL_DIST_CCID into h_ccid;
59
60 IF (SEL_DIST_CCID%NOTFOUND) then exit; end if;
61 no_rows := no_rows + 1;
62 get_segments_success := fnd_flex_ext.get_Segments (
63 application_short_name => 'SQLGL',
64 key_flex_code => 'GL#',
65 structure_number => h_structure_num,
66 combination_id => h_ccid,
67 n_segments => n_segs,
68 segments => all_segments);
69 if (get_segments_success) then
70 h_bal_seg_val(no_rows) := all_segments(balancing_segnum);
71 end if;
72
73 end loop;
74 close SEL_DIST_CCID;
75
76 /* Now Processing the PL/SQL Table containing the values for the balancing
77 segments
78 */
79 if no_rows=1
80 then
81 success:=TRUE;
82 return;
83 end if;
84
85 FOR i IN 1..no_rows LOOP
86 FOR j IN i+1..no_rows LOOP
87 if h_bal_seg_val(i)<>h_bal_seg_val(j)
88 then
89 return;
90 end if;
91 END LOOP;
92 END LOOP;
93
94 success:=TRUE;
95
96 EXCEPTION
97 when balseg_mismatch_error then
98 success:=FALSE;
99 when others then
100 success :=FALSE;
101 error_mesg := fnd_message.get;
102
103 /*FA_STANDARD_PKG.RAISE_ERROR (
104 CALLED_FN => 'FA_CHK_BALSEG_PKG.check_balancing_segments',
105 CALLING_FN => CALLING_FN, p_log_level_rec => p_log_level_rec);
106 */
107 end check_balancing_segments;
108
109 END FA_CHK_BALSEG_PKG;