[Home] [Help]
PACKAGE BODY: APPS.GL_AUTO_ALLOC_PARALLEL_PKG
Source
1 PACKAGE BODY GL_AUTO_ALLOC_PARALLEL_PKG AS
2 /* $Header: glalpllb.pls 120.9 2004/02/28 02:28:29 djogg ship $ */
3
4
5 PROCEDURE diagn_msg (message_string IN VARCHAR2) IS
6
7 BEGIN
8 IF diagn_msg_flag THEN
9 --dbms_output.put_line (message_string);
10 null;
11 END IF;
12 EXCEPTION
13 WHEN OTHERS THEN
14 NULL;
15 END diagn_msg;
16
17
18
19 Procedure Start_Auto_Allocation_Parallel(p_request_Id IN NUMBER) IS
20 l_allocation_set_id Number ;
21 l_allocation_set_name Varchar2(40);
22 l_allocation_set_type_code Varchar2(1);
23 l_ledger_id Number;
24 l_access_set_id Number;
25 l_description Varchar2(240);
26 l_period_name Varchar2(15);
27 l_budget_version_id Number;
28 l_ledger_currency Varchar2(15);
29 l_balancing_segment_value Varchar2(25);
30 l_journal_effective_date Date;
31 l_calculation_effective_date Date;
32 l_usage_code Varchar2(1);
33 l_gl_period_name Varchar2(15);
34 l_pa_period_name Varchar2(15);
35 l_expenditure_item_date Date;
36 l_last_updated_by Number;
37 l_created_by Number;
38 l_last_update_login Number;
39 l_batch_id Number;
40 l_batch_type_code Varchar2(1);
41 l_allocation_method_code Varchar2(1);
42 l_owner Varchar2(50);
43 l_batch_name Varchar2(60);
44 l_step_number Number;
45 l_enable_avg_balances_flag Varchar2(1);
46 l_program_name_code Varchar2(30);
47 req_id Number;
48 t_allocation_method_code Varchar2(1);
49 l_usage_num Number;
50 err_num Number;
51 err_msg Varchar2(100);
52
53 Cursor c_set_name IS
54 Select
55 ALLOCATION_SET_NAME
56 ,ALLOCATION_SET_ID
57 ,ALLOCATION_SET_TYPE_CODE
58 ,ACCESS_SET_ID
59 ,LEDGER_ID
60 ,LEDGER_CURRENCY
61 ,DESCRIPTION
62 ,PERIOD_NAME
63 ,BUDGET_VERSION_ID
64 ,BALANCING_SEGMENT_VALUE
65 ,JOURNAL_EFFECTIVE_DATE
66 ,CALCULATION_EFFECTIVE_DATE
67 ,USAGE_CODE
68 ,GL_PERIOD_NAME
69 ,PA_PERIOD_NAME
70 ,EXPENDITURE_ITEM_DATE
71 ,LAST_UPDATED_BY
72 ,CREATED_BY
73 ,LAST_UPDATE_LOGIN
74 From GL_AUTO_ALLOC_SET_HISTORY
75 Where REQUEST_ID = p_request_Id;
76
77 Cursor c_batches IS
78 Select
79 STEP_NUMBER
80 , BATCH_ID
81 , BATCH_TYPE_CODE
82 , ALLOCATION_METHOD_CODE
83 , OWNER
84 From GL_AUTO_ALLOC_BATCH_HISTORY
85 Where REQUEST_ID = p_request_Id ;
86
87 Begin
88 diagn_msg('Executing Start_Auto_Allocation_Parallel for request_id '||
89 to_char(p_request_Id));
90 Open c_set_name;
91 Fetch c_set_name into
92 l_allocation_set_name
93 ,l_allocation_set_id
94 ,l_allocation_set_type_code
95 ,l_access_set_id
96 ,l_ledger_id
97 ,l_ledger_currency
98 ,l_description
99 ,l_period_name
100 ,l_budget_version_id
101 ,l_balancing_segment_value
102 ,l_journal_effective_date
103 ,l_calculation_effective_date
104 ,l_usage_code
105 ,l_gl_period_name
106 ,l_pa_period_name
107 ,l_expenditure_item_date
108 ,l_last_updated_by
109 ,l_created_by
110 ,l_last_update_login;
111
112 Close c_set_name;
113
114 If l_allocation_set_id IS NULL Then
115 diagn_msg('Fatal error:No Allocation set for '||to_char(p_request_Id));
116 Return;
117 End If;
118
119 Open c_batches;
120 Loop
121 Fetch c_batches into
122 l_step_number
123 ,l_batch_id
124 ,l_batch_type_code
125 ,l_allocation_method_code
126 ,l_owner;
127
128 Exit When c_batches%NOTFOUND;
129
130 l_batch_name := gl_auto_alloc_vw_pkg.Get_Batch_Name(
131 BATCH_TYPE_CODE => l_batch_type_code
132 ,BATCH_ID => l_batch_id);
133
134 -- Fix for bug1863250
135 If l_allocation_method_code = 'I' Then
136 t_allocation_method_code := 'Y' ;
137 Else
138 t_allocation_method_code := 'N';
139 End If;
140
141 If l_usage_code = 'Y' Then
142 l_usage_num := 1;
143 Else
144 l_usage_num := 0;
145 End If;
146
147 If l_batch_type_code = 'R' Then
148 --recurring Batch
149 l_program_name_code := 'GLPRJE';
150 diagn_msg('Line Number:'||to_char(l_STEP_NUMBER)||
151 ' Submitting Recurring Journal');
152 req_id := fnd_request.submit_request(
153 'SQLGL',
154 'GLPRJE',
155 '',
156 '',
157 FALSE,
158 to_char(l_batch_id),
159 l_PERIOD_NAME,
160 to_char(l_access_set_id),
161 to_char(l_budget_version_id),
162 to_char(l_calculation_effective_date, 'YYYY/MM/DD'),
163 to_char(l_journal_effective_date, 'YYYY/MM/DD'),
164 nvl(l_usage_code, 'N'),
165 chr(0), '', '',
166 '', '', '', '', '', '', '', '', '', '',
167 '', '', '', '', '', '', '', '', '', '',
168 '', '', '', '', '', '', '', '', '', '',
169 '', '', '', '', '', '', '', '', '', '',
170 '', '', '', '', '', '', '', '', '', '',
171 '', '', '', '', '', '', '', '', '', '',
172 '', '', '', '', '', '', '', '', '', '',
173 '', '', '', '', '', '', '', '', '', '',
174 '', '', '', '', '', '', '', '', '', '');
175
176 Elsif l_BATCH_TYPE_CODE in ('A','B','E') Then
177 -- if batch is massallocation, massbudget or massencumbrances
178 l_program_name_code := 'GLAMAS';
179 diagn_msg('Line Number:'||to_char(l_STEP_NUMBER)||
180 ' Submitting MassAllocations_'||l_BATCH_TYPE_CODE);
181 req_id := FND_REQUEST.SUBMIT_REQUEST(
182 'SQLGL',
183 'GLAMAS',
184 '',
185 '',
186 FALSE,
187 'C',
188 to_char(l_access_set_id),
189 nvl(t_allocation_method_code ,'N'),
190 to_char(l_usage_num),
191 to_char(l_ledger_id),
192 l_ledger_currency,
193 l_balancing_segment_value,
194 to_char(l_batch_id),
195 l_period_name ,
196 to_char(l_journal_effective_date,'YYYY/MM/DD HH24:MI:SS'),
197 to_char(l_calculation_effective_date,'YYYY/MM/DD HH24:MI:SS'),
198 chr(0),
199 '','','','','','','','','','',
200 '','','','','','','','','','','','','','','',
201 '','','','','','','','','','','','','','','',
202 '','','','','','','','','','','','','','','',
203 '','','','','','','','','','','','','','','',
204 '','','','','','','','','','','','','','','',
205 '','','');
206
207 Elsif l_BATCH_TYPE_CODE = 'P' Then
208 diagn_msg('Line Number:'||to_char(l_STEP_NUMBER)||
209 ' Submitting Project Allocations_'||l_BATCH_TYPE_CODE);
210
211 l_program_name_code := 'PAXALGAT';
212
213 req_id := GL_PA_AUTOALLOC_PKG.Submit_Alloc_Request(
214 l_batch_id
215 ,l_expenditure_item_date
216 ,l_pa_period_name
217 ,l_gl_period_name );
218
219 End If ;
220 If (req_id = 0) Then
221 -- submission failed
222 diagn_msg('Request submission failed for batch '||l_batch_name);
223 Else
224 -- insert record into GL_AUTO_ALLOC_BAT_HIST_DET for view status form
225 diagn_msg('Request_Id:'||to_char(req_id)||
226 'Inserting into GL_AUTO_ALLOC_BAT_HIST_DET');
227 Insert Into GL_AUTO_ALLOC_BAT_HIST_DET (
228 REQUEST_ID
229 ,PARENT_REQUEST_ID
230 ,STEP_NUMBER
231 ,PROGRAM_NAME_CODE
232 ,LAST_UPDATE_DATE
233 ,LAST_UPDATED_BY
234 ,LAST_UPDATE_LOGIN
235 ,CREATION_DATE
236 ,CREATED_BY
237 ,STATUS_CODE
238 ,RUN_MODE )
239 Values
240 ( req_id
241 ,p_request_Id
242 ,l_step_number
243 ,l_program_name_code
244 ,sysdate
245 ,l_last_updated_by
246 ,l_last_update_login
247 ,sysdate
248 ,l_created_by
249 ,NULL
250 ,'P'
251 );
252 End If;
253 Commit;
254 End Loop;
255 diagn_msg('Completed parallel submission successfully');
256
257 EXCEPTION
258 WHEN OTHERS THEN
259 err_num := SQLCODE;
260 err_msg := SUBSTR(SQLERRM, 1, 100);
261 -- dbms_output.put_line('Error: ' || err_num);
262 -- dbms_output.put_line(err_msg);
263 End Start_Auto_Allocation_Parallel;
264
265
266 End GL_AUTO_ALLOC_PARALLEL_PKG;