[Home] [Help]
PACKAGE BODY: APPS.FEM_UD_PKG
Source
1 PACKAGE BODY fem_ud_pkg AS
2 -- $Header: fem_ud_eng.plb 120.13.12010000.2 2008/10/08 18:47:40 huli ship $ */
3 -- ***********************
4 -- Package constants
5 -- ***********************
6 pc_pkg_name CONSTANT VARCHAR2(30) := 'fem_ud_pkg';
7
8 G_FEM constant varchar2(3) := 'FEM';
9 G_YES CONSTANT VARCHAR2(1) := 'Y';
10 G_NO CONSTANT VARCHAR2(1) := 'N';
11
12 pc_ret_sts_success CONSTANT VARCHAR2(1):= fnd_api.g_ret_sts_success;
13 pc_ret_sts_error CONSTANT VARCHAR2(1):= fnd_api.g_ret_sts_error;
14 pc_ret_sts_unexp_error CONSTANT VARCHAR2(1):= fnd_api.g_ret_sts_unexp_error;
15
16 pv_resp_app_id NUMBER := FND_GLOBAL.RESP_APPL_ID;
17 pv_login_id NUMBER := FND_GLOBAL.Login_Id;
18 pv_apps_user_id NUMBER := FND_GLOBAL.USER_ID;
19 pv_request_id NUMBER := fnd_global.conc_request_id;
20 pv_program_id NUMBER := FND_GLOBAL.Conc_Program_Id;
21 pv_program_app_id NUMBER := FND_GLOBAL.Prog_Appl_ID;
22 pv_concurrent_status BOOLEAN;
23
24 pc_log_level_statement CONSTANT NUMBER := fnd_log.level_statement;
25 pc_log_level_procedure CONSTANT NUMBER := fnd_log.level_procedure;
26 pc_log_level_event CONSTANT NUMBER := fnd_log.level_event;
27 pc_log_level_exception CONSTANT NUMBER := fnd_log.level_exception;
28 pc_log_level_error CONSTANT NUMBER := fnd_log.level_error;
29 pc_log_level_unexpected CONSTANT NUMBER := fnd_log.level_unexpected;
30
31 -- Bug 4309949. Hardcode folder to the "Default" folder
32 pc_undo_folder_id CONSTANT NUMBER := 1100;
33
34 -- ***********************
35 -- Package variables
36 -- ***********************
37
38 -- ***********************
39 -- Notification variables
40 -- ***********************
41 pv_undo_object_name VARCHAR2(150);
42 pv_undo_flag VARCHAR2(1);
43 pv_parameter_list wf_parameter_list_t := wf_parameter_list_t();
44
45 -- ***********************
46 -- Exceptions
47 -- ***********************
48 e_cannot_create_object EXCEPTION;
49 e_cannot_delete_object EXCEPTION;
50 e_undo_list_exec_not_success EXCEPTION;
51 e_edit_lock_exists EXCEPTION;
52 e_cannot_generate_dependents EXCEPTION;
53 e_invalid_p_commit EXCEPTION;
54
55 e_not_found_table_or_view EXCEPTION;
56 e_not_found_index EXCEPTION;
57 e_not_found_package EXCEPTION;
58 e_not_found_materialized_view EXCEPTION;
59 e_not_found_database_link EXCEPTION;
60 e_not_found_sequence EXCEPTION;
61 e_not_found_rollback_segment EXCEPTION;
62 e_not_found_synonym EXCEPTION;
63 e_not_found_dblink_in_dml EXCEPTION;
64 e_null_undo_list_name EXCEPTION;
65 e_invalid_dependencies_flag EXCEPTION;
66 e_invalid_dependency_errs_flag EXCEPTION;
67 e_mp_error EXCEPTION;
68
69 e_invalid_undo_list EXCEPTION;
70 e_pl_reg_request_failed EXCEPTION;
71 e_pl_reg_obj_exec_failed EXCEPTION;
72 e_pl_reg_obj_def_failed EXCEPTION;
73 e_could_not_process_undo_list EXCEPTION;
74 e_object_execution_not_found EXCEPTION;
75 e_invalid_folder EXCEPTION;
76 e_cannot_create_undo_list EXCEPTION;
77 e_cannot_add_candidate EXCEPTION;
78 e_list_has_no_candidates EXCEPTION;
79 e_cannot_undo_obj_exec_err EXCEPTION;
80 e_request_not_found EXCEPTION;
81 e_dependencies_found EXCEPTION;
82 e_request_is_running EXCEPTION;
83 e_objexec_is_running EXCEPTION;
84 e_engine_specific_proc_err EXCEPTION;
85 e_cannot_submit_request EXCEPTION;
86 e_cannot_gen_cand_upd_dep EXCEPTION;
87
88 e_cannot_read_object EXCEPTION;
89 e_invalid_preview_flag EXCEPTION;
90 e_invalid_undolist_objdefid EXCEPTION;
91 e_invalid_session_id EXCEPTION;
92 e_invalid_dependency_type EXCEPTION;
93 e_cannot_delete_execution_log EXCEPTION;
94 e_cannot_validate_dependents EXCEPTION;
95 e_cannot_validate_candidates EXCEPTION;
96
97 e_undo_action_not_supported EXCEPTION;
98 e_unexp_error EXCEPTION;
99
100 PRAGMA EXCEPTION_INIT(e_not_found_table_or_view,-942);
101 PRAGMA EXCEPTION_INIT(e_not_found_index,-1418);
102 PRAGMA EXCEPTION_INIT(e_not_found_package,-4043);
103 PRAGMA EXCEPTION_INIT(e_not_found_materialized_view,-12003);
104 PRAGMA EXCEPTION_INIT(e_not_found_database_link,-2024);
105 PRAGMA EXCEPTION_INIT(e_not_found_sequence,-2289);
106 PRAGMA EXCEPTION_INIT(e_not_found_rollback_segment,-1534);
107 PRAGMA EXCEPTION_INIT(e_not_found_synonym,-1434);
108 PRAGMA EXCEPTION_INIT(e_not_found_dblink_in_dml,-2019);
109
110 -- ***************************************************************************
111 -- Private procedure signatures:
112 -- ***************************************************************************
113 PROCEDURE calc_accttbl_upd_dependents (
114 x_msg_count OUT NOCOPY NUMBER,
115 x_msg_data OUT NOCOPY VARCHAR2,
116 x_return_status OUT NOCOPY VARCHAR2,
117 x_upd_dep_calc_id OUT NOCOPY NUMBER,
118 p_request_id IN NUMBER,
119 p_object_id IN NUMBER);
120
121 PROCEDURE delete_execution_log (
122 x_return_status OUT NOCOPY VARCHAR2,
123 x_msg_count OUT NOCOPY NUMBER,
124 x_msg_data OUT NOCOPY VARCHAR2,
125 p_api_version IN NUMBER,
126 p_commit IN VARCHAR2,
127 p_request_id IN NUMBER,
128 p_object_id IN NUMBER);
129
130 PROCEDURE raise_undo_business_event (p_event_name IN VARCHAR,
131 p_request_id IN NUMBER,
132 p_object_id IN NUMBER,
133 p_status IN VARCHAR DEFAULT NULL);
134
135 PROCEDURE Prepare_PL_Register_Record (
136 x_pl_register_record IN OUT nocopy pl_register_record,
137 x_return_status OUT NOCOPY VARCHAR2
138 );
139
140 PROCEDURE Get_Dim_Attribute_Value (
141 p_dimension_varchar_label in varchar2
142 ,p_attribute_varchar_label in varchar2
143 ,p_member_id in number
144 ,x_dim_attribute_varchar_member out nocopy varchar2
145 ,x_date_assign_value out nocopy date,
146 x_return_status OUT NOCOPY VARCHAR2
147 );
148
149 PROCEDURE Get_Dim_Attribute (
150 p_dimension_varchar_label in varchar2
151 ,p_attribute_varchar_label in varchar2
152 ,x_dimension_rec out nocopy dim_attr_record
153 ,x_attribute_id out nocopy number
154 ,x_attr_version_id out nocopy number
155 ,x_return_status OUT NOCOPY VARCHAR2
156 );
157
158 PROCEDURE Get_Object_Definition (
159 p_object_id in number
160 ,p_effective_date in date
161 ,x_obj_def_id out nocopy number
162 );
163
164 PROCEDURE write_debug (
165 p_msg_data IN VARCHAR2,
166 p_user_msg IN VARCHAR2,
167 p_module IN VARCHAR2);
168
169
170 -- ***************************************************************************
171 -- Private procedure bodies:
172 -- ***************************************************************************
173
174 -- ============================================================================
175 -- PRIVATE
176 -- Procedure for getting messages off the stack and posting to the debug or
177 -- concurrent log.
178 -- The procedure always posts messages to the debug log, and only posts to the
179 -- concurrent log if p_user_msg = 'Y'.
180 -- p_user_msg - Valid values 'Y','N'. Indicates whether or not to post message
181 -- to concurrent log.
182 -- p_module - Module from which get_put_messages is called.
183 -- ============================================================================
184 PROCEDURE Get_Put_Messages (
185 p_msg_count IN NUMBER,
186 p_msg_data IN VARCHAR2,
187 p_user_msg IN VARCHAR2,
188 p_module IN VARCHAR2) AS
189
190 v_msg_count NUMBER;
191 v_msg_data VARCHAR2(32000);
192 v_msg_out NUMBER;
193 v_message VARCHAR2(32000);
194
195 v_block CONSTANT VARCHAR2(300) :=
196 p_module||'.get_put_messages';
197
198 BEGIN
199
200 FEM_ENGINES_PKG.TECH_MESSAGE
201 (p_severity => pc_log_level_procedure,
202 p_module => v_block,
203 p_msg_text => 'MSG_COUNT: '||p_msg_count);
204
205 v_msg_data := p_msg_data;
206
207 IF (p_msg_count = 1)
208 THEN
209 FND_MESSAGE.Set_Encoded(v_msg_data);
210 v_message := FND_MESSAGE.Get;
211
212 IF p_user_msg = 'Y' THEN
213 FEM_ENGINES_PKG.User_Message(
214 p_msg_text => v_message);
215 END IF;
216
217 FEM_ENGINES_PKG.TECH_MESSAGE
218 (p_severity => pc_log_level_event,
219 p_module => v_block,
220 p_msg_text => v_message);
221
222 ELSIF (p_msg_count > 1)
223 THEN
224 FOR i IN 1..p_msg_count
225 LOOP
226 FND_MSG_PUB.Get(
227 p_msg_index => i,
228 p_encoded => FND_API.G_FALSE,
229 p_data => v_message,
230 p_msg_index_out => v_msg_out);
231
232 IF p_user_msg = 'Y' THEN
233 FEM_ENGINES_PKG.User_Message(
234 p_msg_text => v_message);
235 END IF;
236
237 FEM_ENGINES_PKG.TECH_MESSAGE
238 (p_severity => pc_log_level_event,
239 p_module => v_block,
240 p_msg_text => v_message);
241
242
243 END LOOP;
244 END IF;
245
246 FND_MSG_PUB.Initialize;
247
248 END Get_Put_Messages;
249 -- ******************************************************************************
250
251 PROCEDURE raise_undo_business_event (p_event_name IN VARCHAR,
252 p_request_id IN NUMBER,
253 p_object_id IN NUMBER,
254 p_status IN VARCHAR DEFAULT NULL) IS
255 -- ============================================================================
256 -- PRIVATE
257 -- This procedure raises the business event that is passed in along
258 -- with all the parameters that are associated with the rule execution
259 -- being removed.
260 --
261 -- p_event_name - Name of the business event
262 -- p_request_id - Request ID of the rule execution being removed
263 -- p_object_id - Object ID of the rule execution being removed
264 -- ============================================================================
265
266 C_MODULE CONSTANT FND_LOG_MESSAGES.module%TYPE :=
267 'fem.plsql.fem_ud_pkg.raise_undo_business_event';
268 C_API_NAME CONSTANT VARCHAR2(30) := 'Raise_Undo_Business_Event';
269 v_calendar_id NUMBER;
270 v_cal_period_id NUMBER;
271 v_ledger_id NUMBER;
272 v_output_dataset_code NUMBER;
273 v_object_execution_date DATE;
274 v_source_system_code NUMBER;
275 v_object_name FEM_OBJECT_CATALOG_VL.object_name%TYPE;
276 v_cal_period_name FEM_CAL_PERIODS_VL.cal_period_name%TYPE;
277 v_calendar_display_code FEM_CALENDARS_VL.calendar_display_code%TYPE;
278 v_calendar_name FEM_CALENDARS_VL.calendar_name%TYPE;
279 v_dataset_display_code FEM_DATASETS_VL.dataset_display_code%TYPE;
280 v_dataset_name FEM_DATASETS_VL.dataset_name%TYPE;
281 v_ledger_display_code FEM_LEDGERS_VL.ledger_display_code%TYPE;
282 v_ledger_name FEM_LEDGERS_VL.ledger_name%TYPE;
283 v_source_system_display_code FEM_SOURCE_SYSTEMS_VL.source_system_display_code%TYPE;
284 v_source_system_name FEM_SOURCE_SYSTEMS_VL.source_system_name%TYPE;
285 v_display_flag FEM_PL_OBJECT_EXECUTIONS.display_flag%TYPE;
286
287 BEGIN
288
289 IF FND_LOG.level_procedure >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
290 FEM_ENGINES_PKG.TECH_MESSAGE(
291 p_severity => FND_LOG.level_procedure,
292 p_module => C_MODULE,
293 p_msg_text => 'Begin Procedure');
294 END IF;
295
296 IF FND_LOG.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
297 FEM_ENGINES_PKG.TECH_MESSAGE(
298 p_severity => FND_LOG.level_statement,
299 p_module => C_MODULE,
300 p_msg_text => 'p_event_name = '||p_event_name);
301 FEM_ENGINES_PKG.TECH_MESSAGE(
302 p_severity => FND_LOG.level_statement,
303 p_module => C_MODULE,
304 p_msg_text => 'p_request_id = '||to_char(p_request_id));
305 FEM_ENGINES_PKG.TECH_MESSAGE(
306 p_severity => FND_LOG.level_statement,
307 p_module => C_MODULE,
308 p_msg_text => 'p_object_id = '||to_char(p_object_id));
309 FEM_ENGINES_PKG.TECH_MESSAGE(
310 p_severity => FND_LOG.level_statement,
311 p_module => C_MODULE,
312 p_msg_text => 'p_status = '||p_status);
313 END IF;
314
315 -- First check to make sure if this rule execution belongs to
316 -- any of specials rules where the same rule can be executed
317 -- repeatedly, for the same parameter set.
318 -- If yes, then skip for all where FEM_PL_OBJECT_EXECUTIONS.display_flag
319 -- is N to avoid duplicate events being raised when Undoing the "same"
320 -- rule execution.
321 BEGIN
322 SELECT nvl(display_flag,'Y')
323 INTO v_display_flag
324 FROM fem_pl_object_executions
325 WHERE request_id = p_request_id
326 AND object_id = p_object_id;
327 EXCEPTION
328 WHEN others THEN
329 v_display_flag := 'Y';
330 END;
331
332 IF v_display_flag = 'N' THEN
333 RETURN; -- Not the best programming style, but beats one huge IF stmt
334 END IF;
335
336 -- Only reset the workflow parameter list when the event being raised
337 -- is the first event: 'oracle.apps.fem.ud.submit'.
338 -- Otherwise, just add status to the list and raise the event:
339 -- 'oracle.apps.fem.ud.complete'
340 IF p_event_name = 'oracle.apps.fem.ud.submit' THEN
341
342 pv_parameter_list.DELETE;
343 pv_parameter_list := wf_parameter_list_t();
344
345 -- **************************************************************
346 -- ** Retrieve notification parameters
347 -- **************************************************************
348
349 -- Retrieve object execution parameters
350 BEGIN
351 SELECT cal_period_id, ledger_id, output_dataset_code,
352 creation_date, source_system_code
353 INTO v_cal_period_id, v_ledger_id, v_output_dataset_code,
354 v_object_execution_date, v_source_system_code
355 FROM fem_pl_requests
356 WHERE request_id = p_request_id;
357 EXCEPTION WHEN NO_DATA_FOUND THEN NULL;
358 END;
359
360 -- Retrieve Object Name
361 BEGIN
362 SELECT object_name
363 INTO v_object_name
364 FROM fem_object_catalog_vl
365 WHERE object_id = p_object_id;
366 EXCEPTION WHEN NO_DATA_FOUND THEN
367 v_object_name := 'OBJECT_ID:'||p_object_id;
368 END;
369
370 -- Retrieve Calendar Period
371 BEGIN
372 SELECT calendar_id, cal_period_name
373 INTO v_calendar_id, v_cal_period_name
374 FROM fem_cal_periods_vl
375 WHERE cal_period_id = v_cal_period_id;
376 EXCEPTION WHEN NO_DATA_FOUND THEN NULL;
377 END;
378
379 -- Retrieve Dataset
380 BEGIN
381 SELECT dataset_display_code, dataset_name
382 INTO v_dataset_display_code, v_dataset_name
383 FROM fem_datasets_vl
384 WHERE dataset_code = v_output_dataset_code;
385 EXCEPTION WHEN NO_DATA_FOUND THEN NULL;
386 END;
387
388 -- Retrieve Ledger
389 BEGIN
390 SELECT ledger_display_code, ledger_name
391 INTO v_ledger_display_code, v_ledger_name
392 FROM fem_ledgers_vl
393 WHERE ledger_id = v_ledger_id;
394 EXCEPTION WHEN NO_DATA_FOUND THEN NULL;
395 END;
396
397 -- Retrieve Source System
398 BEGIN
399 SELECT source_system_display_code, source_system_name
400 INTO v_source_system_display_code, v_source_system_name
401 FROM fem_source_systems_vl
402 WHERE source_system_code = v_source_system_code;
403 EXCEPTION WHEN NO_DATA_FOUND THEN NULL;
404 END;
405
406 -- Retrieve Calendar
407 BEGIN
408 SELECT calendar_display_code, calendar_name
409 INTO v_calendar_display_code, v_calendar_name
410 FROM fem_calendars_vl
411 WHERE calendar_id = v_calendar_id;
412 EXCEPTION WHEN NO_DATA_FOUND THEN NULL;
413 END;
414
415 -- **************************************************************
416 -- ** Add notification parameters to workflow parameter list.
417 -- **************************************************************
418 wf_event.AddParameterToList(
419 p_name=>'SUBMITTER_NAME',
420 p_value=>fnd_global.user_name,
421 p_parameterlist=>pv_parameter_list
422 );
423
424 wf_event.AddParameterToList(
425 p_name=>'UNDO_REQUEST_ID',
426 p_value=> pv_request_id,
427 p_parameterlist=>pv_parameter_list
428 );
429
430 wf_event.AddParameterToList(
431 p_name=>'RULE_REQUEST_ID',
432 p_value=> p_request_id,
433 p_parameterlist=>pv_parameter_list
434 );
435
436 wf_event.AddParameterToList(
437 p_name=>'RULE_OBJECT_NAME',
438 p_value=> v_object_name,
439 p_parameterlist=>pv_parameter_list
440 );
441
442 wf_event.AddParameterToList(
443 p_name=>'DATASET_CODE',
444 p_value=> v_output_dataset_code,
445 p_parameterlist=>pv_parameter_list
446 );
447
448 wf_event.AddParameterToList(
449 p_name=>'DATASET_DISPLAY_CODE',
450 p_value=> v_dataset_display_code,
451 p_parameterlist=>pv_parameter_list
452 );
453
454 wf_event.AddParameterToList(
455 p_name=>'DATASET_NAME',
456 p_value=> v_dataset_name,
457 p_parameterlist=>pv_parameter_list
458 );
459
460 wf_event.AddParameterToList(
461 p_name=>'LEDGER_ID',
462 p_value=> v_ledger_id,
463 p_parameterlist=>pv_parameter_list
464 );
465
466 wf_event.AddParameterToList(
467 p_name=>'LEDGER_DISPLAY_CODE',
468 p_value=> v_ledger_display_code,
469 p_parameterlist=>pv_parameter_list
470 );
471
472 wf_event.AddParameterToList(
473 p_name=>'LEDGER_NAME',
474 p_value=> v_ledger_name,
475 p_parameterlist=>pv_parameter_list
476 );
477
478 wf_event.AddParameterToList(
479 p_name=>'CAL_PERIOD_ID',
480 p_value=> v_cal_period_id,
481 p_parameterlist=>pv_parameter_list
482 );
483
484 wf_event.AddParameterToList(
485 p_name=>'CAL_PERIOD_NAME',
486 p_value=> v_cal_period_name,
487 p_parameterlist=>pv_parameter_list
488 );
489
490 wf_event.AddParameterToList(
491 p_name=>'CALENDAR_NAME',
492 p_value=> v_calendar_name,
493 p_parameterlist=>pv_parameter_list
494 );
495
496 wf_event.AddParameterToList(
497 p_name=>'CALENDAR_DISPLAY_CODE',
498 p_value=> v_calendar_display_code,
499 p_parameterlist=>pv_parameter_list
500 );
501
502 wf_event.AddParameterToList(
503 p_name=>'SOURCE_SYSTEM_CODE',
504 p_value=> v_source_system_code,
505 p_parameterlist=>pv_parameter_list
506 );
507
508 wf_event.AddParameterToList(
509 p_name=>'SOURCE_SYSTEM_DISPLAY_CODE',
510 p_value=> v_source_system_display_code,
511 p_parameterlist=>pv_parameter_list
512 );
513
514 wf_event.AddParameterToList(
515 p_name=>'SOURCE_SYSTEM_NAME',
516 p_value=> v_source_system_name,
517 p_parameterlist=>pv_parameter_list
518 );
519
520 wf_event.AddParameterToList(
521 p_name=>'OBJECT_EXECUTION_DATE',
522 p_value=>FND_DATE.date_to_canonical(v_object_execution_date),
523 p_parameterlist=>pv_parameter_list
524 );
525
526 ELSIF p_event_name = 'oracle.apps.fem.ud.complete' THEN
527 -- Send completion notification
528 wf_event.AddParameterToList(
529 p_name=>'STATUS',
530 p_value=> p_status,
531 p_parameterlist=>pv_parameter_list
532 );
533
534 ELSE
535 RAISE e_unexp_error;
536
537 END IF; -- p_event_name = 'oracle.apps.fem.ud.submit'
538
539
540 -- **************************************************************
541 -- ** Raise notification event
542 -- **************************************************************
543
544 wf_event.raise(
545 p_event_name => p_event_name,
546 p_event_key => 'FEMUNDO_SUBMIT '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'),
547 p_parameters => pv_parameter_list
548 );
549
550 COMMIT;
551
552 IF FND_LOG.level_procedure >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
553 FEM_ENGINES_PKG.TECH_MESSAGE(
554 p_severity => FND_LOG.level_procedure,
555 p_module => C_MODULE,
556 p_msg_text => 'End Procedure');
557 END IF;
558 --
559 EXCEPTION WHEN OTHERS THEN
560
561 FEM_ENGINES_PKG.Tech_Message
562 (p_severity => pc_log_level_unexpected,
563 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
564 p_msg_text => SQLERRM);
565
566 FEM_ENGINES_PKG.Tech_Message
567 (p_severity => pc_log_level_unexpected,
568 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
569 p_msg_text => dbms_utility.format_call_stack);
570
571 END raise_undo_business_event;
572
573 -- ******************************************************************************
574 PROCEDURE delete_execution_log (x_return_status OUT NOCOPY VARCHAR2,
575 x_msg_count OUT NOCOPY NUMBER,
576 x_msg_data OUT NOCOPY VARCHAR2,
577 p_api_version IN NUMBER,
578 p_commit IN VARCHAR2,
579 p_request_id IN NUMBER,
580 p_object_id IN NUMBER) AS
581
582 -- ============================================================================
583 -- PRIVATE
584 -- This procedure removes an execution log from the FEM_PL_xxx tables. It
585 -- drops all temporary objects created by the object execution whose log is
586 -- being removed, then deletes the execution log from the FEM_PL_xxx tables.
587 -- ============================================================================
588
589 c_api_name CONSTANT VARCHAR2(30) := 'delete_execution_log';
590 c_api_version CONSTANT NUMBER := 1.0;
591 v_count_tmpobjs NUMBER := 0;
592 v_object_type_code FEM_OBJECT_TYPES.object_type_code%TYPE;
593 v_pb_object_id FEM_OBJECT_CATALOG_B.object_id%TYPE;
594
595 -- This cursor retrieves all temporary objects created by the object execution.
596 CURSOR c3 IS
597 SELECT object_name, object_type
598 FROM fem_pl_temp_objects
599 WHERE request_id = p_request_id
600 AND object_id = p_object_id
601 ORDER BY object_type, object_name;
602
603
604 BEGIN
605
606 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
607 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
608 p_msg_text => 'Begin. P_REQUEST_ID:'||p_request_id||
609 ' P_OBJECT_ID: '||p_object_id);
610
611 -- Standard Start of API savepoint
612 SAVEPOINT delete_execution_log_pub;
613
614 -- Standard call to check for call compatibility.
615 IF NOT FND_API.Compatible_API_Call (c_api_version,
616 p_api_version,
617 c_api_name,
618 pc_pkg_name)
619 THEN
620 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
621 END IF;
622
623 -- Initialize API return status to success
624 x_return_status := pc_ret_sts_success;
625
626 SELECT object_type_code
627 INTO v_object_type_code
628 FROM fem_object_catalog_b
629 WHERE object_id = p_object_id;
630
631 -- ============================================================================
632 -- STEP 1:
633 -- Drop objects listed in FEM_PL_TEMP_OBJECTS
634 -- If an object is not found, a message is posted and the loop continues
635 -- to drop the remaining objects.
636 -- ============================================================================
637 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
638 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
639 p_msg_text => 'STEP 1: Drop objects listed in FEM_PL_TEMP_OBJECTS.');
640
641 FOR tmpobj IN c3 LOOP
642
643 v_count_tmpobjs := c3%ROWCOUNT;
644
645 -- If rule type of "p_object_id" is MAPPING_PREVIEW" use
646 -- its associated MAPPING_RULE to get the Process Behavior Parameters.
647 IF v_object_type_code = 'MAPPING_PREVIEW' THEN
648 SELECT object_id
649 INTO v_pb_object_id
650 FROM fem_objdef_helper_rules
651 WHERE helper_object_id = p_object_id
652 AND helper_object_type_code = 'MAPPING_PREVIEW';
653 ELSE
654 v_pb_object_id := p_object_id;
655 END IF;
656
657 FEM_DATABASE_UTIL_PKG.Drop_Temp_DB_Objects (
658 p_init_msg_list => FND_API.G_FALSE,
659 p_commit => FND_API.G_FALSE,
660 p_encoded => FND_API.G_TRUE,
661 x_return_status => x_return_status,
662 x_msg_count => x_msg_count,
663 x_msg_data => x_msg_data,
664 p_request_id => p_request_id,
665 p_object_id => p_object_id,
666 p_pb_object_id => v_pb_object_id);
667
668 IF x_return_status <> pc_ret_sts_success THEN
669 FEM_ENGINES_PKG.tech_message(p_severity => pc_log_level_statement,
670 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
671 p_msg_text => 'FEM_DATABASE_UTIL_PKG.Drop_Temp_DB_Objects '
672 ||'failed with return status of: '||x_return_status);
673
674 RAISE e_unexp_error;
675 END IF;
676
677 END LOOP;
678
679 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
680 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
681 p_msg_text => 'Number of temporary objects found in FEM_TEMP_OBJECTS: '||v_count_tmpobjs);
682
683 -- ============================================================================
684 -- STEP 2:
685 -- Delete object execution from process lock tables (FEM_PL_xxxx).
686 -- ============================================================================
687 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
688 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
689 p_msg_text => 'STEP 2: Delete object execution from process lock tables (FEM_PL_xxxx).');
690
691 DELETE fem_pl_temp_objects
692 WHERE request_id = p_request_id
693 AND object_id = p_object_id;
694
695 -- Bug 4382068: Only remove data edit locks if object is of type
696 -- 'OGL_INTG_CAL_RULE','OGL_INTG_DIM_RULE','OGL_INTG_HIER_RULE'
697 IF v_object_type_code IN ('OGL_INTG_CAL_RULE','OGL_INTG_DIM_RULE',
698 'OGL_INTG_HIER_RULE') THEN
699 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
700 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
701 p_msg_text => 'Object type is: '||v_object_type_code||'. Only remove edit locks.');
702
703 -- Remove all defs for the object, regardless of the request
704 -- because these OGL rules can be run again and again
705 -- but Undo only displays the last execution in the conc program UI.
706 DELETE fem_pl_object_defs
707 WHERE object_id = p_object_id;
708
709 -- Once "undone", these rule executions should no longer show up
710 -- in the Undo CM UI.
711 UPDATE fem_pl_object_executions
712 SET display_flag = 'N'
713 WHERE object_id = p_object_id
714 AND display_flag = 'Y';
715 ELSE
716 DELETE fem_pl_obj_exec_steps
717 WHERE request_id = p_request_id
718 AND object_id = p_object_id;
719
720 DELETE fem_pl_tab_updated_cols
721 WHERE request_id = p_request_id
722 AND object_id = p_object_id;
723
724 DELETE fem_pl_tables
725 WHERE request_id = p_request_id
726 AND object_id = p_object_id;
727
728 DELETE fem_pl_chains
729 WHERE request_id = p_request_id
730 AND object_id = p_object_id;
731
732 DELETE fem_pl_object_defs
733 WHERE request_id = p_request_id
734 AND object_id = p_object_id;
735
736 DELETE fem_pl_object_executions
737 WHERE request_id = p_request_id
738 AND object_id = p_object_id;
739
740 -- Only delete request if there are no other executions
741 -- for that request.
742 DELETE fem_pl_requests
743 WHERE request_id = p_request_id
744 AND request_id NOT IN
745 (select request_id FROM fem_pl_object_executions);
746 END IF; -- OGL object type
747
748 IF FND_API.To_Boolean( p_commit ) THEN
749 COMMIT WORK;
750 END IF;
751
752 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
753 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
754 p_msg_text => 'End. X_RETURN_STATUS: '||x_return_status);
755
756 FND_MSG_PUB.Count_And_Get
757 (p_count => x_msg_count,
758 p_data => x_msg_data);
759
760 EXCEPTION
761 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
762 ROLLBACK TO delete_execution_log_pub;
763 x_return_status := pc_ret_sts_unexp_error;
764
765 fem_engines_pkg.tech_message(p_severity => pc_log_level_unexpected,
766 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
767 p_app_name =>'FEM',
768 p_msg_name => 'FEM_BAD_P_API_VER_ERR',p_token1 => 'VALUE',
769 p_value1 => p_api_version, p_trans1 => 'N');
770
771 fem_engines_pkg.put_message(
772 p_app_name =>'FEM',
773 p_msg_name => 'FEM_BAD_P_API_VER_ERR',p_token1 => 'VALUE',
774 p_value1 => p_api_version, p_trans1 => 'N');
775
776 FND_MSG_PUB.Count_And_Get
777 (p_count => x_msg_count,
778 p_data => x_msg_data);
779
780 WHEN OTHERS THEN
781 -- Unexpected exceptions
782 x_return_status := pc_ret_sts_unexp_error;
783
784 -- Log the call stack and the Oracle error message to
785 -- FND_LOG with the "unexpected exception" severity level.
786
787 FEM_ENGINES_PKG.Tech_Message
788 (p_severity => pc_log_level_unexpected,
789 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
790 p_msg_text => SQLERRM);
791
792 FEM_ENGINES_PKG.Tech_Message
793 (p_severity => pc_log_level_unexpected,
794 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
795 p_msg_text => dbms_utility.format_call_stack);
796
797 -- Log the Oracle error message to the stack.
798 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
799 p_msg_name => 'FEM_UNEXPECTED_ERROR',
800 P_TOKEN1 => 'ERR_MSG',
801 P_VALUE1 => SQLERRM);
802
803 FND_MSG_PUB.Count_And_Get
804 (p_count => x_msg_count,
805 p_data => x_msg_data);
806
807 ROLLBACK TO delete_execution_log_pub;
808 END delete_execution_log;
809 -- ****************************************************************************
810
811 -- ***************************************************************************
812 -- Private procedure bodies:
813 -- ***************************************************************************
814
815 -- ****************************************************************************
816 PROCEDURE create_undo_list (x_undo_list_obj_id OUT NOCOPY NUMBER,
817 x_undo_list_obj_def_id OUT NOCOPY NUMBER,
818 x_return_status OUT NOCOPY VARCHAR2,
819 x_msg_count OUT NOCOPY NUMBER,
820 x_msg_data OUT NOCOPY VARCHAR2,
821 p_api_version IN NUMBER,
822 p_commit IN VARCHAR2,
823 p_undo_list_name IN VARCHAR2,
824 p_folder_id IN NUMBER,
825 p_include_dependencies_flag IN VARCHAR2,
826 p_ignore_dependency_errs_flag IN VARCHAR2,
827 p_execution_date IN DATE) AS
828 -- ============================================================================
829 -- PUBLIC
830 -- This procedure is used to create an undo list.
831 -- ============================================================================
832
833 c_api_name CONSTANT VARCHAR2(30) := 'create_undo_list';
834 c_api_version CONSTANT NUMBER := 1.0;
835
836 BEGIN
837
838 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
839 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
840 p_msg_text => 'Begin. P_COMMIT:'||p_commit||
841 ' P_UNDO_LIST_NAME: '||p_undo_list_name||
842 ' P_FOLDER_ID: '||p_folder_id||
843 ' P_INCLUDE_DEPENDENCIES_FLAG: '||p_include_dependencies_flag||
844 ' P_IGNORE_DEPENDENCY_ERRS_FLAG:'||p_ignore_dependency_errs_flag||
845 ' P_EXECUTION_DATE:'||fnd_date.date_to_displaydate(p_execution_date));
846
847 -- Standard Start of API savepoint
848 SAVEPOINT create_undo_list_pub;
849
850 -- Standard call to check for call compatibility.
851 IF NOT FND_API.Compatible_API_Call (c_api_version,
852 p_api_version,
853 c_api_name,
854 pc_pkg_name)
855 THEN
856 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
857 END IF;
858
859 -- Initialize API return status to success
860 x_return_status := pc_ret_sts_success;
861
862 -- ============================================================================
863 -- Validate parameters
864 -- If p_execution_date is null, it is set to sysdate - so no need to validate it
865 -- It is assumed that p_folder_id is validated in the user interface. It is
866 -- also validated in fem_object_catalog_util_pkg.create_object.
867 -- ============================================================================
868 IF p_undo_list_name IS NULL THEN
869 RAISE e_null_undo_list_name;
870 ELSIF p_include_dependencies_flag NOT IN ('Y','N') THEN
871 RAISE e_invalid_dependencies_flag;
872 ELSIF p_ignore_dependency_errs_flag NOT IN ('Y','N') THEN
873 RAISE e_invalid_dependency_errs_flag;
874 ELSIF p_commit NOT IN (FND_API.G_FALSE, FND_API.G_TRUE) THEN
875 RAISE e_invalid_p_commit;
876 END IF;
877
878 -- ============================================================================
879 -- Create object and object definition
880 -- ============================================================================
881 fem_object_catalog_util_pkg.create_object(p_api_version => 1.0,
882 p_commit => FND_API.G_FALSE,
883 p_object_type_code => 'UNDO',
884 p_folder_id => pc_undo_folder_id,
885 p_local_vs_combo_id => NULL,
886 p_object_access_code => 'W',
887 p_object_origin_code => 'USER',
888 p_object_name => p_undo_list_name,
889 p_description => p_undo_list_name,
890 p_effective_start_date => sysdate,
891 p_effective_end_date => to_date('9999/01/01','YYYY/MM/DD'),
892 p_obj_def_name => p_undo_list_name,
893 x_object_id => x_undo_list_obj_id,
894 x_object_definition_id => x_undo_list_obj_def_id,
895 x_msg_count => x_msg_count,
896 x_msg_data => x_msg_data,
897 x_return_status => x_return_status);
898
899 IF x_return_status = pc_ret_sts_success THEN
900 -- ============================================================================
901 -- Create list header in FEM_UD_LISTS
902 -- ============================================================================
903
904 INSERT INTO fem_ud_lists (undo_list_obj_def_id ,include_dependencies_flag ,
905 ignore_dependency_errs_flag,execution_date,
906 object_version_number,created_by,creation_date,
907 last_updated_by,last_update_date,last_update_login)
908 VALUES(x_undo_list_obj_def_id ,p_include_dependencies_flag ,
909 p_ignore_dependency_errs_flag,NVL(p_execution_date,sysdate)
910 ,1,pv_apps_user_id,sysdate,pv_apps_user_id,sysdate,pv_login_id);
911
912 ELSE
913 RAISE e_cannot_create_object;
914 END IF;
915
916
917 IF FND_API.To_Boolean( p_commit ) THEN
918 COMMIT WORK;
919 END IF;
920
921 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
922 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
923 p_msg_text => 'End. x_return_status: '||x_return_status||
924 ' x_undo_list_obj_id:'||x_undo_list_obj_id||
925 ' x_undo_list_obj_def_id'||x_undo_list_obj_def_id);
926
927 EXCEPTION
928 WHEN e_null_undo_list_name THEN
929 x_return_status := pc_ret_sts_error;
930
931 fem_engines_pkg.put_message(p_app_name =>'FEM',
932 p_msg_name => 'FEM_UD_NULL_LIST_NAME_ERR');
933
934 FND_MSG_PUB.Count_And_Get
935 (p_count => x_msg_count,
936 p_data => x_msg_data);
937 WHEN e_invalid_dependencies_flag THEN
938 x_return_status := pc_ret_sts_error;
939
940 fem_engines_pkg.put_message(p_app_name =>'FEM',
941 p_msg_name => 'FEM_UD_BAD_DEPENDENCIES_ERR');
942
943 FND_MSG_PUB.Count_And_Get
944 (p_count => x_msg_count,
945 p_data => x_msg_data);
946 WHEN e_invalid_dependency_errs_flag THEN
947 x_return_status := pc_ret_sts_error;
948
949 fem_engines_pkg.put_message(p_app_name =>'FEM',
950 p_msg_name => 'FEM_UD_BAD_DEP_ERRS_ERR');
951
952 FND_MSG_PUB.Count_And_Get
953 (p_count => x_msg_count,
954 p_data => x_msg_data);
955 WHEN e_invalid_p_commit THEN
956 x_return_status := pc_ret_sts_error;
957
958 fem_engines_pkg.put_message(p_app_name =>'FEM',
959 p_msg_name => 'FEM_BAD_P_COMMIT_ERR');
960
961 FND_MSG_PUB.Count_And_Get
962 (p_count => x_msg_count,
963 p_data => x_msg_data);
964 WHEN e_cannot_create_object THEN
965 ROLLBACK TO create_undo_list_pub;
966 x_return_status := pc_ret_sts_error;
967
968 fem_engines_pkg.put_message(p_app_name =>'FEM',
969 p_msg_name => 'FEM_CANNOT_CREATE_OBJ_ERR');
970
971 FND_MSG_PUB.Count_And_Get
972 (p_count => x_msg_count,
973 p_data => x_msg_data);
974
975 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
976 ROLLBACK TO create_undo_list_pub;
977 x_return_status := pc_ret_sts_unexp_error;
978
979 fem_engines_pkg.tech_message(p_severity => pc_log_level_unexpected,
980 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
981 p_app_name =>'FEM',
982 p_msg_name => 'FEM_BAD_P_API_VER_ERR',p_token1 => 'VALUE',
983 p_value1 => p_api_version, p_trans1 => 'N');
984
985 WHEN OTHERS THEN
986 -- Unexpected exceptions
987 x_return_status := pc_ret_sts_unexp_error;
988
989 -- Log the call stack and the Oracle error message to
990 -- FND_LOG with the "unexpected exception" severity level.
991
992 FEM_ENGINES_PKG.Tech_Message
993 (p_severity => pc_log_level_unexpected,
994 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
995 p_msg_text => SQLERRM);
996
997 FEM_ENGINES_PKG.Tech_Message
998 (p_severity => pc_log_level_unexpected,
999 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1000 p_msg_text => dbms_utility.format_call_stack);
1001
1002 -- Log the Oracle error message to the stack.
1003 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
1004 p_msg_name => 'FEM_UNEXPECTED_ERROR',
1005 P_TOKEN1 => 'ERR_MSG',
1006 P_VALUE1 => SQLERRM);
1007 ROLLBACK TO create_undo_list_pub;
1008
1009 END create_undo_list;
1010 -- *****************************************************************************
1011 PROCEDURE delete_undo_list (x_return_status OUT NOCOPY VARCHAR2,
1012 x_msg_count OUT NOCOPY NUMBER,
1013 x_msg_data OUT NOCOPY VARCHAR2,
1014 p_api_version IN NUMBER,
1015 p_commit IN VARCHAR2,
1016 p_undo_list_obj_id IN NUMBER) AS
1017
1018 -- ============================================================================
1019 -- PUBLIC
1020 -- This procedure is used to delete an undo list.
1021 -- ============================================================================
1022 c_api_name CONSTANT VARCHAR2(30) := 'delete_undo_list';
1023 c_api_version CONSTANT NUMBER := 1.0;
1024 v_undo_list_obj_def_id NUMBER;
1025 v_undo_list_exec_successfully VARCHAR2(1);
1026 v_count NUMBER;
1027
1028 BEGIN
1029
1030 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
1031 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1032 p_msg_text => 'Begin. P_COMMIT:'||p_commit||
1033 ' P_UNDO_LIST_OBJ_ID: '||p_undo_list_obj_id);
1034
1035 -- Standard Start of API savepoint
1036 SAVEPOINT delete_undo_list_pub;
1037
1038 -- Standard call to check for call compatibility.
1039 IF NOT FND_API.Compatible_API_Call (c_api_version,
1040 p_api_version,
1041 c_api_name,
1042 pc_pkg_name)
1043 THEN
1044 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1045 END IF;
1046
1047 -- Initialize API return status to success
1048 x_return_status := pc_ret_sts_success;
1049
1050 -- ============================================================================
1051 -- V01: Check to see if p_undo_list_obj_id is for a valid undo list.
1052 -- ============================================================================
1053 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
1054 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1055 p_msg_text => 'V01: Check to see if p_undo_list_obj_id is for a valid undo list.');
1056
1057 BEGIN
1058
1059 SELECT object_definition_id
1060 INTO v_undo_list_obj_def_id
1061 FROM fem_object_catalog_b o, fem_object_definition_b d
1062 WHERE o.object_id = p_undo_list_obj_id
1063 AND o.object_type_code = 'UNDO'
1064 AND o.object_id = d.object_id;
1065
1066
1067 EXCEPTION WHEN NO_DATA_FOUND THEN
1068 RAISE e_invalid_undo_list;
1069 END;
1070
1071 -- ============================================================================
1072 -- V02: Check to see if user list may be deleted (ie. check to make sure all
1073 -- candidates and dependents in the list have been processed successfully).
1074 -- ============================================================================
1075 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
1076 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1077 p_msg_text => 'V02: Check to see if user list may be deleted.');
1078
1079 SELECT DECODE(count(*),0,'Y','N') INTO v_undo_list_exec_successfully
1080 FROM (select exec_status_code
1081 from fem_ud_list_candidates
1082 where undo_list_obj_def_id = v_undo_list_obj_def_id
1083 and exec_status_code IS NOT NULL
1084 and exec_status_code <> 'SUCCESS'
1085 UNION
1086 select exec_status_code
1087 from fem_ud_list_dependents
1088 where undo_list_obj_def_id = v_undo_list_obj_def_id
1089 and exec_status_code IS NOT NULL
1090 and exec_status_code <> 'SUCCESS'
1091 UNION
1092 select exec_status_code
1093 from fem_ud_lists
1094 where undo_list_obj_def_id = v_undo_list_obj_def_id
1095 and exec_status_code IS NOT NULL
1096 and exec_status_code <> 'SUCCESS');
1097
1098
1099 IF v_undo_list_exec_successfully = 'N' THEN
1100
1101 RAISE e_undo_list_exec_not_success;
1102
1103 END IF;
1104
1105 -- ============================================================================
1106 -- Delete object and object definition (delete_object
1107 -- procedure checks for locks to make sure that
1108 -- object can be deleted before deletion. This procedure also checks to
1109 -- make sure that the user has write access to the folder before deleting
1110 -- object.)
1111 -- ============================================================================
1112
1113 fem_object_catalog_util_pkg.delete_object(p_api_version => 1.0,
1114 p_commit => FND_API.G_FALSE,
1115 p_object_id => p_undo_list_obj_id,
1116 x_msg_count => x_msg_count,
1117 x_msg_data => x_msg_data,
1118 x_return_status => x_return_status);
1119
1120 IF x_return_status = pc_ret_sts_success THEN
1121 -- ============================================================================
1122 -- If the object and its definition were deleted successfully, then
1123 -- delete the list from all the undo tables.
1124 -- ============================================================================
1125
1126 DELETE fem_ud_list_dependents
1127 WHERE undo_list_obj_def_id = v_undo_list_obj_def_id;
1128
1129 DELETE fem_ud_list_candidates
1130 WHERE undo_list_obj_def_id = v_undo_list_obj_def_id;
1131
1132 DELETE fem_ud_lists
1133 WHERE undo_list_obj_def_id = v_undo_list_obj_def_id;
1134
1135 ELSE
1136 RAISE e_cannot_delete_object;
1137 END IF;
1138
1139
1140 IF FND_API.To_Boolean( p_commit ) THEN
1141 COMMIT WORK;
1142 END IF;
1143
1144 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
1145 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1146 p_msg_text => 'End. X_RETURN_STATUS: '||x_return_status);
1147
1148 FND_MSG_PUB.Count_And_Get
1149 (p_count => x_msg_count,
1150 p_data => x_msg_data);
1151
1152 EXCEPTION
1153 WHEN e_invalid_undo_list THEN
1154 x_return_status := pc_ret_sts_error;
1155 ROLLBACK;
1156 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
1157 p_msg_name => 'FEM_UD_INVALID_UNDO_LIST_ERR',
1158 p_token1 => 'OBJECT_ID',
1159 p_value1 => p_undo_list_obj_id,
1160 p_trans1 => 'N');
1161
1162 FND_MSG_PUB.Count_And_Get
1163 (p_count => x_msg_count,
1164 p_data => x_msg_data);
1165
1166 WHEN e_undo_list_exec_not_success THEN
1167 ROLLBACK TO delete_undo_list_pub;
1168 x_return_status := pc_ret_sts_error;
1169
1170 fem_engines_pkg.put_message(p_app_name =>'FEM',
1171 p_msg_name => 'FEM_UD_LIST_EXEC_INCOMPLT_ERR');
1172
1173 FND_MSG_PUB.Count_And_Get
1174 (p_count => x_msg_count,
1175 p_data => x_msg_data);
1176
1177 WHEN e_cannot_delete_object THEN
1178 ROLLBACK TO delete_undo_list_pub;
1179 x_return_status := pc_ret_sts_error;
1180
1181 fem_engines_pkg.put_message(p_app_name =>'FEM',
1182 p_msg_name => 'FEM_CANNOT_DELETE_OBJ_ERR',p_token1 => 'OBJECT',
1183 p_value1 => p_undo_list_obj_id, p_trans1 => 'N');
1184
1185 FND_MSG_PUB.Count_And_Get
1186 (p_count => x_msg_count,
1187 p_data => x_msg_data);
1188
1189 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1190 ROLLBACK TO delete_undo_list_pub;
1191 x_return_status := pc_ret_sts_unexp_error;
1192
1193 fem_engines_pkg.tech_message(p_severity => pc_log_level_unexpected,
1194 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1195 p_app_name =>'FEM',
1196 p_msg_name => 'FEM_BAD_P_API_VER_ERR',p_token1 => 'VALUE',
1197 p_value1 => p_api_version, p_trans1 => 'N');
1198
1199 WHEN OTHERS THEN
1200 -- Unexpected exceptions
1201 x_return_status := pc_ret_sts_unexp_error;
1202
1203 -- Log the call stack and the Oracle error message to
1204 -- FND_LOG with the "unexpected exception" severity level.
1205
1206 FEM_ENGINES_PKG.Tech_Message
1207 (p_severity => pc_log_level_unexpected,
1208 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1209 p_msg_text => SQLERRM);
1210
1211 FEM_ENGINES_PKG.Tech_Message
1212 (p_severity => pc_log_level_unexpected,
1213 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1214 p_msg_text => dbms_utility.format_call_stack);
1215
1216 -- Log the Oracle error message to the stack.
1217 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
1218 p_msg_name => 'FEM_UNEXPECTED_ERROR',
1219 P_TOKEN1 => 'ERR_MSG',
1220 P_VALUE1 => SQLERRM);
1221
1222 ROLLBACK TO delete_undo_list_pub;
1223
1224 END delete_undo_list;
1225 -- *****************************************************************************
1226 PROCEDURE add_candidate (x_return_status OUT NOCOPY VARCHAR2,
1227 x_msg_count OUT NOCOPY NUMBER,
1228 x_msg_data OUT NOCOPY VARCHAR2,
1229 p_api_version IN NUMBER,
1230 p_commit IN VARCHAR2,
1231 p_undo_list_obj_def_id IN NUMBER,
1232 p_request_id IN NUMBER,
1233 p_object_id IN NUMBER) AS
1234
1235 -- ============================================================================
1236 -- PUBLIC
1237 -- This procedure is used to add an object execution to an undo list.
1238 -- ============================================================================
1239 c_api_name CONSTANT VARCHAR2(30) := 'add_candidate';
1240 c_api_version CONSTANT NUMBER := 1.0;
1241 v_approval_edit_lock_exists VARCHAR2(1);
1242 v_data_edit_lock_exists VARCHAR2(1);
1243 v_undo_list_ever_executed VARCHAR2(1);
1244 v_dependency_type VARCHAR2(30);
1245 v_include_dependencies_flag VARCHAR2(1);
1246 v_ignore_dependency_errs_flag VARCHAR2(1);
1247 v_count NUMBER;
1248 v_exec_status_code VARCHAR2(30);
1249 v_obj_def_name FEM_OBJECT_DEFINITION_TL.display_name%TYPE;
1250 v_object_name FEM_OBJECT_CATALOG_TL.object_name%TYPE;
1251
1252 -- This cursor retrieves the snapshot and all other incremental loads that make
1253 -- up a GL load.
1254 -- 10-AUG-04 KFN - The cursor also retrieves all RCM Process Rule executions
1255 -- that have the same ledger, calendar period and dataset code as the current
1256 -- candidate.
1257 -- Bug 4382591: Also retrieve all DataX and Client Data Loader rule
1258 -- executions to the list that have the same ledger, calendar period,
1259 -- dataset code and source system as the current candidate.
1260 -- Bug 5011140 (FP:4596447): Also retrieve all TP Process Rule executions.
1261 CURSOR c1 IS
1262 SELECT pl.request_id, pl.object_id
1263 FROM fem_pl_object_executions pl, fem_object_catalog_b o, fem_pl_requests r1, fem_pl_requests r2
1264 WHERE pl.object_id = o.object_id
1265 AND o.object_id = p_object_id
1266 AND o.object_type_code IN ('OGL_INTG_BAL_RULE','XGL_INTEGRATION',
1267 'RCM_PROCESS_RULE','TP_PROCESS_RULE',
1268 'SOURCE_DATA_LOADER','DATAX_LOADER')
1269 AND pl.request_id = r1.request_id
1270 AND r1.request_id <> p_request_id
1271 AND r2.request_id = p_request_id
1272 AND r2.cal_period_id = r1.cal_period_id
1273 AND r2.ledger_id = r1.ledger_id
1274 AND r2.output_dataset_code = r1.output_dataset_code
1275 AND (r2.source_system_code = r1.source_system_code
1276 OR o.object_type_code IN ('OGL_INTG_BAL_RULE','XGL_INTEGRATION',
1277 'RCM_PROCESS_RULE','TP_PROCESS_RULE'));
1278
1279 BEGIN
1280
1281 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
1282 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1283 p_msg_text => 'Begin. P_COMMIT:'||p_commit||
1284 ' P_UNDO_LIST_OBJ_DEF_ID: '||p_undo_list_obj_def_id||
1285 ' P_REQUEST_ID: '||p_request_id||
1286 ' P_OBJECT_ID: '||p_object_id);
1287
1288 -- Standard Start of API savepoint
1289 SAVEPOINT add_candidate_pub;
1290
1291 -- Standard call to check for call compatibility.
1292 IF NOT FND_API.Compatible_API_Call (c_api_version,
1293 p_api_version,
1294 c_api_name,
1295 pc_pkg_name)
1296 THEN
1297 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1298 END IF;
1299
1300 -- Initialize API return status to success
1301 x_return_status := pc_ret_sts_success;
1302
1303 -- ============================================================================
1304 -- VALIDATIONS:
1305 -- ============================================================================
1306
1307 -- ============================================================================
1308 -- STEP V1: Check to see if user can execute the rule. In FEM.D, if a user
1309 -- can read a rule, then they can execute a rule.
1310 -- ============================================================================
1311 SELECT count(*) INTO v_count
1312 FROM fem_user_folders u, fem_object_catalog_b o
1313 WHERE o.object_id = p_object_id
1314 AND o.folder_id = u.folder_id
1315 AND u.user_id = pv_apps_user_id;
1316
1317 IF v_count = 0 THEN
1318 RAISE e_cannot_read_object;
1319 END IF;
1320 -- ============================================================================
1321 -- STEP V2: Check edit locks. Cannot update list if it has ever been run, or
1322 -- if it is edit locked.
1323 -- ============================================================================
1324 -- Check for edit locks. Cannot update list if it is locked.
1325 fem_pl_pkg.get_object_def_edit_locks (
1326 p_object_definition_id => p_undo_list_obj_def_id,
1327 x_approval_edit_lock_exists => v_approval_edit_lock_exists,
1328 x_data_edit_lock_exists => v_data_edit_lock_exists);
1329
1330 -- This query checks to see if the undo list has ever been run, (as
1331 -- the execution may no longer be in the PL tables).
1332 SELECT DECODE(count(*),0,'N','Y') INTO v_undo_list_ever_executed
1333 FROM (select exec_status_code
1334 from fem_ud_list_candidates
1335 where undo_list_obj_def_id = p_undo_list_obj_def_id
1336 and exec_status_code IS NOT NULL
1337 UNION
1338 select exec_status_code
1339 from fem_ud_list_dependents
1340 where undo_list_obj_def_id = p_undo_list_obj_def_id
1341 and exec_status_code IS NOT NULL
1342 UNION
1343 select exec_status_code
1344 from fem_ud_lists
1345 where undo_list_obj_def_id = p_undo_list_obj_def_id
1346 and exec_status_code IS NOT NULL);
1347
1348
1349 IF v_approval_edit_lock_exists = 'T' OR v_data_edit_lock_exists = 'T'
1350 OR v_undo_list_ever_executed = 'Y' THEN
1351 RAISE e_edit_lock_exists;
1352 END IF;
1353
1354 -- ============================================================================
1355 -- STEP V3: Check for dependencies, if ignore_dependency_errs_flag = 'N' AND
1356 -- include_dependencies_flag = 'N'.
1357 -- NOTE: This only checks for CHAIN dependencies, as UPDATE dependencies are
1358 -- ALWAYS added to the undo list.
1359 -- ============================================================================
1360 SELECT include_dependencies_flag, ignore_dependency_errs_flag,
1361 DECODE(include_dependencies_flag,'Y','ALL','UPDATE')
1362 INTO v_include_dependencies_flag, v_ignore_dependency_errs_flag,v_dependency_type
1363 FROM fem_ud_lists
1364 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id;
1365
1366 IF v_include_dependencies_flag = 'N' AND v_ignore_dependency_errs_flag = 'N'
1367 THEN
1368
1369 SELECT count(*) INTO v_count
1370 FROM fem_pl_chains
1371 WHERE source_created_by_request_id = p_request_id
1372 AND source_created_by_object_id = p_object_id;
1373
1374 IF v_count > 0 THEN
1375 RAISE e_dependencies_found;
1376 END IF;
1377 END IF;
1378
1379 -- ============================================================================
1380 -- STEP V4: Validate that the object execution is not 'RUNNING'.
1381 -- ============================================================================
1382
1383 -- Bug 6443224. If for some reason a rule is in an undo list but is
1384 -- no longer in the PL tables, the concurrent manager must have crashed
1385 -- or Undo must have been killed in mid-processing, before it
1386 -- was able to clean up the undo list.
1387 -- So, if no data found in this query, we can assume it was previously
1388 -- removed and is not currently 'RUNNING'.
1389 BEGIN
1390 SELECT exec_status_code INTO v_exec_status_code
1391 FROM fem_pl_object_executions
1392 WHERE request_id = p_request_id
1393 AND object_id = p_object_id;
1394
1395 IF v_exec_status_code = 'RUNNING' THEN
1396 -- Verify that the request is still running using fem_pl_pkg.set_exec_state
1397
1398 fem_pl_pkg.set_exec_state (p_api_version => 1.0,
1399 p_commit => p_commit,
1400 p_request_id => p_request_id,
1401 p_object_id => p_object_id,
1402 x_msg_count => x_msg_count,
1403 x_msg_data => x_msg_data,
1404 x_return_status => x_return_status);
1405
1406 IF x_msg_count > 0 THEN
1407 Get_Put_Messages(
1408 p_msg_count => x_msg_count,
1409 p_msg_data => x_msg_data,
1410 p_user_msg => 'N',
1411 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
1412 END IF;
1413 END IF;
1414
1415 SELECT exec_status_code INTO v_exec_status_code
1416 FROM fem_pl_object_executions
1417 WHERE request_id = p_request_id
1418 AND object_id = p_object_id;
1419 EXCEPTION
1420 WHEN no_data_found THEN
1421 v_exec_status_code := 'NORMAL';
1422 END;
1423
1424 IF v_exec_status_code = 'RUNNING' THEN
1425 RAISE e_objexec_is_running;
1426 END IF;
1427
1428 -- ============================================================================
1429 -- If the list has never been run, add the candidate to the list and
1430 -- generate the candidate's dependents.
1431 -- ============================================================================
1432
1433 INSERT INTO fem_ud_list_candidates (undo_list_obj_def_id,
1434 object_id, request_id, object_version_number, created_by, creation_date,
1435 last_updated_by, last_update_date, last_update_login)
1436 VALUES (p_undo_list_obj_def_id, p_object_id, p_request_id,
1437 1, pv_apps_user_id, sysdate, pv_apps_user_id, sysdate, pv_login_id);
1438
1439 generate_cand_dependents (
1440 x_return_status => x_return_status,
1441 x_msg_count => x_msg_count,
1442 x_msg_data => x_msg_data,
1443 p_api_version => 2.0,
1444 p_commit => FND_API.G_FALSE,
1445 p_undo_list_obj_def_id => p_undo_list_obj_def_id,
1446 p_request_id => p_request_id,
1447 p_object_id => p_object_id,
1448 p_dependency_type => v_dependency_type);
1449
1450 IF x_return_status <> pc_ret_sts_success THEN
1451 RAISE e_cannot_generate_dependents;
1452 END IF;
1453
1454 -- ============================================================================
1455 -- If this candidate is an OGL or XGL integration, add all its incremental loads
1456 -- and the initial snapshot to the list as candidates, and generate their dependents.
1457 -- 08/10/2004 KFN - If this candidate is an RCM Process Rule, add all executions
1458 -- of that rule that have the same calendar period, ledger and output dataset code
1459 -- to the list as candidates, and generate their dependents. (Note: c1 query
1460 -- modified to include RCM Process Rules).
1461 -- Bug 4382591: Also retrieve all DataX and Client Data Loader rule
1462 -- executions to the list that have the same ledger, calendar period,
1463 -- dataset code and source system as the current candidate.
1464 -- ============================================================================
1465 FOR an_integration_load_exec IN c1 LOOP
1466
1467 INSERT INTO fem_ud_list_candidates (undo_list_obj_def_id,
1468 object_id, request_id, object_version_number, created_by, creation_date,
1469 last_updated_by, last_update_date, last_update_login)
1470 VALUES (p_undo_list_obj_def_id, an_integration_load_exec.object_id,
1471 an_integration_load_exec.request_id, 1, pv_apps_user_id, sysdate,
1472 pv_apps_user_id, sysdate, pv_login_id);
1473
1474 generate_cand_dependents (
1475 x_return_status => x_return_status,
1476 x_msg_count => x_msg_count,
1477 x_msg_data => x_msg_data,
1478 p_api_version => 2.0,
1479 p_commit => FND_API.G_FALSE,
1480 p_undo_list_obj_def_id => p_undo_list_obj_def_id,
1481 p_request_id => an_integration_load_exec.request_id,
1482 p_object_id => an_integration_load_exec.object_id,
1483 p_dependency_type => v_dependency_type);
1484
1485 IF x_return_status <> pc_ret_sts_success THEN
1486 RAISE e_cannot_generate_dependents;
1487 END IF;
1488
1489 END LOOP;
1490
1491 IF FND_API.To_Boolean( p_commit ) THEN
1492 COMMIT WORK;
1493 END IF;
1494
1495 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
1496 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1497 p_msg_text => 'End. X_RETURN_STATUS: '||x_return_status);
1498
1499 FND_MSG_PUB.Count_And_Get
1500 (p_count => x_msg_count,
1501 p_data => x_msg_data);
1502
1503 EXCEPTION
1504 WHEN e_edit_lock_exists THEN
1505 ROLLBACK TO add_candidate_pub;
1506 x_return_status := pc_ret_sts_error;
1507
1508 IF v_data_edit_lock_exists = 'T' THEN
1509 fem_engines_pkg.put_message(p_app_name =>'FEM',
1510 p_msg_name =>'FEM_UD_LOCKED_OBJ_DEF_ERR',
1511 p_token1 => 'OBJECT_DEFINITION_ID',
1512 p_value1 => p_undo_list_obj_def_id,
1513 p_trans1 => 'N');
1514 ELSIF v_undo_list_ever_executed = 'T' THEN
1515 fem_engines_pkg.put_message(p_app_name =>'FEM',
1516 p_msg_name =>'FEM_UD_EXECUTED_OBJ_DEF_ERR',
1517 p_token1 => 'OBJECT_DEFINITION_ID',
1518 p_value1 => p_undo_list_obj_def_id,
1519 p_trans1 => 'N');
1520 ELSIF v_approval_edit_lock_exists = 'T' THEN
1521 SELECT display_name
1522 INTO v_obj_def_name
1523 FROM fem_object_definition_vl
1524 WHERE object_definition_id = p_undo_list_obj_def_id;
1525
1526 fem_engines_pkg.put_message(p_app_name =>'FEM',
1527 p_msg_name =>'FEM_PL_SUBMITTED_DEF_ERR',
1528 p_token1 => 'OBJ_DEF_NAME',
1529 p_value1 => v_obj_def_name);
1530 END IF;
1531
1532 FND_MSG_PUB.Count_And_Get
1533 (p_count => x_msg_count,
1534 p_data => x_msg_data);
1535 WHEN e_dependencies_found THEN
1536 ROLLBACK TO add_candidate_pub;
1537 x_return_status := pc_ret_sts_error;
1538
1539 BEGIN
1540 SELECT object_name
1541 INTO v_object_name
1542 FROM fem_object_catalog_vl
1543 WHERE object_id = p_object_id;
1544 EXCEPTION
1545 WHEN others THEN
1546 v_object_name := to_char(p_object_id);
1547 END;
1548
1549 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
1550 p_msg_name => 'FEM_UD_CAND_DEP_FOUND_ERR',
1551 p_token1 => 'REQUEST_ID',
1552 p_value1 => p_request_id,
1553 p_token2 => 'OBJECT_NAME',
1554 p_value2 => v_object_name);
1555
1556 FND_MSG_PUB.Count_And_Get
1557 (p_count => x_msg_count,
1558 p_data => x_msg_data);
1559
1560 WHEN e_cannot_read_object THEN
1561 ROLLBACK TO add_candidate_pub;
1562 x_return_status := pc_ret_sts_error;
1563
1564 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
1565 p_msg_name => 'FEM_UD_CANNOT_READ_OBJECT_ERR');
1566
1567 FND_MSG_PUB.Count_And_Get
1568 (p_count => x_msg_count,
1569 p_data => x_msg_data);
1570
1571 WHEN e_cannot_generate_dependents THEN
1572 ROLLBACK TO add_candidate_pub;
1573 x_return_status := pc_ret_sts_error;
1574
1575 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
1576 p_msg_name => 'FEM_UD_CANNOT_GEN_DEPENDENTS');
1577
1578 FND_MSG_PUB.Count_And_Get
1579 (p_count => x_msg_count,
1580 p_data => x_msg_data);
1581
1582 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1583 ROLLBACK TO add_candidate_pub;
1584 x_return_status := pc_ret_sts_unexp_error;
1585
1586 fem_engines_pkg.tech_message(p_severity => pc_log_level_unexpected,
1587 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1588 p_app_name =>'FEM',
1589 p_msg_name => 'FEM_BAD_P_API_VER_ERR',p_token1 => 'VALUE',
1590 p_value1 => p_api_version, p_trans1 => 'N');
1591
1592 WHEN OTHERS THEN
1593 -- Unexpected exceptions
1594 x_return_status := pc_ret_sts_unexp_error;
1595
1596 -- Log the call stack and the Oracle error message to
1597 -- FND_LOG with the "unexpected exception" severity level.
1598
1599 FEM_ENGINES_PKG.Tech_Message
1600 (p_severity => pc_log_level_unexpected,
1601 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1602 p_msg_text => SQLERRM);
1603
1604 FEM_ENGINES_PKG.Tech_Message
1605 (p_severity => pc_log_level_unexpected,
1606 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1607 p_msg_text => dbms_utility.format_call_stack);
1608
1609 -- Log the Oracle error message to the stack.
1610 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
1611 p_msg_name => 'FEM_UNEXPECTED_ERROR',
1612 P_TOKEN1 => 'ERR_MSG',
1613 P_VALUE1 => SQLERRM);
1614
1615 FND_MSG_PUB.Count_And_Get
1616 (p_count => x_msg_count,
1617 p_data => x_msg_data);
1618
1619 ROLLBACK TO add_candidate_pub;
1620
1621 END add_candidate;
1622 -- *****************************************************************************
1623 PROCEDURE remove_candidate (x_return_status OUT NOCOPY VARCHAR2,
1624 x_msg_count OUT NOCOPY NUMBER,
1625 x_msg_data OUT NOCOPY VARCHAR2,
1626 p_api_version IN NUMBER,
1627 p_commit IN VARCHAR2,
1628 p_undo_list_obj_def_id IN NUMBER,
1629 p_request_id IN NUMBER,
1630 p_object_id IN NUMBER) AS
1631
1632 -- ============================================================================
1633 -- PUBLIC
1634 -- This procedure is used to remove a candidate from an undo list.
1635 -- ============================================================================
1636 c_api_name CONSTANT VARCHAR2(30) := 'remove_candidate';
1637 c_api_version CONSTANT NUMBER := 1.0;
1638 v_approval_edit_lock_exists VARCHAR2(1);
1639 v_data_edit_lock_exists VARCHAR2(1);
1640 v_undo_list_ever_executed VARCHAR2(1);
1641 v_obj_def_name FEM_OBJECT_DEFINITION_TL.display_name%TYPE;
1642
1643 -- This cursor retrieves the snapshot and all other incremental loads that make
1644 -- up a GL load.
1645 -- 10-AUG-04 KFN - The cursor also retrieves all RCM Process Rule executions
1646 -- that have the same ledger, calendar period and dataset code as the current
1647 -- candidate.
1648 -- Bug 4382591: Also retrieve all DataX and Client Data Loader rule
1649 -- executions to the list that have the same ledger, calendar period,
1650 -- dataset code and source system as the current candidate.
1651 -- Bug 5011140 (FP:4596447): Also retrieve all TP Process Rule executions.
1652 CURSOR c1 IS
1653 SELECT c.request_id, c.object_id
1654 FROM fem_ud_list_candidates c, fem_object_catalog_b o, fem_pl_requests r1, fem_pl_requests r2
1655 WHERE c.object_id = o.object_id
1656 AND o.object_type_code IN ('OGL_INTG_BAL_RULE','XGL_INTEGRATION',
1657 'RCM_PROCESS_RULE','TP_PROCESS_RULE',
1658 'SOURCE_DATA_LOADER','DATAX_LOADER')
1659 AND c.request_id = r1.request_id
1660 AND r1.request_id <> p_request_id
1661 AND r2.request_id = p_request_id
1662 AND r2.cal_period_id = r1.cal_period_id
1663 AND r2.ledger_id = r1.ledger_id
1664 AND r2.output_dataset_code = r1.output_dataset_code
1665 AND (r2.source_system_code = r1.source_system_code
1666 OR o.object_type_code IN ('OGL_INTG_BAL_RULE','XGL_INTEGRATION',
1667 'RCM_PROCESS_RULE','TP_PROCESS_RULE'));
1668
1669 BEGIN
1670
1671 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
1672 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1673 p_msg_text => 'Begin. P_COMMIT:'||p_commit||
1674 ' P_UNDO_LIST_OBJ_DEF_ID: '||p_undo_list_obj_def_id||
1675 ' P_REQUEST_ID: '||p_request_id||
1676 ' P_OBJECT_ID: '||p_object_id);
1677
1678 -- Standard Start of API savepoint
1679 SAVEPOINT remove_candidate_pub;
1680
1681 -- Standard call to check for call compatibility.
1682 IF NOT FND_API.Compatible_API_Call (c_api_version,
1683 p_api_version,
1684 c_api_name,
1685 pc_pkg_name)
1686 THEN
1687 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1688 END IF;
1689
1690 -- Initialize API return status to success
1691 x_return_status := pc_ret_sts_success;
1692
1693 -- ============================================================================
1694 -- VALIDATIONS:
1695 -- Check for edit locks.
1696 -- Cannot update list if it is locked.
1697 -- The list is locked if it has an entry in the FEM_PL tables, OR if
1698 -- it has been processed at least once, and the execution
1699 -- was not successful.
1700 -- ============================================================================
1701 fem_pl_pkg.get_object_def_edit_locks (
1702 p_object_definition_id => p_undo_list_obj_def_id,
1703 x_approval_edit_lock_exists => v_approval_edit_lock_exists,
1704 x_data_edit_lock_exists => v_data_edit_lock_exists);
1705
1706 -- This query checks to see if the undo list has ever been run, (as
1707 -- the execution may no longer be in the PL tables).
1708 SELECT DECODE(count(*),0,'N','Y') INTO v_undo_list_ever_executed
1709 FROM (select exec_status_code
1710 from fem_ud_list_candidates
1711 where undo_list_obj_def_id = p_undo_list_obj_def_id
1712 and exec_status_code IS NOT NULL
1713 UNION
1714 select exec_status_code
1715 from fem_ud_list_dependents
1716 where undo_list_obj_def_id = p_undo_list_obj_def_id
1717 and exec_status_code IS NOT NULL
1718 UNION
1719 select exec_status_code
1720 from fem_ud_lists
1721 where undo_list_obj_def_id = p_undo_list_obj_def_id
1722 and exec_status_code IS NOT NULL);
1723
1724 IF v_approval_edit_lock_exists = 'T' OR v_data_edit_lock_exists = 'T'
1725 OR v_undo_list_ever_executed = 'T' THEN
1726 RAISE e_edit_lock_exists;
1727 END IF;
1728
1729 -- ============================================================================
1730 -- Delete the candidate and its dependents if no edit locks are found.
1731 -- ============================================================================
1732 DELETE fem_ud_list_candidates
1733 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
1734 AND request_id = p_request_id
1735 AND object_id = p_object_id;
1736
1737 DELETE fem_ud_list_dependents
1738 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
1739 AND request_id = p_request_id
1740 AND object_id = p_object_id;
1741
1742 -- ============================================================================
1743 -- If this candidate is an OGL or XGL integration, delete all its incremental loads
1744 -- and the initial snapshot.
1745 -- 08/10/2004 KFN - If this candidate is an RCM Process Rule, delete all executions
1746 -- of that rule that are listed as candidates, which have the same calendar period,
1747 -- ledger and output dataset code as that of the candidate.
1748 -- Bug 4382591: Also retrieve all DataX and Client Data Loader rule
1749 -- executions to the list that have the same ledger, calendar period,
1750 -- dataset code and source system as the current candidate.
1751 -- ============================================================================
1752 FOR an_integration_load_exec IN c1 LOOP
1753
1754 DELETE fem_ud_list_candidates
1755 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
1756 AND request_id = an_integration_load_exec.request_id
1757 AND object_id = an_integration_load_exec.object_id;
1758
1759 DELETE fem_ud_list_dependents
1760 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
1761 AND request_id = an_integration_load_exec.request_id
1762 AND object_id = an_integration_load_exec.object_id;
1763
1764 END LOOP;
1765
1766 IF FND_API.To_Boolean( p_commit ) THEN
1767 COMMIT WORK;
1768 END IF;
1769
1770 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
1771 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1772 p_msg_text => 'End. X_RETURN_STATUS: '||x_return_status);
1773
1774 FND_MSG_PUB.Count_And_Get
1775 (p_count => x_msg_count,
1776 p_data => x_msg_data);
1777
1778 EXCEPTION
1779 WHEN e_edit_lock_exists THEN
1780 ROLLBACK TO remove_candidate_pub;
1781 x_return_status := pc_ret_sts_error;
1782
1783 IF v_data_edit_lock_exists = 'T' THEN
1784 fem_engines_pkg.put_message(p_app_name =>'FEM',
1785 p_msg_name =>'FEM_UD_LOCKED_OBJ_DEF_ERR',
1786 p_token1 => 'OBJECT_DEFINITION_ID',
1787 p_value1 => p_undo_list_obj_def_id,
1788 p_trans1 => 'N');
1789 ELSIF v_undo_list_ever_executed = 'T' THEN
1790 fem_engines_pkg.put_message(p_app_name =>'FEM',
1791 p_msg_name =>'FEM_UD_EXECUTED_OBJ_DEF_ERR',
1792 p_token1 => 'OBJECT_DEFINITION_ID',
1793 p_value1 => p_undo_list_obj_def_id,
1794 p_trans1 => 'N');
1795 ELSIF v_approval_edit_lock_exists = 'T' THEN
1796 SELECT display_name
1797 INTO v_obj_def_name
1798 FROM fem_object_definition_vl
1799 WHERE object_definition_id = p_undo_list_obj_def_id;
1800
1801 fem_engines_pkg.put_message(p_app_name =>'FEM',
1802 p_msg_name =>'FEM_PL_SUBMITTED_DEF_ERR',
1803 p_token1 => 'OBJ_DEF_NAME',
1804 p_value1 => v_obj_def_name);
1805 END IF;
1806
1807 FND_MSG_PUB.Count_And_Get
1808 (p_count => x_msg_count,
1809 p_data => x_msg_data);
1810
1811 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1812 ROLLBACK TO remove_candidate_pub;
1813 x_return_status := pc_ret_sts_unexp_error;
1814
1815 fem_engines_pkg.tech_message(p_severity => pc_log_level_unexpected,
1816 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1817 p_app_name =>'FEM',
1818 p_msg_name => 'FEM_BAD_P_API_VER_ERR',p_token1 => 'VALUE',
1819 p_value1 => p_api_version, p_trans1 => 'N');
1820
1821 WHEN OTHERS THEN
1822 -- Unexpected exceptions
1823 x_return_status := pc_ret_sts_unexp_error;
1824
1825 -- Log the call stack and the Oracle error message to
1826 -- FND_LOG with the "unexpected exception" severity level.
1827
1828 FEM_ENGINES_PKG.Tech_Message
1829 (p_severity => pc_log_level_unexpected,
1830 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1831 p_msg_text => SQLERRM);
1832
1833 FEM_ENGINES_PKG.Tech_Message
1834 (p_severity => pc_log_level_unexpected,
1835 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1836 p_msg_text => dbms_utility.format_call_stack);
1837
1838 -- Log the Oracle error message to the stack.
1839 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
1840 p_msg_name => 'FEM_UNEXPECTED_ERROR',
1841 P_TOKEN1 => 'ERR_MSG',
1842 P_VALUE1 => SQLERRM);
1843
1844 FND_MSG_PUB.Count_And_Get
1845 (p_count => x_msg_count,
1846 p_data => x_msg_data);
1847
1848 ROLLBACK TO remove_candidate_pub;
1849
1850 END remove_candidate;
1851
1852 -- *****************************************************************************
1853 PROCEDURE calc_accttbl_upd_dependents (x_msg_count OUT NOCOPY NUMBER,
1854 x_msg_data OUT NOCOPY VARCHAR2,
1855 x_return_status OUT NOCOPY VARCHAR2,
1856 x_upd_dep_calc_id OUT NOCOPY NUMBER,
1857 p_request_id IN NUMBER,
1858 p_object_id IN NUMBER) AS
1859
1860 -- ============================================================================
1861 -- PRIVATE
1862 -- This procedure calculates all the account table 'UPDATE' dependents
1863 -- for a given object execution.
1864 -- There are two types of 'UPDATE' dependencies that this procedure tracks.
1865 -- Type 1: An object execution that has updated the same column within the
1866 -- same set of data as an undo list candidate.
1867 -- Type 2: An object execution that has updated a column on a row
1868 -- that was inserted by an undo list candidate.
1869 -- In either case, a dependent must have the same parameters (ledger,
1870 -- cal period, dataset) as the candidate.
1871 -- Currently, 'UPDATE' dependencies only apply to account tables.
1872 -- ============================================================================
1873
1874 c_api_name CONSTANT VARCHAR2(30) := 'calc_accttbl_upd_dependents';
1875 v_ledger_id NUMBER;
1876 v_output_dataset_code NUMBER;
1877 v_cal_period_id NUMBER;
1878 v_new_type1 BOOLEAN;
1879 v_new_type2 BOOLEAN;
1880 v_new_dependents BOOLEAN;
1881 v_new_columns BOOLEAN;
1882 v_num_dep_rows NUMBER;
1883
1884 BEGIN
1885
1886 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
1887 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1888 p_msg_text => 'Begin. P_REQUEST_ID: '||p_request_id||
1889 ' P_OBJECT_ID: '||p_object_id);
1890
1891 -- Standard Start of API savepoint
1892 SAVEPOINT calc_accttbl_upd_dep_pub;
1893
1894 -- Initialize variables
1895 v_new_type1 := FALSE;
1896 v_new_type2 := FALSE;
1897 v_new_columns := FALSE;
1898
1899 -- Retrieve number to identify this calculation from the sequence
1900 SELECT fem_ud_upd_dep_s.nextval INTO x_upd_dep_calc_id
1901 FROM dual;
1902
1903 -- Retrieve ledger, dataset code and calendar period for the candidate
1904 SELECT ledger_id, output_dataset_code, cal_period_id
1905 INTO v_ledger_id, v_output_dataset_code, v_cal_period_id
1906 FROM fem_pl_requests
1907 WHERE request_id = p_request_id;
1908
1909 -- Retrieve initial list of type 2 dependents of the candidate.
1910 INSERT INTO fem_ud_upd_dep_t (upd_dep_calc_id, dependent_request_id, dependent_object_id)
1911 SELECT DISTINCT x_upd_dep_calc_id, t1.request_id, t1.object_id
1912 FROM fem_pl_tables t1
1913 WHERE t1.request_id IN (
1914 SELECT r.request_id
1915 FROM fem_pl_requests r
1916 WHERE r.ledger_id = v_ledger_id
1917 AND r.cal_period_id = v_cal_period_id
1918 AND r.output_dataset_code = v_output_dataset_code)
1919 AND t1.table_name IN (
1920 SELECT t2.table_name
1921 FROM fem_pl_tables t2, fem_table_class_assignmt_v t
1922 WHERE t2.request_id = p_request_id
1923 AND t2.object_id = p_object_id
1924 AND t2.statement_type = 'INSERT'
1925 AND t2.table_name = t.table_name
1926 AND t.table_classification_code IN
1927 ('ACCOUNT_PROFITABILITY','FTP_CASH_FLOW',
1928 'FTP_NON_CASH_FLOW','FTP_OPTION_COST') )
1929 AND t1.statement_type = 'UPDATE';
1930
1931 v_new_dependents := (SQL%ROWCOUNT > 0);
1932 v_num_dep_rows := SQL%ROWCOUNT;
1933
1934 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
1935 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1936 p_msg_text => 'Init Type2 dependents found: '||SQL%ROWCOUNT);
1937
1938 -- Retrieve initial list of updated account table columns. The query
1939 -- retrieves all account table columns updated by the candidate.
1940 INSERT INTO fem_ud_upd_cols_t (upd_dep_calc_id, table_name, column_name, checked_flag)
1941 SELECT DISTINCT x_upd_dep_calc_id, c.table_name, c.column_name, 'N'
1942 FROM fem_pl_tab_updated_cols c
1943 WHERE request_id = p_request_id
1944 AND object_id = p_object_id
1945 AND c.table_name IN (
1946 SELECT t.table_name
1947 FROM fem_table_class_assignmt_v t
1948 WHERE t.table_classification_code IN
1949 ('ACCOUNT_PROFITABILITY','FTP_CASH_FLOW',
1950 'FTP_NON_CASH_FLOW','FTP_OPTION_COST') );
1951
1952 v_new_columns := (SQL%ROWCOUNT > 0);
1953
1954 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
1955 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
1956 p_msg_text => 'Init Type1 dependents found: '||SQL%ROWCOUNT);
1957
1958 LOOP
1959 -- Keep looping until no more columns are being added to
1960 -- fem_ud_upd_cols_t AND no more dependents are being added
1961 -- to fem_ud_upd_dep_t.
1962 IF (NOT v_new_columns) AND (NOT v_new_dependents) THEN
1963 EXIT;
1964 END IF;
1965
1966 -- Find type 1 dependents.
1967 -- Technical note: Columns that have previously been checked for
1968 -- dependencies will have fem_ud_upd_cols_t.checked_flag set to 'Y'.
1969 -- In this query, we only want to find update dependencies for columns
1970 -- that have not been checked yet.
1971 INSERT INTO fem_ud_upd_dep_t (upd_dep_calc_id, dependent_request_id, dependent_object_id)
1972 SELECT DISTINCT x_upd_dep_calc_id, c.request_id, c.object_id
1973 FROM fem_pl_tab_updated_cols c
1974 WHERE c.request_id IN (
1975 SELECT r.request_id
1976 FROM fem_pl_requests r
1977 WHERE r.ledger_id = v_ledger_id
1978 AND r.cal_period_id = v_cal_period_id
1979 AND r.output_dataset_code = v_output_dataset_code)
1980 AND (c.table_name, c.column_name) IN (
1981 SELECT table_name, column_name
1982 FROM fem_ud_upd_cols_t
1983 WHERE upd_dep_calc_id = x_upd_dep_calc_id
1984 AND checked_flag = 'N')
1985 AND (c.request_id, c.object_id) NOT IN (
1986 SELECT dependent_request_id, dependent_object_id
1987 FROM fem_ud_upd_dep_t
1988 WHERE upd_dep_calc_id = x_upd_dep_calc_id);
1989
1990 v_new_type1 := (SQL%ROWCOUNT > 0);
1991 v_num_dep_rows := v_num_dep_rows + SQL%ROWCOUNT;
1992
1993 -- Now that these columns have been checked, mark them as such.
1994 UPDATE fem_ud_upd_cols_t SET checked_flag = 'Y'
1995 WHERE upd_dep_calc_id = x_upd_dep_calc_id
1996 AND checked_flag = 'N';
1997
1998 -- Find type 2 dependents.
1999 INSERT INTO fem_ud_upd_dep_t (upd_dep_calc_id, dependent_request_id, dependent_object_id)
2000 SELECT DISTINCT x_upd_dep_calc_id, t1.request_id, t1.object_id
2001 FROM fem_pl_tables t1
2002 WHERE t1.request_id IN (
2003 SELECT r.request_id
2004 FROM fem_pl_requests r
2005 WHERE r.ledger_id = v_ledger_id
2006 AND r.cal_period_id = v_cal_period_id
2007 AND r.output_dataset_code = v_output_dataset_code)
2008 AND t1.table_name IN (
2009 SELECT t2.table_name
2010 FROM fem_pl_tables t2, fem_table_class_assignmt_v t
2011 WHERE t2.table_name = t.table_name
2012 AND t.table_classification_code IN
2013 ('ACCOUNT_PROFITABILITY','FTP_CASH_FLOW',
2014 'FTP_NON_CASH_FLOW','FTP_OPTION_COST')
2015 AND t2.statement_type = 'INSERT'
2016 AND (t2.request_id, t2.object_id) IN (
2017 SELECT dependent_request_id, dependent_object_id
2018 FROM fem_ud_upd_dep_t
2019 WHERE upd_dep_calc_id = x_upd_dep_calc_id))
2020 AND t1.statement_type = 'UPDATE'
2021 AND (t1.request_id, t1.object_id) NOT IN (
2022 SELECT dependent_request_id, dependent_object_id
2023 FROM fem_ud_upd_dep_t
2024 WHERE upd_dep_calc_id = x_upd_dep_calc_id);
2025
2026 v_new_type2 := (SQL%ROWCOUNT > 0);
2027 v_new_dependents := (v_new_type1 OR v_new_type2);
2028 v_num_dep_rows := v_num_dep_rows + SQL%ROWCOUNT;
2029
2030 -- If any new dependents were found, then see if the
2031 -- dependents are updating any columns that have not
2032 -- already been captured by fem_ud_upd_cols_t).
2033 IF v_new_dependents THEN
2034 INSERT INTO fem_ud_upd_cols_t (upd_dep_calc_id, table_name, column_name, checked_flag)
2035 SELECT DISTINCT x_upd_dep_calc_id, c.table_name, c.column_name, 'N'
2036 FROM fem_pl_tab_updated_cols c
2037 WHERE (c.request_id, c.object_id) IN (
2038 SELECT d.dependent_request_id, d.dependent_object_id
2039 FROM fem_ud_upd_dep_t d
2040 WHERE d.upd_dep_calc_id = x_upd_dep_calc_id)
2041 AND c.table_name IN (
2042 SELECT t.table_name
2043 FROM fem_table_class_assignmt_v t
2044 WHERE t.table_classification_code IN
2045 ('ACCOUNT_PROFITABILITY','FTP_CASH_FLOW',
2046 'FTP_NON_CASH_FLOW','FTP_OPTION_COST') )
2047 AND (c.table_name, c.column_name) NOT IN (
2048 SELECT e.table_name, e.column_name
2049 FROM fem_ud_upd_cols_t e
2050 WHERE e.upd_dep_calc_id = x_upd_dep_calc_id);
2051
2052 v_new_columns := (SQL%ROWCOUNT > 0);
2053 ELSE
2054 v_new_columns := FALSE;
2055 END IF; -- v_num_new_dep
2056 END LOOP;
2057
2058 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
2059 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2060 p_msg_text => 'Number of dependents found: '||v_num_dep_rows);
2061
2062 -- Update API return status to success
2063 x_return_status := pc_ret_sts_success;
2064
2065 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
2066 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2067 p_msg_text => 'End. X_RETURN_STATUS: '||x_return_status||' x_upd_dep_calc_id:'||x_upd_dep_calc_id);
2068
2069 EXCEPTION
2070 WHEN NO_DATA_FOUND THEN
2071 ROLLBACK TO calc_accttbl_upd_dep_pub;
2072 x_return_status := pc_ret_sts_error;
2073 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
2074 p_msg_name => 'FEM_UD_REQUEST_NOT_FOUND_WRN',
2075 p_token1 => 'REQUEST_ID',
2076 p_value1 => p_request_id,
2077 p_trans1 => 'N');
2078
2079 FND_MSG_PUB.Count_And_Get
2080 (p_count => x_msg_count,
2081 p_data => x_msg_data);
2082
2083 WHEN OTHERS THEN
2084 -- Unexpected exceptions
2085 x_return_status := pc_ret_sts_unexp_error;
2086
2087 -- Log the call stack and the Oracle error message to
2088 -- FND_LOG with the "unexpected exception" severity level.
2089
2090 FEM_ENGINES_PKG.Tech_Message
2091 (p_severity => pc_log_level_unexpected,
2092 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2093 p_msg_text => SQLERRM);
2094
2095 FEM_ENGINES_PKG.Tech_Message
2096 (p_severity => pc_log_level_unexpected,
2097 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2098 p_msg_text => dbms_utility.format_call_stack);
2099
2100 -- Log the Oracle error message to the stack.
2101 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
2102 p_msg_name => 'FEM_UNEXPECTED_ERROR',
2103 P_TOKEN1 => 'ERR_MSG',
2104 P_VALUE1 => SQLERRM);
2105
2106 FND_MSG_PUB.Count_And_Get
2107 (p_count => x_msg_count,
2108 p_data => x_msg_data);
2109
2110 END calc_accttbl_upd_dependents;
2111
2112 -- *****************************************************************************
2113 PROCEDURE report_cand_dependents (x_msg_count OUT NOCOPY NUMBER,
2114 x_msg_data OUT NOCOPY VARCHAR2,
2115 p_request_id IN NUMBER,
2116 p_object_id IN NUMBER,
2117 p_dependency_type IN VARCHAR2) AS
2118
2119 -- ============================================================================
2120 -- PUBLIC
2121 -- This procedure reports a list of all object executions that used the
2122 -- result data of an undo list candidate as input. The list of dependents are
2123 -- posted as messages in the message stack. It is up to the calling program
2124 -- to retrieve the list of dependents from the message stack.
2125 -- Valid values for p_dependency_type: 'ALL','UPDATE','CHAIN'
2126 -- ============================================================================
2127
2128 c_api_name CONSTANT VARCHAR2(30) := 'report_cand_dependents';
2129 v_count NUMBER := 0;
2130 v_ledger_id NUMBER;
2131 v_cal_period_id NUMBER;
2132 v_output_dataset_code NUMBER;
2133 v_num_of_upd_dependents NUMBER;
2134 v_upd_dep_calc_id NUMBER;
2135 v_return_status VARCHAR2(30);
2136 v_object_name FEM_OBJECT_CATALOG_TL.object_name%TYPE;
2137
2138 -- Cursor to retrieve an object execution's UPDATE dependents
2139 -- Note that this only applies to ACCOUNT tables.
2140 CURSOR c1 (v_upd_dep_calc_id IN NUMBER) IS
2141 SELECT c.upd_dep_calc_id, c.dependent_request_id, c.dependent_object_id
2142 FROM fem_ud_upd_dep_t c
2143 WHERE c.upd_dep_calc_id = v_upd_dep_calc_id
2144 AND NOT (c.dependent_request_id = p_request_id
2145 AND c.dependent_object_id = p_object_id);
2146
2147 -- Cursor to retrieve an object execution's CHAIN dependents
2148 CURSOR c2 IS
2149 SELECT DISTINCT object_id, request_id
2150 FROM fem_pl_chains
2151 START WITH source_created_by_request_id = p_request_id
2152 AND source_created_by_object_id = p_object_id
2153 CONNECT BY
2154 PRIOR object_id=source_created_by_object_id AND
2155 PRIOR request_id=source_created_by_request_id;
2156
2157 BEGIN
2158
2159 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
2160 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2161 p_msg_text => 'Begin. '||
2162 ' P_REQUEST_ID: '||p_request_id||
2163 ' P_OBJECT_ID: '||p_object_id||
2164 ' P_DEPENDENCY_TYPE: '||p_dependency_type);
2165
2166 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
2167 p_msg_name => 'FEM_UD_CAND_DEPENDENTS_TXT',
2168 p_token1 => 'REQUEST_ID',
2169 p_value1 => p_request_id,
2170 p_trans1 => 'N',
2171 p_token2 => 'OBJECT_ID',
2172 p_value2 => p_object_id,
2173 p_trans2 => 'N');
2174
2175 -- ============================================================================
2176 -- STEP 1: Report UPDATE dependents. Note: Update dependents only applicable
2177 -- to ACCOUNT tables.
2178 -- ============================================================================
2179
2180 IF p_dependency_type IN ('ALL','UPDATE') THEN
2181 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
2182 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2183 p_msg_text => 'STEP 1: Report UPDATE dependents.');
2184
2185 BEGIN
2186 calc_accttbl_upd_dependents (
2187 x_msg_count => x_msg_count,
2188 x_msg_data => x_msg_data,
2189 x_return_status => v_return_status,
2190 x_upd_dep_calc_id => v_upd_dep_calc_id,
2191 p_request_id => p_request_id,
2192 p_object_id => p_object_id);
2193
2194 IF v_return_status <> pc_ret_sts_success THEN
2195 RAISE e_cannot_gen_cand_upd_dep;
2196 END IF;
2197 v_count := 0;
2198 FOR an_update_dependent IN c1(v_upd_dep_calc_id) LOOP
2199 v_count := c1%ROWCOUNT;
2200
2201 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
2202 p_msg_name => 'FEM_UD_DEPENDENT_OBJEXEC_TXT',
2203 p_token1 => 'REQUEST_ID',
2204 p_value1 => an_update_dependent.dependent_request_id,
2205 p_trans1 => 'N',
2206 p_token2 => 'OBJECT_ID',
2207 p_value2 => an_update_dependent.dependent_object_id,
2208 p_trans2 => 'N',
2209 p_token3 => 'DEPENDENT_TYPE',
2210 p_value3 => 'UPDATE',
2211 p_trans3 => 'N');
2212
2213 END LOOP;
2214
2215 IF v_count = 0 THEN -- If no dependents found, post message
2216 fem_engines_pkg.put_message(p_app_name =>'FEM',
2217 p_msg_name => 'FEM_UD_NO_UPDATE_DEP_FOUND_TXT');
2218 END IF;
2219
2220 -- Delete update dependent list from temporary tables as no longer needed.
2221 DELETE fem_ud_upd_dep_t WHERE upd_dep_calc_id = v_upd_dep_calc_id;
2222 DELETE fem_ud_upd_cols_t WHERE upd_dep_calc_id = v_upd_dep_calc_id;
2223 COMMIT;
2224
2225 EXCEPTION
2226 WHEN e_cannot_gen_cand_upd_dep THEN
2227 BEGIN
2228 SELECT object_name
2229 INTO v_object_name
2230 FROM fem_object_catalog_vl
2231 WHERE object_id = p_object_id;
2232 EXCEPTION
2233 WHEN others THEN
2234 v_object_name := to_char(p_object_id);
2235 END;
2236
2237 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
2238 p_msg_name => 'FEM_UD_CANNOT_GEN_CAND_DEP_ERR',
2239 p_token1 => 'REQUEST_ID',
2240 p_value1 => p_request_id,
2241 p_token2 => 'OBJECT_NAME',
2242 p_value2 => v_object_name);
2243 END;
2244 END IF;
2245
2246 -- ============================================================================
2247 -- STEP 2: Report CHAIN dependents.
2248 -- ============================================================================
2249 IF p_dependency_type IN ('ALL','CHAIN') THEN
2250
2251 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
2252 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2253 p_msg_text => 'STEP 2: Report CHAIN dependents.');
2254
2255 v_count := 0;
2256 FOR a_chain_dependent IN c2 LOOP
2257 v_count := c2%ROWCOUNT;
2258
2259 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
2260 p_msg_name => 'FEM_UD_DEPENDENT_OBJEXEC_TXT',
2261 p_token1 => 'REQUEST_ID',
2262 p_value1 => a_chain_dependent.request_id,
2263 p_trans1 => 'N',
2264 p_token2 => 'OBJECT_ID',
2265 p_value2 => a_chain_dependent.object_id,
2266 p_trans2 => 'N',
2267 p_token3 => 'DEPENDENT_TYPE',
2268 p_value3 => 'CHAIN',
2269 p_trans3 => 'N');
2270
2271 END LOOP;
2272
2273 IF v_count = 0 THEN -- If no dependents found, post message
2274 fem_engines_pkg.put_message(p_app_name =>'FEM',
2275 p_msg_name => 'FEM_UD_NO_CHAIN_DEP_FOUND_TXT');
2276 END IF;
2277
2278 END IF;
2279
2280 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
2281 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2282 p_msg_text => 'End.');
2283
2284 FND_MSG_PUB.Count_And_Get
2285 (p_count => x_msg_count,
2286 p_data => x_msg_data);
2287
2288 EXCEPTION
2289 WHEN OTHERS THEN
2290 -- Unexpected exceptions
2291 -- Log the call stack and the Oracle error message to
2292 -- FND_LOG with the "unexpected exception" severity level.
2293
2294 FEM_ENGINES_PKG.Tech_Message
2295 (p_severity => pc_log_level_unexpected,
2296 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2297 p_msg_text => SQLERRM);
2298
2299 FEM_ENGINES_PKG.Tech_Message
2300 (p_severity => pc_log_level_unexpected,
2301 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2302 p_msg_text => dbms_utility.format_call_stack);
2303
2304 -- Log the Oracle error message to the stack.
2305 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
2306 p_msg_name => 'FEM_UNEXPECTED_ERROR',
2307 P_TOKEN1 => 'ERR_MSG',
2308 P_VALUE1 => SQLERRM);
2309
2310 FND_MSG_PUB.Count_And_Get
2311 (p_count => x_msg_count,
2312 p_data => x_msg_data);
2313
2314 END report_cand_dependents;
2315 -- *****************************************************************************
2316 PROCEDURE generate_cand_dependents (x_return_status OUT NOCOPY VARCHAR2,
2317 x_msg_count OUT NOCOPY NUMBER,
2318 x_msg_data OUT NOCOPY VARCHAR2,
2319 p_api_version IN NUMBER,
2320 p_commit IN VARCHAR2,
2321 p_undo_list_obj_def_id IN NUMBER DEFAULT NULL,
2322 p_request_id IN NUMBER,
2323 p_object_id IN NUMBER,
2324 p_dependency_type IN VARCHAR2,
2325 p_ud_session_id IN NUMBER DEFAULT NULL,
2326 p_preview_flag IN VARCHAR2 DEFAULT 'N') AS
2327
2328 -- ============================================================================
2329 -- PUBLIC
2330 -- This procedure generates a list of all object executions that used the
2331 -- result data of an undo list candidate as input. The list of dependents are
2332 -- stored in FEM_UD_LIST_DEPENDENTS when p_preview_flag = 'N' and are stored in
2333 -- FEM_UD_PRVIEW_DEPENDENTS when p_preview_flag = 'Y'. This procedure always
2334 -- generates update dependents, and will only generate chain dependents if
2335 -- p_dependency_type = 'ALL'.
2336 -- Note: Original logic allowed user to specify the type of dependencies to
2337 -- include. Current logic always includes update dependencies.
2338 -- Valid values for p_dependency_type: 'ALL','UPDATE'
2339 -- ============================================================================
2340 c_api_name CONSTANT VARCHAR2(30) := 'generate_cand_dependents';
2341 c_api_version CONSTANT NUMBER := 2.0;
2342 v_count NUMBER := 0;
2343 v_ledger_id NUMBER;
2344 v_cal_period_id NUMBER;
2345 v_output_dataset_code NUMBER;
2346 v_undo_list_ever_exec VARCHAR2(1);
2347 v_num_of_upd_dependents NUMBER;
2348 v_upd_dep_calc_id NUMBER;
2349 v_exec_status_code VARCHAR2(30);
2350 v_object_name FEM_OBJECT_CATALOG_TL.object_name%TYPE;
2351
2352 -- Cursor to retrieve an object execution's UPDATE dependents
2353 -- Note that this only applies to ACCOUNT tables.
2354 CURSOR c1 IS
2355 SELECT c.upd_dep_calc_id, c.dependent_request_id, c.dependent_object_id
2356 FROM fem_ud_upd_dep_t c
2357 WHERE c.upd_dep_calc_id = v_upd_dep_calc_id
2358 AND NOT (c.dependent_request_id = p_request_id
2359 AND c.dependent_object_id = p_object_id);
2360
2361 -- Cursor to retrieve an object execution's CHAIN dependents
2362 CURSOR c2 IS
2363 SELECT DISTINCT object_id, request_id
2364 FROM fem_pl_chains
2365 START WITH source_created_by_request_id = p_request_id
2366 AND source_created_by_object_id = p_object_id
2367 CONNECT BY
2368 PRIOR object_id=source_created_by_object_id AND
2369 PRIOR request_id=source_created_by_request_id;
2370
2371 -- Bug 5103063: Add all "hidden" executions onto the preview
2372 -- dependencies list to give the user a more complete picture of what
2373 -- is being undone in the Undo Confirmation Page.
2374 CURSOR c_repeat_execs (p_req_id NUMBER, p_obj_id NUMBER) IS
2375 SELECT pl.request_id, pl.object_id
2376 FROM fem_pl_object_executions pl, fem_object_catalog_b o,
2377 fem_pl_requests r1, fem_pl_requests r2
2378 WHERE pl.object_id = o.object_id
2379 AND o.object_id = p_obj_id
2380 AND o.object_type_code IN ('OGL_INTG_BAL_RULE','XGL_INTEGRATION',
2381 'RCM_PROCESS_RULE','TP_PROCESS_RULE',
2382 'SOURCE_DATA_LOADER','DATAX_LOADER')
2383 AND pl.request_id = r1.request_id
2384 AND r1.request_id <> p_req_id
2385 AND r2.request_id = p_req_id
2386 AND r2.cal_period_id = r1.cal_period_id
2387 AND r2.ledger_id = r1.ledger_id
2388 AND r2.output_dataset_code = r1.output_dataset_code
2389 AND (r2.source_system_code = r1.source_system_code
2390 OR o.object_type_code IN ('OGL_INTG_BAL_RULE','XGL_INTEGRATION',
2391 'RCM_PROCESS_RULE','TP_PROCESS_RULE'));
2392
2393 -- Cursor to retrieve all of an object execution's dependents. This
2394 -- cursor is used to validate the dependents. Use this query when
2395 -- p_preview_flag = 'N'
2396 CURSOR c3 IS
2397 SELECT d.dependent_request_id, d.dependent_object_id, u.folder_id
2398 FROM fem_ud_list_dependents d, fem_object_catalog_b o, fem_user_folders u
2399 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
2400 AND d.request_id = p_request_id
2401 AND d.object_id = p_object_id
2402 AND d.dependent_object_id = o.object_id
2403 AND o.folder_id = u.folder_id (+)
2404 AND u.user_id(+) = pv_apps_user_id;
2405
2406 -- Cursor to retrieve all of an object execution's dependents. This
2407 -- cursor is used to validate the dependents. Use this query when
2408 -- p_preview_flag = 'Y'
2409 CURSOR c4 IS
2410 SELECT d.dependent_request_id, d.dependent_object_id, u.folder_id
2411 FROM fem_ud_prview_dependents d, fem_object_catalog_b o, fem_user_folders u
2412 WHERE d.ud_session_id = p_ud_session_id
2413 AND d.request_id = p_request_id
2414 AND d.object_id = p_object_id
2415 AND d.dependent_object_id = o.object_id
2416 AND o.folder_id = u.folder_id (+)
2417 AND u.user_id(+) = pv_apps_user_id;
2418
2419
2420 BEGIN
2421
2422 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
2423 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2424 p_msg_text => 'Begin. P_COMMIT:'||p_commit||
2425 ' P_PREVIEW_FLAG: '||p_preview_flag||
2426 ' P_UD_SESSION_ID: '||p_ud_session_id||
2427 ' P_UNDO_LIST_OBJ_DEF_ID: '||p_undo_list_obj_def_id||
2428 ' P_REQUEST_ID: '||p_request_id||
2429 ' P_OBJECT_ID: '||p_object_id||
2430 ' P_DEPENDENCY_TYPE: '||p_dependency_type);
2431
2432 -- Standard Start of API savepoint
2433 SAVEPOINT generate_cand_dependents_pub;
2434
2435 -- Standard call to check for call compatibility.
2436 IF NOT FND_API.Compatible_API_Call (c_api_version,
2437 p_api_version,
2438 c_api_name,
2439 pc_pkg_name)
2440 THEN
2441 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2442 END IF;
2443
2444 -- Initialize API return status to success
2445 x_return_status := pc_ret_sts_success;
2446
2447
2448 -- ============================================================================
2449 -- == VALIDATIONS: Validate input parameters
2450 -- ============================================================================
2451 -- STEP V1: Validate p_preview_flag
2452 -- ============================================================================
2453
2454 IF p_preview_flag NOT IN ('N','Y') THEN
2455 RAISE e_invalid_preview_flag;
2456 END IF;
2457 -- ============================================================================
2458 -- STEP V2: Validate p_ud_session_id
2459 -- ============================================================================
2460
2461 IF p_preview_flag = 'Y' AND p_ud_session_id IS NULL THEN
2462 RAISE e_invalid_session_id;
2463 END IF;
2464
2465 -- ============================================================================
2466 -- STEP V3: Validate p_undo_list_obj_def_id
2467 -- ============================================================================
2468 IF p_preview_flag = 'N' AND p_undo_list_obj_def_id IS NULL THEN
2469 RAISE e_invalid_undolist_objdefid;
2470 END IF;
2471
2472 -- ============================================================================
2473 -- STEP V4: Validate p_dependency_type
2474 -- ============================================================================
2475 IF p_dependency_type NOT IN ('ALL','UPDATE') THEN
2476 RAISE e_invalid_dependency_type;
2477 END IF;
2478
2479
2480 -- ============================================================================
2481 -- STEP 1: DELETE existing dependents for the candidate if the undo list has
2482 -- never been run.
2483 -- ============================================================================
2484 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
2485 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2486 p_msg_text => 'STEP 1: DELETE existing dependents for the candidate.');
2487
2488 IF p_preview_flag = 'N' THEN
2489 SELECT DECODE(count(*),0,'N','Y') INTO v_undo_list_ever_exec
2490 FROM (select exec_status_code
2491 from fem_ud_list_candidates
2492 where undo_list_obj_def_id = p_undo_list_obj_def_id
2493 and exec_status_code IS NOT NULL
2494 UNION
2495 select exec_status_code
2496 from fem_ud_list_dependents
2497 where undo_list_obj_def_id = p_undo_list_obj_def_id
2498 and exec_status_code IS NOT NULL
2499 UNION
2500 select exec_status_code
2501 from fem_ud_lists
2502 where undo_list_obj_def_id = p_undo_list_obj_def_id
2503 and exec_status_code IS NOT NULL);
2504
2505 IF v_undo_list_ever_exec = 'N' THEN
2506
2507 DELETE fem_ud_list_dependents
2508 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
2509 AND request_id = p_request_id
2510 AND object_id = p_object_id;
2511
2512 END IF;
2513 ELSIF p_preview_flag = 'Y' THEN
2514 -- Delete dependents for preview list candidate.
2515 DELETE fem_ud_prview_dependents
2516 WHERE ud_session_id = p_ud_session_id
2517 AND request_id = p_request_id
2518 AND object_id = p_object_id;
2519
2520 END IF;
2521 -- ============================================================================
2522 -- STEP 2: Generate UPDATE dependents.
2523 -- Update dependents are only applicable to ACCOUNT tables.
2524 -- ============================================================================
2525 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
2526 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2527 p_msg_text => 'STEP 2: Generate UPDATE dependents.');
2528
2529 BEGIN
2530
2531 calc_accttbl_upd_dependents (
2532 x_msg_count => x_msg_count,
2533 x_msg_data => x_msg_data,
2534 x_return_status => x_return_status,
2535 x_upd_dep_calc_id => v_upd_dep_calc_id,
2536 p_request_id => p_request_id,
2537 p_object_id => p_object_id);
2538
2539 IF x_return_status <> pc_ret_sts_success THEN
2540 RAISE e_cannot_gen_cand_upd_dep;
2541 END IF;
2542
2543 v_count := 0;
2544 FOR updated_col IN c1 LOOP
2545 v_count := c1%ROWCOUNT;
2546
2547 BEGIN
2548
2549 IF p_preview_flag = 'N' THEN
2550 INSERT INTO fem_ud_list_dependents (undo_list_obj_def_id,
2551 request_id, object_id, dependent_request_id, dependent_object_id,
2552 created_by, creation_date, last_updated_by, last_update_date,
2553 last_update_login, object_version_Number)
2554 VALUES (p_undo_list_obj_def_id, p_request_id, p_object_id,
2555 updated_col.dependent_request_id, updated_col.dependent_object_id,
2556 pv_apps_user_id, sysdate, pv_apps_user_id, sysdate, pv_login_id,1);
2557 ELSE -- p_preview_flag = 'Y'
2558 INSERT INTO fem_ud_prview_dependents (ud_session_id,
2559 request_id, object_id, dependent_request_id, dependent_object_id,
2560 created_by, creation_date, last_updated_by, last_update_date,
2561 last_update_login, object_version_Number)
2562 VALUES (p_ud_session_id, p_request_id, p_object_id,
2563 updated_col.dependent_request_id, updated_col.dependent_object_id,
2564 pv_apps_user_id, sysdate, pv_apps_user_id, sysdate, pv_login_id,1);
2565 END IF;
2566 EXCEPTION
2567 WHEN DUP_VAL_ON_INDEX THEN NULL;
2568 END;
2569
2570 END LOOP;
2571
2572 IF v_count = 0 THEN
2573 -- If no UPDATE dependents found, post message
2574 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
2575 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2576 p_app_name =>'FEM',
2577 p_msg_name => 'FEM_UD_NO_UPDATE_DEP_FOUND_TXT');
2578 END IF;
2579
2580 -- Delete update dependent list from temporary tables as no longer needed.
2581 DELETE fem_ud_upd_dep_t WHERE upd_dep_calc_id = v_upd_dep_calc_id;
2582 DELETE fem_ud_upd_cols_t WHERE upd_dep_calc_id = v_upd_dep_calc_id;
2583
2584 EXCEPTION
2585 WHEN e_cannot_gen_cand_upd_dep THEN
2586 ROLLBACK TO generate_cand_dependents_pub;
2587
2588 BEGIN
2589 SELECT object_name
2590 INTO v_object_name
2591 FROM fem_object_catalog_vl
2592 WHERE object_id = p_object_id;
2593 EXCEPTION
2594 WHEN others THEN
2595 v_object_name := to_char(p_object_id);
2596 END;
2597
2598 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
2599 p_msg_name => 'FEM_UD_CANNOT_GEN_CAND_DEP_ERR',
2600 p_token1 => 'REQUEST_ID',
2601 p_value1 => p_request_id,
2602 p_token2 => 'OBJECT_NAME',
2603 p_value2 => v_object_name);
2604
2605 FND_MSG_PUB.Count_And_Get
2606 (p_count => x_msg_count,
2607 p_data => x_msg_data);
2608 END;
2609
2610 -- ============================================================================
2611 -- STEP 3: Generate CHAIN dependents.
2612 -- The current logic ignores p_ignore_dependency_errs_flag
2613 -- Original logic: If p_ignore_dependency_errs_flag = 'Y', and p_dependency_type='ALL'
2614 -- but chain dependents are found, THEN post an error message.
2615 -- ============================================================================
2616 IF p_dependency_type = 'ALL' THEN
2617 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
2618 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2619 p_msg_text => 'STEP 3: Generate CHAIN dependents.');
2620
2621 v_count := 0;
2622 FOR achain IN c2 LOOP
2623 v_count := c2%ROWCOUNT;
2624
2625 BEGIN
2626
2627 IF p_preview_flag = 'N' THEN
2628 INSERT INTO fem_ud_list_dependents (undo_list_obj_def_id, request_id,
2629 object_id, dependent_request_id, dependent_object_id, created_by, creation_date,
2630 last_updated_by, last_update_date, last_update_login, object_version_Number)
2631 VALUES (p_undo_list_obj_def_id, p_request_id, p_object_id, achain.request_id,
2632 achain.object_id, pv_apps_user_id, sysdate, pv_apps_user_id, sysdate,
2633 pv_login_id,1);
2634 ELSE -- p_preview_flag = 'Y'
2635 INSERT INTO fem_ud_prview_dependents (ud_session_id,
2636 request_id, object_id, dependent_request_id, dependent_object_id,
2637 created_by, creation_date, last_updated_by, last_update_date,
2638 last_update_login, object_version_number)
2639 VALUES (p_ud_session_id, p_request_id, p_object_id,
2640 achain.request_id, achain.object_id, pv_apps_user_id,
2641 sysdate, pv_apps_user_id, sysdate, pv_login_id,1);
2642 END IF;
2643
2644 EXCEPTION
2645 WHEN DUP_VAL_ON_INDEX THEN NULL;
2646 END;
2647
2648 END LOOP;
2649
2650 IF v_count = 0 THEN -- If no CHAIN dependents found, post message
2651 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
2652 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2653 p_msg_name => 'FEM_UD_NO_CHAIN_DEP_FOUND_TXT');
2654 END IF;
2655
2656 END IF;
2657
2658 -- ============================================================================
2659 -- STEP 3.5: Generate dependents for "repeat" rule executions that
2660 -- was run for the same rule, cal period, data set, etc. as the undo
2661 -- candidate. Only perform this in the Preview mode.
2662 -- (Added to satisfy bug 5103063)
2663 -- ============================================================================
2664 IF p_preview_flag = 'Y' THEN
2665 IF (pc_log_level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2666 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
2667 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2668 p_msg_text => 'STEP 3.5: Generate "REPEAT" dependents.');
2669 END IF;
2670
2671 v_count := 0;
2672 FOR repeat_execs IN c_repeat_execs(p_request_id, p_object_id) LOOP
2673 v_count := v_count + 1;
2674 BEGIN
2675 INSERT INTO fem_ud_prview_dependents
2676 (ud_session_id,request_id, object_id, dependent_request_id,
2677 dependent_object_id,created_by, creation_date, last_updated_by,
2678 last_update_date,last_update_login, object_version_Number)
2679 VALUES
2680 (p_ud_session_id, p_request_id, p_object_id, repeat_execs.request_id,
2681 repeat_execs.object_id, pv_apps_user_id, sysdate, pv_apps_user_id,
2682 sysdate, pv_login_id, 1);
2683 EXCEPTION
2684 WHEN DUP_VAL_ON_INDEX THEN NULL;
2685 END;
2686 END LOOP;
2687
2688 IF (pc_log_level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2689 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
2690 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2691 p_msg_text => 'STEP 3.5: Number of REPEAT dependencies found: '||v_count);
2692 END IF;
2693 END IF;
2694
2695 -- ============================================================================
2696 -- STEP 4: Validate that user can undo dependents.
2697 -- Note: For undo lists (p_preview_flag = 'N'), when a dependent does
2698 -- not pass validation, an error is raised and no other dependents are
2699 -- validated. For preview lists (p_preview_flag = 'Y'), when a dependent
2700 -- does not pass validation, its status is set accordingly, and the program
2701 -- continues validating all the other dependents. If one or more dependents
2702 -- are found to not pass validation, the status of the candidate is set
2703 -- accordingly.
2704 -- ============================================================================
2705
2706 IF p_preview_flag = 'N' THEN
2707 FOR a_dep IN c3 LOOP
2708
2709 -- =========================================================================
2710 -- Validate that the user can execute (same as user can read) the dependent
2711 -- =========================================================================
2712 IF a_dep.folder_id IS NULL THEN
2713 -- User cannot read the dependent.
2714 RAISE e_cannot_read_object;
2715 END IF;
2716
2717 -- =========================================================================
2718 -- Validate that the dependent is not 'RUNNING'.
2719 -- =========================================================================
2720
2721 -- Bug 6443224. See earlier comment for this bug.
2722 BEGIN
2723 SELECT exec_status_code INTO v_exec_status_code
2724 FROM fem_pl_object_executions
2725 WHERE request_id = a_dep.dependent_request_id
2726 AND object_id = a_dep.dependent_object_id;
2727
2728 IF v_exec_status_code = 'RUNNING' THEN
2729 -- Verify that the request is still running using
2730 -- fem_pl_pkg.set_exec_state
2731 fem_pl_pkg.set_exec_state (p_api_version => 1.0,
2732 p_commit => fnd_api.g_true,
2733 p_request_id => a_dep.dependent_request_id,
2734 p_object_id => a_dep.dependent_object_id,
2735 x_msg_count => x_msg_count,
2736 x_msg_data => x_msg_data,
2737 x_return_status => x_return_status);
2738
2739 IF x_msg_count > 0 THEN
2740 Get_Put_Messages(
2741 p_msg_count => x_msg_count,
2742 p_msg_data => x_msg_data,
2743 p_user_msg => 'N',
2744 p_module => 'fem.plsql.'||pc_pkg_name||'.'
2745 ||c_api_name);
2746 END IF;
2747 END IF;
2748
2749 SELECT exec_status_code INTO v_exec_status_code
2750 FROM fem_pl_object_executions
2751 WHERE request_id = a_dep.dependent_request_id
2752 AND object_id = a_dep.dependent_object_id;
2753 EXCEPTION
2754 WHEN no_data_found THEN
2755 v_exec_status_code := 'NORMAL';
2756 END;
2757
2758 IF v_exec_status_code = 'RUNNING'THEN
2759 RAISE e_objexec_is_running;
2760 END IF;
2761
2762 END LOOP; -- End a_dep loop
2763
2764 ELSIF p_preview_flag = 'Y' THEN
2765
2766 v_count := 0;
2767 FOR a_prvw_dep IN c4 LOOP
2768
2769 -- =========================================================================
2770 -- Validate that the user can execute (same as user can read) the dependent
2771 -- =========================================================================
2772 IF a_prvw_dep.folder_id IS NULL THEN
2773 v_count := v_count + 1;
2774 UPDATE fem_ud_prview_dependents
2775 SET validation_status_code = 'FEM_UD_CANNOT_READ_OBJECT_ERR',
2776 last_Update_date = sysdate, last_Updated_by = pv_apps_user_id
2777 WHERE ud_session_id = p_ud_session_id
2778 AND dependent_request_id = a_prvw_dep.dependent_request_id
2779 AND dependent_object_id = a_prvw_dep.dependent_object_id;
2780
2781 ELSE -- Need to perform second validation only if it passes first one.
2782 -- =========================================================================
2783 -- Validate that the dependent is not 'RUNNING'.
2784 -- =========================================================================
2785
2786 SELECT exec_status_code INTO v_exec_status_code
2787 FROM fem_pl_object_executions
2788 WHERE request_id = a_prvw_dep.dependent_request_id
2789 AND object_id = a_prvw_dep.dependent_object_id;
2790
2791 IF v_exec_status_code = 'RUNNING' THEN
2792 -- Verify that the request is still running using fem_pl_pkg.set_exec_state
2793
2794 fem_pl_pkg.set_exec_state (p_api_version => 1.0,
2795 p_commit => fnd_api.g_true,
2796 p_request_id => a_prvw_dep.dependent_request_id,
2797 p_object_id => a_prvw_dep.dependent_object_id,
2798 x_msg_count => x_msg_count,
2799 x_msg_data => x_msg_data,
2800 x_return_status => x_return_status);
2801
2802 IF x_msg_count > 0 THEN
2803 Get_Put_Messages(
2804 p_msg_count => x_msg_count,
2805 p_msg_data => x_msg_data,
2806 p_user_msg => 'N',
2807 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
2808 END IF;
2809 END IF;
2810
2811 SELECT exec_status_code INTO v_exec_status_code
2812 FROM fem_pl_object_executions
2813 WHERE request_id = a_prvw_dep.dependent_request_id
2814 AND object_id = a_prvw_dep.dependent_object_id;
2815
2816 IF v_exec_status_code = 'RUNNING' THEN
2817 v_count := v_count + 1;
2818 UPDATE fem_ud_prview_dependents
2819 SET validation_status_code = 'FEM_UD_OBJEXEC_IS_RUNNING_ERR',
2820 last_Update_date = sysdate, last_updated_by = pv_apps_user_id
2821 WHERE ud_session_id = p_ud_session_id
2822 AND dependent_request_id = a_prvw_dep.dependent_request_id
2823 AND dependent_object_id = a_prvw_dep.dependent_object_id;
2824 END IF;
2825 END IF;
2826 END LOOP; -- End a_prvw_dep loop
2827
2828 -- Set validation status of dependents that passed validation to 'VALID'
2829 UPDATE fem_ud_prview_dependents
2830 SET validation_status_code = 'FEM_UD_VALID_TXT',
2831 last_update_date = sysdate, last_updated_By = pv_apps_user_id
2832 WHERE ud_session_id = p_ud_session_id
2833 AND request_id = p_request_id
2834 AND object_id = p_object_id
2835 AND validation_status_code IS NULL;
2836
2837 END IF;
2838
2839 IF FND_API.To_Boolean( p_commit ) THEN
2840 COMMIT WORK;
2841 END IF;
2842
2843 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
2844 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2845 p_msg_text => 'End. x_return_status: '||x_return_status);
2846
2847 FND_MSG_PUB.Count_And_Get
2848 (p_count => x_msg_count,
2849 p_data => x_msg_data);
2850
2851 EXCEPTION
2852 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2853 ROLLBACK TO generate_cand_dependents_pub;
2854 x_return_status := pc_ret_sts_unexp_error;
2855
2856 fem_engines_pkg.tech_message(p_severity => pc_log_level_unexpected,
2857 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2858 p_app_name =>'FEM',
2859 p_msg_name => 'FEM_BAD_P_API_VER_ERR',p_token1 => 'VALUE',
2860 p_value1 => p_api_version, p_trans1 => 'N');
2861
2862 fem_engines_pkg.put_message(
2863 p_app_name =>'FEM',
2864 p_msg_name => 'FEM_BAD_P_API_VER_ERR',p_token1 => 'VALUE',
2865 p_value1 => p_api_version, p_trans1 => 'N');
2866
2867 FND_MSG_PUB.Count_And_Get
2868 (p_count => x_msg_count,
2869 p_data => x_msg_data);
2870
2871 WHEN e_invalid_preview_flag THEN
2872 x_return_status := pc_ret_sts_error;
2873
2874 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
2875 p_msg_name => 'FEM_UD_INVALID_PREVIEW_FLAG');
2876
2877 FND_MSG_PUB.Count_And_Get
2878 (p_count => x_msg_count,
2879 p_data => x_msg_data);
2880
2881 WHEN e_invalid_undolist_objdefid THEN
2882 x_return_status := pc_ret_sts_error;
2883
2884 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
2885 p_msg_name => 'FEM_UD_INVALID_UDLISTOBJDEFID');
2886
2887 FND_MSG_PUB.Count_And_Get
2888 (p_count => x_msg_count,
2889 p_data => x_msg_data);
2890
2891 WHEN e_invalid_dependency_type THEN
2892 x_return_status := pc_ret_sts_error;
2893
2894 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
2895 p_msg_name => 'FEM_UD_INVALID_DEPENDENCY_TYPE');
2896
2897 FND_MSG_PUB.Count_And_Get
2898 (p_count => x_msg_count,
2899 p_data => x_msg_data);
2900
2901 WHEN e_invalid_session_id THEN
2902 x_return_status := pc_ret_sts_error;
2903
2904 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
2905 p_msg_name => 'FEM_UD_INVALID_SESSIONID');
2906
2907 FND_MSG_PUB.Count_And_Get
2908 (p_count => x_msg_count,
2909 p_data => x_msg_data);
2910
2911 WHEN e_objexec_is_running THEN
2912 x_return_status := pc_ret_sts_error;
2913
2914 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
2915 p_msg_name => 'FEM_UD_OBJEXEC_IS_RUNNING_ERR');
2916
2917 FND_MSG_PUB.Count_And_Get
2918 (p_count => x_msg_count,
2919 p_data => x_msg_data);
2920
2921 WHEN e_cannot_read_object THEN
2922 x_return_status := pc_ret_sts_error;
2923
2924 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
2925 p_msg_name => 'FEM_UD_CANNOT_READ_OBJECT_ERR');
2926
2927 FND_MSG_PUB.Count_And_Get
2928 (p_count => x_msg_count,
2929 p_data => x_msg_data);
2930
2931 WHEN OTHERS THEN
2932 -- Unexpected exceptions
2933 x_return_status := pc_ret_sts_unexp_error;
2934
2935 -- Log the call stack and the Oracle error message to
2936 -- FND_LOG with the "unexpected exception" severity level.
2937
2938 FEM_ENGINES_PKG.Tech_Message
2939 (p_severity => pc_log_level_unexpected,
2940 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2941 p_msg_text => SQLERRM);
2942
2943 FEM_ENGINES_PKG.Tech_Message
2944 (p_severity => pc_log_level_unexpected,
2945 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
2946 p_msg_text => dbms_utility.format_call_stack);
2947
2948 -- Log the Oracle error message to the stack.
2949 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
2950 p_msg_name => 'FEM_UNEXPECTED_ERROR',
2951 P_TOKEN1 => 'ERR_MSG',
2952 P_VALUE1 => SQLERRM);
2953
2954 FND_MSG_PUB.Count_And_Get
2955 (p_count => x_msg_count,
2956 p_data => x_msg_data);
2957
2958 ROLLBACK TO generate_cand_dependents_pub;
2959 END generate_cand_dependents;
2960 -- *****************************************************************************
2961 PROCEDURE validate_candidates (x_return_status OUT NOCOPY VARCHAR2,
2962 x_msg_count OUT NOCOPY NUMBER,
2963 x_msg_data OUT NOCOPY VARCHAR2,
2964 p_api_version IN NUMBER,
2965 p_commit IN VARCHAR2,
2966 p_undo_list_obj_def_id IN NUMBER DEFAULT NULL,
2967 p_dependency_type IN VARCHAR2,
2968 p_ud_session_id IN NUMBER DEFAULT NULL,
2969 p_preview_flag IN VARCHAR2 DEFAULT 'N') AS
2970 -- ============================================================================
2971 -- PUBLIC
2972 -- This procedure validates all object executions that in the specified undo
2973 -- list or specified undo session. It also generates and validates all
2974 -- dependent object executions.
2975 -- ============================================================================
2976 c_api_name CONSTANT VARCHAR2(30) := 'validate_candidates';
2977 c_api_version CONSTANT NUMBER := 2.0;
2978 v_count NUMBER := 0;
2979 v_count_candidates NUMBER:=0;
2980 v_exec_status_code VARCHAR2(30);
2981
2982 -- This cursor retrieves all candidates in an undo list that have not yet been processed.
2983 CURSOR c1 IS
2984 SELECT request_id, object_id
2985 FROM fem_ud_list_candidates
2986 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
2987 AND (exec_status_code IS NULL OR
2988 exec_status_code <> 'SUCCESS');
2989
2990 -- This cursor retrieves all candidates in an undo list session
2991 CURSOR c2 IS
2992 SELECT request_id, object_id
2993 FROM fem_ud_prview_candidates
2994 WHERE ud_session_id = p_ud_session_id;
2995
2996 BEGIN
2997
2998 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
2999 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3000 p_msg_text => 'Begin. P_COMMIT:'||p_commit||
3001 ' P_PREVIEW_FLAG: '||p_preview_flag||
3002 ' P_UD_SESSION_ID: '||p_ud_session_id||
3003 ' P_UNDO_LIST_OBJ_DEF_ID: '||p_undo_list_obj_def_id||
3004 ' P_DEPENDENCY_TYPE: '||p_dependency_type);
3005
3006 -- Standard Start of API savepoint
3007 SAVEPOINT validate_candidates_pub;
3008
3009 -- Standard call to check for call compatibility.
3010 IF NOT FND_API.Compatible_API_Call (c_api_version,
3011 p_api_version,
3012 c_api_name,
3013 pc_pkg_name)
3014 THEN
3015 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3016 END IF;
3017
3018 -- Initialize API return status to success
3019 x_return_status := pc_ret_sts_success;
3020
3021 -- ============================================================================
3022 -- == VALIDATIONS: Validate input parameters
3023 -- ============================================================================
3024 -- STEP V1: Validate p_preview_flag
3025 -- ============================================================================
3026
3027 IF p_preview_flag NOT IN ('N','Y') THEN
3028 RAISE e_invalid_preview_flag;
3029 END IF;
3030 -- ============================================================================
3031 -- STEP V2: Validate p_ud_session_id
3032 -- ============================================================================
3033
3034 IF p_preview_flag = 'Y' AND p_ud_session_id IS NULL THEN
3035 RAISE e_invalid_session_id;
3036 END IF;
3037
3038 -- ============================================================================
3039 -- STEP V3: Validate p_undo_list_obj_def_id
3040 -- ============================================================================
3041 IF p_preview_flag = 'N' AND p_undo_list_obj_def_id IS NULL THEN
3042 RAISE e_invalid_undolist_objdefid;
3043 END IF;
3044
3045 -- ============================================================================
3046 -- Validate candidates.
3047 -- ============================================================================
3048 v_count_candidates := 0;
3049 IF p_preview_flag = 'N' THEN
3050 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3051 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3052 p_msg_text => 'I am in the section where p_preview_flag = ''N''.');
3053
3054 FOR a_candidate IN c1 LOOP
3055 v_count_candidates := c1%ROWCOUNT;
3056
3057 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3058 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3059 p_msg_text => 'Candidate number:'||v_count_candidates||' REQUEST_ID:'||a_candidate.request_id||
3060 ' OBJECT_ID:'||a_candidate.object_id);
3061 -- ============================================================================
3062 -- V1: Check to make sure user can execute/read the object.
3063 -- ============================================================================
3064 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3065 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3066 p_msg_text => 'Checking to make sure user can read/execute the object');
3067
3068 SELECT count(*) INTO v_count
3069 FROM fem_user_folders u, fem_object_catalog_b o
3070 WHERE o.object_id = a_candidate.object_id
3071 AND o.folder_id = u.folder_id
3072 AND u.user_id = pv_apps_user_id;
3073
3074 IF v_count = 0 THEN
3075 RAISE e_cannot_read_object;
3076 END IF;
3077
3078 -- ============================================================================
3079 -- V2: Check to make sure object execution is not RUNNING.
3080 -- ============================================================================
3081 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3082 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3083 p_msg_text => 'Checking to make sure object is not ''RUNNING''');
3084
3085 -- Bug 6443224. See earlier comment for this bug.
3086 BEGIN
3087 SELECT exec_status_code INTO v_exec_status_code
3088 FROM fem_pl_object_executions
3089 WHERE request_id = a_candidate.request_id
3090 AND object_id = a_candidate.object_id;
3091
3092 IF v_exec_status_code = 'RUNNING' THEN
3093 -- Verify that the request is still running using
3094 -- fem_pl_pkg.set_exec_state
3095 fem_pl_pkg.set_exec_state (p_api_version => 1.0,
3096 p_commit => p_commit,
3097 p_request_id => a_candidate.request_id,
3098 p_object_id => a_candidate.object_id,
3099 x_msg_count => x_msg_count,
3100 x_msg_data => x_msg_data,
3101 x_return_status => x_return_status);
3102
3103 IF x_msg_count > 0 THEN
3104 Get_Put_Messages(
3105 p_msg_count => x_msg_count,
3106 p_msg_data => x_msg_data,
3107 p_user_msg => 'N',
3108 p_module => 'fem.plsql.'||pc_pkg_name||'.'
3109 ||c_api_name);
3110 END IF;
3111 END IF;
3112
3113 SELECT exec_status_code INTO v_exec_status_code
3114 FROM fem_pl_object_executions
3115 WHERE request_id = a_candidate.request_id
3116 AND object_id = a_candidate.object_id;
3117 EXCEPTION
3118 WHEN no_data_found THEN
3119 v_exec_status_code := 'NORMAL';
3120 END;
3121
3122 IF v_exec_status_code = 'RUNNING' THEN
3123 RAISE e_objexec_is_running;
3124 END IF;
3125
3126 -- ============================================================================
3127 -- V3: Check to make sure user can undo all the candidate's dependents.
3128 -- ============================================================================
3129 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3130 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3131 p_msg_text => 'Checking to make sure can undo all candidate''s dependents');
3132
3133 generate_cand_dependents (
3134 p_api_version => 2.0,
3135 p_commit => p_commit,
3136 p_undo_list_obj_def_id => p_undo_list_obj_def_id,
3137 p_request_id => a_candidate.request_id,
3138 p_object_id => a_candidate.object_id,
3139 p_dependency_type => p_dependency_type,
3140 p_preview_flag => 'N',
3141 x_return_status => x_return_status,
3142 x_msg_count => x_msg_count,
3143 x_msg_data => x_msg_data);
3144
3145 IF x_return_status <> pc_ret_sts_success THEN
3146 RAISE e_cannot_validate_dependents;
3147 END IF;
3148 END LOOP;
3149 ELSE -- p_preview_flag = 'Y'
3150 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3151 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3152 p_msg_text => 'I am in the section where p_preview_flag = ''Y''.');
3153
3154 FOR a_candidate IN c2 LOOP
3155 v_count_candidates := c2%ROWCOUNT;
3156
3157 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3158 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3159 p_msg_text => 'Candidate number:'||v_count_candidates||' REQUEST_ID:'||a_candidate.request_id||
3160 ' OBJECT_ID:'||a_candidate.object_id);
3161 BEGIN
3162 -- ============================================================================
3163 -- V1: Check to make sure user can execute/read the object.
3164 -- ============================================================================
3165 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3166 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3167 p_msg_text => 'Checking to make sure user can read/execute the object');
3168
3169 SELECT count(*) INTO v_count
3170 FROM fem_user_folders u, fem_object_catalog_b o
3171 WHERE o.object_id = a_candidate.object_id
3172 AND o.folder_id = u.folder_id
3173 AND u.user_id = pv_apps_user_id;
3174
3175 IF v_count = 0 THEN
3176 RAISE e_cannot_read_object;
3177 END IF;
3178
3179 -- ============================================================================
3180 -- V2: Check to make sure object execution is not RUNNING.
3181 -- ============================================================================
3182 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3183 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3184 p_msg_text => 'Checking to make sure object is not ''RUNNING''');
3185
3186 -- Bug 6443224. See earlier comment for this bug.
3187 BEGIN
3188 SELECT exec_status_code INTO v_exec_status_code
3189 FROM fem_pl_object_executions
3190 WHERE request_id = a_candidate.request_id
3191 AND object_id = a_candidate.object_id;
3192
3193 IF v_exec_status_code = 'RUNNING' THEN
3194 -- Verify that the request is still running using
3195 --fem_pl_pkg.set_exec_state
3196 fem_pl_pkg.set_exec_state (p_api_version => 1.0,
3197 p_commit => p_commit,
3198 p_request_id => a_candidate.request_id,
3199 p_object_id => a_candidate.object_id,
3200 x_msg_count => x_msg_count,
3201 x_msg_data => x_msg_data,
3202 x_return_status => x_return_status);
3203
3204 IF x_msg_count > 0 THEN
3205 Get_Put_Messages(
3206 p_msg_count => x_msg_count,
3207 p_msg_data => x_msg_data,
3208 p_user_msg => 'N',
3209 p_module => 'fem.plsql.'||pc_pkg_name||'.'
3210 ||c_api_name);
3211 END IF;
3212 END IF;
3213
3214 SELECT exec_status_code INTO v_exec_status_code
3215 FROM fem_pl_object_executions
3216 WHERE request_id = a_candidate.request_id
3217 AND object_id = a_candidate.object_id;
3218 EXCEPTION
3219 WHEN no_data_found THEN
3220 v_exec_status_code := 'NORMAL';
3221 END;
3222
3223 IF v_exec_status_code = 'RUNNING' THEN
3224 RAISE e_objexec_is_running;
3225 END IF;
3226
3227 -- ============================================================================
3228 -- V3: Check to make sure user can undo all the candidate's dependents.
3229 -- ============================================================================
3230 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3231 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3232 p_msg_text => 'Checking to make sure can undo all candidate''s dependents');
3233
3234 generate_cand_dependents (
3235 p_api_version => 2.0,
3236 p_commit => p_commit,
3237 p_ud_session_id => p_ud_session_id,
3238 p_request_id => a_candidate.request_id,
3239 p_object_id => a_candidate.object_id,
3240 p_dependency_type => p_dependency_type,
3241 p_preview_flag => 'Y',
3242 x_return_status => x_return_status,
3243 x_msg_count => x_msg_count,
3244 x_msg_data => x_msg_data);
3245
3246 IF x_return_status <> pc_ret_sts_success THEN
3247 RAISE e_cannot_validate_dependents;
3248 END IF;
3249
3250 -- ============================================================================
3251 -- Since the candidate has passed all validations, set its validation
3252 -- status code = 'FEM_UD_VALID_TXT'.
3253 -- ============================================================================
3254 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3255 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3256 p_msg_text => 'Set candidate''s status to ''FEM_UD_VALID_TXT''');
3257
3258 UPDATE fem_ud_prview_candidates
3259 SET validation_status_code = 'FEM_UD_VALID_TXT',
3260 last_update_date = sysdate, last_Updated_by = pv_apps_user_id
3261 WHERE ud_session_id = p_ud_session_id
3262 AND request_id = a_candidate.request_id
3263 AND object_id = a_candidate.object_id;
3264
3265 EXCEPTION
3266 WHEN e_cannot_read_object THEN
3267 UPDATE fem_ud_prview_candidates
3268 SET validation_status_code = 'FEM_UD_CANNOT_READ_OBJECT_ERR',
3269 last_update_date = sysdate, last_Updated_by = pv_apps_user_id
3270 WHERE ud_session_id = p_ud_session_id
3271 AND request_id = a_candidate.request_id
3272 AND object_id = a_candidate.object_id;
3273 WHEN e_objexec_is_running THEN
3274 UPDATE fem_ud_prview_candidates
3275 SET validation_status_code = 'FEM_UD_OBJEXEC_IS_RUNNING_ERR',
3276 last_update_date = sysdate, last_updated_by = pv_apps_user_id
3277 WHERE ud_session_id = p_ud_session_id
3278 AND request_id = a_candidate.request_id
3279 AND object_id = a_candidate.object_id;
3280 WHEN e_cannot_validate_dependents THEN
3281 UPDATE fem_ud_prview_candidates
3282 SET validation_status_code = 'FEM_UD_CANNOT_UNDO_DEPENDENTS',
3283 last_update_date = sysdate, last_Updated_by = pv_apps_user_id
3284 WHERE ud_session_id = p_ud_session_id
3285 AND request_id = a_candidate.request_id
3286 AND object_id = a_candidate.object_id;
3287 END;
3288
3289 END LOOP;
3290
3291 END IF;
3292
3293 IF v_count_candidates = 0 THEN
3294 x_return_status := pc_ret_sts_error;
3295 RAISE e_list_has_no_candidates;
3296 ELSE
3297 x_return_status := pc_ret_sts_success;
3298 END IF;
3299
3300 IF FND_API.To_Boolean( p_commit ) THEN
3301 COMMIT WORK;
3302 END IF;
3303
3304 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
3305 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3306 p_msg_text => 'End. X_RETURN_STATUS: '||x_return_status);
3307
3308 EXCEPTION
3309 WHEN e_invalid_preview_flag THEN
3310 x_return_status := pc_ret_sts_error;
3311
3312 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
3313 p_msg_name => 'FEM_UD_INVALID_PREVIEW_FLAG');
3314
3315 FND_MSG_PUB.Count_And_Get
3316 (p_count => x_msg_count,
3317 p_data => x_msg_data);
3318 WHEN e_invalid_undolist_objdefid THEN
3319 x_return_status := pc_ret_sts_error;
3320
3321 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
3322 p_msg_name => 'FEM_UD_INVALID_UDLISTOBJDEFID');
3323
3324 FND_MSG_PUB.Count_And_Get
3325 (p_count => x_msg_count,
3326 p_data => x_msg_data);
3327 WHEN e_invalid_session_id THEN
3328 x_return_status := pc_ret_sts_error;
3329
3330 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
3331 p_msg_name => 'FEM_UD_INVALID_SESSIONID');
3332
3333 FND_MSG_PUB.Count_And_Get
3334 (p_count => x_msg_count,
3335 p_data => x_msg_data);
3336 WHEN e_cannot_validate_dependents THEN
3337 x_return_status := pc_ret_sts_error;
3338
3339 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
3340 p_msg_name => 'FEM_UD_CANNOT_UNDO_DEPENDENTS');
3341
3342 FND_MSG_PUB.Count_And_Get
3343 (p_count => x_msg_count,
3344 p_data => x_msg_data);
3345 WHEN e_cannot_read_object THEN
3346 x_return_status := pc_ret_sts_error;
3347
3348 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
3349 p_msg_name => 'FEM_UD_CANNOT_READ_OBJECT_ERR');
3350
3351 FND_MSG_PUB.Count_And_Get
3352 (p_count => x_msg_count,
3353 p_data => x_msg_data);
3354 WHEN e_objexec_is_running THEN
3355 x_return_status := pc_ret_sts_error;
3356
3357 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
3358 p_msg_name => 'FEM_UD_OBJEXEC_IS_RUNNING_ERR');
3359
3360 FND_MSG_PUB.Count_And_Get
3361 (p_count => x_msg_count,
3362 p_data => x_msg_data);
3363 WHEN e_list_has_no_candidates THEN
3364 ROLLBACK TO validate_candidates_pub;
3365 x_return_status := pc_ret_sts_error;
3366
3367 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
3368 p_msg_name => 'FEM_UD_NO_CANDIDATES_ERR');
3369
3370 fem_engines_pkg.tech_message(p_severity => pc_log_level_error,
3371 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3372 p_app_name =>'FEM',
3373 p_msg_name => 'FEM_UD_NO_CANDIDATES_ERR');
3374
3375 FND_MSG_PUB.Count_And_Get
3376 (p_count => x_msg_count,
3377 p_data => x_msg_data);
3378
3379 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3380 ROLLBACK TO validate_candidates_pub;
3381 x_return_status := pc_ret_sts_unexp_error;
3382
3383 fem_engines_pkg.tech_message(p_severity => pc_log_level_unexpected,
3384 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3385 p_app_name =>'FEM',
3386 p_msg_name => 'FEM_BAD_P_API_VER_ERR',p_token1 => 'VALUE',
3387 p_value1 => p_api_version, p_trans1 => 'N');
3388
3389 WHEN OTHERS THEN
3390 -- Unexpected exceptions
3391 x_return_status := pc_ret_sts_unexp_error;
3392
3393 -- Log the call stack and the Oracle error message to
3394 -- FND_LOG with the "unexpected exception" severity level.
3395
3396 FEM_ENGINES_PKG.Tech_Message
3397 (p_severity => pc_log_level_unexpected,
3398 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3399 p_msg_text => SQLERRM);
3400
3401 FEM_ENGINES_PKG.Tech_Message
3402 (p_severity => pc_log_level_unexpected,
3403 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3404 p_msg_text => dbms_utility.format_call_stack);
3405
3406 -- Log the Oracle error message to the stack.
3407 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
3408 p_msg_name => 'FEM_UNEXPECTED_ERROR',
3409 P_TOKEN1 => 'ERR_MSG',
3410 P_VALUE1 => SQLERRM);
3411
3412 FND_MSG_PUB.Count_And_Get
3413 (p_count => x_msg_count,
3414 p_data => x_msg_data);
3415
3416 ROLLBACK TO validate_candidates_pub;
3417 END validate_candidates;
3418 -- *****************************************************************************
3419 -- *****************************************************************************
3420 PROCEDURE perform_undo_actions (x_return_status OUT NOCOPY VARCHAR2,
3421 p_undo_list_obj_def_id IN NUMBER,
3422 p_obj_exec_type IN VARCHAR2,
3423 p_request_id IN NUMBER,
3424 p_object_id IN NUMBER) AS
3425
3426 -- ============================================================================
3427 -- PUBLIC
3428 -- This is the main procedure of the 'Undo Engine' that processes each
3429 -- object execution.
3430 -- ============================================================================
3431 c_api_name CONSTANT VARCHAR2(30) := 'perform_undo_actions';
3432 v_sql_stmt VARCHAR2(2000);
3433 v_where_clause VARCHAR2(2000);
3434 v_count_tbls NUMBER := 0;
3435 v_count_cols NUMBER := 0;
3436 v_object_type_code VARCHAR2(30);
3437 v_obj_exec_status VARCHAR2(30);
3438 v_mp_step_name VARCHAR2(30);
3439 v_mp_prg_stat VARCHAR2(100);
3440 v_mp_exception_code VARCHAR2(30);
3441 v_mp_stmt_id VARCHAR2(40);
3442 v_undo_list_obj_id NUMBER;
3443 v_rows_processed NUMBER;
3444 v_undo_flag VARCHAR2(1);
3445 v_msg_count NUMBER;
3446 v_msg_data VARCHAR2(32000);
3447 v_tab_name FEM_PL_TABLES.table_name%TYPE;
3448 v_tab_class FEM_TABLE_CLASS_ASSIGNMT.table_classification_code%TYPE;
3449 v_stmt_type FEM_PL_TABLES.statement_type%TYPE;
3450 v_col_name FEM_PL_TAB_UPDATED_COLS.column_name%TYPE;
3451 v_object_name FEM_OBJECT_CATALOG_VL.object_name%TYPE;
3452
3453 -- Returns a distinct list of tables and undo actions
3454 CURSOR c1 IS
3455 SELECT distinct p.statement_type, p.table_name,
3456 max(t.undo_type) over (partition by p.table_name)
3457 undo_type,
3458 DECODE(p.statement_type, 'INSERT','DELETE','MERGE',
3459 'INSERT and DELETE','UPDATE') undo_statement_type
3460 FROM fem_pl_tables p,
3461 (select decode(table_classification_code,
3462 'TRANSACTION_PROFITABILITY','ZERO_COLUMN_BY_OBJECT',
3463 'CUSTOMER_PROFIT_RESULT','ZERO_COLUMN_BY_OBJECT',
3464 'ACCOUNT_PROFITABILITY','ZERO_COLUMN_BY_PERIOD',
3465 'FTP_CASH_FLOW','ZERO_COLUMN_BY_PERIOD',
3466 'FTP_NON_CASH_FLOW','ZERO_COLUMN_BY_PERIOD',
3467 'FTP_OPTION_COST','ZERO_COLUMN_BY_PERIOD',NULL)
3468 undo_type, table_name
3469 from fem_table_class_assignmt_v) t
3470 WHERE p.request_id = p_request_id
3471 AND p.object_id = p_object_id
3472 AND p.table_name = t.table_name(+)
3473 ORDER BY table_name, statement_type;
3474
3475 CURSOR c2 (v_table_name IN VARCHAR2, v_statement_type IN VARCHAR2) IS
3476 SELECT column_name AS colname
3477 FROM fem_pl_tab_updated_cols
3478 WHERE request_id = p_request_id
3479 AND object_id = p_object_id
3480 AND table_name = v_table_name
3481 AND statement_type = v_statement_type
3482 ORDER BY column_name;
3483
3484 BEGIN
3485
3486 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
3487 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3488 p_msg_text => 'Begin. P_UNDO_LIST_OBJ_DEF_ID: '||p_undo_list_obj_def_id||
3489 ' P_REQUEST_ID: '||p_request_id||
3490 ' P_OBJECT_ID: '||p_object_id||
3491 ' P_OBJ_EXEC_TYPE: '||p_obj_exec_type);
3492
3493 -- Initialize return status to success
3494 x_return_status := pc_ret_sts_success;
3495
3496 -- Retrieve object_type of the object execution.
3497 BEGIN
3498 SELECT o.object_type_code, t.undo_flag
3499 INTO v_object_type_code, v_undo_flag
3500 FROM fem_object_catalog_b o, fem_object_types t
3501 WHERE o.object_id = p_object_id
3502 AND t.object_type_code = o.object_type_code;
3503
3504 EXCEPTION
3505 WHEN NO_DATA_FOUND THEN
3506
3507 fem_engines_pkg.tech_message(p_severity => pc_log_level_event,
3508 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3509 p_msg_text => 'Could not retrieve OBJECT_TYPE_CODE for OBJECT_ID: '||p_object_id);
3510
3511 END;
3512
3513 -- Retrieve undo list object id
3514 SELECT object_id INTO v_undo_list_obj_id
3515 FROM fem_object_definition_b
3516 WHERE object_definition_id = p_undo_list_obj_def_id;
3517
3518 -- ============================================================================
3519 -- STEP 1:
3520 -- Set status of object execution in undo list to 'RUNNING'.
3521 -- ============================================================================
3522 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3523 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3524 p_msg_text => 'STEP 1: Set status of object execution in undo list to ''RUNNING''');
3525
3526 -- Get rule name
3527 BEGIN
3528 SELECT object_name
3529 INTO v_object_name
3530 FROM fem_object_catalog_vl
3531 WHERE object_id = p_object_id;
3532 EXCEPTION
3533 WHEN others THEN
3534 v_object_name := to_char(p_object_id);
3535 END;
3536
3537 fem_engines_pkg.user_message(p_app_name =>'FEM',
3538 p_msg_name => 'FEM_UD_PROCESSING_OBJEXEC_TXT',
3539 p_token1 => 'RULE_NAME',
3540 p_value1 => v_object_name,
3541 p_token2 => 'REQUEST_ID',
3542 p_value2 => p_request_id);
3543
3544 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3545 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3546 p_app_name =>'FEM',
3547 p_msg_name => 'FEM_UD_PROCESSING_OBJEXEC_TXT',
3548 p_token1 => 'RULE_NAME',
3549 p_value1 => v_object_name,
3550 p_token2 => 'REQUEST_ID',
3551 p_value2 => p_request_id);
3552
3553 IF p_obj_exec_type = 'DEPENDENT' THEN
3554 UPDATE fem_ud_list_dependents
3555 SET exec_status_code = 'RUNNING',
3556 last_update_date = sysdate, last_updated_by = pv_apps_user_id
3557 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
3558 AND dependent_request_id = p_request_id
3559 AND dependent_object_id = p_object_id;
3560 ELSE
3561 -- p_obj_exec_type = 'CANDIDATE'
3562 UPDATE fem_ud_list_candidates
3563 SET exec_status_code = 'RUNNING',
3564 last_update_date = sysdate, last_Updated_by = pv_apps_user_id
3565 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
3566 AND request_id = p_request_id
3567 AND object_id = p_object_id;
3568 END IF;
3569 COMMIT;
3570
3571 IF v_undo_flag = 'N' THEN
3572
3573 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3574 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3575 p_msg_text => 'v_undo_flag:'||v_undo_flag||' IGNORE Step 2:Process statements in FEM_PL_TABLES');
3576
3577 ELSE
3578
3579 -- ============================================================================
3580 -- STEP 2:
3581 -- Process statements in FEM_PL_TABLES.
3582 -- ============================================================================
3583 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3584 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3585 p_msg_text => 'STEP 2: Process statements in FEM_PL_TABLES');
3586
3587 FOR atbl IN C1 LOOP
3588 fem_engines_pkg.tech_message(p_severity => pc_log_level_event,
3589 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3590 p_app_name => 'FEM',
3591 p_msg_name => 'FEM_UD_TABLE_STATEMENT_TXT',
3592 p_token1 => 'TABLE_NAME',
3593 p_value1 => atbl.table_name,
3594 p_trans1 => 'N',
3595 p_token2 => 'STATEMENT_TYPE',
3596 p_value2 => atbl.undo_statement_type,
3597 p_trans2 => 'N');
3598
3599
3600 -- set variables for error message
3601 v_tab_name := atbl.table_name;
3602 v_stmt_type := atbl.statement_type;
3603
3604 -- Determine MP step name
3605 BEGIN
3606 SELECT max(decode(table_classification_code,'GENERIC_DATA_TABLE',
3607 'GENERIC_DATA_TABLE','LEDGER')) INTO v_mp_step_name
3608 FROM fem_table_class_assignmt_v
3609 WHERE (table_classification_code = 'GENERIC_DATA_TABLE'
3610 OR table_classification_code like '%LEDGER')
3611 AND table_name = atbl.table_name;
3612 EXCEPTION
3613 WHEN NO_DATA_FOUND THEN
3614 v_mp_step_name := 'ALL';
3615 END;
3616
3617 v_count_tbls := c1%ROWCOUNT;
3618
3619 IF atbl.statement_type = 'INSERT' THEN
3620 -- ============================================================================
3621 -- S2A: Process statements in FEM_PL_TABLES (INSERT statement section)
3622 -- ============================================================================
3623
3624 -- Bug 5738732: Added {{table_partition}} token
3625 v_sql_stmt := 'DELETE '||atbl.table_name||' {{table_partition}} ';
3626 v_where_clause := ' CREATED_BY_REQUEST_ID = '||p_request_id||
3627 ' AND CREATED_BY_OBJECT_ID = '||p_object_id;
3628
3629 v_sql_stmt := v_sql_stmt||' WHERE '||v_where_clause||' AND {{data_slice}} ';
3630 v_mp_stmt_id := atbl.table_name||'_DELETE_'||v_count_tbls;
3631
3632 -- submit statement to MP engine.
3633 -- EXECUTE IMMEDIATE v_sql_stmt||' '||v_where_clause; (pre MP testing)
3634 fem_multi_proc_pkg.master(
3635 x_prg_stat => v_mp_prg_stat,
3636 x_exception_code => v_mp_exception_code,
3637 p_rule_id => v_undo_list_obj_id,
3638 p_eng_step => v_mp_step_name,
3639 p_data_table => atbl.table_name,
3640 p_eng_sql => v_sql_stmt,
3641 p_run_name => v_mp_stmt_id,
3642 p_condition => v_where_clause);
3643
3644 IF v_mp_prg_stat = 'COMPLETE:NORMAL' THEN
3645 -- retrieve number of rows processed and send technical message.
3646 SELECT NVL(SUM(rows_processed),0)
3647 INTO v_rows_processed
3648 FROM fem_mp_process_ctl_t
3649 WHERE req_id = pv_request_id;
3650
3651 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3652 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3653 p_msg_text => 'Number of rows processed:'||v_rows_processed||' ');
3654
3655 ELSIF v_mp_exception_code = 'FEM_MP_NO_DATA_SLICES_ERR' THEN
3656 v_rows_processed := 0;
3657
3658 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3659 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3660 p_msg_text => 'Number of rows processed: 0');
3661
3662 ELSE
3663 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3664 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3665 p_msg_text => 'MP framework return status:'||v_mp_prg_stat||
3666 ' MP exception code:'||v_mp_exception_code||' SQL statement: '||v_sql_stmt);
3667
3668 RAISE e_mp_error;
3669
3670 END IF;
3671
3672 fem_engines_pkg.user_message(p_app_name =>'FEM',
3673 p_msg_name => 'FEM_UD_DELETE_SUMMARY_TXT',
3674 p_token1 => 'NUM_ROWS',
3675 p_value1 => v_rows_processed,
3676 p_token2 => 'TABLE_NAME',
3677 p_value2 => v_tab_name);
3678
3679 fem_multi_proc_pkg.delete_data_slices(
3680 p_req_id => pv_request_id);
3681
3682 ELSIF atbl.statement_type = 'UPDATE' AND
3683 atbl.undo_type IN ('ZERO_COLUMN_BY_PERIOD',
3684 'ZERO_COLUMN_BY_OBJECT') THEN
3685 -- ============================================================================
3686 -- S2B: Process statements in FEM_PL_TABLES (UPDATE statement section)
3687 -- For the FEM.D release. Update statements are only processed for
3688 -- tables that belong to classifications that allow the undo of updates.
3689 -- The list of classifications is currently hard-coded for FEM.D and
3690 -- will be metadata driven in the future. For now, the list can be
3691 -- determined by looking at the "c1" cursor definition.
3692 -- ============================================================================
3693
3694 v_sql_stmt := 'UPDATE '||atbl.table_name
3695 ||' {{table_partition}} SET';
3696
3697 FOR acol IN c2(atbl.table_name, atbl.statement_type) LOOP
3698 v_count_cols := c2%ROWCOUNT; -- Set counter to indicate that at least one column found.
3699
3700 IF v_count_cols = 1 THEN -- If this is first row
3701 v_sql_stmt := v_sql_stmt||' '||acol.colname||'=0';
3702 ELSE
3703 v_sql_stmt := v_sql_stmt||', '||acol.colname||'=0';
3704 END IF;
3705
3706 END LOOP;
3707
3708 IF v_count_cols = 0 THEN
3709 -- No column found
3710
3711 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
3712 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3713 p_app_name =>'FEM',
3714 p_msg_name => 'FEM_UD_NO_UPD_COL_FOUND_WRN');
3715
3716 ELSE
3717 -- at least one column exists
3718 IF atbl.undo_type = 'ZERO_COLUMN_BY_PERIOD' THEN
3719 SELECT ' CAL_PERIOD_ID = '||cal_period_id||
3720 ' AND LEDGER_ID = '||ledger_id||
3721 ' AND DATASET_CODE = '||output_dataset_code
3722 INTO v_where_clause
3723 FROM fem_pl_requests
3724 WHERE request_id = p_request_id;
3725 ELSE -- atbl.undo_type = 'ZERO_COLUMN_BY_OBJECT'
3726 v_where_clause := ' LAST_UPDATED_BY_REQUEST_ID = '||p_request_id||
3727 ' AND LAST_UPDATED_BY_OBJECT_ID = '||p_object_id;
3728 END IF;
3729 -- prepare statement
3730 v_sql_stmt := v_sql_stmt||' WHERE '||v_where_clause||' AND {{data_slice}} ';
3731 v_mp_stmt_id := atbl.table_name||'_UPDATE_'||v_count_tbls;
3732
3733 -- submit statement to MP engine.
3734 -- EXECUTE IMMEDIATE v_sql_stmt||' '||v_where_clause; (pre MP testing)
3735 fem_multi_proc_pkg.master(
3736 x_prg_stat => v_mp_prg_stat,
3737 x_exception_code => v_mp_exception_code,
3738 p_rule_id => v_undo_list_obj_id,
3739 p_eng_step => v_mp_step_name,
3740 p_data_table => atbl.table_name,
3741 p_eng_sql => v_sql_stmt,
3742 p_run_name => v_mp_stmt_id,
3743 p_condition => v_where_clause);
3744
3745 IF v_mp_prg_stat = 'COMPLETE:NORMAL' THEN
3746 -- retrieve number of rows processed and send technical message.
3747 SELECT NVL(SUM(rows_processed),0)
3748 INTO v_rows_processed
3749 FROM fem_mp_process_ctl_t
3750 WHERE req_id = pv_request_id;
3751
3752 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3753 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3754 p_msg_text => 'Number of rows processed:'||v_rows_processed||' ');
3755 ELSIF v_mp_exception_code = 'FEM_MP_NO_DATA_SLICES_ERR' THEN
3756 v_rows_processed := 0;
3757
3758 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3759 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3760 p_msg_text => 'Number of rows processed: 0');
3761 ELSE
3762 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3763 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3764 p_msg_text => 'MP framework return status:'||v_mp_prg_stat||
3765 ' MP exception code:'||v_mp_exception_code||' SQL statement: '||v_sql_stmt);
3766
3767 RAISE e_mp_error;
3768 END IF;
3769
3770 fem_engines_pkg.user_message(p_app_name =>'FEM',
3771 p_msg_name => 'FEM_UD_UPDATE_SUMMARY_TXT',
3772 p_token1 => 'NUM_ROWS',
3773 p_value1 => v_rows_processed,
3774 p_token2 => 'TABLE_NAME',
3775 p_value2 => v_tab_name);
3776
3777 END IF;
3778
3779 fem_multi_proc_pkg.delete_data_slices(
3780 p_req_id => pv_request_id);
3781
3782 ELSIF atbl.statement_type = 'MERGE' THEN
3783 -- For Merge statements, do a DELETE and an UPDATE.
3784 -- =========================================================================
3785 -- S2C: Process statements in FEM_PL_TABLES (MERGE statement section)
3786 -- Undo handles MERGE statements with the same logic as undoing an INSERT
3787 -- statement followed by the undoing of an UPDATE statement (using the
3788 -- same undo logic as above for the individual statements).
3789 -- =========================================================================
3790
3791 -- Test to make sure that if Rule registered update columns,
3792 -- that the table being updated is an undo type that
3793 -- this undo program knows how to handle
3794 OPEN c2(atbl.table_name, atbl.statement_type);
3795 FETCH c2 INTO v_col_name;
3796 -- If no columns, then do not do update, just delete
3797 IF c2%NOTFOUND THEN
3798 CLOSE c2;
3799 ELSE
3800 CLOSE c2;
3801 IF nvl(atbl.undo_type,'XX') NOT IN
3802 ('ZERO_COLUMN_BY_OBJECT',
3803 'ZERO_COLUMN_BY_PERIOD') THEN
3804 RAISE e_undo_action_not_supported;
3805 END IF;
3806 END IF;
3807
3808 ------------------
3809 -- DELETE statement
3810 ------------------
3811 v_sql_stmt := 'DELETE '||atbl.table_name||' {{table_partition}} ';
3812 v_where_clause := ' CREATED_BY_REQUEST_ID = '||p_request_id||
3813 ' AND CREATED_BY_OBJECT_ID = '||p_object_id;
3814
3815 -- prepare statement
3816 v_sql_stmt := v_sql_stmt||' WHERE '||v_where_clause||' AND {{data_slice}} ';
3817 v_mp_stmt_id := atbl.table_name||'_MERGE_DEL_'||v_count_tbls;
3818
3819 -- submit statement to MP engine.
3820 -- EXECUTE IMMEDIATE v_sql_stmt||' '||v_where_clause; (pre MP testing)
3821 fem_multi_proc_pkg.master(
3822 x_prg_stat => v_mp_prg_stat,
3823 x_exception_code => v_mp_exception_code,
3824 p_rule_id => v_undo_list_obj_id,
3825 p_eng_step => v_mp_step_name,
3826 p_data_table => atbl.table_name,
3827 p_eng_sql => v_sql_stmt,
3828 p_run_name => v_mp_stmt_id,
3829 p_condition => v_where_clause);
3830
3831 IF v_mp_prg_stat = 'COMPLETE:NORMAL' THEN
3832 -- retrieve number of rows processed and send technical message.
3833 SELECT NVL(SUM(rows_processed),0)
3834 INTO v_rows_processed
3835 FROM fem_mp_process_ctl_t
3836 WHERE req_id = pv_request_id;
3837
3838 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3839 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3840 p_msg_text => 'Number of rows processed:'||v_rows_processed||' ');
3841 ELSIF v_mp_exception_code = 'FEM_MP_NO_DATA_SLICES_ERR' THEN
3842 v_rows_processed := 0;
3843
3844 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3845 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3846 p_msg_text => 'Number of rows processed: 0');
3847 ELSE
3848 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3849 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3850 p_msg_text => 'MP framework return status:'||v_mp_prg_stat||
3851 ' MP exception code:'||v_mp_exception_code||' SQL statement: '||v_sql_stmt);
3852
3853 RAISE e_mp_error;
3854 END IF;
3855
3856 fem_engines_pkg.user_message(p_app_name =>'FEM',
3857 p_msg_name => 'FEM_UD_DELETE_SUMMARY_TXT',
3858 p_token1 => 'NUM_ROWS',
3859 p_value1 => v_rows_processed,
3860 p_token2 => 'TABLE_NAME',
3861 p_value2 => v_tab_name);
3862
3863 fem_multi_proc_pkg.delete_data_slices(
3864 p_req_id => pv_request_id);
3865
3866
3867 -------------------
3868 -- UPDATE statement
3869 -------------------
3870
3871 -- FEM.D Only handles the following undo types
3872 IF atbl.undo_type IN ('ZERO_COLUMN_BY_PERIOD',
3873 'ZERO_COLUMN_BY_OBJECT') THEN
3874
3875 v_sql_stmt := 'UPDATE '||atbl.table_name
3876 ||' {{table_partition}} SET';
3877
3878 FOR acol IN c2(atbl.table_name, atbl.statement_type) LOOP
3879 v_count_cols := c2%ROWCOUNT; -- Set counter to indicate that at least one column found.
3880
3881 IF v_count_cols = 1 THEN -- If this is first row
3882 v_sql_stmt := v_sql_stmt||' '||acol.colname||'=0';
3883 ELSE
3884 v_sql_stmt := v_sql_stmt||', '||acol.colname||'=0';
3885 END IF;
3886
3887 END LOOP;
3888
3889 IF v_count_cols = 0 THEN
3890 -- No column found
3891
3892 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
3893 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3894 p_app_name =>'FEM',
3895 p_msg_name => 'FEM_UD_NO_UPD_COL_FOUND_WRN');
3896
3897 ELSE
3898 -- at least one column exists
3899
3900 IF atbl.undo_type = 'ZERO_COLUMN_BY_PERIOD' THEN
3901 SELECT ' CAL_PERIOD_ID = '||cal_period_id||
3902 ' AND LEDGER_ID = '||ledger_id||
3903 ' AND DATASET_CODE = '||output_dataset_code
3904 INTO v_where_clause
3905 FROM fem_pl_requests
3906 WHERE request_id = p_request_id;
3907 ELSE -- atbl.undo_type = 'ZERO_COLUMN_BY_OBJECT'
3908 v_where_clause := ' LAST_UPDATED_BY_REQUEST_ID = '||p_request_id||
3909 ' AND LAST_UPDATED_BY_OBJECT_ID = '||p_object_id;
3910 END IF;
3911
3912 -- prepare statement
3913 v_sql_stmt := v_sql_stmt||' WHERE '||v_where_clause||' AND {{data_slice}} ';
3914 v_mp_stmt_id := atbl.table_name||'_MERGE_UPD_'||v_count_tbls;
3915
3916 -- submit statement to MP engine.
3917 -- EXECUTE IMMEDIATE v_sql_stmt||' '||v_where_clause; (pre MP testing)
3918 fem_multi_proc_pkg.master(
3919 x_prg_stat => v_mp_prg_stat,
3920 x_exception_code => v_mp_exception_code,
3921 p_rule_id => v_undo_list_obj_id,
3922 p_eng_step => v_mp_step_name,
3923 p_data_table => atbl.table_name,
3924 p_eng_sql => v_sql_stmt,
3925 p_run_name => v_mp_stmt_id,
3926 p_condition => v_where_clause);
3927
3928 IF v_mp_prg_stat = 'COMPLETE:NORMAL' THEN
3929 -- retrieve number of rows processed and send technical message.
3930 SELECT NVL(SUM(rows_processed),0)
3931 INTO v_rows_processed
3932 FROM fem_mp_process_ctl_t
3933 WHERE req_id = pv_request_id;
3934
3935 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3936 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3937 p_msg_text => 'Number of rows processed:'||v_rows_processed||' ');
3938
3939 ELSIF v_mp_exception_code = 'FEM_MP_NO_DATA_SLICES_ERR' THEN
3940 v_rows_processed := 0;
3941
3942 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3943 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3944 p_msg_text => 'Number of rows processed: 0');
3945
3946 ELSE
3947
3948 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
3949 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3950 p_msg_text => 'MP framework return status:'||v_mp_prg_stat||
3951 ' MP exception code:'||v_mp_exception_code||' SQL statement: '||v_sql_stmt);
3952
3953 RAISE e_mp_error;
3954 END IF;
3955
3956 fem_engines_pkg.user_message(p_app_name =>'FEM',
3957 p_msg_name => 'FEM_UD_UPDATE_SUMMARY_TXT',
3958 p_token1 => 'NUM_ROWS',
3959 p_value1 => v_rows_processed,
3960 p_token2 => 'TABLE_NAME',
3961 p_value2 => v_tab_name);
3962
3963 fem_multi_proc_pkg.delete_data_slices(
3964 p_req_id => pv_request_id);
3965
3966 END IF; -- v_count_cols = 0
3967
3968 END IF; -- atbl.undo_type IN (...)
3969 -- End update portion of merge statement
3970
3971 ELSE
3972 -- Undo does not support the undo of such statement types/tables
3973 RAISE e_undo_action_not_supported;
3974
3975 END IF; -- End statement_type processing.
3976
3977 END LOOP;
3978
3979 IF v_count_tbls = 0 THEN
3980 -- If no table found then
3981 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
3982 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
3983 p_app_name =>'FEM',
3984 p_msg_name => 'FEM_UD_NO_TABLE_FOUND_WRN');
3985
3986 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
3987 p_msg_name => 'FEM_UD_NO_TABLE_FOUND_WRN');
3988 END IF;
3989
3990 Get_Put_Messages(
3991 p_msg_count => v_msg_count,
3992 p_msg_data => v_msg_data,
3993 p_user_msg => 'N',
3994 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
3995 -- End table processing (Step 2 done only if fem_object_types.undo_flag = 'Y').
3996
3997 -- ============================================================================
3998 -- STEP 3:
3999 -- Delete data from the data location tables (FEM_DL_xxxx).
4000 -- This is only required in cases where fem_object_Types.undo_flag='Y'.
4001 -- ============================================================================
4002 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4003 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4004 p_msg_text => 'STEP 3: Delete data from the data location tables (FEM_DL_xxxx).');
4005
4006 fem_dimension_util_pkg.unregister_data_location(
4007 p_request_id => p_request_id,
4008 p_object_id => p_object_id);
4009
4010 END IF;
4011
4012 -- ============================================================================
4013 -- STEP 4:
4014 -- Execute all engine specific procedures.
4015 -- ============================================================================
4016 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4017 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4018 p_msg_text => 'STEP 4: Execute all engine specific procedures.');
4019
4020 IF v_object_type_code IN ('OGL_INTG_BAL_RULE','XGL_INTEGRATION') THEN
4021
4022 fem_gl_post_process_pkg.undo_xgl_interface_error_rows (
4023 p_request_id => p_request_id,
4024 x_return_status => x_return_status,
4025 x_msg_count => v_msg_count,
4026 x_msg_data => v_msg_data);
4027
4028 IF x_return_status <> pc_ret_sts_success THEN
4029
4030 Get_Put_Messages(
4031 p_msg_count => v_msg_count,
4032 p_msg_data => v_msg_data,
4033 p_user_msg => 'Y',
4034 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name||'.undo_xgl_interface_error_rows');
4035
4036 RAISE e_engine_specific_proc_err;
4037 ELSIF v_msg_count > 0 THEN
4038 Get_Put_Messages(
4039 p_msg_count => v_msg_count,
4040 p_msg_data => v_msg_data,
4041 p_user_msg => 'N',
4042 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name||'.undo_xgl_interface_error_rows');
4043
4044 END IF;
4045
4046 END IF;
4047
4048
4049 -- ============================================================================
4050 -- STEP 5:
4051 -- Remove object execution log.
4052 -- ============================================================================
4053
4054 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4055 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4056 p_msg_text => 'STEP 5: Remove object execution log.');
4057
4058 delete_execution_log (
4059 p_commit => FND_API.G_TRUE,
4060 p_api_version => 1.0,
4061 p_request_id => p_request_id,
4062 p_object_id => p_object_id,
4063 x_return_status => x_return_status,
4064 x_msg_count => v_msg_count,
4065 x_msg_data => v_msg_data);
4066
4067 IF x_return_status <> pc_ret_sts_success THEN
4068 Get_Put_Messages(
4069 p_msg_count => v_msg_count,
4070 p_msg_data => v_msg_data,
4071 p_user_msg => 'Y',
4072 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name||'.delete_execution_log');
4073
4074 RAISE e_cannot_delete_execution_log;
4075 END IF;
4076
4077 -- ============================================================================
4078 -- STEP 6:
4079 -- Update status of object execution in undo list.
4080 -- ============================================================================
4081 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4082 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4083 p_msg_text => 'STEP 6: Update status of object execution in undo list to SUCCESS.');
4084
4085 IF p_obj_exec_type = 'DEPENDENT' THEN
4086 UPDATE fem_ud_list_dependents
4087 SET exec_status_code = 'SUCCESS',
4088 last_Update_date = sysdate, last_Updated_by = pv_apps_user_id
4089 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4090 AND dependent_request_id = p_request_id
4091 AND dependent_object_id = p_object_id;
4092 ELSE
4093 -- p_obj_exec_type = 'CANDIDATE'
4094 UPDATE fem_ud_list_candidates
4095 SET exec_status_code = 'SUCCESS',
4096 last_update_date = sysdate, last_updated_by = pv_apps_user_id
4097 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4098 AND request_id = p_request_id
4099 AND object_id = p_object_id;
4100 END IF;
4101 COMMIT;
4102
4103 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
4104 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4105 p_msg_text => 'End. x_return_status: '||x_return_status);
4106
4107 EXCEPTION
4108 WHEN e_undo_action_not_supported THEN
4109 x_return_status := pc_ret_sts_error;
4110
4111 v_tab_class := null;
4112 BEGIN
4113 SELECT max(table_classification_code)
4114 INTO v_tab_class
4115 FROM fem_table_class_assignmt_v
4116 WHERE table_classification_code NOT IN ('CUSTOMER_PROFIT_RESULT',
4117 'TRANSACTION_PROFITABILITY','ACCOUNT_PROFITABILITY',
4118 'FTP_CASH_FLOW','FTP_NON_CASH_FLOW','FTP_OPTION_COST')
4119 AND table_name = v_tab_name;
4120 EXCEPTION WHEN others THEN null;
4121 END;
4122
4123 FEM_ENGINES_PKG.tech_message(
4124 p_severity => pc_log_level_statement,
4125 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4126 p_msg_text => 'Cannot undo table '||v_tab_name
4127 ||' if it belongs to '||v_tab_class||' table class.');
4128
4129 FEM_ENGINES_PKG.tech_message(
4130 p_severity => pc_log_level_statement,
4131 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4132 p_msg_text => 'Statement type = '||v_stmt_type);
4133
4134 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
4135 p_msg_name => 'FEM_UD_ACTION_NOT_SUPPORTED',
4136 p_token1 => 'TAB_NAME',
4137 p_value1 => v_tab_name);
4138
4139 -- Update status of object execution in undo list.
4140 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4141 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4142 p_msg_text => 'Update status of object execution in undo list to ERROR_RERUN');
4143
4144 IF p_obj_exec_type = 'DEPENDENT' THEN
4145 UPDATE fem_ud_list_dependents
4146 SET exec_status_code = 'ERROR_RERUN',
4147 last_update_date = sysdate, last_Updated_by = pv_apps_User_id
4148 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4149 AND dependent_request_id = p_request_id
4150 AND dependent_object_id = p_object_id;
4151
4152 UPDATE fem_ud_list_candidates
4153 SET exec_status_code = 'ERROR_RERUN',
4154 last_update_date = sysdate, last_Updated_by = pv_apps_user_id
4155 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4156 AND exec_status_code = 'RUNNING';
4157 COMMIT;
4158
4159 ELSE
4160 -- p_obj_exec_type = 'CANDIDATE'
4161 UPDATE fem_ud_list_candidates
4162 SET exec_status_code = 'ERROR_RERUN',
4163 last_update_date = sysdate, last_updated_by = pv_apps_user_id
4164 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4165 AND request_id = p_request_id
4166 AND object_id = p_object_id;
4167 END IF;
4168 COMMIT;
4169
4170 WHEN e_mp_error THEN
4171 x_return_status := pc_ret_sts_error;
4172 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
4173 p_msg_name => 'FEM_MP_ERR');
4174
4175 -- Update status of object execution in undo list.
4176 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4177 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4178 p_msg_text => 'Update status of object execution in undo list to ERROR_RERUN');
4179
4180 IF p_obj_exec_type = 'DEPENDENT' THEN
4181 UPDATE fem_ud_list_dependents
4182 SET exec_status_code = 'ERROR_RERUN',
4183 last_update_date = sysdate, last_Updated_by = pv_apps_User_id
4184 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4185 AND dependent_request_id = p_request_id
4186 AND dependent_object_id = p_object_id;
4187
4188 UPDATE fem_ud_list_candidates
4189 SET exec_status_code = 'ERROR_RERUN',
4190 last_update_date = sysdate, last_Updated_by = pv_apps_user_id
4191 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4192 AND exec_status_code = 'RUNNING';
4193 COMMIT;
4194
4195 ELSE
4196 -- p_obj_exec_type = 'CANDIDATE'
4197 UPDATE fem_ud_list_candidates
4198 SET exec_status_code = 'ERROR_RERUN',
4199 last_update_date = sysdate, last_updated_by = pv_apps_user_id
4200 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4201 AND request_id = p_request_id
4202 AND object_id = p_object_id;
4203 END IF;
4204 COMMIT;
4205
4206 WHEN e_engine_specific_proc_err THEN
4207 x_return_status := pc_ret_sts_error;
4208
4209 -- Update status of object execution in undo list.
4210 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4211 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4212 p_msg_text => 'Update status of object execution in undo list to ERROR_RERUN');
4213
4214 IF p_obj_exec_type = 'DEPENDENT' THEN
4215 UPDATE fem_ud_list_dependents
4216 SET exec_status_code = 'ERROR_RERUN',
4217 last_update_date = sysdate, last_Updated_by = pv_apps_user_id
4218 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4219 AND dependent_request_id = p_request_id
4220 AND dependent_object_id = p_object_id;
4221
4222 UPDATE fem_ud_list_candidates
4223 SET exec_status_code = 'ERROR_RERUN',
4224 last_update_date = sysdate, last_Updated_by = pv_apps_user_id
4225 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4226 AND exec_status_code = 'RUNNING';
4227 COMMIT;
4228
4229 ELSE -- p_obj_exec_type = 'CANDIDATE'
4230 UPDATE fem_ud_list_candidates
4231 SET exec_status_code = 'ERROR_RERUN',
4232 last_update_date = sysdate, last_Updated_by = pv_apps_user_id
4233 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4234 AND request_id = p_request_id
4235 AND object_id = p_object_id;
4236 END IF;
4237 COMMIT;
4238 WHEN e_cannot_delete_execution_log THEN
4239 x_return_status := pc_ret_sts_error;
4240
4241 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
4242 p_msg_name => 'FEM_UD_CANNOT_DELETE_EXEC_LOG');
4243
4244 -- Update status of object execution in undo list.
4245 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4246 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4247 p_msg_text => 'Update status of object execution in undo list to ERROR_RERUN');
4248
4249 IF p_obj_exec_type = 'DEPENDENT' THEN
4250 UPDATE fem_ud_list_dependents
4251 SET exec_status_code = 'ERROR_RERUN',
4252 last_update_date = sysdate, last_Updated_by = pv_apps_user_id
4253 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4254 AND dependent_request_id = p_request_id
4255 AND dependent_object_id = p_object_id;
4256
4257 UPDATE fem_ud_list_candidates
4258 SET exec_status_code = 'ERROR_RERUN',
4259 last_Update_date = sysdate, last_Updated_by = pv_apps_user_id
4260 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4261 AND exec_status_code = 'RUNNING';
4262 COMMIT;
4263
4264 ELSE -- p_obj_exec_type = 'CANDIDATE'
4265 UPDATE fem_ud_list_candidates
4266 SET exec_status_code = 'ERROR_RERUN',
4267 last_update_date = sysdate, last_Updated_by = pv_apps_user_id
4268 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4269 AND request_id = p_request_id
4270 AND object_id = p_object_id;
4271 END IF;
4272 COMMIT;
4273 WHEN OTHERS THEN
4274 -- Unexpected exceptions
4275 x_return_status := pc_ret_sts_unexp_error;
4276
4277 -- Log the call stack and the Oracle error message to
4278 -- FND_LOG with the "unexpected exception" severity level.
4279
4280 FEM_ENGINES_PKG.Tech_Message
4281 (p_severity => pc_log_level_unexpected,
4282 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4283 p_msg_text => SQLERRM);
4284
4285 FEM_ENGINES_PKG.Tech_Message
4286 (p_severity => pc_log_level_unexpected,
4287 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4288 p_msg_text => dbms_utility.format_call_stack);
4289
4290 -- Log the Oracle error message to the stack.
4291 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
4292 p_msg_name => 'FEM_UNEXPECTED_ERROR',
4293 P_TOKEN1 => 'ERR_MSG',
4294 P_VALUE1 => SQLERRM);
4295
4296 -- Update status of object execution in undo list.
4297 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4298 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4299 p_msg_text => 'Update status of object execution in undo list to ERROR_RERUN.');
4300
4301 IF p_obj_exec_type = 'DEPENDENT' THEN
4302 UPDATE fem_ud_list_dependents
4303 SET exec_status_code = 'ERROR_RERUN',
4304 last_Update_date = sysdate, last_Updated_by = pv_apps_user_id
4305 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4306 AND dependent_request_id = p_request_id
4307 AND dependent_object_id = p_object_id;
4308
4309 UPDATE fem_ud_list_candidates
4310 SET exec_status_code = 'ERROR_RERUN',
4311 last_update_date = sysdate, last_updated_by = pv_apps_user_id
4312 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4313 AND exec_status_code = 'RUNNING';
4314 COMMIT;
4315
4316 ELSE -- p_obj_exec_type = 'CANDIDATE'
4317 UPDATE fem_ud_list_candidates
4318 SET exec_status_code = 'ERROR_RERUN',
4319 last_Update_date = sysdate, last_Updated_by = pv_apps_user_id
4320 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id
4321 AND request_id = p_request_id
4322 AND object_id = p_object_id;
4323 END IF;
4324 COMMIT;
4325
4326 END perform_undo_actions;
4327 -- *****************************************************************************
4328 PROCEDURE set_process_status (p_undo_list_obj_id IN NUMBER,
4329 p_undo_list_obj_def_id IN NUMBER,
4330 p_execution_status IN VARCHAR2) AS
4331 -- ============================================================================
4332 -- PRIVATE
4333 -- This procedure sets the status of an undo run.
4334 -- ============================================================================
4335
4336 c_api_name CONSTANT VARCHAR2(30) := 'set_process_status';
4337 v_msg_count NUMBER;
4338 v_msg_data VARCHAR2(32000);
4339 v_api_return_status VARCHAR2(30);
4340 e_post_process EXCEPTION;
4341 v_exec_status VARCHAR2(150);
4342
4343 BEGIN
4344 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
4345 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4346 p_msg_text => 'Begin. P_OBJECT_ID: '||p_undo_list_obj_id||
4347 ' P_EXECUTION_STATUS: '||p_execution_status);
4348
4349 -- Update status of undo list
4350 UPDATE fem_ud_lists
4351 SET exec_status_code = p_execution_status,
4352 last_update_date = sysdate, last_Updated_by = pv_apps_user_id
4353 WHERE undo_list_obj_def_id = p_undo_list_obj_def_id;
4354
4355 -- Update Object Execution Status
4356 FEM_PL_PKG.Update_Obj_Exec_Status(
4357 P_API_VERSION => 1.0,
4358 P_COMMIT => FND_API.G_TRUE,
4359 P_REQUEST_ID => pv_request_id,
4360 P_OBJECT_ID => p_undo_list_obj_id,
4361 P_EXEC_STATUS_CODE => p_execution_status,
4362 P_USER_ID => pv_apps_user_id,
4363 P_LAST_UPDATE_LOGIN => null,
4364 X_MSG_COUNT => v_msg_count,
4365 X_MSG_DATA => v_msg_data,
4366 X_RETURN_STATUS => v_API_return_status);
4367
4368 IF v_api_return_status <> pc_ret_sts_success THEN
4369
4370 FEM_ENGINES_PKG.USER_MESSAGE
4371 (P_APP_NAME => 'FEM'
4372 ,P_MSG_NAME => 'FEM_PL_UPD_OBJEXEC_STATUS_ERR'
4373 ,P_TOKEN1 => 'REQUEST_ID'
4374 ,P_VALUE1 => pv_request_id
4375 ,P_TRANS1 => 'N'
4376 ,P_TOKEN2 => 'OBJECT_ID'
4377 ,P_VALUE2 => p_undo_list_obj_id
4378 ,P_TRANS2 => 'N'
4379 ,P_TOKEN3 => 'EXEC_STATUS'
4380 ,P_VALUE3 => p_execution_status
4381 ,P_TRANS3 => 'N');
4382
4383 FEM_ENGINES_PKG.USER_MESSAGE
4384 (P_APP_NAME => 'FEM'
4385 ,P_MSG_NAME => 'FEM_POST_PROC_ERR');
4386
4387 Get_Put_Messages(
4388 p_msg_count => v_msg_count,
4389 p_msg_data => v_msg_data,
4390 p_user_msg => 'N',
4391 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
4392
4393 END IF;
4394
4395 -- Update Request Status
4396 FEM_PL_PKG.Update_Request_Status(
4397 P_API_VERSION => 1.0,
4398 P_COMMIT => FND_API.G_TRUE,
4399 P_REQUEST_ID => pv_request_id,
4400 P_EXEC_STATUS_CODE => p_execution_status,
4401 P_USER_ID => pv_apps_user_id,
4402 P_LAST_UPDATE_LOGIN => null,
4403 X_MSG_COUNT => v_msg_count,
4404 X_MSG_DATA => v_msg_data,
4405 X_RETURN_STATUS => v_API_return_status);
4406
4407 IF v_api_return_status <> pc_ret_sts_success THEN
4408
4409 FEM_ENGINES_PKG.USER_MESSAGE
4410 (P_APP_NAME => 'FEM'
4411 ,P_MSG_NAME => 'FEM_PL_UPD_REQUEST_STATUS_ERR'
4412 ,P_TOKEN1 => 'REQUEST_ID'
4413 ,P_VALUE1 => pv_request_id
4414 ,P_TRANS1 => 'N'
4415 ,P_TOKEN2 => 'EXEC_STATUS'
4416 ,P_VALUE2 => p_execution_status
4417 ,P_TRANS2 => 'N');
4418
4419 FEM_ENGINES_PKG.USER_MESSAGE
4420 (P_APP_NAME => 'FEM'
4421 ,P_MSG_NAME => 'FEM_POST_PROC_ERR');
4422
4423 Get_Put_Messages(
4424 p_msg_count => v_msg_count,
4425 p_msg_data => v_msg_data,
4426 p_user_msg => 'N',
4427 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
4428
4429 END IF;
4430
4431 -- Post Messages
4432 BEGIN
4433 SELECT meaning INTO v_exec_status
4434 FROM fnd_lookup_values
4435 WHERE lookup_type = 'FEM_EXEC_STATUS_DSC'
4436 AND lookup_code = p_execution_status
4437 AND language = USERENV('LANG');
4438 EXCEPTION WHEN NO_DATA_FOUND THEN
4439 v_exec_status := p_execution_status;
4440 END;
4441
4442 -- Set status of request
4443 IF p_execution_status = 'SUCCESS' THEN
4444 FEM_ENGINES_PKG.USER_MESSAGE
4445 (P_APP_NAME => 'FEM'
4446 ,P_MSG_NAME => 'FEM_EXEC_SUCCESS');
4447
4448 pv_concurrent_status := fnd_concurrent.set_completion_status('NORMAL',null);
4449
4450 FEM_ENGINES_PKG.Tech_Message
4451 (p_severity => pc_log_level_unexpected,
4452 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4453 P_MSG_NAME => 'FEM_EXEC_SUCCESS');
4454 ELSIF p_execution_status IN ('ERROR_RERUN') THEN
4455 FEM_ENGINES_PKG.USER_MESSAGE
4456 (P_APP_NAME => 'FEM'
4457 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
4458
4459 pv_concurrent_status := fnd_concurrent.set_completion_status('ERROR',null);
4460
4461 FEM_ENGINES_PKG.Tech_Message
4462 (p_severity => pc_log_level_unexpected,
4463 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4464 P_MSG_NAME => 'FEM_EXEC_RERUN');
4465 END IF;
4466
4467 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
4468 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4469 p_msg_text => 'End');
4470
4471 EXCEPTION
4472 WHEN OTHERS THEN
4473 -- Unexpected exceptions
4474
4475 -- Log the call stack and the Oracle error message to
4476 -- FND_LOG with the "unexpected exception" severity level.
4477
4478 FEM_ENGINES_PKG.Tech_Message
4479 (p_severity => pc_log_level_unexpected,
4480 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4481 p_msg_text => SQLERRM);
4482
4483 FEM_ENGINES_PKG.Tech_Message
4484 (p_severity => pc_log_level_unexpected,
4485 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4486 p_msg_text => dbms_utility.format_call_stack);
4487
4488 -- Log the Oracle error message to the stack.
4489 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
4490 p_msg_name => 'FEM_UNEXPECTED_ERROR',
4491 P_TOKEN1 => 'ERR_MSG',
4492 P_VALUE1 => SQLERRM);
4493
4494 END set_process_status;
4495 -- *****************************************************************************
4496 PROCEDURE execute_undo_list (errbuf OUT NOCOPY VARCHAR2,
4497 retcode OUT NOCOPY VARCHAR2,
4498 p_undo_list_obj_id IN NUMBER) AS
4499 -- ============================================================================
4500 -- PUBLIC
4501 -- This is the main procedure of the 'Undo Engine' that will be invoked
4502 -- via concurrent manager. This procedure processes the specified undo list.
4503 -- ============================================================================
4504
4505 c_api_name CONSTANT VARCHAR2(30) := 'execute_undo_list';
4506 v_count NUMBER;
4507 v_undo_list_obj_def_id NUMBER;
4508 v_previous_request_id NUMBER;
4509 v_exec_state VARCHAR2(30);
4510 v_msg_count NUMBER;
4511 v_msg_data VARCHAR2(32000);
4512 v_return_status VARCHAR2(1);
4513 v_include_dependencies_flag VARCHAR2(1);
4514 v_ignore_dependency_errs_flag VARCHAR2(1);
4515 v_dependency_type VARCHAR2(10);
4516 v_can_user_read_rule_flag VARCHAR2(1);
4517
4518 -- This cursor retrives all candidates in an undo list that have not
4519 -- been executed successfully.
4520 CURSOR c10 IS
4521 SELECT request_id, object_id
4522 FROM fem_ud_list_candidates
4523 WHERE undo_list_obj_def_id = v_undo_list_obj_def_id
4524 AND (exec_status_code IS NULL OR
4525 exec_status_code <> 'SUCCESS')
4526 ORDER BY request_id, object_id;
4527
4528 -- This cursor retrives all dependents for a candidate.
4529 CURSOR c20 (v_request_id IN NUMBER, v_object_id IN NUMBER) IS
4530 SELECT dependent_request_id, dependent_object_id
4531 FROM fem_ud_list_dependents
4532 WHERE undo_list_obj_def_id = v_undo_list_obj_def_id
4533 AND request_id = v_request_id
4534 AND object_id = v_object_id
4535 AND (exec_status_code IS NULL OR
4536 exec_status_code <> 'SUCCESS')
4537 ORDER BY dependent_request_id, dependent_object_id;
4538
4539 -- This cursor retrieves all executions of the undo list
4540 CURSOR c3 IS
4541 SELECT request_id
4542 FROM fem_pl_object_executions
4543 WHERE object_id = p_undo_list_obj_id;
4544
4545 BEGIN
4546 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
4547 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4548 p_msg_text => 'Begin. P_UNDO_LIST_OBJ_ID: '||p_undo_list_obj_id);
4549
4550 -- ============================================================================
4551 -- VALIDATIONS
4552 -- ============================================================================
4553 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4554 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4555 p_msg_text => 'Begin VALIDATIONS: '||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
4556
4557 -- ============================================================================
4558 -- V01: Check to see if p_undo_list_obj_id is for a valid undo list.
4559 -- ============================================================================
4560 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4561 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4562 p_msg_text => 'V01: Check to see if p_undo_list_obj_id is for a valid undo list.');
4563
4564 BEGIN
4565
4566 SELECT u.undo_list_obj_def_id
4567 INTO v_undo_list_obj_def_id
4568 FROM fem_object_catalog_b o, fem_object_definition_b d, fem_ud_lists u
4569 WHERE o.object_id = p_undo_list_obj_id
4570 AND o.object_type_code = 'UNDO'
4571 AND o.object_id = d.object_id
4572 AND d.object_definition_id = u.undo_list_obj_def_id;
4573
4574 EXCEPTION WHEN NO_DATA_FOUND THEN
4575 RAISE e_invalid_undo_list;
4576 END;
4577
4578
4579 -- Bug 4309949: Ignore folder security for Undo rules
4580 -- ============================================================================
4581 -- V02: Check to see if user has privileges to execute the list.
4582 -- ============================================================================
4583 -- fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4584 -- p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4585 -- p_msg_text => 'V02: Check to see if user can read p_undo_list_obj_id.');
4586
4587 -- BEGIN
4588
4589 -- SELECT 'Y'
4590 -- INTO v_can_user_read_rule_flag
4591 -- FROM fem_object_catalog_b o, fem_user_folders u
4592 -- WHERE o.object_id = p_undo_list_obj_id
4593 -- AND o.folder_id = u.folder_id
4594 -- AND u.user_id = pv_apps_user_id;
4595
4596 -- EXCEPTION WHEN NO_DATA_FOUND THEN
4597 -- RAISE e_cannot_read_object;
4598 -- END;
4599
4600
4601 -- ============================================================================
4602 -- V03: Check for dependencies, if ignore_dependency_errs_flag = 'N' AND
4603 -- include_dependencies_flag = 'N'.
4604 -- NOTE: This only checks for CHAIN dependencies, as UPDATE dependencies are
4605 -- ALWAYS added to the undo list.
4606 -- Missing Integration and RCM Process rule candidates are added to the list
4607 -- before checking for dependencies.
4608 -- ============================================================================
4609
4610 SELECT include_dependencies_flag, ignore_dependency_errs_flag
4611 INTO v_include_dependencies_flag, v_ignore_dependency_errs_flag
4612 FROM fem_ud_lists
4613 WHERE undo_list_obj_def_id = v_undo_list_obj_def_id;
4614
4615 IF v_include_dependencies_flag = 'N' AND v_ignore_dependency_errs_flag = 'N'
4616 THEN
4617
4618 SELECT count(*) INTO v_count
4619 FROM fem_pl_chains pl
4620 WHERE (pl.source_created_by_request_id, pl.source_created_by_object_id) IN (
4621 SELECT c.request_id, c.object_id
4622 FROM fem_ud_list_candidates c
4623 WHERE c.undo_list_obj_def_id = v_undo_list_obj_def_id);
4624
4625 IF v_count > 0 THEN
4626 RAISE e_dependencies_found;
4627 END IF;
4628 END IF;
4629
4630 -- Set dependency type
4631 IF v_include_dependencies_flag = 'Y' THEN
4632 v_dependency_type := 'ALL';
4633 ELSE
4634 v_dependency_type := 'UPDATE';
4635 END IF;
4636
4637 -- ============================================================================
4638 -- REGISTRATION
4639 -- ============================================================================
4640 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4641 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4642 p_msg_text => 'Begin REGISTRATION: '||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
4643
4644 -- ============================================================================
4645 -- R01: Register request
4646 -- ============================================================================
4647 FEM_PL_PKG.Register_Request
4648 (P_API_VERSION => 1.0,
4649 P_COMMIT => FND_API.G_FALSE,
4650 P_REQUEST_ID => pv_request_id,
4651 P_USER_ID => pv_apps_user_id,
4652 P_LAST_UPDATE_LOGIN => pv_login_id,
4653 P_PROGRAM_ID => pv_program_id,
4654 P_PROGRAM_LOGIN_ID => pv_login_id,
4655 P_PROGRAM_APPLICATION_ID => pv_program_app_id,
4656 X_MSG_COUNT => v_msg_count,
4657 X_MSG_DATA => v_msg_data,
4658 X_RETURN_STATUS => v_return_status);
4659
4660 IF v_return_status <> pc_ret_sts_success THEN
4661
4662 Get_Put_Messages(
4663 p_msg_count => v_msg_count,
4664 p_msg_data => v_msg_data,
4665 p_user_msg => 'N',
4666 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
4667
4668 RAISE e_pl_reg_request_failed;
4669
4670 END IF;
4671 -- ============================================================================
4672 -- R02: Register object execution
4673 -- ============================================================================
4674 FEM_PL_PKG.Register_Object_Execution
4675 (P_API_VERSION => 1.0,
4676 P_COMMIT => FND_API.G_FALSE,
4677 P_REQUEST_ID => pv_request_id,
4678 P_OBJECT_ID => p_undo_list_obj_id,
4679 P_EXEC_OBJECT_DEFINITION_ID => v_undo_list_obj_def_id,
4680 P_USER_ID => pv_apps_user_id,
4681 P_LAST_UPDATE_LOGIN => pv_login_id,
4682 X_EXEC_STATE => v_exec_state,
4683 X_PREV_REQUEST_ID => v_previous_request_id,
4684 X_MSG_COUNT => v_msg_count,
4685 X_MSG_DATA => v_msg_data,
4686 X_RETURN_STATUS => v_return_status);
4687
4688 IF v_return_status <> pc_ret_sts_success THEN
4689
4690 Get_Put_Messages(
4691 p_msg_count => v_msg_count,
4692 p_msg_data => v_msg_data,
4693 p_user_msg => 'N',
4694 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
4695
4696 RAISE e_pl_reg_obj_exec_failed;
4697
4698 END IF;
4699 -- ============================================================================
4700 -- R02: Register undo list in FEM_PL_OBJECT_DEFS
4701 -- ============================================================================
4702 FEM_PL_PKG.Register_Object_Def
4703 (P_API_VERSION => 1.0,
4704 P_COMMIT => FND_API.G_FALSE,
4705 P_REQUEST_ID => pv_request_id,
4706 P_OBJECT_ID => p_undo_list_obj_id,
4707 P_OBJECT_DEFINITION_ID => v_undo_list_obj_def_id,
4708 P_USER_ID => pv_apps_user_id,
4709 P_LAST_UPDATE_LOGIN => pv_login_id,
4710 X_MSG_COUNT => v_msg_count,
4711 X_MSG_DATA => v_msg_data,
4712 X_RETURN_STATUS => v_return_status);
4713
4714 IF v_return_status <> pc_ret_sts_success THEN
4715
4716 Get_Put_Messages(
4717 p_msg_count => v_msg_count,
4718 p_msg_data => v_msg_data,
4719 p_user_msg => 'N',
4720 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
4721
4722 RAISE e_pl_reg_obj_def_failed;
4723
4724 END IF;
4725
4726 -- ============================================================================
4727 -- R04: COMMIT registration steps
4728 -- ============================================================================
4729 COMMIT;
4730 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4731 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4732 p_msg_text => 'End REGISTRATION: '||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
4733
4734 -- ============================================================================
4735 -- PROCESSING
4736 -- ============================================================================
4737 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4738 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4739 p_msg_text => 'Begin PROCESSING: '||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
4740
4741
4742 -- Set status of undo list to 'RUNNING'
4743 UPDATE fem_ud_lists
4744 SET exec_status_code = 'RUNNING',
4745 last_update_date = sysdate, last_updated_by = pv_apps_User_id
4746 WHERE undo_list_obj_def_id = v_undo_list_obj_def_id;
4747 COMMIT;
4748
4749 SELECT count(*) INTO v_count
4750 FROM fem_ud_list_candidates
4751 WHERE undo_list_obj_def_id = v_undo_list_obj_def_id
4752 AND (exec_status_code IS NULL OR exec_status_code <> 'SUCCESS');
4753
4754 IF v_count > 0 THEN
4755 /*
4756 -- Generate dependents
4757 generate_dependents(
4758 x_return_status => v_return_status,
4759 x_msg_count => v_msg_count,
4760 x_msg_data => v_msg_data,
4761 p_api_version => 2.0,
4762 p_commit => FND_API.G_TRUE,
4763 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
4764 p_dependency_type => v_dependency_type);
4765 */
4766
4767 -- Validate candidates
4768 validate_candidates(
4769 x_return_status => v_return_status,
4770 x_msg_count => v_msg_count,
4771 x_msg_data => v_msg_data,
4772 p_api_version => 2.0,
4773 p_commit => FND_API.G_TRUE,
4774 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
4775 p_dependency_type => v_dependency_type);
4776
4777 IF v_return_status <> pc_ret_sts_success THEN
4778 Get_Put_Messages(
4779 p_msg_count => v_msg_count,
4780 p_msg_data => v_msg_data,
4781 p_user_msg => 'Y',
4782 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
4783
4784 RAISE e_cannot_validate_candidates;
4785
4786 END IF;
4787
4788 END IF;
4789
4790 -- Post following message to output log before undoing executions:
4791 -- "Removing the following rule executions:"
4792 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
4793 p_msg_name => 'FEM_UD_PROCESSING_LIST_TXT');
4794
4795 -- Process all candidates in the list.
4796 FOR a_candidate IN c10 LOOP
4797 v_count := c10%ROWCOUNT;
4798
4799 -- Submit business event: 'oracle.apps.fem.ud.submit'
4800 -- when undo first processes the Undo candidate
4801 raise_undo_business_event (p_event_name => 'oracle.apps.fem.ud.submit',
4802 p_request_id => a_candidate.request_id,
4803 p_object_id => a_candidate.object_id);
4804
4805 UPDATE fem_ud_list_candidates
4806 SET exec_status_code = 'RUNNING',
4807 last_Update_date = sysdate, last_updated_by = pv_apps_user_Id
4808 WHERE undo_list_obj_def_id = v_undo_list_obj_def_id
4809 AND request_id = a_candidate.request_id
4810 AND object_id = a_candidate.object_id;
4811 COMMIT;
4812
4813 FOR a_dependent IN c20(a_candidate.request_id, a_candidate.object_id) LOOP
4814
4815 perform_undo_actions(
4816 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
4817 p_obj_exec_type => 'DEPENDENT',
4818 p_request_id => a_dependent.dependent_request_id,
4819 p_object_id => a_dependent.dependent_object_id,
4820 x_return_status => v_return_status);
4821
4822 IF v_return_status <> pc_ret_sts_success THEN
4823
4824 RAISE e_cannot_undo_obj_exec_err;
4825
4826 END IF;
4827
4828 END LOOP;
4829
4830 -- Undo candidate after all its dependents have been processed successfully
4831 perform_undo_actions(
4832 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
4833 p_obj_exec_type => 'CANDIDATE',
4834 p_request_id => a_candidate.request_id,
4835 p_object_id => a_candidate.object_id,
4836 x_return_status => v_return_status);
4837
4838 -- Submit business event: 'oracle.apps.fem.ud.submit'
4839 -- when undo first processes the Undo candidate
4840 raise_undo_business_event (p_event_name => 'oracle.apps.fem.ud.complete',
4841 p_request_id => a_candidate.request_id,
4842 p_object_id => a_candidate.object_id,
4843 p_status => v_return_status);
4844
4845 IF v_return_status <> pc_ret_sts_success THEN
4846
4847 RAISE e_cannot_undo_obj_exec_err;
4848
4849 END IF;
4850
4851 END LOOP;
4852
4853 IF v_count = 0 THEN
4854 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
4855 p_msg_name => 'FEM_UD_NO_CANDIDATES_ERR');
4856 ELSE
4857 -- If at least one candidate was processed, print a new line in the
4858 -- concurrent output log to separate out the messages printed out
4859 -- in the call to perform_undo_action from any more messages to be
4860 -- printed out later in this execution.
4861 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
4862 p_msg_name => 'FEM_NEW_LINE');
4863 END IF;
4864
4865 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4866 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4867 p_msg_text => 'End PROCESSING: '||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
4868
4869
4870 -- ============================================================================
4871 -- Since the undo run was successful, delete the registration information for
4872 -- this execution, and all executions of this undo list, then also delete
4873 -- the undo list.
4874 -- ============================================================================
4875 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4876 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4877 p_msg_text => 'Since the undo run was successful, delete the undo list and its registration information.');
4878
4879 -- Delete object execution from process lock tables (FEM_PL_xxxx).
4880 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4881 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4882 p_msg_text => 'Delete undo run from process lock tables (FEM_PL_xxxx).');
4883
4884 FOR undo_objexec IN c3 LOOP
4885
4886 delete_execution_log (
4887 p_commit => FND_API.G_TRUE,
4888 p_api_version => 1.0,
4889 p_request_id => undo_objexec.request_id,
4890 p_object_id => p_undo_list_obj_id,
4891 x_return_status => v_return_status,
4892 x_msg_count => v_msg_count,
4893 x_msg_data => v_msg_data);
4894
4895 IF v_return_status <> pc_ret_sts_success THEN
4896 Get_Put_Messages(
4897 p_msg_count => v_msg_count,
4898 p_msg_data => v_msg_data,
4899 p_user_msg => 'Y',
4900 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name||'.delete_execution_log');
4901
4902 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
4903 p_msg_name => 'FEM_UD_CANNOT_DELETE_UNDOEXEC');
4904
4905 END IF;
4906
4907 END LOOP;
4908
4909 -- Delete undo list.
4910 -- Set status of undo list to 'SUCCESS'
4911 UPDATE fem_ud_lists
4912 SET exec_status_code = 'SUCCESS',
4913 last_update_date = sysdate, last_updated_by = pv_apps_user_id
4914 WHERE undo_list_obj_def_id = v_undo_list_obj_def_id;
4915 COMMIT;
4916
4917 delete_undo_list(
4918 p_api_version => 1.0,
4919 p_commit => FND_API.G_TRUE,
4920 p_undo_list_obj_id => p_undo_list_obj_id,
4921 x_return_status => v_return_status,
4922 x_msg_count => v_msg_count,
4923 x_msg_data => v_msg_data);
4924
4925 Get_Put_Messages(
4926 p_msg_count => v_msg_count,
4927 p_msg_data => v_msg_data,
4928 p_user_msg => 'N',
4929 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
4930
4931 IF v_return_status <> pc_ret_sts_success THEN
4932
4933 fem_engines_pkg.user_message(p_app_name =>'FEM',
4934 p_msg_name => 'FEM_UD_CANNOT_DELETE_LIST_ERR');
4935
4936 END IF;
4937
4938 -- ============================================================================
4939 -- SET STATUS
4940 -- ============================================================================
4941 set_process_status (p_undo_list_obj_id => p_undo_list_obj_id,
4942 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
4943 p_execution_status => 'SUCCESS');
4944 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
4945 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4946 p_msg_text => 'End. '||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
4947 -- ============================================================================
4948 -- EXCEPTIONS
4949 -- ============================================================================
4950 EXCEPTION
4951 WHEN e_invalid_undo_list THEN
4952 ROLLBACK;
4953 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
4954 p_msg_name => 'FEM_UD_INVALID_UNDO_LIST_ERR',
4955 p_token1 => 'OBJECT_ID',
4956 p_value1 => p_undo_list_obj_id,
4957 p_trans1 => 'N');
4958
4959 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
4960 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4961 p_msg_name => 'FEM_UD_INVALID_UNDO_LIST_ERR',
4962 p_token1 => 'OBJECT_ID',
4963 p_value1 => p_undo_list_obj_id,
4964 p_trans1 => 'N');
4965
4966 set_process_status (p_undo_list_obj_id => p_undo_list_obj_id,
4967 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
4968 p_execution_status => 'ERROR_RERUN');
4969
4970 WHEN e_cannot_read_object THEN
4971 ROLLBACK;
4972 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
4973 p_msg_name => 'FEM_UD_CANNOT_READ_OBJECT_ERR');
4974
4975 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
4976 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
4977 p_msg_name => 'FEM_UD_CANNOT_READ_OBJECT_ERR');
4978
4979 set_process_status (p_undo_list_obj_id => p_undo_list_obj_id,
4980 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
4981 p_execution_status => 'ERROR_RERUN');
4982
4983 WHEN e_dependencies_found THEN
4984 ROLLBACK;
4985 FEM_ENGINES_PKG.user_message (p_app_name =>'FEM',
4986 p_msg_name => 'FEM_UD_DEPENDENTS_FOUND_ERR',
4987 p_token1 => 'OBJECT_ID',
4988 p_value1 => p_undo_list_obj_id,
4989 p_trans1 => 'N');
4990
4991 FOR a_candidate IN c10 LOOP
4992 report_cand_dependents (
4993 x_msg_count => v_msg_count,
4994 x_msg_data => v_msg_data,
4995 p_request_id => a_candidate.request_id,
4996 p_object_id => a_candidate.object_id,
4997 p_dependency_type => 'CHAIN');
4998
4999 END LOOP;
5000
5001 Get_Put_Messages(
5002 p_msg_count => v_msg_count,
5003 p_msg_data => v_msg_data,
5004 p_user_msg => 'Y',
5005 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
5006
5007 set_process_status (p_undo_list_obj_id => p_undo_list_obj_id,
5008 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
5009 p_execution_status => 'ERROR_RERUN');
5010
5011 WHEN e_pl_reg_request_failed THEN
5012 ROLLBACK;
5013 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5014 p_msg_name => 'FEM_PL_REG_REQUEST_ERR');
5015
5016 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5017 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5018 p_msg_name =>'FEM_PL_REG_REQUEST_ERR');
5019
5020 set_process_status (p_undo_list_obj_id => p_undo_list_obj_id,
5021 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
5022 p_execution_status => 'ERROR_RERUN');
5023
5024 WHEN e_pl_reg_obj_exec_failed THEN
5025 ROLLBACK;
5026 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5027 p_msg_name => 'FEM_PL_REG_OBJ_EXEC_ERR');
5028
5029 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5030 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5031 p_msg_name =>'FEM_PL_REG_OBJ_EXEC_ERR');
5032
5033 set_process_status (p_undo_list_obj_id => p_undo_list_obj_id,
5034 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
5035 p_execution_status => 'ERROR_RERUN');
5036
5037 WHEN e_pl_reg_obj_def_failed THEN
5038 ROLLBACK;
5039 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5040 p_msg_name => 'FEM_PL_REG_OBJ_DEF_ERR');
5041
5042 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5043 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5044 p_msg_name =>'FEM_PL_REG_OBJ_DEF_ERR');
5045
5046 set_process_status (p_undo_list_obj_id => p_undo_list_obj_id,
5047 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
5048 p_execution_status => 'ERROR_RERUN');
5049
5050 WHEN e_cannot_validate_candidates THEN
5051
5052 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5053 p_msg_name => 'FEM_UD_CANNOT_VAL_CANDIDATES');
5054
5055 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5056 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5057 p_msg_name =>'FEM_UD_CANNOT_VAL_CANDIDATES');
5058
5059 set_process_status (p_undo_list_obj_id => p_undo_list_obj_id,
5060 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
5061 p_execution_status => 'ERROR_RERUN');
5062
5063 WHEN e_cannot_undo_obj_exec_err THEN
5064
5065 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5066 p_msg_name => 'FEM_UD_CANNOT_UNDO_OBJ_EXEC');
5067
5068 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5069 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5070 p_msg_name =>'FEM_UD_CANNOT_UNDO_OBJ_EXEC');
5071
5072 set_process_status (p_undo_list_obj_id => p_undo_list_obj_id,
5073 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
5074 p_execution_status => 'ERROR_RERUN');
5075
5076 WHEN e_could_not_process_undo_list THEN
5077 ROLLBACK;
5078 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5079 p_msg_name => 'FEM_UD_INVALID_UNDO_LIST_ERR',
5080 p_token1 => 'OBJECT_ID',
5081 p_value1 => p_undo_list_obj_id,
5082 p_trans1 => 'N');
5083
5084 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5085 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5086 p_msg_name => 'FEM_UD_INVALID_UNDO_LIST_ERR',
5087 p_token1 => 'OBJECT_ID',
5088 p_value1 => p_undo_list_obj_id,
5089 p_trans1 => 'N');
5090
5091 set_process_status (p_undo_list_obj_id => p_undo_list_obj_id,
5092 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
5093 p_execution_status => 'ERROR_RERUN');
5094
5095 WHEN OTHERS THEN
5096 -- Unexpected exceptions
5097 -- Log the call stack and the Oracle error message to
5098 -- FND_LOG with the "unexpected exception" severity level.
5099
5100 FEM_ENGINES_PKG.Tech_Message
5101 (p_severity => pc_log_level_unexpected,
5102 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5103 p_msg_text => SQLERRM);
5104
5105 FEM_ENGINES_PKG.Tech_Message
5106 (p_severity => pc_log_level_unexpected,
5107 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5108 p_msg_text => dbms_utility.format_call_stack);
5109
5110 -- Log the Oracle error message to the stack.
5111 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5112 p_msg_name => 'FEM_UNEXPECTED_ERROR',
5113 P_TOKEN1 => 'ERR_MSG',
5114 P_VALUE1 => SQLERRM);
5115
5116 set_process_status (p_undo_list_obj_id => p_undo_list_obj_id,
5117 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
5118 p_execution_status => 'ERROR_RERUN');
5119
5120 END execute_undo_list;
5121 -- *****************************************************************************
5122 PROCEDURE submit_undo_lists (errbuf OUT NOCOPY VARCHAR2,
5123 retcode OUT NOCOPY VARCHAR2) AS
5124 -- ============================================================================
5125 -- PUBLIC
5126 -- This procedure will submit all undo lists that were created with an
5127 -- execution date which is earlier than or equal to the current date. This
5128 -- will be invoked via concurrent manager.
5129 -- ============================================================================
5130
5131
5132 c_api_name CONSTANT VARCHAR2(30) := 'submit_undo_lists';
5133 v_msg_count NUMBER;
5134 v_msg_data VARCHAR2(32000);
5135 v_subrequest_id NUMBER;
5136 v_total_requests NUMBER := 0;
5137 v_failed_subrequests NUMBER := 0;
5138 v_req_phase VARCHAR2(80);
5139 v_req_status VARCHAR2(80);
5140 v_dev_phase VARCHAR2(30);
5141 v_dev_status VARCHAR2(30);
5142 v_req_message VARCHAR2 (240);
5143 v_prg_stat VARCHAR2(40) := 'NORMAL';
5144 v_check_status BOOLEAN;
5145
5146 CURSOR c1 IS
5147 SELECT o.object_id
5148 FROM fem_object_catalog_b o, fem_object_definition_b d, fem_ud_lists u
5149 WHERE o.object_type_code = 'UNDO'
5150 AND o.object_id = d.object_id
5151 AND d.object_definition_id = u.undo_list_obj_def_id
5152 AND (u.execution_date < SYSDATE OR u.execution_date = SYSDATE)
5153 AND (u.exec_status_code IS NULL OR u.exec_status_code NOT IN ('RUNNING','SUCCESS'));
5154
5155 CURSOR c2 IS
5156 SELECT c.request_id
5157 FROM fnd_concurrent_requests c
5158 WHERE c.parent_request_id = pv_request_id
5159 ORDER BY c.request_id;
5160
5161 BEGIN
5162 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
5163 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5164 p_msg_text => 'Begin.');
5165
5166
5167 -- ============================================================================
5168 -- SUBMIT undo lists for processing.
5169 -- ============================================================================
5170
5171 FOR undolist IN c1 LOOP
5172 v_total_requests := c1%ROWCOUNT;
5173
5174 v_subrequest_id := FND_REQUEST.SUBMIT_REQUEST(
5175 application => 'FEM',
5176 program => 'FEM_UNDO_LIST',
5177 sub_request => FALSE,
5178 argument1 => undolist.object_id);
5179
5180 IF (v_subrequest_id = 0) THEN
5181 v_failed_subrequests := v_failed_subrequests + 1;
5182 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5183 p_msg_name => 'FEM_UD_SUBMIT_LIST_ERR',
5184 P_TOKEN1 => 'OBJECT_ID',
5185 P_VALUE1 => undolist.object_id,
5186 P_TRANS1 => 'N');
5187 ELSE
5188 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5189 p_msg_name => 'FEM_UD_SUBMIT_LIST_TXT',
5190 P_TOKEN1 => 'OBJECT_ID',
5191 P_VALUE1 => undolist.object_id,
5192 P_TRANS1 => 'N',
5193 P_TOKEN2 => 'REQUEST_ID',
5194 P_VALUE2 => v_subrequest_id,
5195 P_TRANS2 => 'N' );
5196 END IF;
5197 COMMIT;
5198
5199 END LOOP;
5200
5201 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
5202 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5203 p_msg_text => 'Total number of undo lists whose execution date is less than or equal to '||
5204 TO_CHAR(sysdate,'DD-MON-YYYY')||':'||v_total_requests);
5205
5206 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
5207 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5208 p_msg_text => 'Total number of undo lists which were not submitted for processing:'||v_failed_subrequests);
5209
5210 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
5211 p_msg_name => 'FEM_UD_SUBMIT_LIST_COMPLTD_TXT');
5212
5213 -- ============================================================================
5214 -- SET STATUS
5215 -- ============================================================================
5216 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
5217 (status => v_prg_stat, message => NULL);
5218
5219 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
5220 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5221 p_msg_text => 'End. '||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
5222 -- ============================================================================
5223 -- EXCEPTIONS
5224 -- ============================================================================
5225 EXCEPTION
5226 WHEN OTHERS THEN
5227 -- Unexpected exceptions
5228 -- Log the call stack and the Oracle error message to
5229 -- FND_LOG with the "unexpected exception" severity level.
5230
5231 FEM_ENGINES_PKG.Tech_Message
5232 (p_severity => pc_log_level_unexpected,
5233 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5234 p_msg_text => SQLERRM);
5235
5236 FEM_ENGINES_PKG.Tech_Message
5237 (p_severity => pc_log_level_unexpected,
5238 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5239 p_msg_text => dbms_utility.format_call_stack);
5240
5241 -- Log the Oracle error message to the stack.
5242 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5243 p_msg_name => 'FEM_UNEXPECTED_ERROR',
5244 P_TOKEN1 => 'ERR_MSG',
5245 P_VALUE1 => SQLERRM,
5246 P_TRANS1 => 'N');
5247
5248 fem_engines_pkg.user_message
5249 (p_app_name => 'FEM'
5250 ,p_msg_name => 'FEM_EXEC_RERUN');
5251
5252 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
5253 (status => 'ERROR', message => NULL);
5254
5255 END submit_undo_lists;
5256 -- *****************************************************************************
5257 PROCEDURE undo_object_execution (errbuf OUT NOCOPY VARCHAR2,
5258 retcode OUT NOCOPY VARCHAR2,
5259 p_object_id IN NUMBER,
5260 p_request_id IN NUMBER,
5261 p_folder_id IN NUMBER,
5262 p_include_dependencies_flag IN VARCHAR2,
5263 p_ignore_dependency_errs_flag IN VARCHAR2) AS
5264 -- ============================================================================
5265 -- PUBLIC
5266 -- This procedure procedure creates an undo list for the object execution, then
5267 -- calls execute_undo_list. This procedure will be invoked via concurrent manager.
5268 -- ============================================================================
5269
5270 c_api_name CONSTANT VARCHAR2(30) := 'undo_object_execution';
5271 v_count NUMBER;
5272 v_undo_list_obj_def_id NUMBER;
5273 v_undo_list_obj_id NUMBER;
5274 v_previous_request_id NUMBER;
5275 v_return_status VARCHAR2(30);
5276 v_msg_count NUMBER;
5277 v_msg_data VARCHAR2(32000);
5278 v_req_phase VARCHAR2(80);
5279 v_req_status VARCHAR2(80);
5280 v_dev_phase VARCHAR2(30);
5281 v_dev_status VARCHAR2(30);
5282 v_req_message VARCHAR2 (240);
5283 v_prg_stat VARCHAR2(40) := 'NORMAL';
5284 v_check_status BOOLEAN;
5285 v_subrequest_id NUMBER;
5286 v_exec_status_code VARCHAR2(80);
5287 v_undo_list_exists VARCHAR2(1);
5288
5289
5290 BEGIN
5291 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
5292 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5293 p_msg_text => 'Begin. P_REQUEST_ID: '||p_request_id||
5294 ' P_FOLDER_ID: '||p_folder_id||
5295 ' P_OBJECT_ID: '||p_object_id||
5296 ' P_INCLUDE_DEPENDENCIES_FLAG: '||p_include_dependencies_flag||
5297 ' P_IGNORE_DEPENDENCY_ERRS_FLAG:'||p_ignore_dependency_errs_flag);
5298
5299 -- ============================================================================
5300 -- VALIDATIONS
5301 -- ============================================================================
5302 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
5303 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5304 p_msg_text => 'Begin VALIDATIONS: '||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
5305
5306 -- ============================================================================
5307 -- V01a: Check to make sure object execution exists.
5308 -- ============================================================================
5309
5310 SELECT COUNT(*)
5311 INTO v_count
5312 FROM fem_pl_object_executions
5313 WHERE request_id = p_request_id
5314 AND object_id = p_object_id;
5315
5316 IF v_count = 0 THEN
5317 RAISE e_object_execution_not_found;
5318 END IF;
5319
5320 -- ============================================================================
5321 -- V01b: Check to make sure user can execute/read the object.
5322 -- ============================================================================
5323 SELECT count(*) INTO v_count
5324 FROM fem_user_folders u, fem_object_catalog_b o
5325 WHERE o.object_id = p_object_id
5326 AND o.folder_id = u.folder_id
5327 AND u.user_id = pv_apps_user_id;
5328
5329 IF v_count = 0 THEN
5330 RAISE e_cannot_read_object;
5331 END IF;
5332
5333 -- Bug 4309949: Ignore folder security for Undo rules
5334 -- ============================================================================
5335 -- V02: Check to make sure folder exists, and that user has write access to folder.
5336 -- This is the folder in which the undo list will be created.
5337 -- ============================================================================
5338 -- SELECT count(*)
5339 -- INTO v_count
5340 -- FROM fem_folders_b b
5341 -- WHERE b.folder_id = p_folder_id
5342 -- AND b.folder_id IN (SELECT u.folder_id FROM fem_user_folders u
5343 -- WHERE u.user_id = pv_apps_user_id
5344 -- AND u.write_flag = 'Y');
5345
5346 -- IF v_count = 0 THEN
5347 -- RAISE e_invalid_folder;
5348 -- END IF;
5349
5350 -- ============================================================================
5351 -- V03: Check to make sure object execution is not RUNNING.
5352 -- ============================================================================
5353 SELECT exec_status_code INTO v_exec_status_code
5354 FROM fem_pl_object_executions
5355 WHERE request_id = p_request_id
5356 AND object_id = p_object_id;
5357
5358 IF v_exec_status_code = 'RUNNING' THEN
5359 -- Verify that the request is still running using fem_pl_pkg.set_exec_state
5360
5361 fem_pl_pkg.set_exec_state (p_api_version => 1.0,
5362 p_commit => fnd_api.g_true,
5363 p_request_id => p_request_id,
5364 p_object_id => p_object_id,
5365 x_msg_count => v_msg_count,
5366 x_msg_data => v_msg_data,
5367 x_return_status => v_return_status);
5368
5369 IF v_msg_count > 0 THEN
5370 Get_Put_Messages(
5371 p_msg_count => v_msg_count,
5372 p_msg_data => v_msg_data,
5373 p_user_msg => 'N',
5374 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
5375 END IF;
5376 END IF;
5377
5378 SELECT exec_status_code INTO v_exec_status_code
5379 FROM fem_pl_object_executions
5380 WHERE request_id = p_request_id
5381 AND object_id = p_object_id;
5382
5383 IF v_exec_status_code = 'RUNNING' THEN
5384 RAISE e_objexec_is_running;
5385 ELSE
5386 -- Create and execute undo list if object execution status <> 'RUNNING'.
5387 -- ============================================================================
5388 -- CREATE or RETRIEVE UNDO LIST
5389 -- ============================================================================
5390 -- If undo list already exists with the same name, post message and retrieve
5391 -- list ID from the database.
5392 BEGIN
5393
5394 SELECT o.object_id, d.object_definition_id, o.object_name
5395 INTO v_undo_list_obj_id, v_undo_list_obj_def_id, pv_undo_object_name
5396 FROM fem_object_catalog_vl o, fem_object_definition_b d
5397 WHERE o.object_type_code = 'UNDO'
5398 AND o.object_id = d.object_id
5399 AND o.object_name = 'UNDO - REQUEST_ID: '||p_request_id||' OBJECT_ID: '||p_object_id;
5400 v_undo_list_exists := 'T';
5401 EXCEPTION WHEN NO_DATA_FOUND THEN
5402 v_undo_list_exists := 'F';
5403 END;
5404
5405 IF v_undo_list_exists = 'F' THEN
5406 -- ============================================================================
5407 -- C1: Create undo list if it does not exist
5408 -- ============================================================================
5409 create_undo_list (p_api_version => 1.0,
5410 p_commit => FND_API.G_TRUE,
5411 p_undo_list_name => 'UNDO - REQUEST_ID: '||p_request_id||' OBJECT_ID: '||p_object_id,
5412 p_folder_id => pc_undo_folder_id,
5413 p_include_dependencies_flag => NVL(p_include_dependencies_flag,'Y'),
5414 p_ignore_dependency_errs_flag => NVL(p_ignore_dependency_errs_flag,'N'),
5415 p_execution_date => sysdate,
5416 x_undo_list_obj_id => v_undo_list_obj_id,
5417 x_undo_list_obj_def_id => v_undo_list_obj_def_id,
5418 x_return_status => v_return_status,
5419 x_msg_count => v_msg_count,
5420 x_msg_data => v_msg_data);
5421
5422 IF v_return_status <> pc_ret_sts_success THEN
5423 Get_Put_Messages(
5424 p_msg_count => v_msg_count,
5425 p_msg_data => v_msg_data,
5426 p_user_msg => 'Y',
5427 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
5428 ROLLBACK;
5429 RAISE e_cannot_create_undo_list;
5430 ELSIF v_msg_count > 0 THEN
5431 Get_Put_Messages(
5432 p_msg_count => v_msg_count,
5433 p_msg_data => v_msg_data,
5434 p_user_msg => 'N',
5435 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
5436 END IF;
5437
5438 pv_undo_object_name := 'UNDO - REQUEST_ID: '||p_request_id||' OBJECT_ID: '||p_object_id;
5439 -- ============================================================================
5440 -- C2: Add object execution to undo list as candidate
5441 -- ============================================================================
5442 add_candidate (p_api_version => 1.0,
5443 p_commit => FND_API.G_TRUE,
5444 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
5445 p_request_id => p_request_id,
5446 p_object_id => p_object_id,
5447 x_return_status => v_return_status,
5448 x_msg_count => v_msg_count,
5449 x_msg_data => v_msg_data);
5450
5451 IF v_return_status <> pc_ret_sts_success THEN
5452 Get_Put_Messages(
5453 p_msg_count => v_msg_count,
5454 p_msg_data => v_msg_data,
5455 p_user_msg => 'Y',
5456 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
5457 ROLLBACK;
5458 RAISE e_cannot_add_candidate;
5459
5460 ELSIF v_msg_count > 0 THEN
5461 Get_Put_Messages(
5462 p_msg_count => v_msg_count,
5463 p_msg_data => v_msg_data,
5464 p_user_msg => 'N',
5465 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
5466 END IF;
5467 END IF;
5468
5469 -- =========================================================================
5470 -- SUBMIT undo list for processing.
5471 -- =========================================================================
5472 execute_undo_list(
5473 errbuf => errbuf,
5474 retcode => retcode,
5475 p_undo_list_obj_id => v_undo_list_obj_id);
5476
5477 END IF;
5478 -- ============================================================================
5479 -- SET STATUS
5480 -- ============================================================================
5481 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
5482 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5483 p_msg_text => 'End. '||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
5484 -- ============================================================================
5485 -- EXCEPTIONS
5486 -- ============================================================================
5487 EXCEPTION
5488 WHEN e_object_execution_not_found THEN
5489 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5490 p_msg_name => 'FEM_UD_OBJ_EXEC_NOT_FOUND_WRN',
5491 p_token1 => 'REQUEST_ID',
5492 p_value1 => p_request_id,
5493 p_trans1 => 'N',
5494 p_token2 => 'OBJECT_ID',
5495 p_value2 => p_object_id,
5496 p_trans2 => 'N');
5497
5498 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5499 p_msg_name => 'FEM_UD_CANNOT_CREATE_LIST_ERR');
5500
5501 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5502 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5503 p_msg_name => 'FEM_UD_OBJ_EXEC_NOT_FOUND_WRN',
5504 p_token1 => 'REQUEST_ID',
5505 p_value1 => p_request_id,
5506 p_trans1 => 'N',
5507 p_token2 => 'OBJECT_ID',
5508 p_value2 => p_object_id,
5509 p_trans2 => 'N');
5510
5511 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5512 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5513 p_msg_name =>'FEM_UD_CANNOT_CREATE_LIST_ERR');
5514
5515 FEM_ENGINES_PKG.USER_MESSAGE
5516 (P_APP_NAME => 'FEM'
5517 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
5518
5519 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
5520 (status => 'ERROR', message => NULL);
5521
5522 WHEN e_cannot_read_object THEN
5523 ROLLBACK;
5524 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5525 p_msg_name => 'FEM_UD_CANNOT_READ_OBJECT_ERR');
5526
5527 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5528 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5529 p_msg_name => 'FEM_UD_CANNOT_READ_OBJECT_ERR');
5530
5531 FEM_ENGINES_PKG.USER_MESSAGE
5532 (P_APP_NAME => 'FEM'
5533 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
5534
5535 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
5536 (status => 'ERROR', message => NULL);
5537
5538 WHEN e_invalid_folder THEN
5539 fem_engines_pkg.user_message(p_app_name =>'FEM',
5540 p_msg_name =>'FEM_IMPEXP_INVALID_FOLDER_ERR',
5541 p_token1 => 'FOLDER',
5542 p_value1 => p_folder_id,
5543 p_trans1 => 'N');
5544
5545 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5546 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5547 p_msg_name =>'FEM_IMPEXP_INVALID_FOLDER_ERR',
5548 p_token1 => 'FOLDER',
5549 p_value1 => p_folder_id,
5550 p_trans1 => 'N');
5551
5552 FEM_ENGINES_PKG.USER_MESSAGE
5553 (P_APP_NAME => 'FEM'
5554 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
5555
5556 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
5557 (status => 'ERROR', message => NULL);
5558
5559 WHEN e_objexec_is_running THEN
5560 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5561 p_msg_name => 'FEM_UD_OBJEXEC_IS_RUNNING_ERR');
5562
5563 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5564 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5565 p_msg_name =>'FEM_UD_OBJEXEC_IS_RUNNING_ERR');
5566
5567 FEM_ENGINES_PKG.USER_MESSAGE
5568 (P_APP_NAME => 'FEM'
5569 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
5570
5571 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
5572 (status => 'ERROR', message => NULL);
5573
5574 WHEN e_cannot_create_undo_list THEN
5575 fem_engines_pkg.user_message(p_app_name =>'FEM',
5576 p_msg_name =>'FEM_UD_CANNOT_CREATE_LIST_ERR');
5577
5578 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5579 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5580 p_msg_name =>'FEM_UD_CANNOT_CREATE_LIST_ERR');
5581
5582 FEM_ENGINES_PKG.USER_MESSAGE
5583 (P_APP_NAME => 'FEM'
5584 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
5585
5586 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
5587 (status => 'ERROR', message => NULL);
5588
5589 WHEN e_cannot_add_candidate THEN
5590 fem_engines_pkg.user_message(p_app_name =>'FEM',
5591 p_msg_name =>'FEM_UD_CANNOT_ADD_CANDIDT_ERR');
5592
5593 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5594 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5595 p_msg_name =>'FEM_UD_CANNOT_ADD_CANDIDT_ERR');
5596
5597 FEM_ENGINES_PKG.USER_MESSAGE
5598 (P_APP_NAME => 'FEM'
5599 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
5600
5601 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
5602 (status => 'ERROR', message => NULL);
5603
5604 WHEN OTHERS THEN
5605 -- Unexpected exceptions
5606 -- Log the call stack and the Oracle error message to
5607 -- FND_LOG with the "unexpected exception" severity level.
5608
5609 FEM_ENGINES_PKG.Tech_Message
5610 (p_severity => pc_log_level_unexpected,
5611 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5612 p_msg_text => SQLERRM);
5613
5614 FEM_ENGINES_PKG.Tech_Message
5615 (p_severity => pc_log_level_unexpected,
5616 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5617 p_msg_text => dbms_utility.format_call_stack);
5618
5619 -- Log the Oracle error message to the stack.
5620 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5621 p_msg_name => 'FEM_UNEXPECTED_ERROR',
5622 P_TOKEN1 => 'ERR_MSG',
5623 P_VALUE1 => SQLERRM);
5624
5625 FEM_ENGINES_PKG.USER_MESSAGE
5626 (P_APP_NAME => 'FEM'
5627 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
5628
5629 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
5630 (status => 'ERROR', message => NULL);
5631
5632 END undo_object_execution;
5633 -- *****************************************************************************
5634 PROCEDURE undo_all_obj_execs_in_request (errbuf OUT NOCOPY VARCHAR2,
5635 retcode OUT NOCOPY VARCHAR2,
5636 p_request_id IN NUMBER,
5637 p_folder_id IN NUMBER,
5638 p_include_dependencies_flag IN VARCHAR2,
5639 p_ignore_dependency_errs_flag IN VARCHAR2) AS
5640 -- ============================================================================
5641 -- PUBLIC
5642 -- This procedure creates an undo list for all object executions in a request,
5643 -- then submits the newly created undo list to the undo engine. This
5644 -- procedure will be invoked via concurrent manager.
5645 -- ============================================================================
5646
5647 c_api_name CONSTANT VARCHAR2(30) := 'undo_all_obj_execs_in_request';
5648 v_count NUMBER;
5649 v_undo_list_obj_def_id NUMBER;
5650 v_undo_list_obj_id NUMBER;
5651 v_previous_request_id NUMBER;
5652 v_return_status VARCHAR2(30);
5653 v_msg_count NUMBER;
5654 v_msg_data VARCHAR2(32000);
5655 v_req_phase VARCHAR2(80);
5656 v_req_status VARCHAR2(80);
5657 v_dev_phase VARCHAR2(30);
5658 v_dev_status VARCHAR2(30);
5659 v_req_message VARCHAR2 (240);
5660 v_prg_stat VARCHAR2(40) := 'NORMAL';
5661 v_check_status BOOLEAN;
5662 v_subrequest_id NUMBER;
5663 v_request_id NUMBER := p_request_id;
5664 v_exec_status_code VARCHAR2(150);
5665 v_undo_list_exists VARCHAR2(1);
5666 v_object_id NUMBER;
5667
5668 CURSOR c1 IS
5669 SELECT object_id
5670 FROM fem_pl_object_executions
5671 WHERE request_id = p_request_id
5672 ORDER BY event_order;
5673
5674 BEGIN
5675 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
5676 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5677 p_msg_text => 'Begin. P_REQUEST_ID: '||p_request_id||
5678 ' P_FOLDER_ID: '||p_folder_id||
5679 ' P_INCLUDE_DEPENDENCIES_FLAG: '||p_include_dependencies_flag||
5680 ' P_IGNORE_DEPENDENCY_ERRS_FLAG:'||p_ignore_dependency_errs_flag);
5681
5682 -- ============================================================================
5683 -- VALIDATIONS
5684 -- ============================================================================
5685 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
5686 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5687 p_msg_text => 'Begin VALIDATIONS: '||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
5688
5689 -- Bug 4309949: Ignore folder security for Undo rules
5690 -- ============================================================================
5691 -- V01: Check to make sure folder exists, and that user has write access to folder
5692 -- ============================================================================
5693 -- SELECT count(*)
5694 -- INTO v_count
5695 -- FROM fem_folders_b b
5696 -- WHERE b.folder_id = p_folder_id
5697 -- AND b.folder_id IN (SELECT u.folder_id FROM fem_user_folders u
5698 -- WHERE u.user_id = pv_apps_user_id
5699 -- AND u.write_flag = 'Y');
5700
5701 -- IF v_count = 0 THEN
5702 -- RAISE e_invalid_folder;
5703 -- END IF;
5704
5705 -- ============================================================================
5706 -- V02: Check to make sure request exists.
5707 -- ============================================================================
5708
5709 SELECT COUNT(*)
5710 INTO v_count
5711 FROM fem_pl_requests
5712 WHERE request_id = p_request_id;
5713
5714 IF v_count = 0 THEN
5715 RAISE e_request_not_found;
5716 END IF;
5717
5718 -- ============================================================================
5719 -- V03: Check to make sure request is not running.
5720 -- ============================================================================
5721 v_check_status := fnd_concurrent.get_request_status (
5722 request_id => v_request_id,
5723 phase => v_req_phase,
5724 status => v_req_status,
5725 dev_phase => v_dev_phase,
5726 dev_status => v_dev_status,
5727 message => v_req_message);
5728
5729 IF v_dev_phase <> 'COMPLETE' THEN
5730 RAISE e_request_is_running;
5731 END IF;
5732
5733 -- ============================================================================
5734 -- V04: Check to make sure request has one or more object executions.
5735 -- If request has no object executions, then unregister the request.
5736 -- ============================================================================
5737
5738 SELECT count(*) INTO v_count
5739 FROM fem_pl_object_executions
5740 WHERE request_id = p_request_id;
5741
5742 IF v_count = 0 THEN
5743 -- IF there are no candidates (no object executions) for this request,
5744 -- then unregister the request.
5745
5746 fem_pl_pkg.unregister_request (
5747 p_api_version => 1.0,
5748 p_commit => FND_API.G_TRUE,
5749 p_request_id => p_request_id,
5750 x_msg_count => v_msg_count,
5751 x_msg_data => v_msg_data,
5752 x_return_status => v_return_status);
5753
5754
5755 IF v_return_status = pc_ret_sts_success THEN
5756
5757 DELETE fem_pl_temp_objects
5758 WHERE request_id = p_request_id;
5759
5760 DELETE fem_pl_obj_exec_steps
5761 WHERE request_id = p_request_id;
5762
5763 DELETE fem_pl_chains
5764 WHERE request_id = p_request_id;
5765
5766 DELETE fem_pl_object_defs
5767 WHERE request_id = p_request_id;
5768
5769 COMMIT;
5770
5771 FEM_ENGINES_PKG.USER_MESSAGE
5772 (P_APP_NAME => 'FEM'
5773 ,P_MSG_NAME => 'FEM_EXEC_SUCCESS');
5774
5775 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
5776 (status => 'NORMAL', message => NULL);
5777
5778 ELSE
5779 FEM_ENGINES_PKG.USER_MESSAGE
5780 (P_APP_NAME => 'FEM'
5781 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
5782
5783 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
5784 (status => 'ERROR', message => NULL);
5785 END IF;
5786
5787 ELSE
5788
5789 -- ============================================================================
5790 -- V05: Check to make sure user can execute/read all objects in the request.
5791 -- ============================================================================
5792
5793 SELECT count(*) INTO v_count
5794 FROM fem_object_catalog_b o, fem_pl_object_executions p
5795 WHERE p.request_id = p_request_id
5796 AND p.object_id = o.object_id
5797 AND o.folder_id NOT IN
5798 (SELECT folder_id
5799 FROM fem_user_folders
5800 WHERE user_id = pv_apps_user_id);
5801
5802 IF v_count > 0 THEN
5803 RAISE e_cannot_read_object;
5804 END IF;
5805
5806
5807 -- Create and execute undo list if request status <> 'RUNNING'.
5808 -- ============================================================================
5809 -- CREATE or RETRIEVE UNDO LIST
5810 -- ============================================================================
5811 -- If undo list already exists with the same name, post message and retrieve
5812 -- list ID from the database.
5813 BEGIN
5814
5815 SELECT o.object_id, d.object_definition_id, o.object_name
5816 INTO v_undo_list_obj_id, v_undo_list_obj_def_id, pv_undo_object_name
5817 FROM fem_object_catalog_vl o, fem_object_definition_b d
5818 WHERE o.object_type_code = 'UNDO'
5819 AND o.object_id = d.object_id
5820 AND o.object_name = 'UNDO - REQUEST_ID: '||p_request_id;
5821 v_undo_list_exists := 'T';
5822
5823 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
5824 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5825 p_msg_text => 'Undo list already exists. OBJECT_ID:'||v_undo_list_obj_id||
5826 ' OBJECT_DEFINITION_ID:'||v_undo_list_obj_def_id);
5827
5828 EXCEPTION WHEN NO_DATA_FOUND THEN
5829 v_undo_list_exists := 'F';
5830 END;
5831
5832 IF v_undo_list_exists = 'F' THEN
5833 -- ============================================================================
5834 -- CREATE UNDO LIST
5835 -- ============================================================================
5836 -- ============================================================================
5837 -- C1: Create undo list
5838 -- ============================================================================
5839 create_undo_list (p_api_version => 1.0,
5840 p_commit => FND_API.G_TRUE,
5841 p_undo_list_name => 'UNDO - REQUEST_ID: '||p_request_id,
5842 p_folder_id => pc_undo_folder_id,
5843 p_include_dependencies_flag => NVL(p_include_dependencies_flag,'Y'),
5844 p_ignore_dependency_errs_flag => NVL(p_ignore_dependency_errs_flag,'N'),
5845 p_execution_date => sysdate,
5846 x_undo_list_obj_id => v_undo_list_obj_id,
5847 x_undo_list_obj_def_id => v_undo_list_obj_def_id,
5848 x_return_status => v_return_status,
5849 x_msg_count => v_msg_count,
5850 x_msg_data => v_msg_data);
5851
5852 IF v_return_status <> pc_ret_sts_success THEN
5853 Get_Put_Messages(
5854 p_msg_count => v_msg_count,
5855 p_msg_data => v_msg_data,
5856 p_user_msg => 'Y',
5857 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
5858 ROLLBACK;
5859 RAISE e_cannot_create_undo_list;
5860 ELSIF v_msg_count > 0 THEN
5861 Get_Put_Messages(
5862 p_msg_count => v_msg_count,
5863 p_msg_data => v_msg_data,
5864 p_user_msg => 'N',
5865 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
5866 END IF;
5867
5868 pv_undo_object_name := 'UNDO - REQUEST_ID: '||p_request_id;
5869 -- ============================================================================
5870 -- C2: Add object executions to undo list as candidates
5871 -- ============================================================================
5872 v_count := 0;
5873
5874 FOR acandidate IN c1 LOOP
5875 v_count := c1%ROWCOUNT;
5876 add_candidate (p_api_version => 1.0,
5877 p_commit => FND_API.G_TRUE,
5878 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
5879 p_request_id => p_request_id,
5880 p_object_id => acandidate.object_id,
5881 x_return_status => v_return_status,
5882 x_msg_count => v_msg_count,
5883 x_msg_data => v_msg_data);
5884
5885 IF v_return_status <> pc_ret_sts_success THEN
5886 Get_Put_Messages(
5887 p_msg_count => v_msg_count,
5888 p_msg_data => v_msg_data,
5889 p_user_msg => 'Y',
5890 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
5891 ROLLBACK;
5892 RAISE e_cannot_add_candidate;
5893
5894 ELSIF v_msg_count > 0 THEN
5895 Get_Put_Messages(
5896 p_msg_count => v_msg_count,
5897 p_msg_data => v_msg_data,
5898 p_user_msg => 'N',
5899 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
5900 END IF;
5901
5902 END LOOP;
5903
5904 IF v_count = 0 THEN
5905 RAISE e_list_has_no_candidates;
5906 END IF;
5907 END IF;
5908
5909 -- =========================================================================
5910 -- SUBMIT undo list for processing.
5911 -- =========================================================================
5912
5913 execute_undo_list(
5914 errbuf => errbuf,
5915 retcode => retcode,
5916 p_undo_list_obj_id => v_undo_list_obj_id);
5917
5918 END IF;
5919 -- ============================================================================
5920 -- SET STATUS
5921 -- ============================================================================
5922 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
5923 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5924 p_msg_text => 'End. '||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
5925 -- ============================================================================
5926 -- EXCEPTIONS
5927 -- ============================================================================
5928 EXCEPTION
5929 WHEN e_request_not_found THEN
5930 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5931 p_msg_name => 'FEM_UD_REQUEST_NOT_FOUND_WRN',
5932 p_token1 => 'REQUEST_ID',
5933 p_value1 => p_request_id,
5934 p_trans1 => 'N');
5935
5936 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5937 p_msg_name => 'FEM_UD_CANNOT_CREATE_LIST_ERR');
5938
5939 FEM_ENGINES_PKG.USER_MESSAGE
5940 (P_APP_NAME => 'FEM'
5941 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
5942
5943 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5944 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5945 p_msg_name => 'FEM_UD_REQUEST_NOT_FOUND_WRN',
5946 p_token1 => 'REQUEST_ID',
5947 p_value1 => p_request_id,
5948 p_trans1 => 'N');
5949
5950 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5951 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5952 p_msg_name =>'FEM_UD_CANNOT_CREATE_LIST_ERR');
5953
5954 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
5955 (status => 'ERROR', message => NULL);
5956
5957 WHEN e_invalid_folder THEN
5958 fem_engines_pkg.user_message(p_app_name =>'FEM',
5959 p_msg_name =>'FEM_IMPEXP_INVALID_FOLDER_ERR',
5960 p_token1 => 'FOLDER',
5961 p_value1 => p_folder_id,
5962 p_trans1 => 'N');
5963
5964 FEM_ENGINES_PKG.USER_MESSAGE
5965 (P_APP_NAME => 'FEM'
5966 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
5967
5968 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5969 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5970 p_msg_name =>'FEM_IMPEXP_INVALID_FOLDER_ERR');
5971
5972 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
5973 (status => 'ERROR', message => NULL);
5974
5975 WHEN e_request_is_running THEN
5976 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5977 p_msg_name => 'FEM_UD_REQUEST_IS_RUNNING_ERR');
5978
5979 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5980 p_msg_name => 'FEM_UD_CANNOT_UNDO_REQUEST_ERR');
5981
5982 FEM_ENGINES_PKG.USER_MESSAGE
5983 (P_APP_NAME => 'FEM'
5984 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
5985
5986 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
5987 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
5988 p_msg_name =>'FEM_UD_REQUEST_IS_RUNNING_ERR');
5989
5990 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
5991 (status => 'ERROR', message => NULL);
5992
5993 WHEN e_cannot_read_object THEN
5994
5995 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5996 p_msg_name => 'FEM_UD_CANNOT_READ_OBJECT_ERR');
5997
5998 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
5999 p_msg_name => 'FEM_UD_CANNOT_UNDO_REQUEST_ERR');
6000
6001 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
6002 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6003 p_msg_name => 'FEM_UD_CANNOT_READ_OBJECT_ERR');
6004
6005
6006 FEM_ENGINES_PKG.USER_MESSAGE
6007 (P_APP_NAME => 'FEM'
6008 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
6009
6010 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
6011 (status => 'ERROR', message => NULL);
6012
6013 WHEN e_cannot_create_undo_list THEN
6014 fem_engines_pkg.user_message(p_app_name =>'FEM',
6015 p_msg_name =>'FEM_UD_CANNOT_CREATE_LIST_ERR');
6016
6017 FEM_ENGINES_PKG.USER_MESSAGE
6018 (P_APP_NAME => 'FEM'
6019 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
6020
6021 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
6022 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6023 p_msg_name =>'FEM_UD_CANNOT_CREATE_LIST_ERR');
6024
6025 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
6026 (status => 'ERROR', message => NULL);
6027
6028 WHEN e_cannot_add_candidate THEN
6029 fem_engines_pkg.user_message(p_app_name =>'FEM',
6030 p_msg_name =>'FEM_UD_CANNOT_ADD_CANDIDT_ERR');
6031
6032 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
6033 p_msg_name => 'FEM_UD_CANNOT_UNDO_REQUEST_ERR');
6034
6035 FEM_ENGINES_PKG.USER_MESSAGE
6036 (P_APP_NAME => 'FEM'
6037 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
6038
6039 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
6040 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6041 p_msg_name =>'FEM_UD_CANNOT_ADD_CANDIDT_ERR');
6042
6043 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
6044 (status => 'ERROR', message => NULL);
6045
6046 WHEN e_list_has_no_candidates THEN
6047 retcode := pc_ret_sts_error;
6048
6049 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
6050 p_msg_name => 'FEM_UD_NO_CANDIDATES_ERR');
6051
6052 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
6053 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6054 p_msg_name =>'FEM_UD_NO_CANDIDATES_ERR');
6055
6056 FEM_ENGINES_PKG.USER_MESSAGE
6057 (P_APP_NAME => 'FEM'
6058 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
6059
6060 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
6061 (status => 'ERROR', message => NULL);
6062
6063 WHEN OTHERS THEN
6064 -- Unexpected exceptions
6065 -- Log the call stack and the Oracle error message to
6066 -- FND_LOG with the "unexpected exception" severity level.
6067
6068 FEM_ENGINES_PKG.Tech_Message
6069 (p_severity => pc_log_level_unexpected,
6070 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6071 p_msg_text => SQLERRM);
6072
6073 FEM_ENGINES_PKG.Tech_Message
6074 (p_severity => pc_log_level_unexpected,
6075 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6076 p_msg_text => dbms_utility.format_call_stack);
6077
6078 -- Log the Oracle error message to the stack.
6079 FEM_ENGINES_PKG.user_message(p_app_name =>'FEM',
6080 p_msg_name => 'FEM_UNEXPECTED_ERROR',
6081 P_TOKEN1 => 'ERR_MSG',
6082 P_VALUE1 => SQLERRM,
6083 P_TRANS1 => 'N');
6084
6085 FEM_ENGINES_PKG.USER_MESSAGE
6086 (P_APP_NAME => 'FEM'
6087 ,P_MSG_NAME => 'FEM_EXEC_RERUN');
6088
6089 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status
6090 (status => 'ERROR', message => NULL);
6091 END undo_all_obj_execs_in_request;
6092 -- *****************************************************************************
6093 PROCEDURE create_and_submit_prview_list (x_request_id OUT NOCOPY NUMBER,
6094 x_undo_list_obj_id OUT NOCOPY NUMBER,
6095 x_undo_list_obj_def_id OUT NOCOPY NUMBER,
6096 x_return_status OUT NOCOPY VARCHAR2,
6097 x_msg_count OUT NOCOPY NUMBER,
6098 x_msg_data OUT NOCOPY VARCHAR2,
6099 p_api_version IN NUMBER,
6100 p_undo_list_name IN VARCHAR2,
6101 p_folder_id IN NUMBER,
6102 p_ud_session_id IN NUMBER) AS
6103
6104 -- ============================================================================
6105 -- PUBLIC
6106 -- This procedure creates an undo list and submits it to concurrent manager
6107 -- for processing by the undo engine.
6108 -- The logic of this procedure is designed to support the initial phase of the
6109 -- undo user interface (FEM.D). In this release, folder security is implemented,
6110 -- and the user interface does not provide a means for the user to review an
6111 -- existing undo list. That is why the undo list is deleted if it is not
6112 -- successfully submitted to concurrent manager, as the user will not have
6113 -- a means to resubmit the list to concurrent manager.
6114 -- Parameter descriptions:
6115 -- p_api_version - Version of the API
6116 -- p_undo_list_name - Name of undo list
6117 -- p_folder_id - Name of folder in which undo will be created. References
6118 -- fem_folders_vl.folder_id.
6119 -- p_ud_session_id - This is the identifier for the user interface session. It
6120 -- is used to identify the rows to retrieve from the
6121 -- FEM_UD_PRVIEW_xxx tables.
6122 -- ============================================================================
6123 c_api_name CONSTANT VARCHAR2(30) := 'create_and_submit_prview_list';
6124 v_count NUMBER;
6125 v_undo_list_obj_def_id NUMBER;
6126 v_undo_list_obj_id NUMBER;
6127 v_exec_status_code VARCHAR2(80);
6128 v_undo_list_exists VARCHAR2(1);
6129
6130 -- This query retrieves all candidate object executions in undo session.
6131 CURSOR c1 IS
6132 SELECT c.request_id, c.object_id, pl.exec_status_code
6133 FROM fem_ud_prview_candidates c, fem_pl_object_executions pl
6134 WHERE c.ud_session_id = p_ud_session_id
6135 AND c.request_id = pl.request_id (+)
6136 AND c.object_id = pl.object_id (+)
6137 ORDER BY c.request_id, c.object_id;
6138
6139 BEGIN
6140 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
6141 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6142 p_msg_text => 'Begin. P_UNDO_LIST_NAME: '||p_undo_list_name||
6143 ' P_FOLDER_ID: '||p_folder_id||
6144 ' P_UD_SESSION_ID: '||p_ud_session_id);
6145
6146 x_return_status := pc_ret_sts_success;
6147
6148 -- ============================================================================
6149 -- VALIDATIONS
6150 -- ============================================================================
6151 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
6152 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6153 p_msg_text => 'Begin VALIDATIONS: '||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
6154
6155 -- Bug 4309949: Ignore folder security for Undo rules
6156 -- ============================================================================
6157 -- V02: Check to make sure folder exists, and that user has write privileges
6158 -- on the folder.
6159 -- ============================================================================
6160 -- SELECT count(*)
6161 -- INTO v_count
6162 -- FROM fem_folders_b b
6163 -- WHERE b.folder_id = p_folder_id
6164 -- AND b.folder_id IN (SELECT u.folder_id FROM fem_user_folders u
6165 -- WHERE u.user_id = pv_apps_user_id
6166 -- AND u.write_flag = 'Y');
6167
6168 -- IF v_count = 0 THEN
6169 -- RAISE e_invalid_folder;
6170 -- END IF;
6171
6172 -- ============================================================================
6173 -- V03: Check to make sure object executions are not RUNNING.
6174 -- ============================================================================
6175 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
6176 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6177 p_msg_text => 'V03: Check to make sure object executions are not RUNNING: '||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
6178
6179 FOR cand_num IN c1 LOOP
6180
6181 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
6182 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6183 p_msg_text => 'Candidate Number:'||c1%ROWCOUNT||' REQUEST_ID:'||cand_num.request_id||
6184 ' OBJECT_ID:'||cand_num.object_id||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
6185
6186 IF cand_num.exec_status_code = 'RUNNING' THEN
6187 -- Verify that the request is still running using fem_pl_pkg.set_exec_state
6188
6189 fem_pl_pkg.set_exec_state (p_api_version => 1.0,
6190 p_commit => fnd_api.g_true,
6191 p_request_id => cand_num.request_id,
6192 p_object_id => cand_num.object_id,
6193 x_msg_count => x_msg_count,
6194 x_msg_data => x_msg_data,
6195 x_return_status => x_return_status);
6196
6197 IF x_msg_count > 0 THEN
6198 Get_Put_Messages(
6199 p_msg_count => x_msg_count,
6200 p_msg_data => x_msg_data,
6201 p_user_msg => 'N',
6202 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
6203 END IF;
6204 END IF;
6205
6206 SELECT exec_status_code INTO v_exec_status_code
6207 FROM fem_pl_object_executions
6208 WHERE request_id = cand_num.request_id
6209 AND object_id = cand_num.object_id;
6210
6211 IF v_exec_status_code = 'RUNNING' THEN
6212 RAISE e_objexec_is_running;
6213 END IF;
6214 END LOOP;
6215
6216 -- Create and execute undo list if all object executions' status <> 'RUNNING'.
6217 -- ============================================================================
6218 -- CREATE or RETRIEVE UNDO LIST
6219 -- ============================================================================
6220 -- If undo list already exists with the same name, post message and retrieve
6221 -- list ID from the database.
6222 BEGIN
6223
6224 SELECT o.object_id, d.object_definition_id
6225 INTO v_undo_list_obj_id, v_undo_list_obj_def_id
6226 FROM fem_object_catalog_vl o, fem_object_definition_b d
6227 WHERE o.object_type_code = 'UNDO'
6228 AND o.object_id = d.object_id
6229 AND o.object_name = p_undo_list_name;
6230 v_undo_list_exists := 'T';
6231 EXCEPTION WHEN NO_DATA_FOUND THEN
6232 v_undo_list_exists := 'F';
6233 END;
6234
6235 IF v_undo_list_exists = 'F' THEN
6236 -- ============================================================================
6237 -- C1: Create undo list if it does not exist
6238 -- ============================================================================
6239 create_undo_list (p_api_version => 1.0,
6240 p_commit => FND_API.G_FALSE,
6241 p_undo_list_name => p_undo_list_name,
6242 p_folder_id => pc_undo_folder_id,
6243 p_include_dependencies_flag => ('Y'),
6244 p_ignore_dependency_errs_flag => ('N'),
6245 p_execution_date => sysdate,
6246 x_undo_list_obj_id => v_undo_list_obj_id,
6247 x_undo_list_obj_def_id => v_undo_list_obj_def_id,
6248 x_return_status => x_return_status,
6249 x_msg_count => x_msg_count,
6250 x_msg_data => x_msg_data);
6251
6252 IF x_return_status <> pc_ret_sts_success THEN
6253 Get_Put_Messages(
6254 p_msg_count => x_msg_count,
6255 p_msg_data => x_msg_data,
6256 p_user_msg => 'Y',
6257 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
6258 ROLLBACK;
6259 RAISE e_cannot_create_undo_list;
6260 ELSIF x_msg_count > 0 THEN
6261 Get_Put_Messages(
6262 p_msg_count => x_msg_count,
6263 p_msg_data => x_msg_data,
6264 p_user_msg => 'N',
6265 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
6266 END IF;
6267
6268 -- ============================================================================
6269 -- C2: Add object executions to undo list as candidates
6270 -- ============================================================================
6271 FOR cand_num IN c1 LOOP
6272 add_candidate (p_api_version => 1.0,
6273 p_commit => FND_API.G_FALSE,
6274 p_undo_list_obj_def_id => v_undo_list_obj_def_id,
6275 p_request_id => cand_num.request_id,
6276 p_object_id => cand_num.object_id,
6277 x_return_status => x_return_status,
6278 x_msg_count => x_msg_count,
6279 x_msg_data => x_msg_data);
6280
6281 IF x_return_status <> pc_ret_sts_success THEN
6282 Get_Put_Messages(
6283 p_msg_count => x_msg_count,
6284 p_msg_data => x_msg_data,
6285 p_user_msg => 'Y',
6286 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
6287 ROLLBACK;
6288 RAISE e_cannot_add_candidate;
6289
6290 ELSIF x_msg_count > 0 THEN
6291 Get_Put_Messages(
6292 p_msg_count => x_msg_count,
6293 p_msg_data => x_msg_data,
6294 p_user_msg => 'N',
6295 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
6296 END IF;
6297 END LOOP;
6298 END IF;
6299
6300 COMMIT;
6301
6302 -- ============================================================================
6303 -- SUBMIT undo list for processing. If list is not submitted successfully,
6304 -- delete list.
6305 -- ============================================================================
6306 x_request_id := FND_REQUEST.SUBMIT_REQUEST(
6307 application => 'FEM',
6308 program => 'FEM_UNDO_LIST',
6309 sub_request => FALSE,
6310 argument1 => v_undo_list_obj_id);
6311
6312 IF (x_request_id = 0) THEN
6313
6314 RAISE e_cannot_submit_request;
6315
6316 END IF;
6317
6318 -- Bug 4337210. Last step is to clean up the preview tables.
6319 -- First delete the preview dependents
6320 DELETE FROM fem_ud_prview_dependents
6321 WHERE ud_session_id = p_ud_session_id;
6322 -- Then delete the preview candidates
6323 DELETE FROM fem_ud_prview_candidates
6324 WHERE ud_session_id = p_ud_session_id;
6325
6326 COMMIT;
6327
6328 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
6329 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6330 p_msg_text => 'Undo list processed using REQUEST_ID:'||x_request_id);
6331 fem_engines_pkg.tech_message(p_severity => pc_log_level_statement,
6332 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6333 p_msg_text => 'End. '||to_char(sysdate,'MM/DD/YYYY HH:MI:SS'));
6334 -- ============================================================================
6335 -- EXCEPTIONS
6336 -- ============================================================================
6337 EXCEPTION
6338 WHEN e_invalid_folder THEN
6339 x_return_status := pc_ret_sts_error;
6340 fem_engines_pkg.put_message(p_app_name =>'FEM',
6341 p_msg_name =>'FEM_IMPEXP_INVALID_FOLDER_ERR',
6342 p_token1 => 'FOLDER',
6343 p_value1 => p_folder_id,
6344 p_trans1 => 'N');
6345
6346 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
6347 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6348 p_msg_name =>'FEM_IMPEXP_INVALID_FOLDER_ERR',
6349 p_token1 => 'FOLDER',
6350 p_value1 => p_folder_id,
6351 p_trans1 => 'N');
6352
6353 -- Standard call to get message count and if count is 1, get message info.
6354 FND_MSG_PUB.Count_And_Get
6355 (p_count => x_msg_count,
6356 p_data => x_msg_data);
6357
6358 WHEN e_objexec_is_running THEN
6359 x_return_status := pc_ret_sts_error;
6360 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
6361 p_msg_name => 'FEM_UD_OBJEXEC_IS_RUNNING_ERR');
6362
6363 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
6364 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6365 p_msg_name =>'FEM_UD_OBJEXEC_IS_RUNNING_ERR');
6366
6367 -- Standard call to get message count and if count is 1, get message info.
6368 FND_MSG_PUB.Count_And_Get
6369 (p_count => x_msg_count,
6370 p_data => x_msg_data);
6371
6372 WHEN e_cannot_create_undo_list THEN
6373 x_return_status := pc_ret_sts_error;
6374 fem_engines_pkg.put_message(p_app_name =>'FEM',
6375 p_msg_name =>'FEM_UD_CANNOT_CREATE_LIST_ERR');
6376
6377 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
6378 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6379 p_msg_name =>'FEM_UD_CANNOT_CREATE_LIST_ERR');
6380
6381 -- Standard call to get message count and if count is 1, get message info.
6382 FND_MSG_PUB.Count_And_Get
6383 (p_count => x_msg_count,
6384 p_data => x_msg_data);
6385
6386 WHEN e_cannot_add_candidate THEN
6387 x_return_status := pc_ret_sts_error;
6388 fem_engines_pkg.put_message(p_app_name =>'FEM',
6389 p_msg_name =>'FEM_UD_CANNOT_ADD_CANDIDT_ERR');
6390
6391 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
6392 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6393 p_msg_name =>'FEM_UD_CANNOT_ADD_CANDIDT_ERR');
6394
6395 -- Standard call to get message count and if count is 1, get message info.
6396 FND_MSG_PUB.Count_And_Get
6397 (p_count => x_msg_count,
6398 p_data => x_msg_data);
6399
6400
6401 WHEN e_cannot_submit_request THEN
6402
6403 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
6404 p_msg_name => 'FEM_UD_SUBMIT_LIST_ERR',
6405 P_TOKEN1 => 'OBJECT_ID',
6406 P_VALUE1 => v_undo_list_obj_id,
6407 P_TRANS1 => 'N');
6408
6409 fem_engines_pkg.tech_message(p_severity => pc_log_level_exception,
6410 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6411 p_msg_name => 'FEM_UD_SUBMIT_LIST_ERR',
6412 P_TOKEN1 => 'OBJECT_ID',
6413 P_VALUE1 => v_undo_list_obj_id,
6414 P_TRANS1 => 'N');
6415
6416 delete_undo_list (
6417 x_return_status => x_return_status,
6418 x_msg_count => x_msg_count,
6419 x_msg_data => x_msg_data,
6420 p_api_version => 1.0,
6421 p_commit => FND_API.G_TRUE,
6422 p_undo_list_obj_id => v_undo_list_obj_id);
6423
6424 IF x_msg_count > 0 THEN
6425 Get_Put_Messages(
6426 p_msg_count => x_msg_count,
6427 p_msg_data => x_msg_data,
6428 p_user_msg => 'N',
6429 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name);
6430 END IF;
6431 x_return_status := pc_ret_sts_unexp_error;
6432
6433 -- Standard call to get message count and if count is 1, get message info.
6434 FND_MSG_PUB.Count_And_Get
6435 (p_count => x_msg_count,
6436 p_data => x_msg_data);
6437
6438 WHEN OTHERS THEN
6439 -- Unexpected exceptions
6440 -- Log the call stack and the Oracle error message to
6441 -- FND_LOG with the "unexpected exception" severity level.
6442 x_return_status := pc_ret_sts_unexp_error;
6443
6444 FEM_ENGINES_PKG.Tech_Message
6445 (p_severity => pc_log_level_unexpected,
6446 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6447 p_msg_text => SQLERRM);
6448
6449 FEM_ENGINES_PKG.Tech_Message
6450 (p_severity => pc_log_level_unexpected,
6451 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6452 p_msg_text => dbms_utility.format_call_stack);
6453
6454 -- Log the Oracle error message to the stack.
6455 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
6456 p_msg_name => 'FEM_UNEXPECTED_ERROR',
6457 P_TOKEN1 => 'ERR_MSG',
6458 P_VALUE1 => SQLERRM);
6459
6460 -- Standard call to get message count and if count is 1, get message info.
6461 FND_MSG_PUB.Count_And_Get
6462 (p_count => x_msg_count,
6463 p_data => x_msg_data);
6464
6465 END create_and_submit_prview_list;
6466 -- ****************************************************************************
6467 PROCEDURE insert_preview_candidates (x_return_status OUT NOCOPY VARCHAR2,
6468 x_msg_count OUT NOCOPY NUMBER,
6469 x_msg_data OUT NOCOPY VARCHAR2,
6470 p_api_version IN NUMBER,
6471 p_ud_session_id IN NUMBER,
6472 p_request_ids IN FEM_NUMBER_TABLE,
6473 p_object_ids IN FEM_NUMBER_TABLE,
6474 p_commit IN VARCHAR2) AS
6475 -- ============================================================================
6476 -- PUBLIC
6477 -- This procedure inserts the Undo Preview Candidates for
6478 -- a given Undo Session.
6479 -- ============================================================================
6480 c_api_name CONSTANT VARCHAR2(30) := 'insert_preview_candidates';
6481 c_api_version CONSTANT NUMBER := 1.0;
6482 v_count NUMBER := 0;
6483
6484 BEGIN
6485
6486 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
6487 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6488 p_msg_text => 'Begin. P_COMMIT:'||p_commit||
6489 ' P_UD_SESSION_ID: '||p_ud_session_id);
6490
6491 -- Standard Start of API savepoint
6492 SAVEPOINT insert_preview_candidates_pub;
6493
6494 -- Standard call to check for call compatibility.
6495 IF NOT FND_API.Compatible_API_Call (c_api_version,
6496 p_api_version,
6497 c_api_name,
6498 pc_pkg_name)
6499 THEN
6500 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6501 END IF;
6502
6503 -- ============================================================================
6504 -- STEP V2: Validate p_ud_session_id
6505 -- ============================================================================
6506
6507 IF p_ud_session_id IS NULL THEN
6508 RAISE e_invalid_session_id;
6509 END IF;
6510
6511 -- Initialize API return status to success
6512 x_return_status := pc_ret_sts_success;
6513
6514 v_count := p_object_ids.COUNT;
6515
6516 IF v_count > 0 THEN
6517 FORALL i in 1..v_count
6518 INSERT INTO fem_ud_prview_candidates(ud_session_id,
6519 request_id, object_id, validation_status_code,
6520 created_by, creation_date, last_updated_by, last_update_date,
6521 last_update_login, object_version_Number)
6522 VALUES (p_ud_session_id, p_request_ids(i), p_object_ids(i),
6523 null,pv_apps_user_id, sysdate, pv_apps_user_id, sysdate, pv_login_id,1);
6524 END IF;
6525
6526 IF v_count = 0 THEN
6527 x_return_status := pc_ret_sts_error;
6528 RAISE e_list_has_no_candidates;
6529 ELSE
6530 x_return_status := pc_ret_sts_success;
6531 END IF;
6532
6533 IF FND_API.To_Boolean( p_commit ) THEN
6534 COMMIT WORK;
6535 END IF;
6536
6537 fem_engines_pkg.tech_message(p_severity => pc_log_level_procedure,
6538 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6539 p_msg_text => 'End. X_RETURN_STATUS: '||x_return_status);
6540
6541 EXCEPTION
6542 WHEN e_invalid_session_id THEN
6543 x_return_status := pc_ret_sts_error;
6544
6545 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
6546 p_msg_name => 'FEM_UD_INVALID_SESSIONID');
6547
6548 FND_MSG_PUB.Count_And_Get
6549 (p_count => x_msg_count,
6550 p_data => x_msg_data);
6551
6552 WHEN e_list_has_no_candidates THEN
6553 ROLLBACK TO insert_preview_candidates_pub;
6554 x_return_status := pc_ret_sts_error;
6555
6556 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
6557 p_msg_name => 'FEM_UD_NO_CANDIDATES_ERR');
6558
6559 fem_engines_pkg.tech_message(p_severity => pc_log_level_error,
6560 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6561 p_app_name =>'FEM',
6562 p_msg_name => 'FEM_UD_NO_CANDIDATES_ERR');
6563
6564 FND_MSG_PUB.Count_And_Get
6565 (p_count => x_msg_count,
6566 p_data => x_msg_data);
6567
6568 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6569 ROLLBACK TO insert_preview_candidates_pub;
6570 x_return_status := pc_ret_sts_unexp_error;
6571
6572 fem_engines_pkg.tech_message(p_severity => pc_log_level_unexpected,
6573 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6574 p_app_name =>'FEM',
6575 p_msg_name => 'FEM_BAD_P_API_VER_ERR',p_token1 => 'VALUE',
6576 p_value1 => p_api_version, p_trans1 => 'N');
6577
6578 WHEN OTHERS THEN
6579 -- Unexpected exceptions
6580 x_return_status := pc_ret_sts_unexp_error;
6581
6582 -- Log the call stack and the Oracle error message to
6583 -- FND_LOG with the "unexpected exception" severity level.
6584
6585 FEM_ENGINES_PKG.Tech_Message
6586 (p_severity => pc_log_level_unexpected,
6587 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6588 p_msg_text => SQLERRM);
6589
6590 FEM_ENGINES_PKG.Tech_Message
6591 (p_severity => pc_log_level_unexpected,
6592 p_module => 'fem.plsql.'||pc_pkg_name||'.'||c_api_name,
6593 p_msg_text => dbms_utility.format_call_stack);
6594
6595 -- Log the Oracle error message to the stack.
6596 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
6597 p_msg_name => 'FEM_UNEXPECTED_ERROR',
6598 P_TOKEN1 => 'ERR_MSG',
6599 P_VALUE1 => SQLERRM);
6600
6601 FND_MSG_PUB.Count_And_Get
6602 (p_count => x_msg_count,
6603 p_data => x_msg_data);
6604
6605 ROLLBACK TO insert_preview_candidates_pub;
6606 END insert_preview_candidates;
6607 -- ****************************************************************************
6608
6609 PROCEDURE Delete_Balances (
6610 p_api_version IN NUMBER DEFAULT 1.0,
6611 p_init_msg_list IN VARCHAR2 DEFAULT FND_API.G_FALSE,
6612 p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE,
6613 p_encoded IN VARCHAR2 DEFAULT FND_API.G_TRUE,
6614 x_return_status OUT NOCOPY VARCHAR2,
6615 x_msg_count OUT NOCOPY NUMBER,
6616 x_msg_data OUT NOCOPY VARCHAR2,
6617 p_current_request_id IN NUMBER,
6618 p_object_id IN NUMBER,
6619 p_cal_period_id IN NUMBER,
6620 p_ledger_id IN NUMBER,
6621 p_dataset_code IN NUMBER
6622 ) IS
6623 -- =========================================================================
6624 -- Purpose
6625 -- Deletes all FEM Balances data of a given ledger, calendar period,
6626 -- and dataset that was created by previous executions of a given rule.
6627 -- Data can only be deleted if the data is not being used by another
6628 -- rule as a data source (i.e. chained) and if the object executions
6629 -- that created the data have finished running.
6630 --
6631 -- Note that this API only works against FEM Balances and can only be
6632 -- called for balances created by the TP_PROCESS_RULE rules.
6633 -- History
6634 -- 01-30-06 G Cheng Bug 4596447. Created.
6635 -- 06-28-06 G Cheng Bug 5360424. Added p_current_request_id param.
6636 -- Arguments
6637 -- p_current_request_id Request ID of execution currently running
6638 -- p_object_id Object ID
6639 -- p_cal_period_id Calendar Period ID
6640 -- p_ledger_id Ledger ID
6641 -- p_dataset_code Dataset Code
6642 -- Return Logic
6643 -- Set x_return_status to 'U' (Unexpected Error) if object type
6644 -- is not TP_PROCESS_RULE.
6645 -- Set x_return_status to 'E' (Error) if the object executions that
6646 -- created the existing FEM Balances data are chained or are still running.
6647 -- Otherwise, set x_return_status to 'S' (Success) after deleting the
6648 -- balances and all related Process Locks and Data Locations related data.
6649 -- =========================================================================
6650 C_MODULE CONSTANT FND_LOG_MESSAGES.module%TYPE :=
6651 'fem.plsql.fem_ud_pkg.delete_balances';
6652 C_API_NAME CONSTANT VARCHAR2(30) := 'Delete_Balances';
6653 C_API_VERSION CONSTANT NUMBER := 1.0;
6654 C_FEM_BALANCES CONSTANT VARCHAR2(30) := 'FEM_BALANCES';
6655 --
6656 e_api_error EXCEPTION;
6657 e_objexec_running EXCEPTION;
6658 e_chain_exists EXCEPTION;
6659 v_object_type FEM_OBJECT_CATALOG_B.object_type_code%TYPE;
6660 v_object_name FEM_OBJECT_CATALOG_TL.object_name%TYPE;
6661 v_request_id FEM_PL_REQUESTS.request_id%TYPE;
6662 v_dep_req_id FEM_PL_REQUESTS.request_id%TYPE;
6663 v_dep_obj_id FEM_OBJECT_CATALOG_B.object_id%TYPE;
6664 v_exec_status_code FEM_PL_REQUESTS.exec_status_code%TYPE;
6665 v_return_status VARCHAR2(1);
6666 v_chain_exists VARCHAR2(1);
6667 v_count NUMBER;
6668 v_sql VARCHAR2(1000);
6669 --
6670 CURSOR c_pl_obj_execs (p_current_request_id NUMBER, p_object_id NUMBER,
6671 p_table_name VARCHAR2, p_cal_period_id NUMBER,
6672 p_ledger_id NUMBER, p_dataset_code NUMBER) IS
6673 SELECT R.request_id, T.object_id, T.table_name
6674 FROM fem_pl_requests R, fem_pl_tables T
6675 WHERE R.request_id = T.request_id
6676 AND R.request_id <> p_current_request_id
6677 AND T.object_id = p_object_id
6678 AND T.table_name = p_table_name
6679 AND R.cal_period_id = p_cal_period_id
6680 AND R.ledger_id = p_ledger_id
6681 AND R.output_dataset_code = p_dataset_code;
6682
6683 CURSOR c_object_name (p_object_id NUMBER) IS
6684 SELECT object_name
6685 FROM fem_object_catalog_vl
6686 WHERE object_id = p_object_id;
6687 --
6688 BEGIN
6689 --
6690 -- Standard Start of API savepoint
6691 SAVEPOINT delete_balances_pub;
6692
6693 IF FND_LOG.level_procedure >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
6694 FEM_ENGINES_PKG.TECH_MESSAGE(
6695 p_severity => FND_LOG.level_procedure,
6696 p_module => C_MODULE,
6697 p_msg_text => 'Begin Procedure');
6698 END IF;
6699
6700 -- Initialize return status to unexpected error
6701 x_return_status := pc_ret_sts_unexp_error;
6702
6703 -- Check for call compatibility.
6704 IF NOT FND_API.Compatible_API_Call (C_API_VERSION,
6705 p_api_version,
6706 C_API_NAME,
6707 pc_pkg_name)
6708 THEN
6709 IF FND_LOG.level_unexpected >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
6710 FEM_ENGINES_PKG.TECH_MESSAGE(
6711 p_severity => FND_LOG.level_unexpected,
6712 p_module => C_MODULE,
6713 p_msg_text => 'INTERNAL ERROR: API Version ('||C_API_VERSION||') not compatible with '
6714 ||'passed in version ('||p_api_version||')');
6715 END IF;
6716 RAISE e_unexp_error;
6717 END IF;
6718
6719 -- This API is only exposed for TP Process Rules at the moment.
6720 -- Any other object types will result in error.
6721 SELECT object_type_code
6722 INTO v_object_type
6723 FROM fem_object_catalog_b
6724 WHERE object_id = p_object_id;
6725
6726 IF nvl(v_object_type,'BADTYPE') <> 'TP_PROCESS_RULE' THEN
6727 IF FND_LOG.level_unexpected >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
6728 FEM_ENGINES_PKG.TECH_MESSAGE(
6729 p_severity => FND_LOG.level_unexpected,
6730 p_module => C_MODULE,
6731 p_msg_text => 'INTERNAL ERROR: p_object_id ('||to_char(p_object_id)
6732 ||') belongs to '||v_object_type||'. This API only '
6733 ||'operates on TP_PROCESS_RULE object types.');
6734 END IF;
6735 RAISE e_unexp_error;
6736 END IF;
6737
6738 -- Log procedure param values
6739 IF FND_LOG.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
6740 FEM_ENGINES_PKG.TECH_MESSAGE(
6741 p_severity => FND_LOG.level_statement,
6742 p_module => C_MODULE,
6743 p_msg_text => 'p_current_request_id = '||to_char(p_current_request_id));
6744 FEM_ENGINES_PKG.TECH_MESSAGE(
6745 p_severity => FND_LOG.level_statement,
6746 p_module => C_MODULE,
6747 p_msg_text => 'p_object_id = '||to_char(p_object_id));
6748 FEM_ENGINES_PKG.TECH_MESSAGE(
6749 p_severity => FND_LOG.level_statement,
6750 p_module => C_MODULE,
6751 p_msg_text => 'p_cal_period_id = '||to_char(p_cal_period_id));
6752 FEM_ENGINES_PKG.TECH_MESSAGE(
6753 p_severity => FND_LOG.level_statement,
6754 p_module => C_MODULE,
6755 p_msg_text => 'p_ledger_id = '||to_char(p_ledger_id));
6756 FEM_ENGINES_PKG.TECH_MESSAGE(
6757 p_severity => FND_LOG.level_statement,
6758 p_module => C_MODULE,
6759 p_msg_text => 'p_dataset_code = '||to_char(p_dataset_code));
6760 END IF;
6761
6762 -- Initialize FND message queue
6763 IF p_init_msg_list = FND_API.G_TRUE then
6764 FND_MSG_PUB.Initialize;
6765 END IF;
6766
6767 -- For now, only restrict to FEM_BALANCES since that is the
6768 -- table that TP Process Rules wants to remove data from.
6769 -- Loop through all object executions to make sure they can be removed.
6770 -- Checks being made are:
6771 -- 1. No chaining on the object executions
6772 -- 2. Object executions are not in the RUNNING state
6773 -- If data from object execution can be removed, delete data from table.
6774 FOR obj_execs IN c_pl_obj_execs (p_current_request_id, p_object_id,
6775 C_FEM_BALANCES, p_cal_period_id,
6776 p_ledger_id, p_dataset_code) LOOP
6777
6778 -- Check to make sure object execution is not chained.
6779 FEM_PL_PKG.check_chaining (
6780 p_commit => FND_API.G_FALSE,
6781 p_encoded => p_encoded,
6782 x_return_status => v_return_status,
6783 x_msg_count => x_msg_count,
6784 x_msg_data => x_msg_data,
6785 p_request_id => obj_execs.request_id,
6786 p_object_id => obj_execs.object_id,
6787 x_dep_request_id => v_dep_req_id,
6788 x_dep_object_id => v_dep_obj_id,
6789 x_chain_exists => v_chain_exists);
6790
6791 IF v_chain_exists = FND_API.G_TRUE THEN
6792 v_request_id := obj_execs.request_id;
6793 RAISE e_chain_exists;
6794 END IF;
6795
6796 -- Check to make sure object execution is not RUNNING.
6797 FEM_PL_PKG.Get_Exec_Status (
6798 p_commit => FND_API.G_FALSE,
6799 p_encoded => p_encoded,
6800 x_return_status => v_return_status,
6801 x_msg_count => x_msg_count,
6802 x_msg_data => x_msg_data,
6803 p_request_id => obj_execs.request_id,
6804 p_object_id => obj_execs.object_id,
6805 x_exec_status_code => v_exec_status_code);
6806
6807 IF v_exec_status_code = 'RUNNING' THEN
6808 v_request_id := obj_execs.request_id;
6809 RAISE e_objexec_running;
6810 END IF;
6811
6812 -- Delete data from the table
6813 v_sql := 'DELETE FROM ' ||C_FEM_BALANCES
6814 ||' WHERE CREATED_BY_REQUEST_ID = '||obj_execs.request_id
6815 ||' AND CREATED_BY_OBJECT_ID = '||obj_execs.object_id;
6816 BEGIN
6817 EXECUTE IMMEDIATE v_sql;
6818 EXCEPTION
6819 WHEN others THEN
6820 IF FND_LOG.level_unexpected >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
6821 FEM_ENGINES_PKG.TECH_MESSAGE(
6822 p_severity => FND_LOG.level_unexpected,
6823 p_module => C_MODULE,
6824 p_msg_text => 'The following SQL failed unexpected: '||v_sql);
6825 END IF;
6826 RAISE E_UNEXP_ERROR;
6827 END;
6828
6829 -- Delete PL Tables registration information
6830 DELETE FROM fem_pl_tables
6831 WHERE object_id = obj_execs.object_id
6832 AND request_id = obj_execs.request_id
6833 AND table_name = obj_execs.table_name;
6834
6835 -- Unregister Data Locations
6836 FEM_DIMENSION_UTIL_PKG.UnRegister_Data_Location (
6837 p_request_id => obj_execs.request_id,
6838 p_object_id => obj_execs.object_id,
6839 p_table_name => obj_execs.table_name);
6840
6841 -- Check FEM_PL_TABLES.
6842 -- If there are no more tables registered for the request,
6843 -- the whole object execution should be removed.
6844 SELECT count(*)
6845 INTO v_count
6846 FROM fem_pl_tables
6847 WHERE object_id = obj_execs.object_id
6848 AND request_id = obj_execs.request_id;
6849
6850 IF v_count = 0 THEN
6851 delete_execution_log (x_return_status => x_return_status,
6852 x_msg_count => x_msg_count,
6853 x_msg_data => x_msg_data,
6854 p_api_version => 1.0,
6855 p_commit => FND_API.G_FALSE,
6856 p_request_id => obj_execs.request_id,
6857 p_object_id => obj_execs.object_id);
6858 IF x_return_status <> pc_ret_sts_success THEN
6859 RAISE e_api_error;
6860 END IF;
6861 END IF;
6862 END LOOP;
6863
6864 x_return_status := pc_ret_sts_success;
6865
6866 IF (p_commit = FND_API.G_TRUE) THEN
6867 COMMIT;
6868 END IF;
6869
6870 IF FND_LOG.level_procedure >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
6871 FEM_ENGINES_PKG.TECH_MESSAGE(
6872 p_severity => FND_LOG.level_procedure,
6873 p_module => C_MODULE,
6874 p_msg_text => 'End Procedure');
6875 END IF;
6876 --
6877 EXCEPTION
6878 WHEN e_objexec_running THEN
6879 ROLLBACK TO delete_balances_pub;
6880
6881 OPEN c_object_name(p_object_id);
6882 FETCH c_object_name INTO v_object_name;
6883 CLOSE c_object_name;
6884
6885 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
6886 p_msg_name => 'FEM_UD_NO_DEL_RUNNING_OBJEXEC',
6887 p_token1 => 'RULE_NAME',
6888 p_value1 => v_object_name,
6889 p_token2 => 'REQ_ID',
6890 p_value2 => v_request_id);
6891
6892 FND_MSG_PUB.Count_And_Get
6893 (p_count => x_msg_count,
6894 p_data => x_msg_data);
6895 x_return_status := pc_ret_sts_error;
6896
6897 WHEN e_chain_exists THEN
6898 ROLLBACK TO delete_balances_pub;
6899
6900 OPEN c_object_name(p_object_id);
6901 FETCH c_object_name INTO v_object_name;
6902 CLOSE c_object_name;
6903
6904 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
6905 p_msg_name => 'FEM_UD_NO_DEL_CHAINED_OBJEXEC',
6906 p_token1 => 'DEP_RULE_NAME',
6907 p_value1 => v_dep_obj_id,
6908 p_token2 => 'DEP_REQ_ID',
6909 p_value2 => v_dep_req_id,
6910 p_token3 => 'RULE_NAME',
6911 p_value3 => v_object_name,
6912 p_token4 => 'REQ_ID',
6913 p_value4 => v_request_id);
6914
6915 FND_MSG_PUB.Count_And_Get
6916 (p_count => x_msg_count,
6917 p_data => x_msg_data);
6918
6919 x_return_status := pc_ret_sts_error;
6920
6921 -- When a call to an API fails, just exit because all return params
6922 -- have already been set by the API itself.
6923 WHEN e_api_error THEN
6924 ROLLBACK TO delete_balances_pub;
6925 WHEN others THEN
6926 ROLLBACK TO delete_balances_pub;
6927
6928 IF FND_LOG.level_unexpected >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
6929 FEM_ENGINES_PKG.TECH_MESSAGE(
6930 p_severity => FND_LOG.level_unexpected,
6931 p_module => C_MODULE,
6932 p_msg_text => 'Unexpected error: '||SQLERRM);
6933 END IF;
6934 IF FND_LOG.level_procedure >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
6935 FEM_ENGINES_PKG.TECH_MESSAGE(
6936 p_severity => FND_LOG.level_procedure,
6937 p_module => C_MODULE,
6938 p_msg_text => 'End Procedure');
6939 END IF;
6940 x_return_status := pc_ret_sts_unexp_error;
6941 --
6942 END Delete_Balances;
6943 -- ****************************************************************************
6944
6945 PROCEDURE Remove_Process_Locks (
6946 p_api_version IN NUMBER,
6947 p_init_msg_list IN VARCHAR2 DEFAULT FND_API.G_FALSE,
6948 p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE,
6949 p_encoded IN VARCHAR2 DEFAULT FND_API.G_TRUE,
6950 x_return_status OUT NOCOPY VARCHAR2,
6951 x_msg_count OUT NOCOPY NUMBER,
6952 x_msg_data OUT NOCOPY VARCHAR2,
6953 p_request_id IN NUMBER,
6954 p_object_id IN NUMBER
6955 ) IS
6956 -- =========================================================================
6957 -- Purpose
6958 -- Removes all process locks and all registered temporary objects for
6959 -- those rules that register with the Process Locks framework but is
6960 -- not removed as part of the Undo framework. This API calls the
6961 -- existing private procedure FEM_UD_PKG.Delete_Execution_Log once it
6962 -- verifies that the rule execution being passed in belongs to a rule
6963 -- type that has its Undo Flag attribute set to No, has not registered
6964 -- any tables in FEM_PL_TABLES (i.e. has not output data), and is not
6965 -- still running.
6966 -- History
6967 -- 01-05-07 G Cheng Bug 5746626. Created.
6968 -- Arguments
6969 -- p_request_id Request ID of execution being removed
6970 -- p_object_id Object ID of execution being removed
6971 -- Return Logic
6972 -- Set x_return_status to 'U' (Unexpected Error) if the object type's
6973 -- Undo Flag attribute is set to No or any tables were registered.
6974 -- Set x_return_status to 'E' (Error) if the execution is still running.
6975 -- Otherwise, set x_return_status to 'S' (Success) after deleting
6976 -- all Process Locks data.
6977 -- =========================================================================
6978 C_MODULE CONSTANT FND_LOG_MESSAGES.module%TYPE :=
6979 'fem.plsql.fem_ud_pkg.remove_process_locks';
6980 C_API_NAME CONSTANT VARCHAR2(30) := 'Remove_Process_Locks';
6981 C_API_VERSION CONSTANT NUMBER := 1.0;
6982 --
6983 e_api_error EXCEPTION;
6984 e_objexec_running EXCEPTION;
6985 v_undo_flag FEM_OBJECT_TYPES_B.undo_flag%TYPE;
6986 v_object_name FEM_OBJECT_CATALOG_TL.object_name%TYPE;
6987 v_exec_status_code FEM_PL_REQUESTS.exec_status_code%TYPE;
6988 v_count NUMBER;
6989 --
6990 CURSOR c_object_name (p_object_id NUMBER) IS
6991 SELECT object_name
6992 FROM fem_object_catalog_vl
6993 WHERE object_id = p_object_id;
6994 --
6995 BEGIN
6996 --
6997 -- Standard Start of API savepoint
6998 SAVEPOINT remove_process_locks_pub;
6999
7000 IF FND_LOG.level_procedure >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
7001 FEM_ENGINES_PKG.TECH_MESSAGE(
7002 p_severity => FND_LOG.level_procedure,
7003 p_module => C_MODULE,
7004 p_msg_text => 'Begin Procedure');
7005 END IF;
7006
7007 -- Initialize return status to unexpected error
7008 x_return_status := pc_ret_sts_unexp_error;
7009
7010 -- Check for call compatibility.
7011 IF NOT FND_API.Compatible_API_Call (C_API_VERSION,
7012 p_api_version,
7013 C_API_NAME,
7014 pc_pkg_name)
7015 THEN
7016 IF FND_LOG.level_unexpected >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
7017 FEM_ENGINES_PKG.TECH_MESSAGE(
7018 p_severity => FND_LOG.level_unexpected,
7019 p_module => C_MODULE,
7020 p_msg_text => 'INTERNAL ERROR: API Version ('||C_API_VERSION
7021 ||') not compatible with '
7022 ||'passed in version ('||p_api_version||')');
7023 END IF;
7024 RAISE e_unexp_error;
7025 END IF;
7026
7027 -- Initialize FND message queue
7028 IF p_init_msg_list = FND_API.G_TRUE then
7029 FND_MSG_PUB.Initialize;
7030 END IF;
7031
7032 -- Log procedure param values
7033 IF FND_LOG.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
7034 FEM_ENGINES_PKG.TECH_MESSAGE(
7035 p_severity => FND_LOG.level_statement,
7036 p_module => C_MODULE,
7037 p_msg_text => 'p_request_id = '||to_char(p_request_id));
7038 FEM_ENGINES_PKG.TECH_MESSAGE(
7039 p_severity => FND_LOG.level_statement,
7040 p_module => C_MODULE,
7041 p_msg_text => 'p_object_id = '||to_char(p_object_id));
7042 END IF;
7043
7044 -- This API should only be called to remove rules where its rule type
7045 -- Undo Flag attribute is set to N.
7046 SELECT undo_flag
7047 INTO v_undo_flag
7048 FROM fem_object_catalog_b oc, fem_object_types_b ot
7049 WHERE oc.object_id = p_object_id
7050 AND oc.object_type_code = ot.object_type_code;
7051
7052 IF nvl(v_undo_flag,'XX') <> 'N' THEN
7053 IF FND_LOG.level_unexpected >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
7054 FEM_ENGINES_PKG.TECH_MESSAGE(
7055 p_severity => FND_LOG.level_unexpected,
7056 p_module => C_MODULE,
7057 p_msg_text => 'INTERNAL ERROR: p_object_id ('||to_char(p_object_id)
7058 ||') belongs to a rule type where its Undo Flag'
7059 ||' attribute is set to: '||v_undo_flag
7060 ||'. This API only operates on rule types where its'
7061 ||' Undo Flag is set to N.');
7062 END IF;
7063 RAISE e_unexp_error;
7064 END IF;
7065
7066 -- This API should only be called to remove rule types that do not
7067 -- register any tables (i.e. output any data).
7068 SELECT count(*)
7069 INTO v_count
7070 FROM fem_pl_tables
7071 WHERE object_id = p_object_id
7072 AND request_id = p_request_id;
7073
7074 IF v_count > 0 THEN
7075 IF FND_LOG.level_unexpected >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
7076 FEM_ENGINES_PKG.TECH_MESSAGE(
7077 p_severity => FND_LOG.level_unexpected,
7078 p_module => C_MODULE,
7079 p_msg_text => 'INTERNAL ERROR: p_object_id ('||to_char(p_object_id)
7080 ||') registered this many tables: '||v_count
7081 ||'. This API can only process against rules that do'
7082 ||' NOT output data.');
7083 END IF;
7084 RAISE e_unexp_error;
7085 END IF;
7086
7087 -- Check to make sure object execution is not RUNNING.
7088 FEM_PL_PKG.Get_Exec_Status (
7089 p_commit => FND_API.G_FALSE,
7090 p_encoded => p_encoded,
7091 x_return_status => x_return_status,
7092 x_msg_count => x_msg_count,
7093 x_msg_data => x_msg_data,
7094 p_request_id => p_request_id,
7095 p_object_id => p_object_id,
7096 x_exec_status_code => v_exec_status_code);
7097
7098 IF x_return_status <> pc_ret_sts_success THEN
7099 IF FND_LOG.level_unexpected >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
7100 FEM_ENGINES_PKG.TECH_MESSAGE(
7101 p_severity => FND_LOG.level_unexpected,
7102 p_module => C_MODULE,
7103 p_msg_text => 'INTERNAL ERROR: Call to FEM_PL_PKG.Get_Exec_Status'
7104 ||' failed with return status: '||x_return_status);
7105 END IF;
7106
7107 RAISE e_api_error;
7108 END IF;
7109
7110 IF v_exec_status_code = 'RUNNING' THEN
7111 RAISE e_objexec_running;
7112 END IF;
7113
7114 -- Passed all checks, can remove process locks now.
7115 delete_execution_log (x_return_status => x_return_status,
7116 x_msg_count => x_msg_count,
7117 x_msg_data => x_msg_data,
7118 p_api_version => 1.0,
7119 p_commit => FND_API.G_FALSE,
7120 p_request_id => p_request_id,
7121 p_object_id => p_object_id);
7122
7123 IF x_return_status <> pc_ret_sts_success THEN
7124 IF FND_LOG.level_unexpected >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
7125 FEM_ENGINES_PKG.TECH_MESSAGE(
7126 p_severity => FND_LOG.level_unexpected,
7127 p_module => C_MODULE,
7128 p_msg_text => 'INTERNAL ERROR: Call to FEM_PL_PKG.Get_Exec_Status'
7129 ||' failed with return status: '||x_return_status);
7130 END IF;
7131
7132 RAISE e_api_error;
7133 END IF;
7134
7135 x_return_status := pc_ret_sts_success;
7136
7137 IF (p_commit = FND_API.G_TRUE) THEN
7138 COMMIT;
7139 END IF;
7140
7141 IF FND_LOG.level_procedure >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
7142 FEM_ENGINES_PKG.TECH_MESSAGE(
7143 p_severity => FND_LOG.level_procedure,
7144 p_module => C_MODULE,
7145 p_msg_text => 'End Procedure');
7146 END IF;
7147 --
7148 EXCEPTION
7149 WHEN e_objexec_running THEN
7150 ROLLBACK TO remove_process_locks_pub;
7151
7152 OPEN c_object_name(p_object_id);
7153 FETCH c_object_name INTO v_object_name;
7154 CLOSE c_object_name;
7155
7156 FEM_ENGINES_PKG.put_message(p_app_name =>'FEM',
7157 p_msg_name => 'FEM_UD_NO_DEL_RUNNING_OBJEXEC',
7158 p_token1 => 'RULE_NAME',
7159 p_value1 => v_object_name,
7160 p_token2 => 'REQ_ID',
7161 p_value2 => p_request_id);
7162
7163 FND_MSG_PUB.Count_And_Get
7164 (p_count => x_msg_count,
7165 p_data => x_msg_data);
7166 x_return_status := pc_ret_sts_error;
7167
7168 WHEN e_api_error THEN
7169 -- When a call to an API fails, just exit because all return params
7170 -- have already been set by the API itself.
7171 ROLLBACK TO remove_process_locks_pub;
7172 WHEN others THEN
7173 ROLLBACK TO remove_process_locks_pub;
7174
7175 IF FND_LOG.level_unexpected >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
7176 FEM_ENGINES_PKG.TECH_MESSAGE(
7177 p_severity => FND_LOG.level_unexpected,
7178 p_module => C_MODULE,
7179 p_msg_text => 'Unexpected error: '||SQLERRM);
7180 END IF;
7181 IF FND_LOG.level_procedure >= FND_LOG.G_CURRENT_RUNTIME_LEVEL THEN
7182 FEM_ENGINES_PKG.TECH_MESSAGE(
7183 p_severity => FND_LOG.level_procedure,
7184 p_module => C_MODULE,
7185 p_msg_text => 'End Procedure');
7186 END IF;
7187 x_return_status := pc_ret_sts_unexp_error;
7188 --
7189 END Remove_Process_Locks;
7190
7191 /*============================================================================+
7192 | PROCEDURE
7193 | Repair_PL_Request
7194 |
7195 | DESCRIPTION
7196 | Main concurrent program to repair the Process Log/Process Lock entries based on
7197 | the Created_By_Request_ID and Created_By_Object_ID columns, etc. from
7198 | FEM_BALANCES, such as to restore the entries sufficiently in the executed
7199 | Rules UI for Undo to be invoked again to finish the job. See bug 7260263.
7200 |
7201 | SCOPE - PUBLIC
7202 |
7203 | MODIFICATION HISTORY
7204 | huli 26-AUG-2008 Created
7205 |
7206 +============================================================================*/
7207
7208 PROCEDURE Repair_PL_Request (
7209 errbuf out nocopy varchar2
7210 ,retcode out nocopy varchar2
7211 ,p_request_id in number default null
7212 ,p_object_id in number default null
7213 )
7214 IS
7215
7216 -----------------------
7217 -- Declare constants --
7218 -----------------------
7219 l_api_name constant varchar2(30) := 'Repair_PL_Request';
7220 l_reg_rec pl_register_record;
7221
7222 l_return_status varchar2(1);
7223 l_msg_count NUMBER;
7224 l_msg_data varchar2(2000);
7225 l_obj_def_id fem_object_definition_b.object_definition_id%TYPE := NULL;
7226 l_exec_state varchar2(30); -- normal, restart, rerun
7227 l_prev_request_id number;
7228
7229 l_prg_msg VARCHAR2(2000);
7230 l_callstack VARCHAR2(2000);
7231 l_exe_ok BOOLEAN := TRUE;
7232 l_not_found_exe BOOLEAN := TRUE;
7233
7234
7235
7236 ----------------------------
7237 -- Declare static cursors --
7238 ----------------------------
7239 cursor c_missing_pl_entry is
7240 select row_count, bal.created_by_object_id, bal.created_by_request_id, bal.ledger_id bal_ledger_id,
7241 bal.cal_period_id bal_cal_period_id, bal.source_system_code bal_source_system_code,
7242 bal.dataset_code bal_dataset_code, exe.request_id execution_request_id,
7243 requests.request_id request_request_id, tab.request_id tab_request_id,
7244 requests.effective_date request_effective_date, requests.cal_period_id request_cal_period_id, requests.ledger_id request_ledger_id,
7245 requests.dataset_io_obj_def_id request_dataset_io_obj_def_id, requests.output_dataset_code request_output_dataset_code,
7246 requests.source_system_code request_source_system_code, requests.program_id, requests.program_application_id,
7247 requests.exec_status_code, requests.last_updated_by, requests.program_login_id, obj.object_name
7248 from (select count(*) row_count, created_by_object_id, created_by_request_id, ledger_id, cal_period_id, source_system_code,
7249 dataset_code
7250 from fem_balances
7251 WHERE (p_request_id IS NULL OR created_by_request_id = p_request_id)
7252 AND (p_object_id IS NULL OR created_by_object_id = p_object_id)
7253 AND source_system_code = (SELECT source_system_code
7254 FROM fem_source_systems_b src_system
7255 WHERE src_system.source_system_display_code = 'PFT'
7256 and src_system.personal_flag = 'N')
7257 GROUP BY created_by_object_id, created_by_request_id, ledger_id, cal_period_id, source_system_code,
7258 dataset_code) bal,
7259 fem_pl_object_executions exe,
7260 fem_pl_requests requests,
7261 fem_pl_tables tab,
7262 fem_object_catalog_vl obj
7263 where bal.created_by_object_id = obj.object_id
7264 and obj.object_type_code = 'MAPPING_RULE'
7265 and exe.object_id(+) = bal.created_by_object_id
7266 and exe.request_id(+) = bal.created_by_request_id
7267 and requests.request_id(+) = bal.created_by_request_id
7268 and tab.object_id(+) = bal.created_by_object_id
7269 and tab.request_id(+) = bal.created_by_request_id
7270 and tab.table_name(+) = 'FEM_BALANCES'
7271 and (exe.object_id is null or exe.request_id is null or requests.request_id is null
7272 or tab.object_id is null or tab.request_id is null) ;
7273
7274 /******************************************************************************
7275 * *
7276 * Repair_PL_Request *
7277 * Execution Block *
7278 * *
7279 ******************************************************************************/
7280
7281 BEGIN
7282
7283 -- Initialize Message Stack on FND_MSG_PUB
7284 FND_MSG_PUB.Initialize;
7285
7286 write_debug(
7287 p_msg_data => 'BEGIN',
7288 p_user_msg => 'N',
7289 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name
7290 );
7291 /****
7292 write_debug (' Repair_PL_Request 1');
7293
7294 FEM_ENGINES_PKG.Tech_Message (
7295 p_severity => pc_log_level_procedure
7296 ,p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7297 ,p_msg_text => 'BEGIN'
7298 );
7299 ****/
7300
7301 SAVEPOINT Repair_PL_Request;
7302 ------------------------------------------------
7303 -- Initialize Package and Procedure Variables --
7304 ------------------------------------------------
7305 l_reg_rec.accurate_eff_dt_flg := G_NO;
7306
7307 --write_debug (' Repair_PL_Request 2');
7308 write_debug(
7309 p_msg_data => 'Repair_PL_Request 2',
7310 p_user_msg => 'N',
7311 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name
7312 );
7313
7314 FOR missing_entry IN c_missing_pl_entry LOOP
7315 l_not_found_exe := FALSE;
7316
7317 l_exe_ok := TRUE;
7318 l_reg_rec.object_id := missing_entry.created_by_object_id;
7319 l_reg_rec.request_id := missing_entry.created_by_request_id;
7320 l_reg_rec.cal_period_id := missing_entry.bal_cal_period_id;
7321 l_reg_rec.ledger_id := missing_entry.bal_ledger_id;
7322 l_reg_rec.output_dataset_code := missing_entry.bal_dataset_code;
7323 l_reg_rec.source_system_code := missing_entry.bal_source_system_code;
7324 l_reg_rec.program_id := missing_entry.program_id;
7325 l_reg_rec.program_application_id := missing_entry.program_application_id;
7326 l_reg_rec.exec_status_code := missing_entry.exec_status_code;
7327
7328 --write_debug (' Repair_PL_Request 3, l_reg_rec.object_id:'
7329 -- || l_reg_rec.object_id || ' l_reg_rec.request_id:'
7330 -- || l_reg_rec.request_id || ' l_reg_rec.cal_period_id:'
7331 -- || l_reg_rec.cal_period_id || ' l_reg_rec.ledger_id:'
7332 -- || l_reg_rec.ledger_id || ' l_reg_rec.output_dataset_code:'
7333 -- || l_reg_rec.output_dataset_code);
7334
7335 write_debug(
7336 p_msg_data => ' Repair_PL_Request 3, l_reg_rec.object_id:'
7337 || l_reg_rec.object_id || ' l_reg_rec.request_id:'
7338 || l_reg_rec.request_id || ' l_reg_rec.cal_period_id:'
7339 || l_reg_rec.cal_period_id || ' l_reg_rec.ledger_id:'
7340 || l_reg_rec.ledger_id || ' l_reg_rec.output_dataset_code:'
7341 || l_reg_rec.output_dataset_code,
7342 p_user_msg => 'N',
7343 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name
7344 );
7345 --Call the rountine FEM_PL_PKG.Register_Request to register the request if the request entry is missing
7346 IF (missing_entry.request_request_id IS NULL) THEN
7347 write_debug(
7348 p_msg_data => ' Repair_PL_Request 4',
7349 p_user_msg => 'N',
7350 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name
7351 );
7352
7353 Prepare_PL_Register_Record (
7354 x_pl_register_record => l_reg_rec,
7355 x_return_status =>l_return_status
7356 );
7357 IF ( l_return_status <> pc_ret_sts_success) THEN
7358 l_exe_ok := FALSE;
7359 write_debug(
7360 p_msg_data => ' Repair_PL_Request 4A, fails to call Prepare_PL_Register_Record ',
7361 p_user_msg => 'N',
7362 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name
7363 );
7364 FEM_ENGINES_PKG.User_Message (
7365 p_app_name => G_FEM
7366 ,p_msg_name => 'FEM_UD_CANT_REPAIR_EXEC'
7367 ,p_token1 => 'object_name'
7368 ,p_value1 => missing_entry.object_name
7369 ,p_token2 => 'request_id'
7370 ,p_value2 => missing_entry.created_by_request_id
7371 ,p_token3 => 'object_id'
7372 ,p_value3 => missing_entry.created_by_object_id
7373 );
7374 END IF;
7375
7376 IF (l_exe_ok) THEN
7377 write_debug(
7378 p_msg_data => ' Repair_PL_Request 5, before calling FEM_PL_PKG.Register_Request ',
7379 p_user_msg => 'N',
7380 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name
7381 );
7382
7383 FEM_PL_PKG.Register_Request (
7384 p_api_version => 1.0
7385 ,p_commit => FND_API.G_FALSE
7386 ,p_cal_period_id => l_reg_rec.cal_period_id
7387 ,p_ledger_id => l_reg_rec.ledger_id
7388 ,p_dataset_io_obj_def_id => l_reg_rec.dataset_io_obj_def_id
7389 ,p_output_dataset_code => l_reg_rec.output_dataset_code
7390 ,p_source_system_code => l_reg_rec.source_system_code
7391 ,p_effective_date => l_reg_rec.effective_date
7392 ,p_rule_set_obj_def_id => NULL
7393 ,p_rule_set_name => NULL
7394 ,p_request_id => l_reg_rec.request_id
7395 ,p_user_id => l_reg_rec.user_id
7396 ,p_last_update_login => l_reg_rec.login_id
7397 ,p_program_id => l_reg_rec.program_id
7398 ,p_program_login_id => l_reg_rec.login_id
7399 ,p_program_application_id => l_reg_rec.program_application_id
7400 ,p_exec_mode_code => null
7401 ,p_dimension_id => null
7402 ,p_table_name => null
7403 ,p_hierarchy_name => null
7404 ,x_msg_count => l_msg_count
7405 ,x_msg_data => l_msg_data
7406 ,x_return_status => l_return_status
7407 );
7408
7409
7410 if (l_return_status <> pc_ret_sts_success) then
7411 FEM_ENGINES_PKG.User_Message (
7412 p_app_name => G_FEM
7413 ,p_msg_name => 'FEM_UD_CANT_REPAIR_EXEC'
7414 ,p_token1 => 'object_name'
7415 ,p_value1 => missing_entry.object_name
7416 ,p_token2 => 'request_id'
7417 ,p_value2 => missing_entry.created_by_request_id
7418 ,p_token3 => 'object_id'
7419 ,p_value3 => missing_entry.created_by_object_id
7420 );
7421 Get_Put_Messages(
7422 p_msg_count => l_msg_count,
7423 p_msg_data => l_msg_data,
7424 p_user_msg => G_YES,
7425 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name);
7426
7427 --write_debug (' Repair_PL_Request 6, fail to call FEM_PL_PKG.Register_Request, l_msg_count:'
7428 -- || l_msg_count || ' l_msg_data:' || l_msg_data);
7429 l_exe_ok := FALSE;
7430 end if;
7431 END IF; --(l_exe_ok)
7432
7433 ELSE
7434 l_reg_rec.user_id := missing_entry.last_updated_by;
7435 l_reg_rec.login_id := missing_entry.program_login_id;
7436 l_reg_rec.request_id := missing_entry.request_request_id;
7437 l_reg_rec.cal_period_id := missing_entry.bal_cal_period_id;
7438 l_reg_rec.ledger_id := missing_entry.bal_ledger_id;
7439 l_reg_rec.output_dataset_code := missing_entry.bal_dataset_code;
7440 l_reg_rec.source_system_code := missing_entry.bal_source_system_code;
7441 l_reg_rec.effective_date := missing_entry.request_effective_date;
7442 l_reg_rec.accurate_eff_dt_flg := G_YES;
7443 write_debug(
7444 p_msg_data => ' Repair_PL_Request 6',
7445 p_user_msg => 'N',
7446 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name
7447 );
7448
7449 END IF;
7450
7451 --Call the process lock API FEM_PL_PKG.Register_Object_Execution to register
7452 --the object executions, also call the process lock API FEM_PL_PKG.Register_Object_Def
7453 --to register object definition if the entry in the fem_pl_object_executions is missing
7454 IF (l_exe_ok AND
7455 missing_entry.execution_request_id IS NULL) THEN
7456 write_debug(
7457 p_msg_data => ' Repair_PL_Request 7',
7458 p_user_msg => 'N',
7459 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name
7460 );
7461 Get_Object_Definition (
7462 p_object_id => l_reg_rec.object_id
7463 ,p_effective_date => l_reg_rec.effective_date
7464 ,x_obj_def_id => l_obj_def_id
7465 );
7466 IF (l_obj_def_id IS NOT NULL) THEN
7467 write_debug(
7468 p_msg_data => ' Repair_PL_Request 8, before FEM_PL_PKG.Register_Object_Execution, l_reg_rec.user_id:'
7469 || l_reg_rec.user_id || ' l_reg_rec.login_id:'
7470 || l_reg_rec.login_id || ' l_obj_def_id:' || l_obj_def_id,
7471 p_user_msg => 'N',
7472 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name
7473 );
7474
7475 FEM_PL_PKG.Register_Object_Execution (
7476 p_api_version => 1.0
7477 ,p_commit => FND_API.G_FALSE
7478 ,p_request_id => l_reg_rec.request_id
7479 ,p_object_id => l_reg_rec.object_id
7480 ,p_exec_object_definition_id => l_obj_def_id
7481 ,p_user_id => l_reg_rec.user_id
7482 ,p_last_update_login => l_reg_rec.login_id
7483 ,p_exec_mode_code => null
7484 ,x_exec_state => l_exec_state
7485 ,x_prev_request_id => l_prev_request_id
7486 ,x_msg_count => l_msg_count
7487 ,x_msg_data => l_msg_data
7488 ,x_return_status => l_return_status
7489 );
7490
7491 IF (l_return_status <> pc_ret_sts_success) THEN
7492 FEM_ENGINES_PKG.User_Message (
7493 p_app_name => G_FEM
7494 ,p_msg_name => 'FEM_UD_CANT_REPAIR_EXEC'
7495 ,p_token1 => 'object_name'
7496 ,p_value1 => missing_entry.object_name
7497 ,p_token2 => 'request_id'
7498 ,p_value2 => missing_entry.created_by_request_id
7499 ,p_token3 => 'object_id'
7500 ,p_value3 => missing_entry.created_by_object_id
7501 );
7502 Get_Put_Messages(
7503 p_msg_count => l_msg_count,
7504 p_msg_data => l_msg_data,
7505 p_user_msg => G_YES,
7506 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name);
7507 l_exe_ok := FALSE;
7508 --write_debug (' Repair_PL_Request 10, fail to call FEM_PL_PKG.Register_Object_Execution, l_msg_count:'
7509 -- || l_msg_count || ' l_msg_data:' || l_msg_data);
7510 ELSE
7511 FEM_PL_PKG.Update_Obj_Exec_Status(
7512 P_API_VERSION => 1.0,
7513 P_COMMIT => FND_API.G_FALSE,
7514 P_REQUEST_ID => l_reg_rec.request_id,
7515 P_OBJECT_ID => l_reg_rec.object_id,
7516 P_EXEC_STATUS_CODE => 'SUCCESS',
7517 P_USER_ID => l_reg_rec.user_id,
7518 P_LAST_UPDATE_LOGIN => l_reg_rec.login_id,
7519 X_MSG_COUNT => l_msg_count,
7520 X_MSG_DATA => l_msg_data,
7521 X_RETURN_STATUS => l_return_status);
7522 IF (l_return_status <> pc_ret_sts_success) THEN
7523 FEM_ENGINES_PKG.User_Message (
7524 p_app_name => G_FEM
7525 ,p_msg_name => 'FEM_UD_CANT_REPAIR_EXEC'
7526 ,p_token1 => 'object_name'
7527 ,p_value1 => missing_entry.object_name
7528 ,p_token2 => 'request_id'
7529 ,p_value2 => missing_entry.created_by_request_id
7530 ,p_token3 => 'object_id'
7531 ,p_value3 => missing_entry.created_by_object_id
7532 );
7533
7534 Get_Put_Messages(
7535 p_msg_count => l_msg_count,
7536 p_msg_data => l_msg_data,
7537 p_user_msg => G_YES,
7538 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name);
7539 END IF;
7540 END IF;
7541
7542 IF (l_exe_ok
7543 AND l_reg_rec.accurate_eff_dt_flg = G_YES) THEN
7544 --write_debug (' Repair_PL_Request 11, before Register_Object_Def');
7545 write_debug(
7546 p_msg_data => ' Repair_PL_Request 9',
7547 p_user_msg => 'N',
7548 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name
7549 );
7550
7551 FEM_PL_PKG.Register_Object_Def (
7552 p_api_version => 1.0
7553 ,p_commit => FND_API.G_FALSE
7554 ,p_request_id => l_reg_rec.request_id
7555 ,p_object_id => l_reg_rec.object_id
7556 ,p_object_definition_id => l_obj_def_id
7557 ,p_user_id => l_reg_rec.user_id
7558 ,p_last_update_login => l_reg_rec.login_id
7559 ,x_msg_count => l_msg_count
7560 ,x_msg_data => l_msg_data
7561 ,x_return_status => l_return_status
7562 );
7563 IF (l_return_status <> pc_ret_sts_success) THEN
7564 FEM_ENGINES_PKG.User_Message (
7565 p_app_name => G_FEM
7566 ,p_msg_name => 'FEM_UD_CANT_REPAIR_EXEC'
7567 ,p_token1 => 'object_name'
7568 ,p_value1 => missing_entry.object_name
7569 ,p_token2 => 'request_id'
7570 ,p_value2 => missing_entry.created_by_request_id
7571 ,p_token3 => 'object_id'
7572 ,p_value3 => missing_entry.created_by_object_id
7573 );
7574 Get_Put_Messages(
7575 p_msg_count => l_msg_count,
7576 p_msg_data => l_msg_data,
7577 p_user_msg => G_YES,
7578 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name);
7579 l_exe_ok := FALSE;
7580 --write_debug (' Repair_PL_Request 12, fail to call Register_Object_Def, l_msg_count:'
7581 -- || l_msg_count || ' l_msg_data:' || l_msg_data);
7582 END IF;
7583
7584 END IF;
7585 END IF;
7586 END IF;--l_exe_ok AND missing_entry.execution_request_id IS NULL
7587
7588 --Call the process lock API FEM_PL_PKG.Register_Table to register the FEM_BALANCES
7589 --table if the corresponding entry is missing from the fem_pl_tables
7590 IF (l_exe_ok AND missing_entry.tab_request_id IS NULL) THEN
7591 --write_debug (' Repair_PL_Request 13, before Register_Table');
7592 write_debug(
7593 p_msg_data => ' Repair_PL_Request 10',
7594 p_user_msg => 'N',
7595 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name
7596 );
7597
7598 FEM_PL_PKG.Register_Table (
7599 p_api_version => 1.0
7600 ,p_commit => FND_API.G_FALSE
7601 ,p_request_id => l_reg_rec.request_id
7602 ,p_object_id => l_reg_rec.object_id
7603 ,p_table_name => 'FEM_BALANCES'
7604 ,p_statement_type => 'INSERT'
7605 ,p_num_of_output_rows => missing_entry.row_count
7606 ,p_user_id => l_reg_rec.user_id
7607 ,p_last_update_login => l_reg_rec.login_id
7608 ,x_msg_count => l_msg_count
7609 ,x_msg_data => l_msg_data
7610 ,x_return_status => l_return_status
7611 );
7612 IF (l_return_status <> pc_ret_sts_success) THEN
7613 FEM_ENGINES_PKG.User_Message (
7614 p_app_name => G_FEM
7615 ,p_msg_name => 'FEM_UD_CANT_REPAIR_EXEC'
7616 ,p_token1 => 'object_name'
7617 ,p_value1 => missing_entry.object_name
7618 ,p_token2 => 'request_id'
7619 ,p_value2 => missing_entry.created_by_request_id
7620 ,p_token3 => 'object_id'
7621 ,p_value3 => missing_entry.created_by_object_id
7622 );
7623 Get_Put_Messages(
7624 p_msg_count => l_msg_count,
7625 p_msg_data => l_msg_data,
7626 p_user_msg => G_YES,
7627 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name);
7628 l_exe_ok := FALSE;
7629 --write_debug (' Repair_PL_Request 14, fail to call Register_Table, l_msg_count:'
7630 -- || l_msg_count || ' l_msg_data:' || l_msg_data);
7631 END IF;
7632 END IF;
7633
7634 IF (l_exe_ok) THEN
7635 --write_debug (' Repair_PL_Request 15, before Register_Data_Location');
7636 write_debug(
7637 p_msg_data => ' Repair_PL_Request 11',
7638 p_user_msg => 'N',
7639 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name
7640 );
7641
7642 FEM_ENGINES_PKG.User_Message (
7643 p_app_name => G_FEM
7644 ,p_msg_name => 'FEM_UD_REPAIR_SUCCESS'
7645 ,p_token1 => 'object_name'
7646 ,p_value1 => missing_entry.object_name
7647 ,p_token2 => 'object_id'
7648 ,p_value2 => missing_entry.created_by_object_id
7649 ,p_token3 => 'request_id'
7650 ,p_value3 => missing_entry.created_by_request_id
7651 );
7652
7653 FEM_DIMENSION_UTIL_PKG.Register_Data_Location (
7654 p_request_id => l_reg_rec.request_id
7655 ,p_object_id => l_reg_rec.object_id
7656 ,p_table_name => 'FEM_BALANCES'
7657 ,p_ledger_id => l_reg_rec.ledger_id
7658 ,p_cal_per_id => l_reg_rec.cal_period_id
7659 ,p_dataset_cd => l_reg_rec.output_dataset_code
7660 ,p_source_cd => l_reg_rec.source_system_code
7661 ,p_load_status => null
7662 );
7663 END IF;--l_exe_ok
7664
7665
7666 END LOOP;
7667
7668 IF (l_not_found_exe) THEN
7669
7670 FEM_ENGINES_PKG.User_Message (
7671 p_app_name => G_FEM
7672 ,p_msg_name => 'FEM_UD_NO_NEED_REPAIR_EXEC'
7673 );
7674
7675 END IF;
7676 --write_debug (' Repair_PL_Request 16, before commit');
7677 write_debug(
7678 p_msg_data => ' Repair_PL_Request 12',
7679 p_user_msg => 'N',
7680 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name
7681 );
7682
7683 COMMIT;
7684
7685 EXCEPTION
7686 WHEN OTHERS THEN
7687
7688 l_prg_msg := SQLERRM;
7689 l_callstack := DBMS_UTILITY.Format_Call_Stack;
7690
7691 IF (c_missing_pl_entry%ISOPEN) THEN CLOSE c_missing_pl_entry;
7692 END IF;
7693
7694 --write_debug (' Repair_PL_Request 17, l_prg_msg:' || l_prg_msg
7695 -- || ' l_callstack:' || l_callstack);
7696 write_debug(
7697 p_msg_data => ' Repair_PL_Request 17, l_prg_msg:' || l_prg_msg
7698 || ' l_callstack:' || l_callstack,
7699 p_user_msg => 'N',
7700 p_module => 'fem.plsql.'||pc_pkg_name||'.'||l_api_name
7701 );
7702
7703 pv_concurrent_status := FND_CONCURRENT.Set_Completion_Status('ERROR',null);
7704
7705
7706 FEM_ENGINES_PKG.Tech_Message (
7707 p_severity => pc_log_level_unexpected
7708 ,p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7709 ,p_msg_text => l_prg_msg
7710 );
7711
7712 FEM_ENGINES_PKG.Tech_Message (
7713 p_severity => pc_log_level_unexpected
7714 ,p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7715 ,p_msg_text => l_callstack
7716 );
7717
7718 FEM_ENGINES_PKG.User_Message (
7719 p_app_name => G_FEM
7720 ,p_msg_name => 'FEM_UNEXPECTED_ERROR'
7721 ,p_token1 => 'ERR_MSG'
7722 ,p_value1 => l_prg_msg
7723 );
7724
7725
7726 ROLLBACK TO Repair_PL_Request;
7727
7728 END Repair_PL_Request;
7729
7730
7731 /*============================================================================+
7732 | PROCEDURE
7733 | Prepare_PL_Register_Record
7734 |
7735 | DESCRIPTION
7736 | Retrieve the following information
7737 | 1. effective date based on either the concurrent program parameters or
7738 | the end date of cal period
7739 |
7740 |
7741 |
7742 | SCOPE - PRIVATE
7743 |
7744 +============================================================================*/
7745
7746 PROCEDURE Prepare_PL_Register_Record (
7747 x_pl_register_record IN OUT nocopy pl_register_record,
7748 x_return_status OUT NOCOPY VARCHAR2
7749 )
7750 IS
7751
7752 CURSOR c_fnd_concurrent (p_request_id IN NUMBER) IS
7753 SELECT STATUS_CODE, ARGUMENT1, ARGUMENT2, ARGUMENT3, ARGUMENT4,
7754 ARGUMENT5, ARGUMENT6, ARGUMENT7, ARGUMENT8, requested_by,
7755 conc_login_id, CONCURRENT_PROGRAM_ID, PROGRAM_APPLICATION_ID
7756 FROM FND_CONCURRENT_REQUESTS
7757 WHERE request_id = p_request_id;
7758
7759
7760 CURSOR c_get_output_ds_obj_def_id IS
7761 select dataset_io_obj_def_id
7762 from fem_ds_input_output_defs
7763 where output_dataset_code = x_pl_register_record.output_dataset_code
7764 and rownum = 1;
7765
7766
7767 l_fnd_concurrent_rec c_fnd_concurrent%ROWTYPE;
7768
7769 l_dummy VARCHAR2(30);
7770 l_api_name constant varchar2(30) := 'Prepare_PL_Register_Record';
7771 l_prg_msg VARCHAR2(2000);
7772 l_callstack VARCHAR2(2000);
7773 l_prepare_pl_register_rc_err exception;
7774
7775 BEGIN
7776 x_return_status := pc_ret_sts_success;
7777 OPEN c_fnd_concurrent (x_pl_register_record.request_id);
7778 FETCH c_fnd_concurrent INTO l_fnd_concurrent_rec;
7779
7780 --FEM_ENGINES_PKG.Tech_Message (
7781 -- p_severity => pc_log_level_procedure
7782 -- ,p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7783 -- ,p_msg_text => 'request_id:' || x_pl_register_record.request_id
7784 -- || ' and object_id:' || x_pl_register_record.object_id
7785 --);
7786
7787 write_debug(
7788 p_msg_data => 'request_id:' || x_pl_register_record.request_id
7789 || ' and object_id:' || x_pl_register_record.object_id,
7790 p_user_msg => 'N',
7791 p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7792 );
7793
7794 -- the request is wiped out from the FND_CONCURRENT_REQUESTS
7795 IF (c_fnd_concurrent%notfound) THEN
7796
7797 --FEM_ENGINES_PKG.Tech_Message (
7798 -- p_severity => pc_log_level_procedure
7799 -- ,p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7800 -- ,p_msg_text => 'request_id:' || x_pl_register_record.request_id
7801 -- || ' wiped out from the FND_CONCURRENT_REQUESTS'
7802 --);
7803
7804 write_debug(
7805 p_msg_data => 'request_id:' || x_pl_register_record.request_id
7806 || ' wiped out from the FND_CONCURRENT_REQUESTS',
7807 p_user_msg => 'N',
7808 p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7809 );
7810
7811 Get_Dim_Attribute_Value (
7812 p_dimension_varchar_label => 'CAL_PERIOD'
7813 ,p_attribute_varchar_label => 'CAL_PERIOD_END_DATE'
7814 ,p_member_id => x_pl_register_record.cal_period_id
7815 ,x_dim_attribute_varchar_member => l_dummy
7816 ,x_date_assign_value => x_pl_register_record.effective_date
7817 ,x_return_status => x_return_status
7818 );
7819 IF (x_return_status <> pc_ret_sts_success) THEN
7820 --FEM_ENGINES_PKG.Tech_Message (
7821 --p_severity => pc_log_level_procedure
7822 --,p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7823 --,p_msg_text => 'Can not retrieve the ending date for cal period:'
7824 -- || x_pl_register_record.cal_period_id);
7825 write_debug(
7826 p_msg_data => 'Can not retrieve the ending date for cal period:'
7827 || x_pl_register_record.cal_period_id,
7828 p_user_msg => 'N',
7829 p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7830 );
7831
7832 RAISE l_prepare_pl_register_rc_err;
7833 END IF;
7834
7835 write_debug(
7836 p_msg_data => 'x_pl_register_record.effective_date:'
7837 || x_pl_register_record.effective_date,
7838 p_user_msg => 'N',
7839 p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7840 );
7841
7842
7843 x_pl_register_record.dataset_io_obj_def_id := NULL;
7844
7845 OPEN c_get_output_ds_obj_def_id;
7846 FETCH c_get_output_ds_obj_def_id INTO x_pl_register_record.dataset_io_obj_def_id;
7847 CLOSE c_get_output_ds_obj_def_id;
7848
7849 IF (x_pl_register_record.dataset_io_obj_def_id IS NULL) THEN
7850
7851 --FEM_ENGINES_PKG.Tech_Message (
7852 --p_severity => pc_log_level_procedure
7853 --,p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7854 --,p_msg_text => 'Can not retrieve data set object definition id for the data set code:'
7855 -- || x_pl_register_record.output_dataset_code);
7856
7857 write_debug(
7858 p_msg_data => 'Can not retrieve data set object definition id for the data set code:'
7859 || x_pl_register_record.output_dataset_code,
7860 p_user_msg => 'N',
7861 p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7862 );
7863
7864 RAISE l_prepare_pl_register_rc_err;
7865
7866 END IF;
7867
7868 x_pl_register_record.user_id := FND_GLOBAL.user_id;
7869 x_pl_register_record.login_id := FND_GLOBAL.login_id;
7870 x_pl_register_record.program_id := FND_GLOBAL.conc_program_id;
7871 x_pl_register_record.program_application_id := FND_GLOBAL.prog_appl_id;
7872 ELSE
7873 x_pl_register_record.cal_period_id := TO_NUMBER(l_fnd_concurrent_rec.ARGUMENT4);
7874 x_pl_register_record.effective_date := FND_DATE.Canonical_To_Date(l_fnd_concurrent_rec.ARGUMENT2);
7875 x_pl_register_record.dataset_io_obj_def_id := TO_NUMBER(l_fnd_concurrent_rec.ARGUMENT5);
7876 x_pl_register_record.user_id := l_fnd_concurrent_rec.requested_by;
7877 x_pl_register_record.login_id := l_fnd_concurrent_rec.conc_login_id;
7878 x_pl_register_record.program_id := l_fnd_concurrent_rec.CONCURRENT_PROGRAM_ID;
7879 x_pl_register_record.program_application_id := l_fnd_concurrent_rec.PROGRAM_APPLICATION_ID;
7880 x_pl_register_record.program_application_id := l_fnd_concurrent_rec.PROGRAM_APPLICATION_ID;
7881 x_pl_register_record.accurate_eff_dt_flg := G_YES;
7882 END IF;
7883
7884 --FEM_ENGINES_PKG.Tech_Message (
7885 -- p_severity => pc_log_level_procedure
7886 -- ,p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7887 -- ,p_msg_text => 'cal_period_id:' || x_pl_register_record.cal_period_id
7888 -- || ' and effective_date:' || x_pl_register_record.effective_date
7889 -- || ' and dataset_io_obj_def_id:' || x_pl_register_record.dataset_io_obj_def_id
7890 --);
7891
7892 write_debug(
7893 p_msg_data => 'cal_period_id:' || x_pl_register_record.cal_period_id
7894 || ' and effective_date:' || x_pl_register_record.effective_date
7895 || ' and dataset_io_obj_def_id:' || x_pl_register_record.dataset_io_obj_def_id,
7896 p_user_msg => 'N',
7897 p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7898 );
7899
7900
7901 CLOSE c_fnd_concurrent;
7902
7903 EXCEPTION
7904
7905 WHEN l_prepare_pl_register_rc_err THEN
7906 IF (c_fnd_concurrent%ISOPEN) THEN CLOSE c_fnd_concurrent;
7907 END IF;
7908 x_return_status := pc_ret_sts_error;
7909
7910 WHEN OTHERS THEN
7911 IF (c_fnd_concurrent%ISOPEN) THEN CLOSE c_fnd_concurrent;
7912 END IF;
7913
7914 l_prg_msg := SQLERRM;
7915 l_callstack := DBMS_UTILITY.Format_Call_Stack;
7916
7917 write_debug(
7918 p_msg_data => ' l_prg_msg:' || l_prg_msg || ' and l_callstack:' || l_callstack,
7919 p_user_msg => 'N',
7920 p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7921 );
7922
7923
7924 FEM_ENGINES_PKG.Tech_Message (
7925 p_severity => pc_log_level_unexpected
7926 ,p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7927 ,p_msg_text => l_prg_msg
7928 );
7929
7930 FEM_ENGINES_PKG.Tech_Message (
7931 p_severity => pc_log_level_unexpected
7932 ,p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
7933 ,p_msg_text => l_callstack
7934 );
7935
7936 FEM_ENGINES_PKG.User_Message (
7937 p_app_name => G_FEM
7938 ,p_msg_name => 'FEM_UNEXPECTED_ERROR'
7939 ,p_token1 => 'ERR_MSG'
7940 ,p_value1 => l_prg_msg
7941 );
7942 x_return_status := pc_ret_sts_unexp_error;
7943 END;
7944
7945
7946 /*============================================================================+
7947 | PROCEDURE
7948 | Get_Dim_Attribute_Value
7949 |
7950 | DESCRIPTION
7951 | Get Dimension Attribute Value for the specified dimension label, attribute
7952 | label and member id.
7953 |
7954 | SCOPE - PRIVATE
7955 |
7956 +============================================================================*/
7957
7958 PROCEDURE Get_Dim_Attribute_Value (
7959 p_dimension_varchar_label in varchar2
7960 ,p_attribute_varchar_label in varchar2
7961 ,p_member_id in number
7962 ,x_dim_attribute_varchar_member out nocopy varchar2
7963 ,x_date_assign_value out nocopy date,
7964 x_return_status OUT NOCOPY VARCHAR2
7965 )
7966 IS
7967
7968 l_api_name constant varchar2(30) := 'Get_Dim_Attribute_Value';
7969
7970 l_dimension_rec dim_attr_record;
7971
7972 l_dimension_id number;
7973 l_attribute_id number;
7974 l_attr_version_id number;
7975
7976 l_get_dim_attr_val_error exception;
7977
7978 BEGIN
7979 x_return_status := pc_ret_sts_success;
7980
7981 FEM_ENGINES_PKG.Tech_Message (
7982 p_severity => pc_log_level_procedure
7983 ,p_module => 'fem.plsql.'||pc_pkg_name||'.' ||l_api_name
7984 ,p_msg_text => 'BEGIN'
7985 );
7986
7987 Get_Dim_Attribute (
7988 p_dimension_varchar_label => p_dimension_varchar_label
7989 ,p_attribute_varchar_label => p_attribute_varchar_label
7990 ,x_dimension_rec => l_dimension_rec
7991 ,x_attribute_id => l_attribute_id
7992 ,x_attr_version_id => l_attr_version_id
7993 ,x_return_status => x_return_status
7994 );
7995
7996 begin
7997 write_debug(
7998 p_msg_data => ' select dim_attribute_varchar_member'||
7999 ' ,date_assign_value'||
8000 ' from '||l_dimension_rec.attr_table||
8001 ' where attribute_id = :b_attribute_id'||
8002 ' and version_id = :b_attr_version_id'||
8003 ' and '||l_dimension_rec.member_col||' = :b_member_id',
8004 p_user_msg => 'N',
8005 p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
8006 );
8007
8008 execute immediate
8009 ' select dim_attribute_varchar_member'||
8010 ' ,date_assign_value'||
8011 ' from '||l_dimension_rec.attr_table||
8012 ' where attribute_id = :b_attribute_id'||
8013 ' and version_id = :b_attr_version_id'||
8014 ' and '||l_dimension_rec.member_col||' = :b_member_id'
8015 into x_dim_attribute_varchar_member
8016 ,x_date_assign_value
8017 using l_attribute_id
8018 ,l_attr_version_id
8019 ,p_member_id;
8020
8021 exception
8022 when others then
8023
8024 write_debug(
8025 p_msg_data => ' exception:' || SQLERRM,
8026 p_user_msg => 'N',
8027 p_module => 'fem.plsql.'||pc_pkg_name||'.'|| l_api_name
8028 );
8029
8030 FEM_ENGINES_PKG.User_Message (
8031 p_app_name => 'FEM'
8032 ,p_msg_name => 'FEM_ENG_NO_DIM_ATTR_VAL_ERR'
8033 ,p_token1 => 'DIMENSION_VARCHAR_LABEL'
8034 ,p_value1 => p_dimension_varchar_label
8035 ,p_token2 => 'ATTRIBUTE_VARCHAR_LABEL'
8036 ,p_value2 => p_attribute_varchar_label
8037 );
8038 raise l_get_dim_attr_val_error;
8039 end;
8040
8041 FEM_ENGINES_PKG.Tech_Message (
8042 p_severity => pc_log_level_procedure
8043 ,p_module => 'fem.plsql.'||pc_pkg_name||'.' ||l_api_name
8044 ,p_msg_text => 'END'
8045 );
8046
8047 EXCEPTION
8048
8049 when l_get_dim_attr_val_error then
8050
8051 FEM_ENGINES_PKG.Tech_Message (
8052 p_severity => pc_log_level_unexpected
8053 ,p_module => 'fem.plsql.'||pc_pkg_name||'.' ||l_api_name
8054 ,p_msg_text => 'Get Dimension Attribute Value Exception'
8055 );
8056
8057 x_return_status := pc_ret_sts_unexp_error;
8058
8059 END Get_Dim_Attribute_Value;
8060
8061
8062 /*============================================================================+
8063 | PROCEDURE
8064 | Get_Dim_Attribute
8065 |
8066 | DESCRIPTION
8067 | Get the dimension and attribute information for the specified dimension
8068 | label and attribute label.
8069 |
8070 | SCOPE - PRIVATE
8071 |
8072 +============================================================================*/
8073
8074 PROCEDURE Get_Dim_Attribute (
8075 p_dimension_varchar_label in varchar2
8076 ,p_attribute_varchar_label in varchar2
8077 ,x_dimension_rec out nocopy dim_attr_record
8078 ,x_attribute_id out nocopy number
8079 ,x_attr_version_id out nocopy number
8080 ,x_return_status OUT NOCOPY VARCHAR2
8081 )
8082 IS
8083
8084 l_api_name constant varchar2(30) := 'Get_Dim_Attribute';
8085
8086 l_get_dim_attr_error exception;
8087
8088 BEGIN
8089
8090 FEM_ENGINES_PKG.Tech_Message (
8091 p_severity => pc_log_level_procedure
8092 ,p_module => 'fem.plsql.'||pc_pkg_name||'.' ||l_api_name
8093 ,p_msg_text => 'BEGIN'
8094 );
8095
8096
8097 begin
8098 select att.attribute_id
8099 ,ver.version_id
8100 ,dim.member_col
8101 ,dim.attribute_table_name
8102 into x_attribute_id
8103 ,x_attr_version_id
8104 ,x_dimension_rec.member_col
8105 ,x_dimension_rec.attr_table
8106 from fem_dim_attributes_b att
8107 ,fem_dim_attr_versions_b ver
8108 ,fem_xdim_dimensions_vl dim
8109 where att.attribute_varchar_label = p_attribute_varchar_label
8110 AND dim.dimension_varchar_label = p_dimension_varchar_label
8111 AND dim.dimension_id = att.dimension_id
8112 and att.attribute_id = ver.attribute_id
8113 and ver.default_version_flag = 'Y';
8114 exception
8115 when others then
8116 FEM_ENGINES_PKG.User_Message (
8117 p_app_name => G_FEM
8118 ,p_msg_name => 'FEM_ENG_NO_DIM_ATTR_VER_ERR'
8119 ,p_token1 => 'DIMENSION_VARCHAR_LABEL'
8120 ,p_value1 => p_dimension_varchar_label
8121 ,p_token2 => 'ATTRIBUTE_VARCHAR_LABEL'
8122 ,p_value2 => p_attribute_varchar_label
8123 );
8124 raise l_get_dim_attr_error;
8125 end;
8126
8127 FEM_ENGINES_PKG.Tech_Message (
8128 p_severity => pc_log_level_procedure
8129 ,p_module => 'fem.plsql.'||'.'||l_api_name
8130 ,p_msg_text => 'END'
8131 );
8132
8133 EXCEPTION
8134
8135 when l_get_dim_attr_error then
8136
8137 FEM_ENGINES_PKG.Tech_Message (
8138 p_severity => pc_log_level_unexpected
8139 ,p_module => 'fem.plsql.'||pc_pkg_name||'.' ||l_api_name
8140 ,p_msg_text => 'Get Dimension Attribute Exception'
8141 );
8142
8143 x_return_status := pc_ret_sts_error;
8144
8145 END Get_Dim_Attribute;
8146
8147
8148 /*============================================================================+
8149 | PROCEDURE
8150 | Get_Object_Definition
8151 |
8152 | DESCRIPTION
8153 | Get the object definition id for the specified object id and effective date.
8154 |
8155 |
8156 | SCOPE - PRIVATE
8157 |
8158 +============================================================================*/
8159
8160 PROCEDURE Get_Object_Definition (
8161 p_object_id in number
8162 ,p_effective_date in date
8163 ,x_obj_def_id out nocopy number
8164 )
8165 IS
8166
8167 l_api_name constant varchar2(30) := 'Get_Object_Definition';
8168
8169 l_object_name varchar2(150);
8170 l_object_type_code varchar2(30);
8171
8172 BEGIN
8173
8174 FEM_ENGINES_PKG.Tech_Message (
8175 p_severity => pc_log_level_procedure
8176 ,p_module => 'fem.plsql.'||pc_pkg_name||'.' ||l_api_name
8177 ,p_msg_text => 'BEGIN'
8178 );
8179
8180 select d.object_definition_id
8181 into x_obj_def_id
8182 from fem_object_definition_b d
8183 where d.object_id = p_object_id
8184 and p_effective_date between d.effective_start_date and d.effective_end_date
8185 and d.old_approved_copy_flag = 'N';
8186
8187 FEM_ENGINES_PKG.Tech_Message (
8188 p_severity => pc_log_level_procedure
8189 ,p_module => 'fem.plsql.'||pc_pkg_name||'.' ||l_api_name
8190 ,p_msg_text => 'BEGIN'
8191 );
8192
8193 EXCEPTION
8194
8195 when no_data_found then
8196
8197 select d.object_definition_id
8198 into x_obj_def_id
8199 from fem_object_definition_b d
8200 where d.object_id = p_object_id
8201 AND ROWNUM = 1;
8202
8203 FEM_ENGINES_PKG.Tech_Message (
8204 p_severity => pc_log_level_unexpected
8205 ,p_module => 'fem.plsql.'||pc_pkg_name||'.' ||l_api_name
8206 ,p_msg_text => 'No Object Definition was found for Object:' || p_object_id
8207 || ' and effective date:' || p_effective_date
8208 );
8209
8210 END Get_Object_Definition;
8211
8212 PROCEDURE write_debug (
8213 p_msg_data IN VARCHAR2,
8214 p_user_msg IN VARCHAR2,
8215 p_module IN VARCHAR2)
8216 IS
8217 BEGIN
8218 FEM_ENGINES_PKG.Tech_Message (
8219 p_severity => pc_log_level_event
8220 ,p_module => p_module
8221 ,p_msg_text => p_msg_data
8222 );
8223
8224 --DBMS_OUTPUT.PUT_LINE (' p_module:' || p_module || ' message:');
8225 --DBMS_OUTPUT.PUT_LINE ( p_msg_data);
8226 END write_debug;
8227
8228 -- ****************************************************************************
8229
8230 END fem_ud_pkg;