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