1 PACKAGE BODY ecx_outbound as
2 -- $Header: ECXOUBXB.pls 120.12 2006/12/18 09:40:38 susaha ship $
3
4 l_procedure PLS_INTEGER := ecx_debug.g_procedure;
5 l_statement PLS_INTEGER := ecx_debug.g_statement;
6 l_unexpected PLS_INTEGER := ecx_debug.g_unexpected;
7 l_procedureEnabled boolean := ecx_debug.g_procedureEnabled;
8 l_statementEnabled boolean := ecx_debug.g_statementEnabled;
9 l_unexpectedEnabled boolean := ecx_debug.g_unexpectedEnabled;
10
11 TYPE l_stack is table of pls_integer index by binary_integer;
12 i_stack l_stack;
13
14 /**
15 stage 10 - Pre-Processing
16 stage 20 - In-Processing
17 stage 30 - Post-Processing
18 **/
19
20 procedure move_from_source_to_target
21 (
22 i_target_level IN pls_integer
23 )
24 is
25
26 i_method_name varchar2(2000) := 'ecx_outbound.move_from_source_to_target';
27 i pls_integer;
28 begin
29 if (l_procedureEnabled) then
30 ecx_debug.push(i_method_name);
31 end if;
32 if(l_statementEnabled) then
33 ecx_debug.log(l_statement,'i_target_level',i_target_level,i_method_name);
34 end if;
35 /**
36 Move the Values from Source to the Target
37 **/
38
39 for i in ecx_utils.g_target_levels(i_target_level).file_start_pos..ecx_utils.g_target_levels(i_target_level).file_end_pos
40 loop
41 /** Do a Clean up for the Target **/
42 ecx_utils.g_target(i).value := null;
43
44 /** Change required for Clob Support -- 2263729 ***/
45 ecx_utils.g_target(i).clob_value := null;
46 ecx_utils.g_target(i).clob_length := null;
47 ecx_utils.g_target(i).is_clob := null;
48
49 if ecx_utils.g_target(i).map_attribute_id is not null
50 then
51 /** Change required for Clob Support -- 2263729 **/
52 if (ecx_utils.g_source(ecx_utils.g_target(i).map_attribute_id).data_type = 112) Then
53 ecx_utils.g_target(i).clob_length := ecx_utils.g_source(ecx_utils.g_target(i).map_attribute_id).clob_length;
54 ecx_utils.g_target(i).is_clob := ecx_utils.g_source(ecx_utils.g_target(i).map_attribute_id).is_clob;
55
56 if (ecx_utils.g_source(ecx_utils.g_target(i).map_attribute_id).clob_length > ecx_utils.G_CLOB_VARCHAR_LEN)
57 Then
58
59 ecx_utils.g_target(i).clob_value := ecx_utils.g_source(ecx_utils.g_target(i).map_attribute_id).clob_value;
60 else
61 ecx_utils.g_target(i).value :=
62 ecx_utils.g_source(ecx_utils.g_target(i).map_attribute_id).value;
63 end if;
64 else
65 ecx_utils.g_target(i).value :=
66 ecx_utils.g_source(ecx_utils.g_target(i).map_attribute_id).value;
67 end if;
68 end if;
69
70 /** If the value is null then assign the target default value
71 If ecx_utils.g_target(i).value is null
72 then
73 ecx_utils.g_target(i).value := ecx_utils.g_target(i).default_value;
74 End if;
75 if(l_statementEnabled) then
76 ecx_debug.log(l_statement, ecx_utils.g_target(i).attribute_name,ecx_utils.g_target(i).value,
77 i_method_name);
78 end if;
79 End if;
80 **/
81
82 If ecx_utils.g_target(i).clob_value is not null Then
83 if(l_statementEnabled) then
84 ecx_debug.log(l_statement,i||'=>'||ecx_utils.g_target(i).parent_attribute_id||'=>'||
85 ecx_utils.g_target(i).attribute_type||'=>'||
86 ecx_utils.g_target(i).attribute_name,ecx_utils.g_target(i).clob_value,
87 i_method_name);
88 end if;
89 else
90 -- if clob_value is null this means that it is varchar2
91 /** If the value is null then assign the target default value **/
92 If ecx_utils.g_target(i).value is null
93 then
94 ecx_utils.g_target(i).value := ecx_utils.g_target(i).default_value;
95 End if;
96 if(l_statementEnabled) then
97 ecx_debug.log(l_statement,i||'=>'||ecx_utils.g_target(i).parent_attribute_id||'=>'||
98 ecx_utils.g_target(i).attribute_type||'=>'||
99 ecx_utils.g_target(i).attribute_name,ecx_utils.g_target(i).value,
100 i_method_name);
101 end if;
102 End If;
103 end loop;
104 if (l_procedureEnabled) then
105 ecx_debug.pop(i_method_name);
106 end if;
107 exception
108 when others then
109 if(l_unexpectedEnabled) then
110 ecx_debug.log(l_unexpected,'ECX','ECX_PROGRAM_ERROR',i_method_name,'PROGRESS_LEVEL',
111 'ECX_OUTBOUND.MOVE_FROM_SOURCE_TO_TARGET');
112 ecx_debug.log(l_unexpected,'ECX','ECX_ERROR_MESSAGE',i_method_name,'ERROR_MESSAGE',SQLERRM);
113 end if;
114 ecx_debug.setErrorInfo(2, 30, SQLERRM || ' - ECX_OUTBOUND.MOVE_FROM_SOURCE_TO_TARGET');
115 if(l_unexpectedEnabled) then
116 ecx_debug.log(l_unexpected,'ECX', SQLERRM || ' - ECX_OUTBOUND.MOVE_FROM_SOURCE_TO_TARGET',
117 i_method_name);
118 end if;
119 if (l_procedureEnabled) then
120 ecx_debug.pop(i_method_name);
121 end if;
122 raise ecx_utils.PROGRAM_EXIT;
123 end move_from_source_to_target;
124
125 procedure processTarget
126 (
127 i_target in pls_integer
128 )
129 is
130 i_method_name varchar2(2000) := 'ecx_outbound.processtarget';
131 i_init_msg_list varchar2(20);
132 i_simulate varchar2(20);
133 i_validation_level varchar2(20);
134 i_commit varchar2(20);
135 i_return_status varchar2(20);
136 i_msg_count varchar2(20);
137 i_msg_data varchar2(2000);
138
139 begin
140
141 if (l_procedureEnabled) then
142 ecx_debug.push(i_method_name);
143 end if;
144 if(l_statementEnabled) then
145 ecx_debug.log(l_statement,'i_target',i_target,i_method_name);
146 end if;
147
148 -- don't need t execute stage 10, level 0 action for target as this is
149 -- already done in the initilization phase
150 if (i_target <> 0)
151 then
152 -- Pre-Processing Stage for Target
153 ecx_actions.execute_stage_data ( 10, i_target, 'T');
154 end if;
155
156 /** Move the Values from Source to the Target **/
157 move_from_source_to_target(i_target);
158
159 -- In Processing Stage for Target
160 ecx_actions.execute_stage_data ( 20, i_target, 'T');
161
162 ecx_print_local.print_new_level
163 (
164 i_target,
165 ecx_utils.g_target_levels(i_target).dtd_node_index
166 );
167
168 if (i_target <> 0)
169 then
170 -- Post Processing Stage for Target
171 ecx_actions.execute_stage_data ( 30, i_target, 'T');
172 end if;
173 if (l_procedureEnabled) then
174 ecx_debug.pop(i_method_name);
175 end if;
176
177 exception
178 when ecx_utils.program_exit then
179 ecx_debug.pop('ECX_OUTBOUND.processTarget');
180 raise ecx_utils.program_exit;
181 when others then
182 if(l_unexpectedEnabled) then
183 ecx_debug.log(l_unexpected,'ECX','ECX_PROGRAM_ERROR',i_method_name,'PROGRESS_LEVEL',
184 'ECX_OUTBOUND.PROCESSTARGET');
185 ecx_debug.log(l_unexpected,'ECX','ECX_ERROR_MESSAGE',i_method_name,'ERROR_MESSAGE',SQLERRM);
186 end if;
187 ecx_debug.setErrorInfo(2, 30, SQLERRM || ' - ECX_OUTBOUND.PROCESSTARGET');
188 if(l_unexpectedEnabled) then
189 ecx_debug.log(l_unexpected, 'ECX', SQLERRM || ' - ECX_OUTBOUND.PROCESSTARGET',
190 i_method_name);
191 end if;
192 if (l_procedureEnabled) then
193 ecx_debug.pop(i_method_name);
194 end if;
195 raise ecx_utils.PROGRAM_EXIT;
196 end processTarget;
197
198 procedure process_data
199 (
200 i IN pls_integer,
201 i_stage in pls_integer ,
202 i_next IN pls_integer
203 )
204 is
205
206 i_method_name varchar2(2000) := 'ecx_outbound.process_data';
207 i_init_msg_list varchar2(20);
208 i_simulate varchar2(20);
209 i_validation_level varchar2(20);
210 i_commit varchar2(20);
211 i_return_status varchar2(20);
212 i_msg_count varchar2(20);
213 i_msg_data varchar2(2000);
214 j pls_integer;
215 begin
216 if (l_procedureEnabled) then
217 ecx_debug.push(i_method_name);
218 end if;
219 if(l_statementEnabled) then
220 ecx_debug.log(l_statement,'i',i,i_method_name);
221 ecx_debug.log(l_statement,'i_stage',i_stage,i_method_name);
222 ecx_debug.log(l_statement,'i_next',i_next,i_method_name);
223 end if;
224
225 if i < 0
226 then
227 if (l_procedureEnabled) then
228 ecx_debug.pop(i_method_name);
229 end if;
230 return;
231 end if;
232
233 if i_stage = 10
234 then
235
236 /** Should clean up the Current Source and the down levels first**/
237 for k in i..ecx_utils.g_source_levels.last
238 loop
239 for j in ecx_utils.g_source_levels(k).file_start_pos..ecx_utils.g_source_levels(k).file_end_pos
240 loop
241 if ecx_utils.g_source(j).default_value is null
242 then
243 ecx_utils.g_source(j).value := null;
244 ecx_utils.g_source(j).clob_value := null;
245 ecx_utils.g_source(j).is_clob := null;
246 ecx_utils.g_source(j).clob_length := null;
247 else
248 ecx_utils.g_source(j).value := ecx_utils.g_source(j).default_value;
249 end if;
250 if(l_statementEnabled) then
251 ecx_debug.log(l_statement,'Source '||ecx_utils.g_source(j).attribute_name,
252 ecx_utils.g_source(j).value,i_method_name);
253 end if;
254 end loop;
255 end loop;
256
257 -- For level 0 this is already done in the initialization
258 if (i <> 0)
259 then
260 /** Execute the pre-processing for the Source **/
261 ecx_actions.execute_stage_data (i_stage, i, 'S');
262 end if;
263 end if;
264
265 if i_stage = 20
266 then
267 -- Perform Code Conversion
268 ecx_code_conversion_pvt.populate_plsql_tbl_with_extval
269 (
270 p_api_version_number => 1.0,
271 p_init_msg_list => i_init_msg_list,
272 p_simulate => i_simulate,
273 p_commit => i_commit,
274 p_validation_level => i_validation_level,
275 p_return_status => i_return_status,
276 p_msg_count => i_msg_count,
277 p_msg_data => i_msg_data,
278 p_level => i,
279 p_tbl => ecx_utils.g_source,
280 p_tp_id => ecx_utils.g_rec_tp_id,
281 p_standard_id => ecx_utils.g_standard_id
282 );
283
284 --Check the Status of the Code Conversion API and take appropriate action.
285 IF (
286 i_return_status = ecx_code_conversion_pvt.G_RET_STS_ERROR OR
287 i_return_status is NULL OR
288 i_return_status = ecx_code_conversion_pvt.G_RET_STS_UNEXP_ERROR
289 )
290 THEN
291 if(l_statementEnabled) then
292 ecx_debug.log(l_statement,'ECX','ECX_PROGRAM_ERROR',i_method_name,'PROGRESS_LEVEL',
293 'ECX_OUTBOUND.PROCESS_DATA');
294 ecx_debug.log(l_statement,'ECX','EC_CODE_CONVERSION_FAILED',i_method_name,'LEVEL',i);
295 end if;
296 ecx_utils.i_ret_code := 2;
297 RAISE ecx_utils.PROGRAM_EXIT;
298 END IF;
299
300 /** Execute the In-processing for the Source **/
301 ecx_actions.execute_stage_data (i_stage, i, 'S');
302
303 for j in ecx_utils.g_source_levels(i).first_target_level .. ecx_utils.g_source_levels(i).last_target_level
304 loop
305 /** Initialize the Target **/
306 for k in ecx_utils.g_target_levels(j).file_start_pos..ecx_utils.g_target_levels(j).file_end_pos
307 loop
308 if ecx_utils.g_target(k).default_value is null
309 then
310 ecx_utils.g_target(k).value := null;
311 /** Change required for Clob Support -- 2263729 ***/
312 ecx_utils.g_target(k).clob_value := null;
313 ecx_utils.g_target(k).clob_length := null;
314 ecx_utils.g_target(k).is_clob := null;
315 else
316 ecx_utils.g_target(k).value := ecx_utils.g_target(k).default_value;
317 end if;
318 if(l_statementEnabled) then
319 ecx_debug.log(l_statement,'target '||ecx_utils.g_target(k).attribute_name,
320 ecx_utils.g_target(k).value,i_method_name);
321 end if;
322 end loop;
323 end loop;
324
325 /** Check for Collapsion. Do depth checking for Collapsion only **/
326 if(l_statementEnabled) then
327 ecx_debug.log(l_statement,'Previous Level',i,i_method_name);
328 ecx_debug.log(l_statement,'Current Level',i_next,i_method_name);
329 end if;
330
331 if ( ecx_utils.g_source_levels(i).last_source_level -
332 ecx_utils.g_source_levels(i).first_source_level > 0 )
333 then
334 if i_next > i
335 then
336 if ( i_next >= ecx_utils.g_source_levels(i).first_source_level )
337 and
338 ( i_next <= ecx_utils.g_source_levels(i).last_source_level )
339 then
340 if(l_statementEnabled) then
341 ecx_debug.log(l_statement,'Skipping Source',i,i_method_name);
342 end if;
343 else
344 processTarget(ecx_utils.g_source_levels(i).first_target_level);
345 end if;
346 end if;
347
348 if i_next <= i
349 then
350 processTarget(ecx_utils.g_source_levels(i).first_target_level);
351 end if;
352 else
353 /** Else Expansion or 1-1 mapping **/
354 for j in ecx_utils.g_source_levels(i).first_target_level .. ecx_utils.g_source_levels(i).last_target_level
355 loop
356 processTarget(j);
357 end loop;
358 end if;
359 end if;
360
361 if i_stage = 30
362 then
363 -- For level 0 this will be done in the end
364 if (i <> 0)
365 then
366 /** Execute the Post-processing for the Source **/
367 ecx_actions.execute_stage_data (30, i, 'S');
368 end if;
369
370 /*
371 Before doing a stage 30 for level we need to print any remaning discontinuous elements
372 for this level. This way if another occurrance of this level arrives the data for the
373 discontinuous elements will be printed before it gets overwritten.
374 */
375
376 -- for all the target levels mapped to this source level print the discont elements
377 j := ecx_utils.g_source_levels(i).last_target_level;
378 if (l_statementEnabled) then
379 ecx_debug.log(l_statement,'last target level', ecx_utils.g_source_levels(i).last_target_level,i_method_name);
380 ecx_debug.log(l_statement, 'first target level', ecx_utils.g_source_levels(i).first_target_level,
381 i_method_name);
382 end if;
383 while (j >= ecx_utils.g_source_levels(i).first_target_level)
384 loop
385 ecx_print_local.print_discont_elements(ecx_print_local.last_printed + 1,
386 ecx_utils.g_target_levels(j).file_end_pos,
387 ecx_utils.g_target(ecx_utils.g_target_levels(j).file_start_pos).attribute_id,
388 j);
389 j := j - 1;
390 end loop;
391 end if;
392
393 if (l_procedureEnabled) then
394 ecx_debug.pop(i_method_name);
395 end if;
396 exception
397 when ecx_utils.program_exit then
398 if (l_procedureEnabled) then
399 ecx_debug.pop(i_method_name);
400 end if;
401 raise ecx_utils.program_exit;
402 when others then
403 ecx_debug.setErrorInfo(2, 30, SQLERRM || ' - ECX_OUTBOUND.PROCESS_DATA');
404 if(l_unexpectedEnabled) then
405 ecx_debug.log(l_unexpected, 'ECX', SQLERRM || ' - ECX_OUTBOUND.PROCESS_DATA',i_method_name);
406 end if;
407 if (l_procedureEnabled) then
408 ecx_debug.pop(i_method_name);
409 end if;
410 raise ecx_utils.program_exit;
411 end process_data;
412
413
414 procedure print_stack
415 is
416 i_method_name varchar2(2000) := 'ecx_outbound.print_stack';
417 begin
418
419 if(l_statementEnabled) then
420 ecx_debug.log(l_statement,'Stack Status','====',i_method_name);
421 end if;
422 for i in 1..i_stack.COUNT
423 loop
424 if(l_statementEnabled) then
425 ecx_debug.log(l_statement,i_stack(i),i_method_name);
426 end if;
427 end loop;
428 exception
429 when others then
430 ecx_debug.setErrorInfo(2, 30, SQLERRM || ' - ECX_OUTBOUND.PRINT_STACK');
431 if(l_unexpectedEnabled) then
432 ecx_debug.log(l_unexpected,'ECX', SQLERRM || ' - ECX_OUTBOUND.PRINT_STACK',i_method_name);
433 end if;
434 raise ecx_utils.program_exit;
435 end print_stack;
436
437 procedure pop
438 (
439 i_next in pls_integer
440 )
441 is
442 i_method_name varchar2(2000) := 'ecx_outbound.pop';
443
444 begin
445 if (l_procedureEnabled) then
446 ecx_debug.push(i_method_name );
447 end if;
448 if(l_statementEnabled) then
449 ecx_debug.log(l_statement,'i_next',i_next,i_method_name);
450 print_stack;
451 end if;
452
453 if i_stack.COUNT = 0
454 then
455 if(l_statementEnabled) then
456 ecx_debug.log(l_statement,'Stack Error. Nothing to pop','xxxxx',i_method_name);
457 end if;
458 if (l_procedureEnabled) then
459 ecx_debug.pop(i_method_name);
460 end if;
461 return;
462 end if;
463
464 /** Post Process and then pop. **/
465 process_data(i_stack(i_stack.COUNT),30,i_next);
466
467 i_stack.delete(i_stack.COUNT);
468
469 if(l_statementEnabled) then
470 print_stack;
471 end if;
472 if (l_procedureEnabled) then
473 ecx_debug.pop(i_method_name );
474 end if;
475 exception
476 when ecx_utils.program_exit then
477 if (l_procedureEnabled) then
478 ecx_debug.pop(i_method_name);
479 end if;
480 raise ecx_utils.program_exit;
481 when others then
482 ecx_debug.setErrorInfo(2, 30, SQLERRM || ' - ECX_OUTBOUND.POP');
483 if(l_unexpectedEnabled) then
484 ecx_debug.log(l_unexpected, 'ECX', SQLERRM || ' - ECX_OUTBOUND.POP',i_method_name);
485 end if;
486 if (l_procedureEnabled) then
487 ecx_debug.pop(i_method_name);
488 end if;
489 raise ecx_utils.program_exit;
490 end pop;
491
492 procedure push
493 (
494 i in pls_integer
495 )
496 is
497
498 i_method_name varchar2(2000) := 'ecx_outbound.push';
499 begin
500 if (l_procedureEnabled) then
501 ecx_debug.push(i_method_name);
502 end if;
503 if(l_statementEnabled) then
504 ecx_debug.log(l_statement,i,i_method_name);
505 print_stack;
506 end if;
507
508 if i_stack.COUNT = 0
509 then
510 -- Nothing on the Stack. Push the value
511 i_stack(i_stack.COUNT+1):=i;
512
513 /** pre stage processing **/
514 process_data(i_stack(i_stack.COUNT),10,i);
515
516 if(l_statementEnabled) then
517 print_stack;
518 end if;
519
520 if (l_procedureEnabled) then
521 ecx_debug.pop(i_method_name);
522 end if;
523
524 return;
525 end if;
526
527 if i > i_stack(i_stack.COUNT)
528 then
529 /** In stage processing **/
530 process_data(i_stack(i_stack.COUNT),20,i);
531
532 -- Push
533 i_stack(i_stack.COUNT+1):=i;
534
535 /** pre stage processing **/
536 process_data(i_stack(i_stack.COUNT),10,i);
537
538 if(l_statementEnabled) then
539 print_stack;
540 end if;
541
542 if (l_procedureEnabled) then
543 ecx_debug.pop(i_method_name);
544 end if;
545 return;
546 end if;
547
548 if i = i_stack(i_stack.COUNT)
549 then
550 /** In-Processing and then pop the Top Entry. **/
551 process_data(i_stack(i_stack.COUNT),20,i);
552 pop(i);
553 end if;
554
555 if i_stack.COUNT <> 0
556 then
557 if i < i_stack(i_stack.COUNT)
558 then
559
560 /** In-Processing and then pop the Top Entry. **/
561 process_data(i_stack(i_stack.COUNT),20,i);
562 pop(i);
563
564 /** Pop The rest of the Elements **/
565 while ( i <= i_stack(i_stack.COUNT) )
566 loop
567 pop(i);
568 exit when i_stack.COUNT = 0;
569 end loop;
570
571 end if;
572 end if;
573
574 -- Push the value
575 i_stack(i_stack.COUNT+1):=i;
576 /** pre stage processing **/
577 process_data(i_stack(i_stack.COUNT),10,i);
578
579
580 if(l_statementEnabled) then
581 print_stack;
582 end if;
583
584 if (l_procedureEnabled) then
585 ecx_debug.pop(i_method_name);
586 end if;
587 exception
588 when ecx_utils.program_exit then
589 if (l_procedureEnabled) then
590 ecx_debug.pop(i_method_name);
591 end if;
592 raise ecx_utils.program_exit;
593 when others then
594 ecx_debug.setErrorInfo(2, 30, SQLERRM || ' - ECX_OUTBOUND.PUSH');
595 if(l_unexpectedEnabled) then
596 ecx_debug.log(l_unexpected,'ECX', SQLERRM || ' - ECX_OUTBOUND.PUSH',i_method_name);
597 end if;
598 if (l_procedureEnabled) then
599 ecx_debug.pop(i_method_name);
600 end if;
601 raise ecx_utils.program_exit;
602 end push;
603
604
605 procedure popall
606 is
607 i_method_name varchar2(2000) := 'ecx_outbound.popall';
608 begin
609 if (l_procedureEnabled) then
610 ecx_debug.push(i_method_name );
611 end if;
612 /** In-Process the last Level on the Stack **/
613 if i_stack.COUNT <> 0
614 then
615 process_data(i_stack(i_stack.COUNT),20,0);
616 end if;
617
618 if(l_statementEnabled) then
619 print_stack;
620 end if;
621
622 while ( i_stack.COUNT > 0)
623 loop
624 pop(0);
625 end loop;
626
627 if(l_statementEnabled) then
628 print_stack;
629 end if;
630
631 if (l_procedureEnabled) then
632 ecx_debug.pop(i_method_name );
633 end if;
634
635 exception
636 when ecx_utils.program_exit then
637 if (l_procedureEnabled) then
638 ecx_debug.pop(i_method_name );
639 end if;
640 raise ecx_utils.program_exit;
641 when others then
642 ecx_debug.setErrorInfo(2, 30, SQLERRM || ' - ECX_OUTBOUND.POPALL');
643 if(l_unexpectedEnabled) then
644 ecx_debug.log(l_unexpected,'ECX', SQLERRM || ' - ECX_OUTBOUND.POPALL',i_method_name);
645 end if;
646 if (l_procedureEnabled) then
647 ecx_debug.pop(i_method_name );
648 end if;
649 raise ecx_utils.program_exit;
650 end popall;
651
652 /**
653 Fetches data from the ec_views recurrsively for a given document.
654 **/
655 procedure fetch_data_from_view
656 (
657 i_level IN pls_integer
658 )
659 is
660 i_method_name varchar2(2000) := 'ecx_outbound.fetch_data_from_view';
661 i_column_counter pls_integer :=0;
662 i_rows_processed pls_integer ;
663 i_start_element varchar2(2000);
664 j pls_integer;
665 i_count pls_integer;
666 l_clob clob;
667 i_len pls_integer;
668 BEGIN
669 if (l_procedureEnabled) then
670 ecx_debug.push(i_method_name );
671 end if;
672 if(l_statementEnabled) then
673 ecx_debug.log(l_statement,'i_level',i_level,i_method_name);
674 ecx_debug.log(l_statement,'Source level',ecx_utils.g_source_levels.COUNT,i_method_name);
675 ecx_debug.log(l_statement,'target_source_levels',ecx_utils.g_target_source_levels.COUNT,i_method_name);
676 end if;
677 -- push root element on stack
678 if (i_level = 0)
679 then
680 push(i_level);
681 end if;
682
683 for i in 1..ecx_utils.g_source_levels.last
684 loop
685 IF ecx_utils.g_source_levels(i).parent_level = i_level
686 THEN
687 if(l_statementEnabled) then
688 ecx_debug.log(l_statement,'SQL Statement',ecx_utils.g_source_levels(i).sql_stmt,i_method_name);
689 end if;
690 -- Set the Global Variable for Current Level
691 ecx_utils.g_current_level := i;
692
693 /* Bind the Variables for the Where Clause */
694 ecx_actions.bind_variables_for_view(10,i);
695 i_rows_processed := dbms_sql.execute (ecx_utils.g_source_levels(i).Cursor_Handle);
696 if(l_statementEnabled) then
697 ecx_debug.log(l_statement,'Cursor Handle',ecx_utils.g_source_levels(i).Cursor_handle,
698 i_method_name);
699 end if;
700
701
702 while (dbms_sql.fetch_rows( ecx_utils.g_source_levels(i).Cursor_handle) > 0)
703 LOOP
704 push(i);
705
706 if(l_statementEnabled) then
707 ecx_debug.log(l_statement,'Executing Fetch Rows',i_method_Name);
708 end if;
709
710 -- Get Values from the View
711 -- Initialize the Column Counter
712 i_column_counter :=0;
713 j := ecx_utils.g_source_levels(i).file_start_pos;
714 loop
715 if (ecx_utils.g_source(j).external_level = i)
716 then
717 i_column_counter := i_column_counter + 1;
718
719 if ecx_utils.g_source(j).data_type <> 112 Then
720 dbms_sql.column_value
721 (
722 ecx_utils.g_source_levels(i).Cursor_handle,
723 i_column_counter,
724 ecx_utils.g_source(j).value
725 );
726 else
727 dbms_sql.column_value
728 (
729 ecx_utils.g_source_levels(i).Cursor_handle,
730 i_column_counter,
731 ecx_utils.g_source(j).clob_value
732 );
733 /** Change required for Clob Support -- 2263729 ***/
734 ecx_utils.g_source(j).clob_length := dbms_lob.getlength( ecx_utils.g_source(j).clob_value);
735 i_len := ecx_utils.g_source(j).clob_length;
736
737 ecx_utils.g_source(j).is_clob := 'N';
738
739 If i_len <= ecx_utils.G_CLOB_VARCHAR_LEN Then
740 ecx_utils.g_source(j).is_clob := 'Y'; /** To indicate value has a shorter string of clob value ***/
741 ecx_utils.g_source(j).value :=
742 dbms_lob.substr(ecx_utils.g_source(j).clob_value,i_len,1);
743 ecx_utils.g_source(j).clob_value := null ;
744 ecx_utils.g_source(j).clob_length := null ;
745 End If;
746 end if;
747
748 /** If the value is null set the default value **/
749 if ecx_utils.g_source(j).value is null
750 then
751 ecx_utils.g_source(j).value := ecx_utils.g_source(j).default_value;
752 end if;
753
754 if(l_statementEnabled) then
755 if ecx_utils.g_source(j).base_column_name is not null
756 then
757 /** Change required for Clob Support -- 2263729 ***/
758 if ecx_utils.g_source(j).data_type = 112 Then
759 if ecx_utils.g_source(j).clob_value is null Then
760
761 ecx_debug.log(l_statement,
762 ecx_utils.g_source(j).base_column_name,
763 ecx_utils.g_source(j).value,
764 i_method_name
765 );
766
767 else
768
769 ecx_debug.log(l_statement,
770 ecx_utils.g_source(j).base_column_name,
771 ecx_utils.g_source(j).clob_value,
772 i_method_name
773 );
774 end if;
775 else
776
777 ecx_debug.log(l_statement,
778 ecx_utils.g_source(j).base_column_name,
779 ecx_utils.g_source(j).value,
780 i_method_name
781 );
782 End If;
783 end if;
784 end if;
785 end if;
786 exit when j = ecx_utils.g_source_levels(i).file_end_pos;
787 j := ecx_utils.g_source.next(j);
788 end loop;
789 if(l_statementEnabled) then
790 ecx_debug.log(l_statement,'All Rows fetched',i_method_name);
791 end if;
792
793
794 i_count :=0;
795 if (ecx_utils.g_source_levels.count <> 0)
796 then
797 for m in ecx_utils.g_source_levels.first..ecx_utils.g_source_levels.last
798 loop
799 if(l_statementEnabled) then
800 ecx_debug.log(l_statement,'Source level '||m,'Parent level'||ecx_utils.g_source_levels(m).parent_level,
801 i_method_name);
802 end if;
803 if ecx_utils.g_source_levels(m).parent_level=i
804 then
805 i_count := i_count+1;
806 end if;
807 end loop;
808 end if;
809 if(l_statementEnabled) then
810 ecx_debug.log(l_statement,'i_count',i_count,i_method_name);
811 end if;
812
813 if i_count > 0
814 then
815 fetch_data_from_view(i);
816 end if;
817
818 END LOOP;
819 if i = 1
820 then
821 ecx_utils.g_source_levels(i).rows_processed := dbms_sql.last_row_count;
822 else
823 ecx_utils.g_source_levels(i).rows_processed :=
824 ecx_utils.g_source_levels(i).rows_processed + dbms_sql.last_row_count;
825 end if;
826 END IF;
827 end loop;
828 if (l_procedureEnabled) then
829 ecx_debug.pop(i_method_name );
830 end if;
831 EXCEPTION
832 WHEN invalid_number then
833 if(l_unexpectedEnabled) then
834 ecx_debug.log(l_unexpected,'ECX','ECX_PROGRAM_ERROR',i_method_name,
835 'PROGRESS_LEVEL','ECX_OUTBOUND.FETCH_DATA_FROM_VIEW');
836 ecx_debug.log(l_unexpected,'ECX','ECX_ERROR_MESSAGE',i_method_name,
837 'ERROR_MESSAGE',SQLERRM);
838 end if;
839 ecx_debug.setErrorInfo(2,30,'ECX_INVALID_NUMBER - ECX_OUTBOUND.FETCH_DATA_FROM_VIEW' );
840 if (l_procedureEnabled) then
841 ecx_debug.pop(i_method_name);
842 end if;
843 raise ecx_utils.program_exit;
844 WHEN ecx_utils.PROGRAM_EXIT then
845 raise;
846 WHEN OTHERS THEN
847 if(l_unexpectedEnabled) then
848 ecx_debug.log(l_unexpected,'ECX','ECX_PROGRAM_ERROR',i_method_name,'PROGRESS_LEVEL',
849 'ECX_OUTBOUND.FETCH_DATA_FROM_VIEW');
850 ecx_debug.log(l_unexpected,'ECX','ECX_ERROR_MESSAGE',i_method_name,'ERROR_MESSAGE',SQLERRM);
851 end if;
852 ecx_debug.setErrorInfo(2, 30, SQLERRM || ' - ECX_OUTBOUND.FETCH_DATA_FROM_VIEW');
853 if(l_unexpectedEnabled) then
854 ecx_debug.log(l_unexpected, 'ECX', SQLERRM || ' - ECX_OUTBOUND.FETCH_DATA_FROM_VIEW',
855 i_method_name);
856 end if;
857 if (l_procedureEnabled) then
858 ecx_debug.pop(i_method_name );
859 end if;
860 raise ecx_utils.PROGRAM_EXIT;
861 END fetch_data_from_view;
862
863 procedure log_summary(level pls_integer)
864 is
865 i_method_name varchar2(2000);
866 begin
867 i_method_name:='ecx_outbound.log_summary';
868 if (l_procedureEnabled) then
869 ecx_debug.push(i_method_name);
870 end if;
871
872 ecx_debug.log(level,'Processing Summary','====',i_method_name);
873 if (ecx_utils.g_source_levels.count <> 0)
874 then
875 for i in ecx_utils.g_source_levels.first..ecx_utils.g_source_levels.last
876 loop
877 ecx_debug.log(level,ecx_utils.g_source_levels(i).rows_processed||
878 ' row(s) processed for Level : '|| ecx_utils.g_source_levels(i).start_element
879 || '('|| i || ') ',i_method_name);
880 end loop;
881 end if;
882 if (l_procedureEnabled) then
883 ecx_debug.pop(i_method_name);
884 end if;
885 exception
886 when others then
887 ecx_debug.setErrorInfo(2, 30, SQLERRM || ' - ECX_OUTBOUND.LOG_SUMMARY');
888 if(l_unexpectedEnabled) then
889 ecx_debug.log(l_unexpected,'ECX', SQLERRM || ' - ECX_OUTBOUND.LOG_SUMMARY',i_method_name);
890 end if;
891 if (l_procedureEnabled) then
892 ecx_debug.pop(i_method_name);
893 end if;
894
895 raise ecx_utils.program_exit;
896 end log_summary;
897
898 /**
899 Main Call for Processing Outbound Documents
900 **/
901 procedure process_outbound_documents
902 (
903 i_message_standard IN varchar2,
904 i_transaction_type IN varchar2,
905 i_transaction_subtype IN varchar2,
906 i_tp_id IN varchar2,
907 i_tp_site_id IN varchar2,
908 i_tp_type In varchar2,
909 i_document_id IN varchar2,
910 i_map_code IN varchar2,
911 i_xmldoc IN OUT NOCOPY clob,
912 i_message_type IN varchar2
913 )
914 is
915
916 i_method_name varchar2(2000) := 'ecx_outbound.process_outbound_documents';
917
918 i_msgid raw(16);
919 i_dtd_id pls_integer;
920 i_run_id pls_integer;
921 i_variable_found BOOLEAN := TRUE;
922 i_stack_pos pls_integer;
923 i_fullpath ecx_objects.fullpath%TYPE;
924 i_root_element ecx_objects.root_element%TYPE;
925 i_filename varchar2(200);
926 i_temp varchar2(32767);
927 i_logdir varchar2(200);
928 x_same_map BOOLEAN := FALSE;
929 i_tp_header_id pls_integer;
930 i_map_id pls_integer;
931 i_standard_id pls_integer;
932 i_parameterlist wf_parameter_list_t;
933 i_parameter wf_parameter_t;
934 counter number;
935 i_paramCount number;
936 i_stack_param_name VARCHAR2(2000);
937 i_stack_param_value VARCHAR2(4000);
938 i_param_name VARCHAR2(30);
939 i_mode varchar2(10) := 'FALSE';
940 l_IANAcharset varchar2(2000);
941 l_xmldecl varchar2(4000);
942 l_parseXML boolean;
943 l_value number;
944 i_node_type pls_integer;
945
946 attachment_id pls_integer;
947 ctemp varchar2(32767);
948 clength pls_integer;
949 offset pls_integer := 1;
950 g_varmaxlength pls_integer := 1999;
951 g_instlmode VARCHAR2(100);
952
953 begin
954
955
956 if (l_procedureEnabled) then
957 ecx_debug.push(i_method_name );
958 end if;
959 if(l_statementEnabled) then
960 ecx_debug.log(l_statement,'ECX','ECX_START_OUTBOUND','MAP_ID',i_map_id,i_method_name);
961 ecx_debug.log(l_statement,'i_message_standard',i_message_standard,i_method_name);
962 ecx_debug.log(l_statement,'i_transaction_type',i_transaction_type,i_method_name);
963 ecx_debug.log(l_statement,'i_transaction_subtype',i_transaction_subtype,i_method_name);
964 ecx_debug.log(l_statement,'i_tp_id',i_tp_id,i_method_name);
965 ecx_debug.log(l_statement,'i_tp_site_id',i_tp_site_id,i_method_name);
966 ecx_debug.log(l_statement,'i_tp_type',i_tp_type,i_method_name);
967 ecx_debug.log(l_statement,'i_document_id',i_document_id,i_method_name);
968 ecx_debug.log(l_statement,'i_map_code',i_map_code,i_method_name);
969 end if;
970
971 /** check for the Event Object. If null , initialize it **/
972 if ecx_utils.g_event is null
973 then
974 wf_event_t.initialize(ecx_utils.g_event);
975 end if;
976 i_parameterlist := wf_event_t.getParameterList(ecx_utils.g_event);
977 if(l_statementEnabled) then
978 if i_parameterList is not null
979 then
980 for i in i_parameterList.FIRST..i_parameterList.LAST
981 loop
982 i_parameter := i_parameterList(i);
983 ecx_debug.log(l_statement,i_parameter.getName(),i_parameter.getValue(),i_method_name);
984 end loop;
985 end if;
986 end if;
987
988
989 /** Set the GLobal variables **/
990 ecx_utils.g_transaction_type := i_transaction_type;
991 ecx_utils.g_transaction_subtype := i_transaction_subtype;
992 ecx_utils.g_document_id := i_document_id;
993
994 /** Check for Message Standard Code **/
995 begin
996 select standard_id
997 into i_standard_id
998 from ecx_standards
999 where standard_code = i_message_standard
1000 and standard_type = nvl(i_message_type, 'XML');
1001
1002 ecx_utils.g_standard_id := i_standard_id;
1003 exception
1004 when others then
1005 ecx_debug.setErrorInfo(1, 30, 'ECX_CODE_CONVERSION_DISABLED',
1006 'MESSAGE_STANDARD', i_message_standard);
1007 if(l_statementEnabled) then
1008 ecx_debug.log(l_statement,'ECX', 'ECX_CODE_CONVERSION_DISABLED',i_method_name,
1009 'MESSAGE_STANDARD', i_message_standard);
1010 end if;
1011 end;
1012
1013 /** Check for Map Code **/
1014 begin
1015 select map_id
1016 into i_map_id
1017 from ecx_mappings
1018 where map_code = i_map_code;
1019 exception
1020 when others then
1021 ecx_debug.setErrorInfo(1, 30, 'ECX_MAP_NOT_FOUND', 'MAP_CODE', i_map_code);
1022 if(l_unexpectedEnabled) then
1023 ecx_debug.log(l_unexpected,'ECX', 'ECX_MAP_NOT_FOUND', i_method_name,'MAP_CODE', i_map_code);
1024 end if;
1025 raise ecx_utils.program_exit;
1026 end;
1027
1028 /** Check for tp_header_id **/
1029 begin
1030 select tp_header_id
1031 into i_tp_header_id
1032 from ecx_tp_headers
1033 where party_id = i_tp_id
1034 and party_site_id = i_tp_site_id
1035 and party_type = i_tp_type;
1036
1037 /** Set the GLobal g_rcv_tp_id **/
1038 ecx_utils.g_rec_tp_id:= i_tp_header_id;
1039 exception
1040 when others then
1041 ecx_debug.setErrorInfo(1, 30, 'ECX_TP_NOT_FOUND', 'PARTY_ID', i_tp_id);
1042 if(l_statementEnabled) then
1043 ecx_debug.log(l_statement,'ECX', 'ECX_TP_NOT_FOUND', i_method_name,'PARTY_ID', i_tp_id);
1044 end if;
1045 end;
1046
1047 begin
1048 select root_element,
1049 fullpath
1050 into i_root_element,
1051 i_filename
1052 from ecx_objects eo
1053 where eo.map_id = i_map_id
1054 and eo.object_type in ('DTD','XML')
1055 and eo.object_id = 2;
1056 exception
1057 when others then
1058 ecx_debug.setErrorInfo(1, 30, 'ECX_ROOT_ELEMENT_NOT_FOUND', 'MAP_ID', i_map_id);
1059 if(l_unexpectedEnabled) then
1060 ecx_debug.log(l_unexpected,'ECX', 'ECX_ROOT_ELEMENT_NOT_FOUND',i_method_name, 'MAP_ID', i_map_id);
1061 end if;
1062 raise ecx_utils.program_exit;
1063 end;
1064
1065 /**
1066 Initialize Memory Structures Set the direction for the Transaction **/
1067 ecx_utils.g_direction :='OUT';
1068 ecx_utils.initialize(i_map_id,x_same_map);
1069
1070
1071 /**
1072 Find the Stack Variable.If Found set the value.
1073 **/
1074 i_variable_found := ecx_actions.find_stack_variable
1075 (
1076 'TRANSACTION_TYPE',
1077 i_stack_pos
1078 );
1079
1080 if (i_variable_found AND i_transaction_type is not null)
1081 then
1082 ecx_utils.g_stack(i_stack_pos).variable_value := i_transaction_type;
1083 end if;
1084
1085 i_variable_found := ecx_actions.find_stack_variable
1086 (
1087 'TRANSACTION_SUBTYPE',
1088 i_stack_pos
1089 );
1090
1091 if (i_variable_found AND i_transaction_subtype is not null)
1092 then
1093 ecx_utils.g_stack(i_stack_pos).variable_value := i_transaction_subtype;
1094 end if;
1095
1096
1097 i_variable_found := ecx_actions.find_stack_variable
1098 (
1099 'DOCUMENT_ID',
1100 i_stack_pos
1101 );
1102
1103 if (i_variable_found AND i_document_id is not null)
1104 then
1105 ecx_utils.g_stack(i_stack_pos).variable_value := i_document_id;
1106 end if;
1107
1108 i_variable_found := ecx_actions.find_stack_variable
1109 (
1110 'TP_ID',
1111 i_stack_pos
1112 );
1113
1114 if (i_variable_found AND i_tp_id is not null)
1115 then
1116 ecx_utils.g_stack(i_stack_pos).variable_value := i_tp_id;
1117 end if;
1118
1119 i_variable_found := ecx_actions.find_stack_variable
1120 (
1121 'TP_SITE_ID',
1122 i_stack_pos
1123 );
1124
1125 if (i_variable_found AND i_tp_site_id is not null)
1126 then
1127 ecx_utils.g_stack(i_stack_pos).variable_value := i_tp_site_id;
1128 end if;
1129
1130 i_variable_found := ecx_actions.find_stack_variable
1131 (
1132 'TP_TYPE',
1133 i_stack_pos
1134 );
1135
1136 if (i_variable_found AND i_tp_type is not null)
1137 then
1138 ecx_utils.g_stack(i_stack_pos).variable_value := i_tp_type;
1139 end if;
1140
1141 /* If the input wf_event_t object passed is null , the following loop raises an exception.
1142 so initialize the i_event_obj
1143 IF ( i_event_obj IS NULL ) THEN
1144 WF_EVENT_T.initialize(i_event_obj);
1145 END IF; */
1146
1147 -- Get the Parameter List from the Global Event Message Object. Iterate through it and populate the
1148 -- Global variables in the Engine Stack
1149 if i_parameterlist is not null
1150 then
1151 FOR counter in i_parameterList.FIRST..i_parameterList.LAST
1152 LOOP
1153 i_parameter := i_parameterList(counter);
1154 if i_parameter is not null
1155 then
1156 i_stack_param_name := i_parameter.getname();
1157 -- For backward Compatability , if the ECX_PARAMETER1..5 is passed changed it to
1158 -- PARAMETER1..5
1159 if i_stack_param_name = 'ECX_PARAMETER1'
1160 then
1161 i_stack_param_name := 'PARAMETER1';
1162
1163 elsif i_stack_param_name = 'ECX_PARAMETER2'
1164 then
1165 i_stack_param_name := 'PARAMETER2';
1166
1167 elsif i_stack_param_name = 'ECX_PARAMETER3'
1168 then
1169 i_stack_param_name := 'PARAMETER3';
1170
1171 elsif i_stack_param_name = 'ECX_PARAMETER4'
1172 then
1173 i_stack_param_name := 'PARAMETER4';
1174
1175 elsif i_stack_param_name = 'ECX_PARAMETER5'
1176 then
1177 i_stack_param_name := 'PARAMETER5';
1178 end if;
1179
1180 if ( i_stack_param_name is not null)
1181 then
1182 i_variable_found := ecx_actions.find_stack_variable
1183 (
1184 i_stack_param_name,
1185 i_stack_pos
1186 );
1187
1188 if (i_variable_found)
1189 then
1190 i_stack_param_value := i_parameter.getValue();
1191 /** Only overwrite the Global variable value if not null **/
1192 if i_stack_param_value is not null
1193 then
1194 ecx_utils.g_stack(i_stack_pos).variable_value
1195 := i_stack_param_value;
1196 end if;
1197 end if;
1198 end if;
1199 end if;
1200 END LOOP;
1201 end if;
1202 /* End of changes for bug 2120165 */
1203
1204 /**
1205 Should Avoid Parsing and Loading the Next Map if it is same as the previous one.
1206 **/
1207 if NOT (x_same_map)
1208 then
1209 ecx_utils.load_objects(i_map_id);
1210 end if;
1211
1212 if (ecx_utils.g_source_levels.count <> 0)
1213 then
1214 for i in ecx_utils.g_source_levels.first..ecx_utils.g_source_levels.last
1215 loop
1216 ecx_utils.g_source_levels(i).rows_processed := 0;
1217 end loop;
1218 end if;
1219 /**
1220 Initialize the temporary XML Buffer
1221 **/
1222 ecx_print_local.i_tmpxml.DELETE;
1223 ecx_print_local.l_node_stack.DELETE;
1224
1225 l_IANACharset := ECX_UTIL_API.getIANACharset();
1226 l_xmlDecl := 'version = "1.0" encoding= "'||l_IANAcharset||'" standalone="no"';
1227
1228 /** PI Node **/
1229 --ecx_print_local.pi_node('xml','version = "1.0" standalone="no" ');
1230 ecx_print_local.pi_node('xml',l_xmlDecl);
1231
1232 /** Comment Node **/
1233 ecx_print_local.comment_node('Oracle eXtensible Markup Language Gateway Server ');
1234
1235
1236 /** DOCUMENT NODE **/
1237 if (not ecx_utils.g_delete_doctype) then
1238 ecx_print_local.document_node(i_root_element,i_filename,null);
1239 if(l_statementEnabled) then
1240 ecx_debug.log(l_statement, 'Printed DOCTYPE', i_method_name);
1241 end if;
1242 end if;
1243
1244 fetch_data_from_view (0);
1245 popall;
1246 ecx_print_local.xmlPOPALL(i_xmldoc);
1247
1248 ecx_util_api.parseXML(ecx_utils.g_parser, i_xmldoc, l_parseXML, ecx_utils.g_xmldoc);
1249 if(l_statementEnabled) then
1250 ecx_debug.log(l_statement, 'Parsed XML', l_parseXML,i_method_name);
1251 end if;
1252
1253 -- Post-Processing for the Document on Target Side
1254 ecx_actions.execute_stage_data
1255 (
1256 30,
1257 0,
1258 'T'
1259 );
1260
1261 -- Post Processing for the Document on Source Side
1262 ecx_actions.execute_stage_data
1263 (
1264 30,
1265 0,
1266 'S'
1267 );
1268
1269 -- set the out variable to have the latest document.
1270 if l_parseXML then
1271 dbms_lob.trim(i_xmldoc, 0);
1272 xmlDOM.writetoCLOB(ecx_utils.g_xmldoc,i_xmldoc);
1273
1274 g_instlmode := wf_core.translate('WF_INSTALL');
1275
1276 if (l_statementEnabled)
1277 then
1278 IF g_instlmode = 'EMBEDDED' THEN
1279 fnd_message.set_name('ecx', 'XML File for logging');
1280 attachment_id := fnd_log.message_with_attachment(fnd_log.level_statement, substr(ecx_debug.g_aflog_module_name,1,length(ecx_debug.g_aflog_module_name)-4)||'.xml', TRUE);
1281 if(attachment_id <> -1 AND i_xmldoc is not null) then
1282 clength := dbms_lob.getlength(i_xmldoc);
1283 while clength >= offset LOOP
1284 ctemp := dbms_lob.substr(i_xmldoc,g_varmaxlength,offset);
1285 fnd_log_attachment.writeln(attachment_id, ctemp);
1286 offset := offset + g_varmaxlength;
1287 End Loop;
1288 fnd_log_attachment.close(attachment_id);
1289 end if;
1290 ELSE
1291 xmlDOM.writetofile(ecx_utils.g_xmldoc,ecx_utils.g_logdir||'/'||
1292 substr(ecx_utils.g_logfile,1,length(ecx_utils.g_logfile)-4)
1293 ||'.xml');
1294 END IF;
1295 end if;
1296 end if;
1297
1298 if(l_statementEnabled) then
1299 ecx_outbound.log_summary(l_statement);
1300
1301 ecx_debug.log(l_statement,'ECX','ECX_DOCUMENTS_PROCESSED',i_method_name,'NO_OF_DOCS',
1302 ecx_utils.g_source_levels(0).rows_processed);
1303 ecx_debug.log(l_statement,'ECX','ECX_FINISH_OUTBOUND',i_method_name,'MAP_ID',i_map_id);
1304 end if;
1305
1306 if not XMLDom.isNull(ecx_utils.g_xmldoc) then
1307 i_node_type := xmlDOM.getNodeType(ecx_utils.g_xmldoc);
1308 if (i_node_type = xmlDOM.DOCUMENT_NODE) then
1309 xmlDOM.freeDocument(xmlDOM.makeDocument(ecx_utils.g_xmldoc));
1310 else
1311 xmlDOM.freeDocFrag(xmlDOM.makeDocumentFragment(ecx_utils.g_xmldoc));
1312 end if;
1313 xmlparser.freeparser(ecx_utils.g_parser);
1314 end if;
1315 if (l_procedureEnabled) then
1316 ecx_debug.pop(i_method_name );
1317 end if;
1318
1319 EXCEPTION
1320 WHEN ecx_utils.PROGRAM_EXIT then
1321 if(l_unexpectedEnabled) then
1322 ecx_debug.log(l_unexpected, 'Clean-up i_stack, l_node_stack, i_tmpxml and last_printed',
1323 i_method_name);
1324 ecx_outbound.log_summary(l_unexpected);
1325 end if;
1326 i_stack.DELETE;
1327 ecx_print_local.i_tmpxml.DELETE;
1328 ecx_print_local.l_node_stack.DELETE;
1329 ecx_print_local.last_printed := -1;
1330 if (l_procedureEnabled) then
1331 ecx_debug.pop(i_method_name );
1332 end if;
1333 raise ecx_utils.program_exit;
1334 WHEN OTHERS THEN
1335 if(l_unexpectedEnabled) then
1336 ecx_debug.log(l_unexpected,'ECX','ECX_PROGRAM_ERROR',i_method_name,'PROGRESS_LEVEL',
1337 'ECX_OUTBOUND.PROCESS_OUTBOUND_DOCUMENTS');
1338 ecx_debug.log(l_unexpected,'ECX','ECX_ERROR_MESSAGE',i_method_name,'ERROR_MESSAGE',SQLERRM);
1339 ecx_outbound.log_summary(l_unexpected);
1340 end if;
1341 ecx_debug.setErrorInfo(2, 30, SQLERRM || ' - ECX_OUTBOUND.PROCESS_OUTBOUND_DOCUMENTS');
1342 if(l_unexpectedEnabled) then
1343 ecx_debug.log(l_unexpected, 'ECX', SQLERRM || ' - ECX_OUTBOUND.PROCESS_OUTBOUND_DOCUMENTS',i_method_name);
1344 ecx_debug.log(l_unexpected, 'Clean-up i_stack, l_node_stack, i_tmpxml and last_printed',i_method_name);
1345 end if;
1346 i_stack.DELETE;
1347 ecx_print_local.i_tmpxml.DELETE;
1348 ecx_print_local.l_node_stack.DELETE;
1349 ecx_print_local.last_printed := -1;
1350 if (l_procedureEnabled) then
1351 ecx_debug.pop(i_method_name );
1352 end if;
1353 raise ecx_utils.PROGRAM_EXIT;
1354 end process_outbound_documents;
1355
1356
1357 procedure putmsg
1358 (
1359 i_transaction_type IN varchar2,
1360 i_transaction_subtype IN varchar2,
1361 i_party_id IN varchar2,
1362 i_party_site_id IN varchar2,
1363 i_party_type IN varchar2,
1364 i_document_id IN varchar2,
1365 i_map_code IN varchar2,
1366 i_message_type IN varchar2,
1367 i_message_standard IN varchar2,
1368 i_ext_type IN varchar2,
1369 i_ext_subtype IN varchar2,
1370 i_destination_code IN varchar2,
1371 i_destination_type IN varchar2,
1372 i_destination_address IN varchar2,
1373 i_username IN varchar2,
1374 i_password IN varchar2,
1375 i_attribute1 IN varchar2,
1376 i_attribute2 IN varchar2,
1377 i_attribute3 IN varchar2,
1378 i_attribute4 IN varchar2,
1379 i_attribute5 IN varchar2,
1380 i_debug_level IN pls_integer,
1381 i_trigger_id IN number,
1382 i_msgid OUT NOCOPY raw
1383 )
1384 is
1385 i_method_name varchar2(2000) := 'ecx_outbound.putmsg';
1386 i_xmldoc CLOB;
1387 ecx_logging_enabled boolean := false;
1388 e_qtimeout exception;
1389 pragma exception_init(e_qtimeout,-25228);
1390 i_logdir varchar2(200);
1391 i_direct BOOLEAN := true;
1392
1393 /* Start changes for bug 2120165 */
1394 i_paramCount number;
1395 /* End of changes for bug 2120165 */
1396
1397 i_from_agt wf_agent_t := wf_agent_t(NULL, NULL);
1398 i_system varchar2(200);
1399
1400 cursor get_run_s
1401 is
1402 select ecx_output_runs_s.NEXTVAL
1403 from dual;
1404
1405 p_aflog_module_name VARCHAR2(2000) ;
1406
1407 begin
1408 --- Sets the Log Directory in both Standalone and the Embedded mode
1409 ecx_utils.getLogDirectory;
1410
1411 if ecx_utils.g_logfile is null
1412 then
1413 i_direct := false;
1414 -- Fetch the Run Id for the Transaction
1415 open get_run_s;
1416 fetch get_run_s
1417 into ecx_utils.g_run_id;
1418 close get_run_s;
1419
1420 ecx_utils.g_logfile :=i_message_standard||'OUT'||
1421 i_transaction_type||i_transaction_subtype||i_document_id||ecx_utils.g_run_id||'.log';
1422
1423 p_aflog_module_name := '';
1424 IF (i_message_standard is not null) THEN
1425 p_aflog_module_name := p_aflog_module_name||i_message_standard||'.';
1426 END IF;
1427 p_aflog_module_name := p_aflog_module_name || 'out.';
1428 IF (i_transaction_type is not null) THEN
1429 p_aflog_module_name := p_aflog_module_name||i_transaction_type||'.';
1430 END IF;
1431 IF (i_transaction_subtype is not null) THEN
1432 p_aflog_module_name := p_aflog_module_name||i_transaction_subtype||'.';
1433 END IF;
1434 IF (i_document_id is not null) THEN
1435 p_aflog_module_name := p_aflog_module_name||i_document_id||'.';
1436 END IF;
1437 IF (ecx_utils.g_run_id is not null) THEN
1438 p_aflog_module_name := p_aflog_module_name||ecx_utils.g_run_id;
1439 END IF;
1440 p_aflog_module_name := p_aflog_module_name||'.log';
1441
1442 ecx_debug.enable_debug_new(i_debug_level,ecx_utils.g_logdir,ecx_utils.g_logfile, p_aflog_module_name);
1443 end if;
1444
1445 -- Assign local variables with the ecx_debug global variables
1446 l_procedure := ecx_debug.g_procedure;
1447 l_statement := ecx_debug.g_statement;
1448 l_unexpected := ecx_debug.g_unexpected;
1449 l_procedureEnabled := ecx_debug.g_procedureEnabled;
1450 l_statementEnabled := ecx_debug.g_statementEnabled;
1451 l_unexpectedEnabled := ecx_debug.g_unexpectedEnabled;
1452
1453 if (l_procedureEnabled) then
1454 ecx_debug.push(i_method_name);
1455 end if;
1456
1457 if(l_statementEnabled) then
1458 ecx_debug.log(l_statement,'i_transaction_type',i_transaction_type,i_method_name );
1459 ecx_debug.log(l_statement,'i_transaction_subtype',i_transaction_subtype,i_method_name );
1460 ecx_debug.log(l_statement,'i_party_id',i_party_id,i_method_name );
1461 ecx_debug.log(l_statement,'i_party_site_id',i_party_site_id,i_method_name );
1462 ecx_debug.log(l_statement,'i_party_type',i_party_type,i_method_name );
1463 ecx_debug.log(l_statement,'i_document_id',i_document_id,i_method_name );
1464 ecx_debug.log(l_statement,'i_map_code',i_map_code,i_method_name );
1465 ecx_debug.log(l_statement,'i_message_type',i_message_type,i_method_name );
1466 ecx_debug.log(l_statement,'i_message_standard',i_message_standard,i_method_name );
1467 ecx_debug.log(l_statement,'i_ext_type',i_ext_type,i_method_name );
1468 ecx_debug.log(l_statement,'i_ext_subtype',i_ext_subtype,i_method_name );
1469 ecx_debug.log(l_statement,'i_destination_code',i_destination_code,i_method_name );
1470 ecx_debug.log(l_statement,'i_destination_address',i_destination_address,i_method_name );
1471 ecx_debug.log(l_statement,'i_destination_type',i_destination_type,i_method_name );
1472 ecx_debug.log(l_statement,'i_username',i_username,i_method_name );
1473 ecx_debug.log(l_statement,'i_password',i_password,i_method_name );
1474 ecx_debug.log(l_statement,'i_attribute1',i_attribute1,i_method_name );
1475 ecx_debug.log(l_statement,'i_attribute2',i_attribute2,i_method_name );
1476 ecx_debug.log(l_statement,'i_attribute3',i_attribute3,i_method_name );
1477 ecx_debug.log(l_statement,'i_attribute4',i_attribute4,i_method_name );
1478 ecx_debug.log(l_statement,'i_attribute5',i_attribute5,i_method_name );
1479 end if;
1480
1481 ecx_errorlog.outbound_engine
1482 (
1483 i_trigger_id,
1484 '10',
1485 'Processing message...',
1486 null,
1487 null,
1488 i_party_type
1489 );
1490
1491 process_outbound_documents
1492 (
1493 i_message_standard,
1494 i_transaction_type,
1495 i_transaction_subtype,
1496 i_party_id,
1497 i_party_site_id,
1498 i_party_type,
1499 i_document_id,
1500 i_map_code,
1501 i_xmldoc,
1502 i_message_type
1503 );
1504
1505 -- call ecx_out_wf_qh.enqueue with the correct parameters
1506 ecx_utils.g_event.addParameterToList('PARTY_TYPE', i_party_type);
1507 ecx_utils.g_event.addParameterToList('PARTYID', i_destination_code);
1508 ecx_utils.g_event.addParameterToList('PARTY_SITE_ID', i_destination_code);
1509 ecx_utils.g_event.addParameterToList('DOCUMENT_NUMBER', ecx_utils.g_document_id);
1510 ecx_utils.g_event.addParameterToList('MESSAGE_TYPE', i_message_type);
1511 ecx_utils.g_event.addParameterToList('MESSAGE_STANDARD', i_message_standard);
1512 ecx_utils.g_event.addParameterToList('TRANSACTION_TYPE', i_ext_type);
1513 ecx_utils.g_event.addParameterToList('TRANSACTION_SUBTYPE', i_ext_subtype);
1514 ecx_utils.g_event.addParameterToList('PROTOCOL_TYPE', i_destination_type);
1515 ecx_utils.g_event.addParameterToList('PROTOCOL_ADDRESS', i_destination_address);
1516 ecx_utils.g_event.addParameterToList('USERNAME', i_username);
1517 ecx_utils.g_event.addParameterToList('PASSWORD', i_password);
1518 ecx_utils.g_event.addParameterToList('ATTRIBUTE1', i_attribute1);
1519 ecx_utils.g_event.addParameterToList('ATTRIBUTE2', i_attribute2);
1520 ecx_utils.g_event.addParameterToList('ATTRIBUTE3', i_attribute3);
1521 ecx_utils.g_event.addParameterToList('ATTRIBUTE4', i_attribute4);
1522 ecx_utils.g_event.addParameterToList('ATTRIBUTE5', i_attribute5);
1523 ecx_utils.g_event.addParameterToList('TRIGGER_ID', i_trigger_id);
1524 ecx_utils.g_event.addParameterToList('LOGFILE', ecx_utils.g_logfile);
1525 ecx_utils.g_event.addParameterToList('ITEM_TYPE', ecx_utils.g_item_type);
1526 ecx_utils.g_event.addParameterToList('ITEM_KEY', ecx_utils.g_item_key);
1527 ecx_utils.g_event.addParameterToList('ACTIVITY_ID', ecx_utils.g_activity_id);
1528 ecx_utils.g_event.addParameterToList('EVENT_NAME', ecx_utils.g_event.event_name);
1529 ecx_utils.g_event.addParameterToList('EVENT_KEY', ecx_utils.g_event.event_key);
1530 ecx_utils.g_event.event_data := i_xmldoc;
1531
1532 -- set the from agent
1533 select name
1534 into i_system
1535 from wf_systems
1536 where guid = wf_core.translate('WF_SYSTEM_GUID');
1537
1538 -- set default outbound agents based on protocol_type
1539 if (upper(i_destination_type) = 'SOAP') then
1540 i_from_agt.setname('WF_WS_JMS_OUT');
1541
1542 -- set default Web Services related attributes
1543 ecx_utils.g_event.addParameterToList('WS_SERVICE_NAMESPACE',
1544 'urn:defaultSoapMessaging');
1545 ecx_utils.g_event.addParameterToList('WS_PORT_OPERATION',
1546 'ReceiveDocument');
1547 ecx_utils.g_event.addParameterToList('WS_HEADER_IMPL_CLASS',
1548 'oracle.apps.fnd.wf.ws.client.DefaultHeaderGenerator');
1549 ecx_utils.g_event.addParameterToList('WS_RESPONSE_IMPL_CLASS',
1550 'oracle.apps.fnd.wf.ws.client.WfWsResponse');
1551 ecx_utils.g_event.addParameterToList('WS_CONSUMER', 'ecx');
1552
1553 else
1554
1555 if (upper(i_destination_type) = 'JMS') then
1556 if(i_destination_address is null) then
1557 i_from_agt.setname('WF_JMS_OUT');
1558 else
1559 i_from_agt.setname(i_destination_address);
1560 end if;
1561 else
1562 i_from_agt.setname('ECX_OUTBOUND');
1563 end if;
1564
1565 end if;
1566 i_from_agt.setsystem(i_system);
1567 ecx_utils.g_event.setFromAgent(i_from_agt);
1568
1569 if(l_statementEnabled) then
1570 ecx_debug.log(l_statement, 'Calling WF_EVENT.Send for Enqueue', i_method_name);
1571 end if;
1572 wf_event.send(ecx_utils.g_event);
1573 ecx_errorlog.outbound_log(ecx_utils.g_event);
1574
1575 if (upper(i_destination_type) = 'SOAP') or
1576 (upper(i_destination_type) = 'JMS') then
1577 i_msgid := wf_event.g_msgid; -- JMS QH store enqueue msgid in wf_event.g_msgid
1578 else
1579 i_msgid := ecx_out_wf_qh.msgid;
1580 end if;
1581
1582 -- check the retcode and retmsg. This should be populated here only
1583 -- in the case of dup val index when inserting in doclogs (since no
1584 -- exception is raised in this case)
1585 if (ecx_out_wf_qh.retmsg is not null) then
1586 ecx_debug.setErrorInfo(ecx_out_wf_qh.retcode, 30, ecx_out_wf_qh.retmsg);
1587 if(l_unexpectedEnabled) then
1588 ecx_debug.log(l_unexpected, ecx_utils.i_errbuf,i_method_name);
1589 end if;
1590 end if;
1591
1592 if dbms_lob.istemporary(i_xmldoc) = 1 then
1593 dbms_lob.freetemporary(i_xmldoc);
1594 end if;
1595
1596 if(l_statementEnabled) then
1597 ecx_debug.log(l_statement,'msgid',i_msgid,i_method_name);
1598 end if;
1599 if (l_procedureEnabled) then
1600 ecx_debug.pop(i_method_name);
1601 end if;
1602
1603 if NOT ( i_direct )
1604 then
1605 ecx_debug.print_log;
1606 ecx_debug.disable_debug;
1607 ecx_utils.g_logfile:=null;
1608 end if;
1609
1610 EXCEPTION
1611 WHEN ecx_utils.PROGRAM_EXIT then
1612 if dbms_lob.istemporary(i_xmldoc) = 1 then
1613 dbms_lob.freetemporary(i_xmldoc);
1614 end if;
1615 if (l_procedureEnabled) then
1616 ecx_debug.pop(i_method_name);
1617 end if;
1618 if NOT ( i_direct )
1619 then
1620 ecx_debug.print_log;
1621 ecx_debug.disable_debug;
1622 ecx_utils.g_logfile:=null;
1623
1624 ecx_errorlog.outbound_engine
1625 (
1626 i_trigger_id,
1627 ecx_utils.i_ret_code,
1628 ecx_utils.i_errbuf,
1629 i_msgid,
1630 null,
1631 i_party_type
1632 );
1633
1634 else
1635 raise ecx_utils.program_exit;
1636 end if;
1637
1638 WHEN OTHERS THEN
1639 if (ecx_out_wf_qh.retmsg is null AND ecx_out_wf_qh.retcode = 0)
1640 then
1641 ecx_debug.setErrorInfo(2, 30, SQLERRM);
1642 if(l_unexpectedEnabled) then
1643 ecx_debug.log(l_unexpected, 'ECX', SQLERRM,i_method_name);
1644 end if;
1645 else
1646 ecx_debug.setErrorInfo(ecx_out_wf_qh.retcode, 30, ecx_out_wf_qh.retmsg);
1647 if(l_unexpectedEnabled) then
1648 ecx_debug.log(l_unexpected, 'msg and code set in queue handler',i_method_name);
1649 ecx_debug.log(l_unexpected,ecx_utils.i_errbuf,i_method_name);
1650 end if;
1651 end if;
1652
1653 if dbms_lob.istemporary(i_xmldoc) = 1 then
1654 dbms_lob.freetemporary(i_xmldoc);
1655 end if;
1656
1657 if (l_procedureEnabled) then
1658 ecx_debug.pop(i_method_name);
1659 end if;
1660 if NOT ( i_direct )
1661 then
1662 IF (ecx_logging_enabled ) THEN
1663 ecx_debug.print_log;
1664 ecx_debug.disable_debug;
1665 ecx_utils.g_logfile:=null;
1666 END IF;
1667 ecx_errorlog.outbound_engine
1668 (
1669 i_trigger_id,
1670 ecx_utils.i_ret_code,
1671 ecx_utils.i_errbuf,
1672 i_msgid,
1673 null,
1674 i_party_type
1675 );
1676 else
1677 raise ecx_utils.program_exit;
1678 end if;
1679
1680 end putmsg;
1681
1682 /* Wrapper procedure for backward comaptibilty */
1683 procedure putmsg
1684 (
1685 i_transaction_type IN varchar2,
1686 i_transaction_subtype IN varchar2,
1687 i_party_id IN varchar2,
1688 i_party_site_id IN varchar2,
1689 i_party_type IN varchar2,
1690 i_document_id IN varchar2,
1691 i_parameter1 IN varchar2,
1692 i_parameter2 IN varchar2,
1693 i_parameter3 IN varchar2,
1694 i_parameter4 IN varchar2,
1695 i_parameter5 IN varchar2,
1696 i_map_code IN varchar2,
1697 i_message_type IN varchar2,
1698 i_message_standard IN varchar2,
1699 i_ext_type IN varchar2,
1700 i_ext_subtype IN varchar2,
1701 i_destination_code IN varchar2,
1702 i_destination_type IN varchar2,
1703 i_destination_address IN varchar2,
1704 i_username IN varchar2,
1705 i_password IN varchar2,
1706 i_attribute1 IN varchar2,
1707 i_attribute2 IN varchar2,
1708 i_attribute3 IN varchar2,
1709 i_attribute4 IN varchar2,
1710 i_attribute5 IN varchar2,
1711 i_debug_level IN pls_integer,
1712 i_trigger_id IN number,
1713 i_msgid OUT NOCOPY raw
1714 ) as
1715
1716
1717 i_method_name varchar2(2000) := 'ecx_outbound.putmsg';
1718
1719 -- logging enabled
1720 ecx_logging_enabled boolean := false;
1721 logging_enabled varchar2(20);
1722 module varchar2(2000);
1723
1724 begin
1725 --To populate the global variable ecx_debug.g_v_module_name , need to call ecx_debug.module_enabled
1726 ecx_debug.g_v_module_name := 'ecx.plsql.';
1727 ecx_debug.module_enabled(i_message_standard,i_transaction_type,i_transaction_subtype,i_document_id);
1728 fnd_profile.get('AFLOG_ENABLED',logging_enabled);
1729 fnd_profile.get('AFLOG_MODULE',module);
1730 if(logging_enabled = 'Y' AND ((lower(module) like 'ecx%'
1731 AND instr(lower(ecx_debug.g_v_module_name),rtrim(lower(module),'%'))> 0)
1732 OR module='%')
1733 AND FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) then
1734 ecx_logging_enabled := true;
1735 end if;
1736 -- /logging enabled
1737
1738 /**
1739 Populate the Parameters in the global event Object .if it is null ,
1740 initialize and create a new Instance and populate the variables
1741 **/
1742
1743 if ecx_utils.g_event is null
1744 then
1745 wf_event_t.initialize(ecx_utils.g_event);
1746
1747 end if;
1748
1749 /* Add the above Parameters to the Global Event Message Object
1750 For backward compatability */
1751
1752 ecx_utils.g_event.addparametertolist('PARAMETER1',i_parameter1);
1753 ecx_utils.g_event.addparametertolist('PARAMETER2',i_parameter2);
1754 ecx_utils.g_event.addparametertolist('PARAMETER3',i_parameter3);
1755 ecx_utils.g_event.addparametertolist('PARAMETER4',i_parameter4);
1756 ecx_utils.g_event.addparametertolist('PARAMETER5',i_parameter5);
1757
1758 putmsg( i_transaction_type ,
1759 i_transaction_subtype ,
1760 i_party_id ,
1761 i_party_site_id ,
1762 i_party_type ,
1763 i_document_id ,
1764 i_map_code ,
1765 i_message_type ,
1766 i_message_standard ,
1767 i_ext_type ,
1768 i_ext_subtype ,
1769 i_destination_code ,
1770 i_destination_type ,
1771 i_destination_address ,
1772 i_username ,
1773 i_password ,
1774 i_attribute1 ,
1775 i_attribute2 ,
1776 i_attribute3 ,
1777 i_attribute4 ,
1778 i_attribute5 ,
1779 i_debug_level ,
1780 i_trigger_id ,
1781 i_msgid );
1782 Exception
1783 WHEN OTHERS THEN
1784 ecx_debug.setErrorInfo(2, 30, SQLERRM || ' - ECX_OUTBOUND.putmsg ');
1785 if(l_unexpectedEnabled) then
1786 ecx_debug.log(l_unexpected,'ECX', SQLERRM || ' - ECX_OUTBOUND.putmsg ',
1787 i_method_name);
1788 end if;
1789 raise ecx_utils.PROGRAM_EXIT;
1790 end putmsg;
1791
1792 procedure GETXML
1793 (
1794 i_message_standard IN varchar2,
1795 i_transaction_type IN varchar2,
1796 i_transaction_subtype IN varchar2,
1797 i_tp_id IN varchar2,
1798 i_tp_site_id IN varchar2,
1799 i_tp_type In varchar2,
1800 i_document_id IN varchar2,
1801 i_map_code IN varchar2,
1802 i_debug_level IN pls_integer,
1803 i_xmldoc IN OUT NOCOPY clob,
1804 i_ret_code OUT NOCOPY pls_integer,
1805 i_errbuf OUT NOCOPY varchar2,
1806 i_log_file OUT NOCOPY varchar2,
1807 i_message_type IN VARCHAR2 default 'XML'
1808 )
1809 is
1810 i_method_name varchar2(2000) := 'ecx_outbound.getxml';
1811 /* Start changes for Bug 2120165 */
1812 i_paramCount number;
1813 /* End of changes for bug 2120165 */
1814 cursor get_run_s
1815 is
1816 select ecx_output_runs_s.NEXTVAL
1817 from dual;
1818
1819 i_logdir varchar2(200);
1820 i_tmpxmldoc CLOB;
1821 p_aflog_module_name VARCHAR2(2000) ;
1822 g_instlmode VARCHAR2(100);
1823
1824 ecx_logging_enabled boolean := false;
1825 logging_enabled varchar2(20);
1826 module varchar2(2000);
1827
1828 begin
1829 --To populate the global variable ecx_debug.g_v_module_name , need to call ecx_debug.module_enabled
1830 ecx_debug.g_v_module_name := 'ecx.plsql.';
1831 ecx_debug.module_enabled(i_message_standard,i_transaction_type,i_transaction_subtype,i_document_id);
1832
1833 g_instlmode := wf_core.translate('WF_INSTALL');
1834
1835 if(g_instlmode = 'EMBEDDED')
1836 then
1837 fnd_profile.get('AFLOG_ENABLED',logging_enabled);
1838 fnd_profile.get('AFLOG_MODULE',module);
1839 if(logging_enabled = 'Y' AND ((lower(module) like 'ecx%'
1840 AND instr(lower(ecx_debug.g_v_module_name),rtrim(lower(module),'%'))> 0)
1841 OR module='%')
1842 AND FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) then
1843 ecx_logging_enabled := true;
1844 end if;
1845 elsif(g_instlmode = 'STANDALONE')
1846 then
1847 if (i_debug_level > 0) then
1848 ecx_logging_enabled := true;
1849 end if;
1850 end if;
1851
1852 IF (ecx_logging_enabled ) THEN
1853 --- Sets the Log Directory in both Standalone and the Embedded mode
1854 ecx_utils.getLogDirectory;
1855
1856 /** Fetch the Run Id for the Transaction **/
1857 open get_run_s;
1858 fetch get_run_s
1859 into ecx_utils.g_run_id;
1860 close get_run_s;
1861
1862 ecx_utils.g_logfile :=i_message_standard||'OUT'||
1863 i_transaction_type||i_transaction_subtype||i_document_id||ecx_utils.g_run_id||'.log';
1864
1865 p_aflog_module_name := '';
1866 IF (i_message_standard is not null) THEN
1867 p_aflog_module_name := p_aflog_module_name||i_message_standard||'.';
1868 END IF;
1869 p_aflog_module_name := p_aflog_module_name || 'out.';
1870 IF (i_transaction_type is not null) THEN
1871 p_aflog_module_name := p_aflog_module_name||i_transaction_type||'.';
1872 END IF;
1873 IF (i_transaction_subtype is not null) THEN
1874 p_aflog_module_name := p_aflog_module_name||i_transaction_subtype||'.';
1875 END IF;
1876 IF (i_document_id is not null) THEN
1877 p_aflog_module_name := p_aflog_module_name||i_document_id||'.';
1878 END IF;
1879 IF (ecx_utils.g_run_id is not null) THEN
1880 p_aflog_module_name := p_aflog_module_name||ecx_utils.g_run_id;
1881 END IF;
1882 p_aflog_module_name := p_aflog_module_name||'.log';
1883 ecx_debug.enable_debug_new(i_debug_level,ecx_utils.g_logdir,ecx_utils.g_logfile, p_aflog_module_name);
1884 END IF;
1885
1886 IF g_instlmode = 'EMBEDDED' THEN
1887 IF (ecx_logging_enabled ) THEN
1888 i_log_file := ecx_debug.g_sqlprefix || p_aflog_module_name;
1889 ELSE
1890 i_log_file := 'Please ensure that FND-Logging is enabled for module '||ecx_debug.g_sqlprefix||'%';
1891 END IF;
1892 ELSE
1893 if (ecx_logging_enabled) then
1894 i_log_file := ecx_utils.g_logdir||ecx_utils.getFileSeparator()||ecx_utils.g_logfile;
1895 else
1896 i_log_file := 'Please ensure that logging is enabled';
1897 end if;
1898 END IF;
1899
1900 /* Assign local variables with the ecx_debug global variables*/
1901 l_procedure := ecx_debug.g_procedure;
1902 l_statement := ecx_debug.g_statement;
1903 l_unexpected := ecx_debug.g_unexpected;
1904 l_procedureEnabled := ecx_debug.g_procedureEnabled;
1905 l_statementEnabled := ecx_debug.g_statementEnabled;
1906 l_unexpectedEnabled := ecx_debug.g_unexpectedEnabled;
1907
1908 if (l_procedureEnabled) then
1909 ecx_debug.push(i_method_name);
1910 end if;
1911
1912 if(l_statementEnabled) then
1913 ecx_debug.log(l_statement,'i_transaction_type',i_transaction_type,i_method_name );
1914 ecx_debug.log(l_statement,'i_transaction_subtype',i_transaction_subtype,i_method_name );
1915 ecx_debug.log(l_statement,'i_tp_id',i_tp_id,i_method_name );
1916 ecx_debug.log(l_statement,'i_tp_site_id',i_tp_site_id,i_method_name );
1917 ecx_debug.log(l_statement,'i_tp_type',i_tp_type,i_method_name );
1918 ecx_debug.log(l_statement,'i_document_id',i_document_id,i_method_name );
1919 ecx_debug.log(l_statement,'i_map_code',i_map_code,i_method_name );
1920 end if;
1921 -- initialize i_tmpxmldoc
1922 dbms_lob.createtemporary(i_tmpxmldoc,TRUE,DBMS_LOB.SESSION);
1923
1924 process_outbound_documents
1925 (
1926 i_message_standard,
1927 i_transaction_type,
1928 i_transaction_subtype,
1929 i_tp_id,
1930 i_tp_site_id,
1931 i_tp_type,
1932 i_document_id,
1933 i_map_code,
1934 i_tmpxmldoc
1935 );
1936 -- assign i_tmpxmldoc to the return variable
1937 i_xmldoc := i_tmpxmldoc;
1938
1939 -- free i_tmpxmldoc
1940 if i_tmpxmldoc is not null
1941 then
1942 dbms_lob.freetemporary (i_tmpxmldoc);
1943 end if;
1944 ecx_debug.setErrorInfo(0, 10, 'ECX_SUCCESSFUL_EXECUTION');
1945 i_ret_code := ecx_utils.i_ret_code;
1946 i_errbuf := ecx_utils.i_errbuf;
1947
1948 if(ecx_utils.i_ret_code = 0 ) then
1949 if(l_statementEnabled) then
1950 ecx_debug.log(l_statement, 'Ret Code',ecx_utils.i_ret_code,i_method_name);
1951 ecx_debug.log(l_statement, 'Ret Msg ',ecx_utils.i_errbuf,i_method_name);
1952 end if;
1953 else
1954 if(l_unexpectedEnabled) then
1955 ecx_debug.log(l_unexpected, 'Ret Code',ecx_utils.i_ret_code,i_method_name);
1956 ecx_debug.log(l_unexpected, 'Ret Msg ',ecx_utils.i_errbuf,i_method_name);
1957 end if;
1958 end if;
1959
1960 if(l_procedureEnabled) then
1961 ecx_debug.pop(i_method_name);
1962 end if;
1963 IF (ecx_logging_enabled ) THEN
1964 ecx_debug.print_log;
1965 ecx_debug.disable_debug;
1966 END IF;
1967 EXCEPTION
1968 WHEN ecx_utils.program_exit THEN
1969 i_ret_code := ecx_utils.i_ret_code;
1970 i_errbuf := ecx_utils.i_errbuf;
1971 if(l_unexpectedEnabled) then
1972 ecx_debug.log(l_unexpected,ecx_utils.i_errbuf,i_method_name);
1973 end if;
1974 if(l_procedureEnabled) then
1975 ecx_debug.pop(i_method_name);
1976 end if;
1977 -- free i_tmpxmldoc
1978 if i_tmpxmldoc is not null
1979 then
1980 dbms_lob.freetemporary (i_tmpxmldoc);
1981 end if;
1982 IF (ecx_logging_enabled ) THEN
1983 ecx_debug.print_log;
1984 ecx_debug.disable_debug;
1985 END IF;
1986 WHEN OTHERS THEN
1987 ecx_debug.setErrorInfo(2, 30, SQLERRM || ' - ECX_OUTBOUND.PUTMSG');
1988 if(l_unexpectedEnabled) then
1989 ecx_debug.log(l_unexpected,'ECX', SQLERRM || ' - ECX_OUTBOUND.PUTMSG',i_method_name);
1990 end if;
1991 i_ret_code := ecx_utils.i_ret_code;
1992 i_errbuf := ecx_utils.i_errbuf;
1993 if(l_procedureEnabled) then
1994 ecx_debug.pop(i_method_name);
1995 end if;
1996 -- free i_tmpxmldoc
1997 if i_tmpxmldoc is not null
1998 then
1999 dbms_lob.freetemporary (i_tmpxmldoc);
2000 end if;
2001 IF (ecx_logging_enabled ) THEN
2002 ecx_debug.print_log;
2003 ecx_debug.disable_debug;
2004 END IF;
2005 end GETXML;
2006
2007 end ecx_outbound;