DBA Data[Home] [Help]

PACKAGE BODY: APPS.FA_BEGIN_MASS_TRX_PKG

Source


1 PACKAGE BODY FA_BEGIN_MASS_TRX_PKG AS
2 /* $Header: FAXBMTB.pls 120.5 2005/07/25 10:05:11 yyoon ship $ */
3 
4 --
5 -- FUNCTION faxbmt
6 --
7 
8 FUNCTION faxbmt (X_book         IN      VARCHAR2,
9                  X_request_id   IN      NUMBER,
10 		 X_result	IN OUT NOCOPY BOOLEAN,
11                  p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)      RETURN BOOLEAN IS
12     h_trx_type		 varchar2(20);
13     h_conc_program_id 	 number(15);
14     h_set_of_books_id    number(15);
15     h_mrc_sob_type_code  varchar2(1);
16 BEGIN
17 
18     fnd_profile.get('GL_SET_OF_BKS_ID',h_set_of_books_id);
19 
20     if not fa_cache_pkg.fazcsob
21             (X_set_of_books_id   => h_set_of_books_id,
22              X_mrc_sob_type_code => h_mrc_sob_type_code
23              ,p_log_level_rec => p_log_level_rec) then
24       fa_srvr_msg.add_sql_error
25            (calling_fn => 'FA_BEGIN_MASS_TRX_PKG.faxbmt'
26                       ,p_log_level_rec => p_log_level_rec);
27       return(FALSE);
28     end if;
29 
30     if (X_request_id IS NOT NULL and X_request_id <> 0) then
31 	SELECT RE.CONCURRENT_PROGRAM_ID
32         INTO h_conc_program_id
33         FROM FND_CONCURRENT_REQUESTS RE
34         WHERE RE.REQUEST_ID = X_request_id
35         AND   RE.PROGRAM_APPLICATION_ID in (140, 8731);
36         -- AND   RE.PROGRAM_APPLICATION_ID  = 140;  -- commented for bug2250373
37 
38 /*  BUG# 1468964
39     changed to incorporate all mass programs calls
40     only depreciation should use "other".  All
41     other programs should verify that periods are
42     in sync between primary and reporting books
43       -- bridgway 10/18/00
44 */
45 
46 	SELECT DECODE(PR.CONCURRENT_PROGRAM_NAME,
47                        'FAMTFR',  'TRANSFER',
48                        'FAMAPT',  'RECLASS',
49 		       'FAMRCL',  'RECLASS',
50                        'FARET',   'GAINLOSS',
51                        'FAMRET',  'MASSRET',
52                        'FAMRST',  'MASSRST',
53                        'FADRB',   'RB_DEP',
54                        'FADRB2',  'RB_DEP',
55                        'FAJERB',  'RB_CJE',
56                        'FAMCP',   'COPY',
57                        'FAIMCP',  'COPY',
58                        'FATAXUP', 'TAXUP',
59                        'FAUSTR',  'TAXUP',
60                        'FAACUP',  'TAXUP',
61                        'FATMTA',  'TAXUP',
62                        'FAMACH',  'MASSCHG',
63                        'FAVRVL',  'REVAL',
64                        'FACXTRET','TRANSFER', -- bug# 2153455
65                        'FACTFR',  'TRANSFER', -- bug# 2153455
66                        'FACHRMR', 'TRANSFER', -- bug# 2153455
67                        'OTHER')
68         INTO  h_trx_type
69         FROM  FND_CONCURRENT_PROGRAMS PR
70         WHERE PR.CONCURRENT_PROGRAM_ID = h_conc_program_id
71         AND PR.APPLICATION_ID in ( 140, 8731 );
72         -- AND   PR.APPLICATION_ID  = 140;  -- commented for bug2250373
73     else
74 	-- assume TRANSFER (most restrictive)
75 	h_trx_type := 'TRANSFER';
76     end if;
77 
78     /*
79      * Call faxcbs() to check the book status with submit_flag == FALSE
80      * and start_flag == TRUE because we are not submitting depreciation
81      * but are starting a mass process
82      */
83     if not FA_CHK_BOOKSTS_PKG.faxcbs(X_book, FALSE, TRUE,
84 				     0, h_trx_type, X_result) then
85 	FA_SRVR_MSG.Add_Message(
86 		CALLING_FN => 'FA_BEGIN_MASS_TRX_PKG.faxbmt'
87 		,p_log_level_rec => p_log_level_rec);
88 	X_result := FALSE;
89 	return (FALSE);
90     end if;
91 
92     /* All checks completed, update book_controls with mass request id */
93 
94     /*
95      * Ensure this is the only request running against the book by
96      * updating the request ID in fa_book_controls to the request_id
97      * of the running request
98      */
99 
100     if (h_mrc_sob_type_code = 'R') then
101       UPDATE  fa_book_controls_mrc_v
102       SET     mass_request_id = X_request_id
103       WHERE   book_type_code = X_book;
104     else
105       UPDATE  fa_book_controls
106       SET     mass_request_id = X_request_id
107       WHERE   book_type_code = X_book;
108     end if;
109 
110     return (TRUE);
111 
112 EXCEPTION
113     WHEN NO_DATA_FOUND THEN
114 	FA_SRVR_MSG.Add_Message(
115 		CALLING_FN => 'FA_BEGIN_MASS_TRX_PKG.faxbmt',
116                 NAME => 'CONC_MISSING_REQUEST',
117                 TOKEN1 => 'ROUTINE', VALUE1 => 'FA_TRXAPP',
118                 TOKEN2 => 'REQUEST', VALUE2 => X_request_id
119  		,p_log_level_rec => p_log_level_rec);
120 	X_result := FALSE;
121 	return (FALSE);
122     WHEN OTHERS THEN
123 	FA_SRVR_MSG.Add_SQL_Error
124                 (CALLING_FN=>'FA_BEGIN_MASS_TRX_PKG.faxbmt'
125                                 ,p_log_level_rec => p_log_level_rec);
126 	X_result := FALSE;
127 	return (FALSE);
128 END faxbmt;
129 
130 
131 --
132 -- FUNCTION faxemt
133 --
134 FUNCTION faxemt (X_book         IN      VARCHAR2,
135                  X_request_id   IN      NUMBER,
136                  p_log_level_rec        IN     FA_API_TYPES.log_level_rec_type default null)      RETURN BOOLEAN IS
137     h_set_of_books_id    number(15);
138     h_mrc_sob_type_code  varchar2(1);
139 BEGIN
140 
141     fnd_profile.get('GL_SET_OF_BKS_ID',h_set_of_books_id);
142 
143     if not fa_cache_pkg.fazcsob
144             (X_set_of_books_id   => h_set_of_books_id,
145              X_mrc_sob_type_code => h_mrc_sob_type_code
146              ,p_log_level_rec => p_log_level_rec) then
147       fa_srvr_msg.add_sql_error
148            (calling_fn => 'FA_BEGIN_MASS_TRX_PKG.faxemt'
149                       ,p_log_level_rec => p_log_level_rec);
150       return(FALSE);
151     end if;
152 
153     if (h_mrc_sob_type_code = 'R') then
154       UPDATE  fa_book_controls_mrc_v
155       SET     mass_request_id = NULL
156       WHERE   book_type_code = X_book
157       AND     mass_request_id = X_request_id;
158     else
159       UPDATE  fa_book_controls
160       SET     mass_request_id = NULL
161       WHERE   book_type_code = X_book
162       AND     mass_request_id = X_request_id;
163     end if;
164 
165     commit work;
166 
167     return (TRUE);
168 EXCEPTION
169     WHEN OTHERS THEN
170 	rollback work;
171 	FA_SRVR_MSG.Add_SQL_Error
172                 (CALLING_FN=>'FA_BEGIN_MASS_TRX_PKG.faxemt'
173                                 ,p_log_level_rec => p_log_level_rec);
174 	return (FALSE);
175 END faxemt;
176 
177 
178 END FA_BEGIN_MASS_TRX_PKG;