DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_BDGT_REALLOC_LOG_PKG

Source


1 PACKAGE BODY pqh_bdgt_realloc_log_pkg AS
2 /* $Header: pqbpllog.pkb 115.4 2004/06/15 13:47:02 rthiagar noship $ */
3 
4 g_table_route_id   NUMBER(15);
5 
6 g_package  varchar2(33) := '  pqh_bdgt_realloc_log_pkg.';  -- Global package name
7 
8 FUNCTION get_table_route_for_bpl RETURN NUMBER IS
9   CURSOR csr_table_route IS
10   SELECT table_route_id
11   FROM   pqh_table_route
12   WHERE  table_alias =  'BPL';
13   l_tab_route NUMBER(15);
14   l_proc  varchar2(80) := g_package||'get_table_rout_for_bpl';
15 BEGIN
16   hr_utility.set_location('Entering'||l_proc,10);
17   OPEN csr_table_route;
18   FETCH  csr_table_route INTO l_tab_route;
19   CLOSE csr_table_route;
20   hr_utility.set_location('Leaving with table_route'||l_tab_route||l_proc,10);
21   RETURN l_tab_route;
22 END get_table_route_for_bpl;
23 
24 FUNCTION get_process_log_id(p_entity_type in varchar2  -- F/T/DD/RD
25                         ,p_transaction_id IN number  Default Null-- Realloc Transaction Id
26                         ,p_entity_id IN number  Default Null -- Donor Receiver Entity
27                         ,p_folder_id IN number) -- Realloc Folder Id
28 RETURN NUMBER IS
29     CURSOR CSR_batch_master_log IS
30      SELECT process_log_id
31      FROM   pqh_process_log
32      WHERE  txn_id = p_folder_id
33      AND    module_cd = 'BUDGET_REALLOCATION';
34 
35     Cursor Csr_get_log (p_batch_id IN number)
36     IS SELECT process_log_id,
37               txn_id,
38               information_category
39      FROM     pqh_process_log
40      START WITH txn_id = p_transaction_id
41      AND        master_process_log_id     =  p_batch_id
42      AND        module_cd = 'BUDGET_REALLOCATION'
43      CONNECT BY PRIOR  process_log_id = master_process_log_id;
44      l_proc varchar2(80) := g_package||'get_process_log_id';
45      l_mast_log_id NUMBER(15);
46 BEGIN
47     hr_utility.set_location(l_proc,10);
48     OPEN CSR_batch_master_log;
49     FETCH CSR_batch_master_log INTO l_mast_log_id;
50     CLOSE CSR_batch_master_log ;
51     IF p_entity_type = 'F' THEN
52      hr_utility.set_location('Leaving with master log id as '||l_mast_log_id||l_proc,20);
53      RETURN l_mast_log_id;
54     END IF;
55     FOR l_rec IN Csr_get_log(l_mast_log_id)
56     LOOP
57       IF p_entity_type = 'T' AND l_rec.txn_id = p_transaction_id AND l_rec.information_category = 'T' THEN
58          hr_utility.set_location('Leaving with master log id as '||l_rec.process_log_id||l_proc,20);
59          RETURN l_rec.process_log_id;
60       ELSIF p_entity_type = 'D'AND l_rec.txn_id = -1*p_transaction_id AND l_rec.information_category = 'D' THEN
61          hr_utility.set_location('Leaving with master log id as '||l_rec.process_log_id||l_proc,20);
62          RETURN l_rec.process_log_id;
63       ELSIF p_entity_type = 'R'AND l_rec.txn_id = -2*p_transaction_id AND l_rec.information_category = 'R' THEN
64          hr_utility.set_location('Leaving with master log id as '||l_rec.process_log_id||l_proc,20);
65          RETURN l_rec.process_log_id;
66       ELSIF p_entity_type IN ('DD','RD')
67             AND l_rec.information_category = p_entity_type
68             AND l_rec.txn_id = p_entity_id THEN
69          hr_utility.set_location('Leaving with master log id as '||l_rec.process_log_id||l_proc,20);
70          RETURN l_rec.process_log_id;
71       END IF;
72     END LOOP;
73     hr_utility.set_location('Leaving with master log id as -1'||l_proc,20);
74     RETURN -1;
75 END;
76 
77 PROCEDURE  start_log_for_folder(p_folder_id IN Number) IS
78 
79 Cursor csr_folder_dtls IS
80 SELECT fld.name,
81        pb.budget_name||'-'||bvr.version_number,
82        pb.budgeted_entity_cd,
83        fld.budget_unit_id
84 FROM   pqh_budget_pools fld,
85        pqh_budgets pb,
86        pqh_budget_versions bvr
87 WHERE  fld.pool_id = p_folder_id
88 AND    fld.budget_version_id = bvr.budget_version_id
89 AND    bvr.budget_id = pb.budget_id;
90  l_budget_name  VARCHAR2(40);
91  l_folder_name  varchar2(30);
92  l_entity_cd    varchar2(30);
93  l_unit_id      NUMBER(15);
94  l_folder_amt   NUMBER(22,3);
95  l_proc  varchar2(80) := g_package||'start_log_for_folder';
96 BEGIN
97     hr_utility.set_location('Entering '||l_proc,10);
98     OPEN csr_folder_dtls;
99     FETCH csr_folder_dtls INTO l_folder_name, l_budget_name,l_entity_cd, l_unit_id;
100     CLOSE csr_folder_dtls;
101     g_table_route_id := get_table_route_for_bpl;
102 --Folder
103     PQH_PROCESS_BATCH_LOG.START_LOG( p_batch_id => p_folder_id
104                                     ,p_module_cd => 'BUDGET_REALLOCATION'
105                                     ,p_log_context=> l_folder_name
106                                     ,p_information_category => 'F'
107                                     ,p_information1 => l_budget_name
108                                     ,p_information2 => l_entity_cd
109                                     ,p_information3 => l_unit_id
110                                     ,p_information4 => pqh_bdgt_realloc_utility.GET_FOLDER_LEVEL_TRANS_AMT(p_folder_id));   --Build a new canvas for this level
111    hr_utility.set_location('Leaving '||l_proc,20);
112 END start_log_for_folder;
113 
114 PROCEDURE start_log_for_transaction( p_folder_id IN number
115                                     ,p_transaction_id IN Number) is
116 
117  Cursor csr_trnx_name IS
118    SELECT name
119    FROM   pqh_budget_pools
120    WHERE  pool_id = p_transaction_id;
121    l_name Varchar2(30);
122    l_master_log_id  Number(15);
123    l_process_log_id NUMBER(15);
124    l_ovn   NUMBER(9);
125    l_proc  varchar2(80) := g_package||'start_log_for_transaction';
126    PRAGMA AUTONOMOUS_TRANSACTION;
127 BEGIN
128   hr_utility.set_location('Entering '||l_proc,10);
129   OPEN csr_trnx_name;
130   FETCH csr_trnx_name INTO l_name;
131   CLOSE csr_trnx_name;
132   l_master_log_id := get_process_log_id(p_entity_type => 'F'
133                                        ,p_folder_id => p_folder_id);
134   pqh_process_log_api.create_process_log(p_process_log_id => l_process_log_id
135                                          ,p_module_cd => 'BUDGET_REALLOCATION'
136                                          ,p_txn_id => p_transaction_id
137                                          ,p_log_context => l_name
138                                          ,p_batch_start_date => sysdate
139                                          ,p_master_process_log_id => l_master_log_id
140                                          ,p_message_type_cd => 'START'
141                                          ,p_message_text => 'Process Started'
142                                          ,p_effective_date => sysdate
143                                          ,p_object_version_number => l_ovn
144                                          ,p_information_category => 'T');
145   hr_utility.set_location('Inserted a row for Transaction Level '||l_proc,20);
146   l_master_log_id := l_process_log_id; -- Transaction level Process Log ID
147   pqh_process_log_api.create_process_log(p_process_log_id=> l_process_log_id
148                                          ,p_module_cd => 'BUDGET_REALLOCATION'
149                                          ,p_txn_id => -1*p_transaction_id
150                                          ,p_log_context => hr_general.decode_lookup('PQH_REALLOC_RECORD_TYPE','D')
151                                          ,p_batch_start_date => sysdate
152                                          ,p_master_process_log_id => l_master_log_id
153                                          ,p_message_type_cd => 'START'
154                                          ,p_message_text => 'Process Started'
155                                          ,p_effective_date => sysdate
156                                          ,p_object_version_number => l_ovn
157                                          ,p_information_category => 'D');
158   hr_utility.set_location('Inserted a row for Transaction-Donor Level '||l_proc,25);
159   pqh_process_log_api.create_process_log(p_process_log_id=> l_process_log_id
160                                          ,p_module_cd => 'BUDGET_REALLOCATION'
161                                          ,p_txn_id => -2*p_transaction_id
162                                          ,p_log_context => hr_general.decode_lookup('PQH_REALLOC_RECORD_TYPE','R')
163                                          ,p_batch_start_date => sysdate
164                                          ,p_master_process_log_id => l_master_log_id
165                                          ,p_message_type_cd => 'START'
166                                          ,p_message_text => 'Process Started'
167                                          ,p_effective_date => sysdate
168                                          ,p_object_version_number => l_ovn
169                                          ,p_information_category => 'R');
170   hr_utility.set_location('Inserted a row for Transaction-Receiver Level '||l_proc,25);
171 
172 
173   Commit;
174   hr_utility.set_location('Inserted a row for Transaction-Receive Level. Leaving '||l_proc,25);
175 END start_log_for_transaction;
176 PROCEDURE start_log_for_entity(p_folder_id IN NUMBER
177                               ,p_transaction_id IN NUMBER
178                               ,p_txn_entity_type IN varchar2 --(D/R)
179                               ,p_bdgt_entity_type IN varchar2
180                               ,p_entity_id IN NUMBER) IS
181    l_master_log_id NUMBER(15);
182    l_entity_name    VARCHAR2(240);
183    l_log_id   NUMBER(15);
184    l_ovn            NUMBER(9);
185    l_proc    varchar2(80) := g_package||'start_log_for_entity';
186    PRAGMA AUTONOMOUS_TRANSACTION;
187 BEGIN
188    hr_utility.set_location('Entering '||l_proc,10);
189 -- Log context for entity is the entity name
190   IF p_bdgt_entity_type = 'POSITION' THEN
191      l_entity_name := hr_general.decode_position_latest_name(p_entity_id);
192   ELSIF p_bdgt_entity_type = 'ORGANIZATION' THEN
193      l_entity_name := hr_general.decode_organization(p_entity_id);
194   ELSIF p_bdgt_entity_type = 'JOB' THEN
195      l_entity_name := hr_general.decode_job(p_entity_id);
196   ELSIF p_bdgt_entity_type = 'GRADE' THEN
197      l_entity_name := hr_general.decode_grade(p_entity_id);
198   END IF;
199   l_master_log_id := get_process_log_id(p_folder_id => p_folder_id
200                                        ,p_transaction_id => p_transaction_id
201                                        ,p_entity_type => p_txn_entity_type);
202 
203   pqh_process_log_api.create_process_log(p_process_log_id => l_log_id
204                                          ,p_module_cd => 'BUDGET_REALLOCATION'
205                                          ,p_txn_id => p_entity_id
206                                          ,p_log_context => l_entity_name
207                                          ,p_batch_start_date => sysdate
208                                          ,p_master_process_log_id => l_master_log_id
209                                          ,p_message_type_cd => 'START'
210                                          ,p_message_text => 'Process Started'
211                                          ,p_information_category => p_txn_entity_type||'D'
212                                          ,p_effective_date => sysdate
213                                          ,p_object_version_number => l_ovn);
214   commit;
215   hr_utility.set_location('Leaving '||l_proc,20);
216 END start_log_for_entity;
217 
218 FUNCTION get_batch_status(p_start_log_id IN NUMBER) RETURN varchar2 IS
219 
220 CURSOR csr_status (p_message_type_cd  IN VARCHAR2 ) IS
221 SELECT COUNT(*)
222 FROM pqh_process_log
223 WHERE message_type_cd = p_message_type_cd
224 START WITH  process_log_id = p_start_log_id
225 CONNECT BY PRIOR process_log_id = master_process_log_id;
226 
227 l_count_error           NUMBER := 0;
228 l_count_warning         NUMBER := 0;
229 l_status                VARCHAR2(30);
230 l_proc                  varchar2(80) := g_package||'get_batch_status';
231 BEGIN
232   hr_utility.set_location('Entering '||l_proc,10);
233   /*
234     Compute the status of the batch. If there exists any record in the batch with
235     message_type_cd = 'ERROR' then the transaction_status = 'ERROR'
236     If there only exists records in the batch with message_type_cd = 'WARNING' then
237     the transaction_status = 'WARNING'
238     If there are NO records in the batch with message_type_cd = 'WARNING' OR 'ERROR' then
239     the transaction_status = 'SUCCESS'
240   */
241    OPEN csr_status(p_message_type_cd => 'ERROR');
242      FETCH csr_status INTO l_count_error;
243    CLOSE csr_status;
244    OPEN csr_status(p_message_type_cd => 'WARNING');
245      FETCH csr_status INTO l_count_warning;
246    CLOSE csr_status;
247    IF l_count_error <> 0 THEN
248      -- there are one or more errors
249       l_status := 'ERROR';
250    ELSE
251      -- errors are 0 , check for warnings
252       IF l_count_warning <> 0 THEN
253         -- there are one or more warnings
254         l_status := 'WARNING';
255       ELSE
256         -- no errors or warnings
257          l_status := 'SUCCESS';
258       END IF;
259    END IF;
260    hr_utility.set_location('Leaving '||l_status||l_proc,10);
261    RETURN l_status;
262 END get_batch_status;
263 PROCEDURE end_realloc_log(p_txn_entity_type IN varchar2
264                          ,p_folder_id IN NUMBER
265                          ,p_transaction_id IN NUMBER
266                          ,p_entity_id IN NUMBER  Default NULL
267                          ) IS
268 
269 l_status                VARCHAR2(30);
270 PRAGMA AUTONOMOUS_TRANSACTION;
271 l_process_log_id NUMBER(15);
272 l_proc varchar2(80) := g_package||'end_realloc_log';
273 BEGIN
274    hr_utility.set_location('Entering '||l_proc,10);
275    l_process_log_id := get_process_log_id(p_entity_type => p_txn_entity_type
276                                          ,p_folder_id => p_folder_id
277                                          ,p_transaction_id => p_transaction_id
278                                          ,p_entity_id => p_entity_id);
279    l_status := get_batch_status(l_process_log_id);
280   /*
281     update the 'start' record for this transaction with message_type_cd = 'COMPLETE'
282   */
283    UPDATE pqh_process_log
284    SET message_type_cd = DECODE(message_type_cd,'ERROR',message_type_cd,'COMPLETE'),
285        message_text   = DECODE(message_type_cd,'ERROR',message_text,fnd_message.get_string('PQH','PQH_PROCESS_COMPLETED')),
286        batch_status = DECODE(batch_status,'ERROR',batch_status,l_status),
287        batch_end_date = sysdate
288    WHERE process_log_id = l_process_log_id;
289    hr_utility.set_location('Leaving '||l_proc,20);
290    Commit;
291 END end_realloc_log;
292 
293 PROCEDURE update_log_message(p_folder_id IN Number
294                             ,p_txn_entity_type IN varchar2 ---- T/D/R/DP
295                             ,p_transaction_id IN Number Default Null
296                             ,p_entity_id IN Number Default Null
297                             ,p_budget_period_id IN NUMBER default Null
298                             ,p_message_type_cd  IN varchar2  -- E/I/W
299                             ,p_message_text IN varchar2) IS
300   l_proc varchar2(80) := g_package||'update_log_message';
301   l_process_log_id  NUMBER(15);
302   l_message_type_cd VARCHAR2(30);
303   l_status varchar2(30);
304   l_log_context  Varchar2(200);
305   l_ovn NUMBER(9);
306   l_period_log_id NUMBER(15);
307   l_folder_log_id NUMBER(15);
308   Cursor Csr_period_dates IS
309     SELECT to_char(tp1.start_date,'DD-MM-RRRR')||' '||to_char(tp2.end_date,'DD-MM-RRRR')
310     FROM   pqh_budget_periods bpr,
311            per_time_periods tp1,
312            per_time_periods tp2
313     WHERE  bpr.budget_period_id = p_budget_period_id
314     AND    tp1.time_period_id = bpr.start_time_period_id
315     AND    tp2.time_period_id = bpr.end_time_period_id;
316   Cursor csr_rcvr_dates IS
317    SELECT  to_char(bpr.start_date,'DD-MM-RRRR')||' '||to_char(bpr.end_date,'DD-MM-RRRR')
318    FROM    pqh_bdgt_pool_realloctions bpr
319    WHERE   bpr.reallocation_id = p_budget_period_id;
320 
321   PRAGMA AUTONOMOUS_TRANSACTION;
322 BEGIN
323    hr_utility.set_location('Entering '||l_proc,10);
324    IF p_folder_id IS NULL THEN
325      hr_api.mandatory_arg_error(p_api_name => 'PQH_BDGT_REALLOC_LOG_PKG'
326                                ,p_argument => 'p_folder_id'
327                                ,p_argument_value => p_folder_id);
328    END IF;
329    IF p_txn_entity_type IS NULL THEN
330      hr_api.mandatory_arg_error(p_api_name => 'PQH_BDGT_REALLOC_LOG_PKG'
331                                ,p_argument => 'p_txn_entity_type'
332                                ,p_argument_value => p_txn_entity_type);
333    END IF;
334    IF p_message_type_cd = 'E' THEN
335      l_message_type_cd := 'ERROR';
336      l_status := 'ERROR';
337    ELSIF p_message_type_cd = 'W' THEN
338      l_message_type_cd := 'WARNING';
339      l_status := 'WARNING';
340    END IF;
341    IF p_txn_entity_type = 'F' THEN
342     l_process_log_id := get_process_log_id(p_entity_type => 'F'
343                                           ,p_folder_id => p_folder_id);
344     l_log_context := 'FOLDER';
345        pqh_process_log_api.create_process_log(p_process_log_id => l_folder_log_id
346                                              ,p_module_cd => 'BUDGET_REALLOCATION'
347                                              ,p_txn_id => p_folder_id
348                                              ,p_log_context => l_log_context
349                                              ,p_master_process_log_id => l_process_log_id
350                                              ,p_message_text => NVL(p_message_text,'Completed Successfully')
351                                              ,p_message_type_cd => NVL(l_message_type_cd,'COMPLETE')
352                                              ,p_information_category => p_txn_entity_type
353                                              ,p_object_version_number => l_ovn
354                                              ,p_effective_date => sysdate );
355 
356    ELSIF p_txn_entity_type = 'T' THEN
357      IF p_transaction_id IS NULL THEN
358          hr_api.mandatory_arg_error(p_api_name => 'PQH_BDGT_REALLOC_LOG_PKG'
359                                    ,p_argument => 'p_transaction_id'
360                                    ,p_argument_value => p_transaction_id);
361       END IF;
362       l_process_log_id := get_process_log_id(p_entity_type => 'T'
363                                            ,p_transaction_id => p_transaction_id
364                                            ,p_folder_id => p_folder_id);
365       UPDATE  pqh_process_log
366       set     message_type_cd =  l_message_type_cd
367              ,batch_status = l_status
368              ,message_text = p_message_text
369       WHERE   process_log_id = l_process_log_id;
370      ELSIF p_txn_entity_type IN ('DP','RP') THEN
371        IF p_transaction_id IS NULL THEN
372          hr_api.mandatory_arg_error(p_api_name => 'PQH_BDGT_REALLOC_LOG_PKG'
373                                    ,p_argument => 'p_transaction_id'
374                                    ,p_argument_value => p_transaction_id);
375        END IF;
376        IF p_entity_id IS NULL THEN
377          hr_api.mandatory_arg_error(p_api_name => 'PQH_BDGT_REALLOC_LOG_PKG'
378                                    ,p_argument => 'p_entity_id'
379                                    ,p_argument_value => p_entity_id);
380        END IF;
381        IF p_budget_period_id IS NULL THEN
382          hr_api.mandatory_arg_error(p_api_name => 'PQH_BDGT_REALLOC_LOG_PKG'
383                                    ,p_argument => 'p_budget_period_id'
384                                    ,p_argument_value => p_budget_period_id);
385        END IF;
386        l_process_log_id := get_process_log_id(p_entity_type=> substr(p_txn_entity_type,1,1)||'D'
387                                              ,p_transaction_id => p_transaction_id
388                                              ,p_folder_id => p_folder_id
389                                              ,p_entity_id => p_entity_id);
390        IF p_txn_entity_type = 'DP' THEN
391          OPEN csr_period_dates;
392          FETCH csr_period_dates INTO l_log_context;
393          CLOSE csr_period_dates;
394        ELSIF p_txn_entity_type = 'RP' THEN
395         OPEN csr_rcvr_dates;
396         FETCH csr_rcvr_dates INTO l_log_context;
397         CLOSE csr_rcvr_dates;
398        END IF;
399        pqh_process_log_api.create_process_log(p_process_log_id => l_period_log_id
400                                              ,p_module_cd => 'BUDGET_REALLOCATION'
401                                              ,p_txn_id => p_budget_period_id
402                                              ,p_log_context => l_log_context
403                                              ,p_master_process_log_id => l_process_log_id
404                                              ,p_message_text => NVL(p_message_text,'Completed Successfully')
405                                              ,p_message_type_cd => NVL(l_message_type_cd,'COMPLETE')
406                                              ,p_information_category => p_txn_entity_type
407                                              ,p_object_version_number => l_ovn
408                                              ,p_effective_date => sysdate );
409 
410    END IF;
411    COMMIT;
412    hr_utility.set_location('Leaving '||l_proc,20);
413 END update_log_message;
414 
415 PROCEDURE  start_log(p_folder_id IN Number
416                     ,p_transaction_id IN Number
417                     ,p_entity_id IN Number
418                     ,p_txn_entity_type IN varchar2 -- F/T/R/D
419                     ,p_bdgt_entity_type IN varchar2 ) IS
420   l_proc varchar2(80) := g_package||'start_log';
421 BEGIN
422    hr_utility.set_location('Entering '||l_proc,10);
423    IF p_txn_entity_type = 'F' THEN
424       start_log_for_folder(p_folder_id=> p_folder_id);
425    ELSIF p_txn_entity_type = 'T' THEN
426       start_log_for_transaction( p_folder_id => p_folder_id
427                                 ,p_transaction_id => p_transaction_id);
428    ELSIF p_txn_entity_type IN ('D','R') THEN
429       start_log_for_entity(p_folder_id => p_folder_id
430                           ,p_transaction_id => p_transaction_id
431                           ,p_txn_entity_type =>p_txn_entity_type
432                           ,p_bdgt_entity_type => p_bdgt_entity_type
433                           ,p_entity_id => p_entity_id);
434    END IF;
435    hr_utility.set_location('Leaving '||l_proc,20);
436 END start_log;
437 
438 PROCEDURE log_rule_for_entity(p_folder_id IN NUMBER
439                              ,p_transaction_id IN NUMBER
440                              ,p_txn_entity_type IN varchar2 --(D/R)
441                              ,p_bdgt_entity_type IN varchar2
442                              ,p_entity_id IN NUMBER
443                              ,p_budget_period_id IN NUMBER
444                              ,p_rule_name IN varchar2
445                              ,p_rule_level IN varchar2
446                              ,p_rule_msg_cd IN Varchar2) IS
447 
448   l_master_log_id  NUMBER(15);
449   l_message_text   VARCHAR2(4000);
450   l_ovn            NUMBER(9);
451   l_rule_log_id NUMBER(15);
452   l_message_type_cd VARCHAR2(30);
453   PRAGMA AUTONOMOUS_TRANSACTION;
454   l_proc    varchar2(80) := g_package||'log_rule_for_entity';
455 BEGIN
456    hr_utility.set_location('Entering '||l_proc,10);
457 -- set the message level based on the rule level for the current rule violation
458    IF   p_rule_level = 'E' THEN
459      l_message_type_cd := 'ERROR';
460   ELSIF p_rule_level = 'W' THEN
461      l_message_type_cd := 'WARNING';
462   END IF;
463 --Calling code is to send the message text now. so no need for set_name call
464 --  fnd_message.set_name(8302,p_rule_msg_cd);
465 --
466   l_message_text :=  p_rule_msg_cd;
467   IF p_txn_entity_type = 'F' THEN
468    update_log_message(p_folder_id => p_folder_id
469                      ,p_txn_entity_type => 'F'
470                      ,p_message_type_cd => p_rule_level
471                      ,p_message_text => l_message_text);
472    hr_utility.set_location('Leaving from F '||l_proc,11);
473    RETURN;
474   ELSIF p_txn_entity_type = 'T' THEN
475     update_log_message(p_folder_id => p_folder_id
476                       ,p_transaction_id => p_transaction_id
477                       ,p_txn_entity_type => 'T'
478                       ,p_message_type_cd => p_rule_level
479                       ,p_message_text=> l_message_text);
480    hr_utility.set_location('Leaving from T '||l_proc,11);
481    RETURN;
482   END IF;
483   IF p_txn_entity_type IN ('DP','RP') THEN
484    -- code for inserting a row under the entity for Donor Periods under a Donor Entity
485      update_log_message(p_folder_id => p_folder_id
486                        ,p_transaction_id => p_transaction_id
487                        ,p_entity_id => p_entity_id
488                        ,p_txn_entity_type => p_txn_entity_type
489                        ,p_budget_period_id => p_budget_period_id
490                        ,p_message_type_cd => p_rule_level
491                        ,p_message_text => l_message_text);
492    hr_utility.set_location('Leaving from DP '||l_proc,12);
493    RETURN;
494   END IF;
495 
496   l_master_log_id := get_process_log_id(p_folder_id => p_folder_id
497                                        ,p_transaction_id => p_transaction_id
498                                        ,p_entity_type => p_txn_entity_type||'D'
499                                        ,p_entity_id => p_entity_id);
500 
501   -- Create an entry in the process log for the current rule under the current entity
502    pqh_process_log_api.create_process_log(p_process_log_id => l_rule_log_id
503                                          ,p_module_cd => 'BUDGET_REALLOCATION'
504                                          ,p_txn_id => p_entity_id
505                                          ,p_log_context => p_rule_name
506                                          ,p_master_process_log_id => l_master_log_id
507                                          ,p_message_text => NVL(l_message_text,'Completed Successfully')
508                                          ,p_message_type_cd => NVL(l_message_type_cd,'COMPLETE')
509                                          ,p_information_category => p_txn_entity_type||'M'
510                                          ,p_object_version_number => l_ovn
511                                          ,p_effective_date => sysdate );
512    hr_utility.set_location('Leaving '||l_proc,20);
513 
514   commit;
515 END  log_rule_for_entity;
516 
517 PROCEDURE end_log(p_txn_entity_type IN varchar2
518                  ,p_folder_id IN NUMBER
519                  ,p_transaction_id IN NUMBER
520                  ,p_entity_id IN NUMBER) IS
521   l_proc  varchar2(80) := g_package||'end_log';
522 BEGIN
523      hr_utility.set_location('Entering '||l_proc,10);
524      IF p_txn_entity_type = 'F' THEN
525            PQH_PROCESS_BATCH_LOG.END_LOG;
526      ELSIF p_txn_entity_type = 'T' THEN
527           end_realloc_log(p_txn_entity_type => p_txn_entity_type
528                          ,p_folder_id => p_folder_id
529                          ,p_transaction_id => p_transaction_id);
530           end_realloc_log(p_txn_entity_type => 'D'
531                          ,p_folder_id => p_folder_id
532                          ,p_transaction_id => p_transaction_id);
533           end_realloc_log(p_txn_entity_type => 'R'
534                          ,p_folder_id => p_folder_id
535                          ,p_transaction_id => p_transaction_id);
536      ELSE
537           end_realloc_log(p_txn_entity_type => p_txn_entity_type||'D'
538                          ,p_folder_id => p_folder_id
539                          ,p_transaction_id => p_transaction_id
540                          ,p_entity_id => p_entity_id);
541     END IF;
542     hr_utility.set_location('Leaving '||l_proc,20);
543 END end_log;
544 END pqh_bdgt_realloc_log_pkg;