[Home] [Help]
PACKAGE BODY: APPS.ECX_INBOUND_TRIG
Source
1 package body ecx_inbound_trig as
2 -- $Header: ECXINBTB.pls 120.20.12020000.5 2013/04/30 18:17:07 jmaddila 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 attribute_rec is RECORD
12 (
13 attribute_name varchar2(256),
14 element_tag_name varchar2(256),
15 value varchar2(4000)
16 );
17
18 TYPE attr_tbl is TABLE of attribute_rec index by BINARY_INTEGER;
19 /** Define the local variable for storing the attributes with the values **/
20 i_attr_rec attr_tbl;
21
22
23 function is_routing_supported
24 (
25 p_map_id IN pls_integer
26 ) return boolean is
27
28 l_tar_obj_type Varchar2(200);
29 i_method_name varchar2(2000):='ecx_inbound_trig.is_routing_supported';
30
31 begin
32 SELECT object_type
33 INTO l_tar_obj_type
34 FROM ecx_objects
35 WHERE map_id = p_map_id
36 AND object_id = 2;
37
38 if (l_tar_obj_type = 'DB') then
39 return false;
40 else
41 return true;
42 end if;
43
44 exception
45 when others then
46 ecx_debug.setErrorInfo(2, 30,
47 SQLERRM||' - ECX_INBOUND_TRIG.IS_ROUTING_SUPPORTED');
48 if(l_unexpectedEnabled) then
49 --ecx_debug.log(l_statement, ecx_utils.i_errbuf, i_method_name);
50 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
51 end if;
52 raise ecx_utils.program_exit;
53 end is_routing_supported;
54
55
56 procedure get_element_value
57 (
58 i_doc IN xmlDOM.DOMDocument,
59 i_element IN varchar2,
60 i_value OUT NOCOPY varchar2
61 )
62 is
63
64
65 i_method_name varchar2(2000) := 'ecx_inbound_trig.get_element_value';
66 nl xmlDOM.DOMNodeList := null;
67 n pls_integer;
68 pnode xmlDOM.DOMNode;
69 cnode xmlDOM.DOMNode;
70 begin
71 if (l_procedureEnabled) then
72 ecx_debug.push(i_method_name);
73 end if;
74 if(l_statementEnabled) then
75 ecx_debug.log(l_statement,'i_doc',i_doc.id,i_method_name);
76 ecx_debug.log(l_statement,'i_element',i_element,i_method_name);
77 end if;
78 nl := xmlDOM.getElementsByTagName(i_doc,i_element);
79
80 if (not xmlDOM.isNull(nl))
81 then
82 n := xmlDOM.getLength(nl);
83 if n > 0
84 then
85 pnode := xmlDOM.item(nl,0);
86 cnode := xmlDOM.getFirstChild(pnode);
87 if (not xmlDOM.isNull(cnode))
88 then
89 i_value := xmlDOM.getNodeValue(cnode);
90 end if;
91 end if;
92 end if;
93 if(l_statementEnabled) then
94 ecx_debug.log(l_statement,'i_value',i_value,i_method_name);
95 end if;
96 if (l_procedureEnabled) then
97 ecx_debug.pop(i_method_name);
98 end if;
99 exception
100 when others then
101 ecx_debug.setErrorInfo(2,30,
102 SQLERRM ||' - ECX_INBOUND_TRIG.GET_ELEMENT_VALUE');
103 if(l_unexpectedEnabled) then
104 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
105 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
106 end if;
107 raise ecx_utils.program_exit;
108 end get_element_value;
109
110 procedure getAttributes
111 (
112 i_standard_code in varchar2,
113 i_doc IN xmlDOM.DOMDocument,
114 i_standard_type in varchar2
115 )
116 is
117
118 i_method_name varchar2(2000) := 'ecx_inbound_trig.get_element_value';
119 cursor get_attributes
120 (
121 p_standard_code IN varchar2,
122 p_standard_type IN varchar2
123 )
124 is
125 select attribute_name,
126 element_tag_name
127 from ecx_standard_attributes esa,
128 ecx_standards es
129 where es.standard_code = p_standard_code
130 and es.standard_type = nvl(p_standard_type, 'XML')
131 and esa.standard_id = es.standard_id;
132
133 i_string varchar2(2000) := ' update ecx_doclogs set ';
134
135 i_value varchar2(2000);
136
137 i_single varchar2(3):= '''';
138 begin
139 if (l_procedureEnabled) then
140 ecx_debug.push(i_method_name);
141 end if;
142 if(l_statementEnabled) then
143 ecx_debug.log(l_statement,'i_standard_code',i_standard_code,i_method_name);
144 end if;
145
146 if i_standard_code is null
147 then
148 if (l_procedureEnabled) then
149 ecx_debug.pop(i_method_name);
150 end if;
151 return;
152 end if;
153 /** Initialize the attr table **/
154 i_attr_rec.DELETE;
155
156 /** Get all the Attributes and capture the value **/
157 for c1 in get_Attributes(p_standard_code=>i_standard_code, p_standard_type =>i_standard_type)
158 loop
159 if ( c1.attribute_name is not null and c1.element_tag_name is not null)
160 then
161 i_attr_rec(i_attr_rec.COUNT + 1).attribute_name := c1.attribute_name;
162 i_attr_rec(i_attr_rec.COUNT).element_tag_name := c1.element_tag_name;
163
164 /** Search for the attribute in the XML File **/
165 get_element_value(i_doc,c1.element_tag_name,i_attr_rec(i_attr_rec.COUNT).value);
166 if(l_statementEnabled) then
167 ecx_debug.log(l_statement,i_attr_rec(i_attr_rec.COUNT).attribute_name,
168 i_attr_rec(i_attr_rec.COUNT).value,i_method_name);
169 end if;
170 i_string := i_string ||' '||i_attr_rec(i_attr_rec.COUNT).attribute_name || ' = '||
171 i_single||i_attr_rec(i_attr_rec.COUNT).value || i_single||' ,';
172 end if;
173 end loop;
174
175 /** remove the last , and put the statement for the where clause **/
176 i_string := substr(i_string,1,length(i_string)-1);
177 i_string := i_string || ' where msgid = '||i_single||ecx_utils.g_msgid||i_single;
178
179 if i_attr_rec.count > 0
180 then
181 if(l_statementEnabled) then
182 ecx_debug.log(l_statement,'i_string',i_string,i_method_name);
183 end if;
184 execute immediate i_string;
185 end if;
186 if (l_procedureEnabled) then
187 ecx_debug.pop(i_method_name);
188 end if;
189 exception
190 when others then
191 ecx_debug.setErrorInfo(2,30,SQLERRM ||' - ECX_INBOUND_TRIG.getAttributes');
192 if(l_unexpectedEnabled) then
193 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
194 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
195 end if;
196 raise ecx_utils.program_exit;
197 end getAttributes;
198
199 /**
200 For BES - removed send_error
201 **/
202
203 procedure parsepayload
204 (
205 i_payload IN CLOB
206 )
207 is
208
209 i_method_name varchar2(2000) := 'ecx_inbound_trig.parsepayload';
210 begin
211 if (l_procedureEnabled) then
212 ecx_debug.push(i_method_name);
213 end if;
214 xmlparser.parseCLOB(ecx_utils.g_parser,i_payload);
215 if (l_procedureEnabled) then
216 ecx_debug.pop(i_method_name);
217 end if;
218 exception
219 -- Put All DOM Parser Exceptions Here.
220 when xmlDOM.INDEX_SIZE_ERR then
221 ecx_debug.setErrorInfo(1,20,SQLERRM);
222 if(l_unexpectedEnabled) then
223 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
224 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
225 end if;
226 if (l_procedureEnabled) then
227 ecx_debug.pop(i_method_name);
228 end if;
229 raise ecx_utils.program_exit;
230 when xmlDOM.DOMSTRING_SIZE_ERR then
231 ecx_debug.setErrorInfo(1,20,SQLERRM);
232 if(l_unexpectedEnabled) then
233 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
234 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
235 end if;
236 if (l_procedureEnabled) then
237 ecx_debug.pop(i_method_name);
238 end if;
239 raise ecx_utils.program_exit;
240 when xmlDOM.HIERARCHY_REQUEST_ERR then
241 ecx_debug.setErrorInfo(1,20,SQLERRM);
242 if(l_unexpectedEnabled) then
243 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
244 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
245 end if;
246 if (l_procedureEnabled) then
247 ecx_debug.pop(i_method_name);
248 end if;
249 raise ecx_utils.program_exit;
250 when xmlDOM.WRONG_DOCUMENT_ERR then
251 ecx_debug.setErrorInfo(1,20,SQLERRM);
252 if(l_unexpectedEnabled) then
253 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
254 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
255 end if;
256 if (l_procedureEnabled) then
257 ecx_debug.pop(i_method_name);
258 end if;
259 raise ecx_utils.program_exit;
260 when xmlDOM.INVALID_CHARACTER_ERR then
261 ecx_debug.setErrorInfo(1,20,SQLERRM);
262 if(l_unexpectedEnabled) then
263 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
264 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
265 end if;
266 if (l_procedureEnabled) then
267 ecx_debug.pop(i_method_name);
268 end if;
269 raise ecx_utils.program_exit;
270 when xmlDOM.NO_DATA_ALLOWED_ERR then
271 ecx_debug.setErrorInfo(1,20,SQLERRM);
272 if(l_unexpectedEnabled) then
273 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
274 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
275 end if;
276 if (l_procedureEnabled) then
277 ecx_debug.pop(i_method_name);
278 end if;
279 raise ecx_utils.program_exit;
280 when xmlDOM.No_MODIFICATION_ALLOWED_ERR then
281 ecx_debug.setErrorInfo(1,20,SQLERRM);
282 if(l_unexpectedEnabled) then
283 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
284 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
285 end if;
286 if (l_procedureEnabled) then
287 ecx_debug.pop(i_method_name);
288 end if;
289 raise ecx_utils.program_exit;
290 when xmlDOM.NOT_FOUND_ERR then
291 ecx_debug.setErrorInfo(1,20,SQLERRM);
292 if(l_unexpectedEnabled) then
293 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
294 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
295 end if;
296 if (l_procedureEnabled) then
297 ecx_debug.pop(i_method_name);
298 end if;
299 raise ecx_utils.program_exit;
300 when xmlDOM.NOT_SUPPORTED_ERR then
301 ecx_debug.setErrorInfo(1,20,SQLERRM);
302 if(l_unexpectedEnabled) then
303 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
304 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
305 end if;
306 if (l_procedureEnabled) then
307 ecx_debug.pop(i_method_name);
308 end if;
309 raise ecx_utils.program_exit;
310 when xmlDOM.INUSE_ATTRIBUTE_ERR then
311 ecx_debug.setErrorInfo(1,20,SQLERRM);
312 if(l_unexpectedEnabled) then
313 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
314 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
315 end if;
316 if (l_procedureEnabled) then
317 ecx_debug.pop(i_method_name);
318 end if;
319 raise ecx_utils.program_exit;
320 when others then
321 ecx_debug.setErrorInfo(1,20,SQLERRM||' - ECX_INBOUND_TRIG.PARSEPAYLOAD ');
322 if(l_unexpectedEnabled) then
323 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
324 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
325 end if;
326 if (l_procedureEnabled) then
327 ecx_debug.pop(i_method_name);
328 end if;
329 raise ecx_utils.program_exit;
330 end parsepayload;
331
332
333 /**
334 Writes the XML from the CLOB to the file system
335 **/
336 procedure writeXMLToFile
337 (
338 i_xmldoc IN OUT NOCOPY CLOB
339 )
340 is
341 i_method_name varchar2(2000) := 'ecx_inbound_trig.writexmltofile';
342 i_logdir varchar2(200);
343
344 attachment_id pls_integer;
345 ctemp varchar2(32767);
346 clength pls_integer;
347 offset pls_integer := 1;
348 g_varmaxlength pls_integer := 1999;
349 g_instlmode VARCHAR2(100);
350
351 begin
352 g_instlmode := wf_core.translate('WF_INSTALL');
353 if (l_procedureEnabled) then
354 ecx_debug.push(i_method_name);
355 end if;
356 dbms_lob.createtemporary(i_xmldoc, TRUE,DBMS_LOB.SESSION);
357 dbms_lob.trim(i_xmldoc, 0);
358 xmlDOM.writetoCLOB(ecx_utils.g_xmldoc,i_xmldoc);
359
360 -- write XML to FS if debug > 0
361 if (l_statementEnabled)
362 then
363 IF g_instlmode = 'EMBEDDED' THEN
364 fnd_message.set_name('ecx', 'XML File for logging');
365 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);
366 if(attachment_id <> -1 AND i_xmldoc is not null) then
367 clength := dbms_lob.getlength(i_xmldoc);
368 while clength >= offset LOOP
369 ctemp := dbms_lob.substr(i_xmldoc,g_varmaxlength,offset);
370 fnd_log_attachment.writeln(attachment_id, ctemp);
371 offset := offset + g_varmaxlength;
372 End Loop;
373 fnd_log_attachment.close(attachment_id);
374 end if;
375 ELSE
376 xmlDOM.writetofile(ecx_utils.g_xmldoc,
377 ecx_utils.g_logdir||ecx_utils.getFileSeparator()||
378 substr(ecx_utils.g_logfile, 1,
379 length(ecx_utils.g_logfile)-4) ||'.xml');
380 END IF;
381 end if;
382
383
384 if (l_procedureEnabled) then
385 ecx_debug.pop(i_method_name);
386 end if;
387 end writeXMLToFile;
388
389
390 procedure processXMLData
391 (
392 i_map_id IN pls_integer,
393 i_payload IN clob,
394 i_header_id IN pls_integer,
395 i_rcv_tp_id IN pls_integer,
396 i_message_standard IN varchar2,
397 i_xmldoc OUT NOCOPY CLOB,
398 i_message_type IN varchar2
399 )
400 is
401
402 i_method_name varchar2(2000) := 'ecx_inbound_trig.processxmldata';
403 i_doc xmlDOM.DOMDocument;
404 l_same_map Boolean;
405 l_parseXML boolean;
406
407 begin
408 if (l_procedureEnabled) then
409 ecx_debug.push(i_method_name);
410 end if;
411 if(l_statementEnabled) then
412 ecx_debug.log(l_statement,'ecx_utils.g_map_id',ecx_utils.g_map_id,i_method_name);
413 ecx_debug.log(l_statement,'i_map_id',i_map_id,i_method_name);
414 ecx_debug.log(l_statement,'i_header_id',i_header_id,i_method_name);
415 ecx_debug.log(l_statement,'i_rcv_tp_id',i_rcv_tp_id,i_method_name);
416 ecx_debug.log(l_statement,'i_message_standard',i_message_standard,i_method_name);
417 end if;
418 -- Set the Transaction direction
419 ecx_utils.g_rec_tp_id := i_rcv_tp_id;
420 ecx_utils.g_direction := 'IN';
421 ecx_utils.initialize (i_map_id,l_same_map);
422 ecx_utils.g_source := ecx_utils.g_empty_source;
423 ecx_utils.g_target := ecx_utils.g_empty_target;
424
425 if (not ecx_utils.dom_printing) then
426 ecx_inbound_new.process_xml_doc (i_payload, i_map_id, i_xmldoc, l_parseXML);
427 else
428 /** Parse the Payload and handle any errors **/
429 begin
430 parsepayload(i_payload);
431 exception
432 when others then
433 raise ecx_utils.program_exit;
434 end;
435
436 i_doc := xmlparser.getDocument(ecx_utils.g_parser);
437
438 /** Assign it to the Global XML Document **/
439 ecx_utils.g_xmldoc := xmlDOM.makeNode(i_doc);
440
441 /** Get all the attributes in a generic way for a given standard and save in ecx_doclogs**/
442 getAttributes (
443 i_message_standard,
444 i_doc,
445 i_message_type
446 );
447
448 ecx_inbound.process_xml_doc (i_doc,i_map_id, i_header_id, i_rcv_tp_id,
449 i_xmldoc, l_parseXML);
450 end if;
451
452 /* bug 8718549 , commented free parser code as it was done twice in this procedure
453 xmlparser.freeparser(ecx_utils.g_parser);
454 if(ecx_utils.dom_printing = false and ecx_utils.structure_printing = true) -- xmltoxml different dtds.
455 then
456 xmlparser.freeparser(ecx_utils.g_inb_parser);
457 end if; */
458
459 if (ecx_utils.dom_printing or (ecx_utils.structure_printing and l_parseXML)) then
460 if(l_statementEnabled) then
461 ecx_debug.log(l_statement,'XML is validated by the parser.',i_method_name);
462 end if;
463 writeXMLToFile(i_xmldoc);
464
465 begin
466 if not xmlDOM.isNull(ecx_utils.g_xmldoc) then
467 xmlDOM.freeDocument(xmlDOM.makeDocument(ecx_utils.g_xmldoc));
468 end if;
469 exception
470 when others then
471 null;
472 end;
473 else
474 if(l_statementEnabled) then
475 ecx_debug.log(l_statement,'XML is not validated by the parser.',i_method_name);
476 end if;
477 end if;
478 --for bug 5609625
479 xmlparser.freeparser(ecx_utils.g_parser);
480 if(ecx_utils.dom_printing = false and ecx_utils.structure_printing = true) -- xmltoxml different dtds.
481 then
482 xmlparser.freeparser(ecx_utils.g_inb_parser);
483 end if;
484 ---end of 5609625
485
486 if (l_procedureEnabled) then
487 ecx_debug.pop(i_method_name);
488 end if;
489
490 exception
491 when ecx_utils.program_exit then
492 if (l_procedureEnabled) then
493 ecx_debug.pop(i_method_name);
494 end if;
495 if(l_unexpectedEnabled) then
496 ecx_debug.log(l_unexpected,'Clean-up last_printed',i_method_name);
497 end if;
498 ecx_print_local.last_printed := -1;
499
500 begin
501 if not xmlDOM.isNull(ecx_utils.g_xmldoc) then
502 xmlDOM.freeDocument(xmlDOM.makeDocument(ecx_utils.g_xmldoc));
503 end if;
504 exception
505 when others then
506 null;
507 end;
508 raise ecx_utils.program_exit;
509
510 when others then
511 ecx_debug.setErrorInfo(1,20,SQLERRM||' - ECX_INBOUND_TRIG.processXMLData ');
512 if(l_unexpectedEnabled) then
513 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
514 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
515 ecx_debug.log(l_unexpected,'Clean-up last_printed',i_method_name);
516 end if;
517 ecx_print_local.last_printed := -1;
518 if (l_procedureEnabled) then
519 ecx_debug.pop(i_method_name);
520 end if;
521
522 begin
523 if not xmlDOM.isNull(ecx_utils.g_xmldoc) then
524 xmlDOM.freeDocument(xmlDOM.makeDocument(ecx_utils.g_xmldoc));
525 end if;
526 exception
527 when others then
528 null;
529 end;
530 raise ecx_utils.program_exit;
531 end processXMLData;
532
533 procedure validate_message
534 (
535 m_msgid IN raw,
536 m_message_standard IN varchar2,
537 m_ext_type in varchar2,
538 m_ext_subtype in varchar2,
539 m_party_ext_code IN varchar2,
540 m_document_number IN varchar2,
541 m_routing_ext_code IN varchar2,
542 m_payload IN clob,
543 m_message_type IN varchar2
544 )
545 is
546 i_method_name varchar2(2000) := 'ecx_inbound_trig.validate_message';
547 i_map_id pls_integer;
548 o_ret_code pls_integer;
549 o_ret_msg varchar2(2000);
550 i_dtd_id pls_integer;
551 i_rcv_tp_id pls_integer;
552 o_payload CLOB default null;
553 l_same_map Boolean;
554 i_routing_id pls_integer;
555 i_rcv_detail_id pls_integer;
556 i_header_id pls_integer;
557 i_int_transaction_type varchar2(200);
558 i_int_transaction_subtype varchar2(200);
559 i_out_msgid raw(16);
560 i_confirmation pls_integer;
561 -- i_node_type pls_integer;
562 i_map_type pls_integer := 0;
563
564 /** trading partner variables **/
565 p_party_id number;
566 p_party_site_id number;
567 p_org_id pls_integer;
568 p_admin_email varchar2(256);
569 retcode pls_integer;
570 retmsg varchar2(2000);
571 i_no_routing varchar2(2) := 'N';
572 cursor c_tp_details
573 (
574 p_ext_type IN varchar2,
575 p_ext_subtype IN varchar2,
576 p_party_ext_code in varchar2,
577 p_message_standard in varchar2,
578 p_message_type in varchar2
579 )
580 is
581 select etd.map_id map_id,
582 etd.routing_id routing_id,
583 etd.tp_header_id tp_header_id,
584 etd.confirmation confirmation
585 from ecx_tp_details etd,
586 ecx_ext_processes eep,
587 ecx_standards es
588 where etd.source_tp_location_code = p_party_ext_code
589 and eep.ext_type = p_ext_type
590 and eep.ext_subtype = p_ext_subtype
591 and eep.ext_process_id = etd.ext_process_id
592 and eep.standard_id = es.standard_id
593 and es.standard_code = p_message_standard
594 and es.standard_type = nvl(p_message_type, 'XML')
595 and eep.direction = 'IN';
596
597 cursor get_routing_for_extcode
598 (
599 p_ext_type IN varchar2,
600 p_ext_subtype IN varchar2,
601 p_party_ext_code in varchar2,
602 p_message_standard in varchar2,
603 p_message_type in varchar2
604 )
605 is
606 select etd.tp_header_id tp_header_id,
607 etd.tp_detail_id tp_detail_id
608 from ecx_tp_details etd,
609 ecx_ext_processes eep,
610 ecx_standards es
611 where etd.source_tp_location_code = p_party_ext_code
612 and eep.ext_type = p_ext_type
613 and eep.ext_subtype = p_ext_subtype
614 and eep.ext_process_id = etd.ext_process_id
615 and eep.standard_id = es.standard_id
616 and es.standard_code = p_message_standard
617 and es.standard_type = nvl(p_message_type, 'XML')
618 and eep.direction = 'OUT';
619
620 cursor get_receiver_tp_id
621 (
622 p_routing_id IN pls_integer
623 ) is
624 select tp_header_id
625 from ecx_tp_details
626 where tp_detail_id = p_routing_id;
627
628 begin
629 if (l_procedureEnabled) then
630 ecx_debug.push(i_method_name);
631 end if;
632 if(l_statementEnabled) then
633 ecx_debug.log(l_statement,'m_message_standard',m_message_standard,i_method_name);
634 ecx_debug.log(l_statement,'m_ext_type',m_ext_type,i_method_name);
635 ecx_debug.log(l_statement,'m_ext_subtype',m_ext_subtype,i_method_name);
636 ecx_debug.log(l_statement,'m_party_ext_code',m_party_ext_code,i_method_name);
637 ecx_debug.log(l_statement,'m_document_number',m_document_number,i_method_name);
638 ecx_debug.log(l_statement,'m_routing_ext_code',m_routing_ext_code,i_method_name);
639 end if;
640 ecx_utils.i_ret_code :=0;
641 ecx_utils.i_errbuf :=null;
642 --MLS
643 ecx_utils.i_errparams := null;
644 ecx_utils.g_ret_code := 0;
645
646 --Check whether the Document has been enabled in the Exchange Server.
647 --If yes get the Map Id.
648 open c_tp_details ( m_ext_type, m_ext_subtype,m_party_ext_code,m_message_standard, m_message_type);
649 fetch c_tp_details
650 into i_map_id,
651 i_routing_id,
652 i_header_id,
653 i_confirmation;
654
655 if c_tp_details%NOTFOUND
656 then
657 ecx_debug.setErrorInfo(1,30,'ECX_TRANACTION_NOT_ENABLED',
658 'p_ext_type',
659 m_ext_type,
660 'p_ext_subtype',
661 m_ext_subtype,
662 'p_party_ext_code',
663 m_party_ext_code);
664
665 if(l_statementEnabled) then
666 ecx_debug.log(l_statement,'ECX','ECX_TRANACTION_NOT_ENABLED',
667 i_method_name,
668 'p_ext_type',
669 m_ext_type,
670 'p_ext_subtype',
671 m_ext_subtype,
672 'p_party_ext_code',
673 m_party_ext_code);
674 end if;
675
676 close c_tp_details;
677 raise ecx_utils.program_exit;
678 end if;
679
680 close c_tp_details;
681 -- Set the Sender's tp_id
682 ecx_utils.g_snd_tp_id := i_header_id;
683 if(l_statementEnabled) then
684 ecx_debug.log(l_statement,'i_map_id',i_map_id,i_method_name);
685 ecx_debug.log(l_statement,'i_routing_id',i_routing_id,i_method_name);
686 ecx_debug.log(l_statement,'i_header_id',i_header_id,i_method_name);
687 ecx_debug.log(l_statement,'i_confirmation',i_confirmation,i_method_name);
688 end if;
689
690 if (i_routing_id is not null or m_routing_ext_code is not null) then if not (is_routing_supported(i_map_id)) then
691 ecx_debug.setErrorInfo(2, 25, 'ECX_ROUTING_NOT_SUPPORTED');
692 raise ecx_utils.program_exit;
693 end if;
694 end if;
695
696 --Call the Send and Receive TP Id api's over here
697 --Pass through transaction Type , Document Number , Sender's Tp Id.
698 --i_transaction_type,i_document_number,i_snd_tp_id
699
700 --- Check whether routing enabled or not, if yes , is it static otherwise dynamic
701 if i_routing_id is not null
702 then
703 if m_routing_ext_code is not null
704 then
705 if(l_statementEnabled) then
706 ecx_debug.log(l_statement,'Dynamic Routing1',m_routing_ext_code,i_method_name);
707 end if;
708 open get_routing_for_extcode ( m_ext_type,m_ext_subtype,m_routing_ext_code,m_message_standard, m_message_type);
709 fetch get_routing_for_extcode
710 into i_rcv_tp_id,i_routing_id;
711
712 if get_routing_for_extcode%NOTFOUND
713 then
714 ecx_debug.setErrorInfo(1,30,
715 'ECX_DYN_ROUTING_NOT_ENABLED',
716 'p_ext_type',
717 m_ext_type,
718 'p_ext_subtype',
719 m_ext_subtype,
720 'p_party_ext_code',
721 m_party_ext_code);
722
723 if(l_statementEnabled) then
724 ecx_debug.log(l_statement,'ECX',
725 'ECX_DYN_ROUTING_NOT_ENABLED',
726 i_method_name,
727 'p_ext_type',
728 m_ext_type,
729 'p_ext_subtype',
730 m_ext_subtype,
731 'p_party_ext_code',
732 m_party_ext_code);
733 end if;
734
735 close get_routing_for_extcode;
736 raise ecx_utils.program_exit;
737 end if;
738
739 close get_routing_for_extcode;
740
741 else
742 open get_receiver_tp_id (i_routing_id);
743 fetch get_receiver_tp_id into i_rcv_tp_id;
744
745 if get_receiver_tp_id%NOTFOUND
746 then
747 ecx_debug.setErrorInfo(1,30,
748 'ECX_STATIC_ROUTING_NOT_ENABLED',
749 'p_ext_type',
750 m_ext_type,
751 'p_ext_subtype',
752 m_ext_subtype,
753 'p_party_ext_code',
754 m_party_ext_code);
755
756 if(l_statementEnabled) then
757 ecx_debug.log(l_statement,'ECX',
758 'ECX_STATIC_ROUTING_NOT_ENABLED',
759 i_method_name,
760 'p_ext_type',
761 m_ext_type,
762 'p_ext_subtype',
763 m_ext_subtype,
764 'p_party_ext_code',
765 m_party_ext_code);
766 end if;
767
768
769 close get_receiver_tp_id;
770 raise ecx_utils.program_exit;
771 end if;
772 close get_receiver_tp_id;
773 if(l_statementEnabled) then
774 ecx_debug.log(l_statement,'Static Routing',i_method_name);
775 end if;
776
777 end if;
778 ecx_utils.g_rec_tp_id := i_rcv_tp_id;
779 if(l_statementEnabled) then
780 ecx_debug.log(l_statement,'Receiver Tp Id ',i_rcv_tp_id,i_method_name);
781 end if;
782
783 else
784 --- Check for m_routing_ext_code if not null then use it
785
786 if m_routing_ext_code is not null
787 then
788 if(l_statementEnabled) then
789 ecx_debug.log(l_statement,'Dynamic Routing2',m_routing_ext_code,i_method_name);
790 end if;
791 open get_routing_for_extcode ( m_ext_type,m_ext_subtype,m_routing_ext_code,m_message_standard, m_message_type);
792 fetch get_routing_for_extcode
793 into i_rcv_tp_id,i_routing_id;
794
795 if get_routing_for_extcode%NOTFOUND
796 then
797 ecx_debug.setErrorInfo(1,30,
798 'ECX_DYN_ROUTING_NOT_ENABLED',
799 'p_ext_type',
800 m_ext_type,
801 'p_ext_subtype',
802 m_ext_subtype,
803 'p_party_ext_code',
804 m_party_ext_code);
805
806 if(l_statementEnabled) then
807 ecx_debug.log(l_statement,'ECX',
808 'ECX_DYN_ROUTING_NOT_ENABLED',
809 i_method_name,
810 'p_ext_type',
811 m_ext_type,
812 'p_ext_subtype',
813 m_ext_subtype,
814 'p_party_ext_code',
815 m_party_ext_code);
816 end if;
817
818 close get_routing_for_extcode;
819 raise ecx_utils.program_exit;
820 end if;
821 close get_routing_for_extcode;
822 else
823 -- if neither static nor dynamic routing is specified.
824 select count(1) into i_map_type
825 from ecx_objects
826 where object_type <> 'DB' and map_id = i_map_id;
827 i_no_routing := 'Y';
828 if (i_map_type = 2) then
829 -- Only if map is xml to xml or dtd to dtd type
830 -- Give warning message.
831 ecx_utils.g_ret_code := 1;
832 if(l_statementEnabled) then
833 ecx_debug.log(l_statement,'ecx_utils.g_ret_code',' 1',i_method_name);
834 end if;
835 end if;
836 end if;
837 end if;
838
839 -- need to set the g_routing_id here, so that it would set it
840 -- for both dynamic and static routing.
841 ecx_utils.g_routing_id := i_routing_id;
842 if(l_statementEnabled) then
843 ecx_debug.log(l_statement,'ecx_utils.g_routing_id',ecx_utils.g_routing_id,
844 i_method_name);
845 end if;
846
847 /**
848 Since we have the sender tp_id , we can call the senders_tp_info and populate the org_id
849 **/
850 if ( ecx_utils.g_snd_tp_id is not null )
851 then
852 null;
853 ecx_trading_partner_pvt.get_tp_info
854 (
855 ecx_utils.g_snd_tp_id,
856 p_party_id,
857 p_party_site_id,
858 ecx_utils.g_org_id,
859 p_admin_email,
860 retcode,
861 retmsg
862 );
863 end if;
864
865
866 if(l_statementEnabled) then
867 ecx_debug.log(l_statement,'ECX','ECX_START_INBOUND',i_method_name, 'TRANSACTION_TYPE', m_ext_type);
868 end if;
869 /*bug 16442475:If value of profile ECX_IN_JAVA_PROCESSING is Y*/
870 if ECX_UTIL_API.isInJavaProcessEnabled then
871 raiseEvent(
872 i_msgid => m_msgid,
873 i_document_number => m_document_number,
874 i_map_id => i_map_id,
875 i_rcv_tp_id => i_rcv_tp_id,
876 i_payload => m_payload,
877 i_no_routing => i_no_routing);
878 if(l_statementEnabled) then
879 ecx_debug.log(l_statement, 'ECX', 'Raised an event to process an xml at java layer',i_method_name);
880 end if;
881 else
882 processXMLData
883 (
884 i_map_id,
885 m_payload,
886 i_header_id,
887 i_rcv_tp_id,
888 m_message_standard,
889 o_payload,
890 m_message_type
891 );
892 if(l_statementEnabled) then
893 ecx_debug.log(l_statement, 'ECX', 'ECX_END_INBOUND',i_method_name, 'TRANSACTION_TYPE', m_ext_type);
894 end if;
895
896 savepoint save_xml_doc;
897
898 --If it is a pass through transaction , then put the Message on the Outbound Queue
899 if i_routing_id is not null
900 then
901 if(l_statementEnabled) then
902 ecx_debug.log(l_statement,'Routing Enqueued for MSGID : '|| m_msgid,i_method_name);
903 end if;
904 put_on_outbound
905 (
906 o_payload,
907 m_document_number,
908 i_routing_id,
909 m_msgid
910 );
911
912 else
913 if(l_statementEnabled) then
914 ecx_debug.log(l_statement,'Update doclogs for Msg Id : ' , m_msgid,i_method_name);
915 end if;
916 ecx_errorlog.update_log_document
917 (
918 m_msgid,
919 null,
920 'Inbound processing complete.',
921 ecx_utils.g_logfile,
922 null
923 );
924 end if;
925
926 if o_payload is not null
927 then
928 dbms_lob.freetemporary (o_payload);
929 end if;
930 end if;
931 if (l_procedureEnabled) then
932 ecx_debug.pop(i_method_name);
933 end if;
934 exception
935 when ecx_utils.program_exit then
936 --ecx_utils.g_map_id := -1;
937 if (l_procedureEnabled) then
938 ecx_debug.pop(i_method_name);
939 end if;
940
941 if o_payload is not null
942 then
943 dbms_lob.freetemporary (o_payload);
944 end if;
945 raise ecx_utils.program_exit;
946 when others then
947 --ecx_utils.g_map_id := -1;
948 ecx_debug.setErrorInfo(2,30,SQLERRM||' - ECX_INBOUND_TRIG.VALIDATE_MESSAGE ');
949 if(l_unexpectedEnabled) then
950 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
951 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
952 end if;
953
954 if o_payload is not null
955 then
956 dbms_lob.freetemporary (o_payload);
957 end if;
958 if (l_procedureEnabled) then
959 ecx_debug.pop(i_method_name);
960 end if;
961 raise ecx_utils.program_exit;
962 end validate_message;
963
964
965 procedure getmsg_from_queue
966 (
967 i_queue_name IN varchar2,
968 i_msgid OUT NOCOPY RAW
969 )
970 is
971 i_method_name varchar2(2000) := 'ecx_inbound_trig.getmsg_from_queue';
972 v_message system.ecxmsg;
973 v_dequeueoptions dbms_aq.dequeue_options_t;
974 v_messageproperties dbms_aq.message_properties_t;
975 c_nummessages CONSTANT INTEGER :=1;
976 e_qtimeout exception;
977 pragma exception_init(e_qtimeout,-25228);
978 l_retcode pls_integer := 0;
979 l_retmsg Varchar2(200) := null;
980
981 begin
982 if (l_procedureEnabled) then
983 ecx_debug.push(i_method_name);
984 end if;
985
986 if(l_statementEnabled) then
987 ecx_debug.log(l_statement,'i_queue_name',i_queue_name,i_method_name);
988 end if;
989
990 v_dequeueoptions.navigation := dbms_aq.FIRST_MESSAGE;
991 v_dequeueoptions.dequeue_mode := dbms_aq.BROWSE;
992 for i in 1..c_nummessages
993 loop
994 v_dequeueoptions.wait:=dbms_aq.NO_WAIT;
995
996 dbms_aq.dequeue
997 (
998 queue_name=>i_queue_name,
999 dequeue_options=>v_dequeueoptions,
1000 message_properties=>v_messageproperties,
1001 payload=>v_message,
1002 msgid=> i_msgid
1003 );
1004
1005 --Retrieve the Message Attributes
1006
1007 if(l_statementEnabled) then
1008 ecx_debug.log(l_statement,'Message Standard',v_message.message_standard,i_method_name);
1009 ecx_debug.log(l_statement,'Message Type',v_message.message_type,i_method_name);
1010 ecx_debug.log(l_statement,'Transaction Type',v_message.transaction_type,i_method_name);
1011 ecx_debug.log(l_statement,'Transaction Sub Type',v_message.transaction_subtype,i_method_name);
1012 ecx_debug.log(l_statement,'Party Id',v_message.partyid,i_method_name);
1013 ecx_debug.log(l_statement,'party Site Id',v_message.party_site_id,i_method_name);
1014 ecx_debug.log(l_statement,'party type',v_message.party_type,i_method_name);
1015 ecx_debug.log(l_statement,'protocol_type ',v_message.protocol_type,i_method_name);
1016 ecx_debug.log(l_statement,'Protocol Address ',v_message.protocol_address,i_method_name);
1017 ecx_debug.log(l_statement,'Username ',v_message.username,i_method_name);
1018 ecx_debug.log(l_statement,'Password ',v_message.password,i_method_name);
1019 end if;
1020 begin
1021 ecx_errorlog.log_document (
1022 l_retcode,
1023 l_retmsg,
1024 i_msgid,
1025 v_message.message_type,
1026 v_message.message_standard,
1027 v_message.transaction_type,
1028 v_message.transaction_subtype,
1029 v_message.document_number,
1030 v_message.partyid,
1031 v_message.party_site_id,
1032 v_message.party_type,
1033 v_message.protocol_type,
1034 v_message.protocol_address,
1035 v_message.username,
1036 v_message.password,
1037 v_message.attribute1,
1038 v_message.attribute2,
1039 v_message.attribute3,
1040 v_message.attribute4,
1041 v_message.attribute5,
1042 v_message.payload,
1043 null
1044 );
1045
1046 if (l_retcode = 1) then
1047 if(l_unexpectedEnabled) then
1048 ecx_debug.log(l_unexpected, l_retmsg,i_method_name);
1049 end if;
1050 elsif (l_retcode >= 2 ) then
1051 if(l_unexpectedEnabled) then
1052 ecx_debug.log(l_unexpected,l_retmsg,i_method_name);
1053 end if;
1054 raise ecx_utils.program_exit;
1055 end if;
1056 end;
1057 if(l_statementEnabled) then
1058 ecx_debug.log(l_statement,'MessageId', i_msgid,i_method_name);
1059 end if;
1060
1061 end loop;
1062 if(l_statementEnabled) then
1063 ecx_debug.log(l_statement,'i_msgid',i_msgid,i_method_name);
1064 end if;
1065 if (l_procedureEnabled) then
1066 ecx_debug.pop(i_method_name);
1067 end if;
1068 exception
1069 when ecx_utils.program_exit then
1070 raise;
1071 when others then
1072 ecx_debug.setErrorInfo(2,30,SQLERRM||' - ECX_INBOUND_TRIG.GETMSG_FROM_QUEUE');
1073 if(l_unexpectedEnabled) then
1074 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
1075 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
1076 end if;
1077 raise ecx_utils.program_exit;
1078 end getmsg_from_queue;
1079
1080
1081 procedure put_on_outbound
1082 (
1083 i_xmldoc IN OUT NOCOPY CLOB,
1084 i_document_number IN varchar2,
1085 i_tp_detail_id IN pls_integer,
1086 i_msgid IN raw
1087 )
1088 is
1089
1090
1091 i_method_name varchar2(2000) := 'ecx_inbound_trig.put_on_outbound';
1092 e_qtimeout exception;
1093
1094 i_out_msgid raw(16);
1095 i_standard_type varchar2(20);
1096 i_standard_code varchar2(20);
1097 i_ext_type varchar2(200);
1098 i_ext_subtype varchar2(200);
1099 i_source_code varchar2(200);
1100 i_destination_code varchar2(200);
1101 i_destination_type varchar2(200);
1102 i_destination_address ecx_tp_details.protocol_address%TYPE;
1103 i_username varchar2(200);
1104 i_password varchar2(500);
1105 i_hub_user_id number DEFAULT 0;
1106 pragma exception_init(e_qtimeout,-25228);
1107 i_event wf_event_t;
1108 i_from_agt wf_agent_t := wf_agent_t(NULL, NULL);
1109 i_system varchar2(200);
1110 i_int_type varchar2(200);
1111 i_int_subtype varchar2(200);
1112 i_party_id number;
1113 i_party_site_id number;
1114 i_party_type varchar2(200);
1115
1116 begin
1117
1118 if (l_procedureEnabled) then
1119 ecx_debug.push(i_method_name);
1120 end if;
1121 if(l_statementEnabled) then
1122 ecx_debug.log(l_statement,'i_document_number',i_document_number,i_method_name);
1123 ecx_debug.log(l_statement,'i_tp_detail_id',i_tp_detail_id,i_method_name);
1124 end if;
1125
1126 begin
1127 select es.standard_type standard_type,
1128 es.standard_code standard_code,
1129 source_tp_location_code source,
1130 external_tp_location_code destination,
1131 protocol_type,
1132 protocol_address,
1133 username,
1134 password,
1135 hub_user_id,
1136 eep.ext_type ext_type,
1137 eep.ext_subtype ext_subtype,
1138 et.transaction_type,
1139 et.transaction_subtype,
1140 eth.party_id,
1141 eth.party_site_id,
1142 eth.party_type
1143 into i_standard_type,
1144 i_standard_code,
1145 i_source_code,
1146 i_destination_code,
1147 i_destination_type,
1148 i_destination_address,
1149 i_username,
1150 i_password,
1151 i_hub_user_id,
1152 i_ext_type,
1153 i_ext_subtype,
1154 i_int_type,
1155 i_int_subtype,
1156 i_party_id,
1157 i_party_site_id,
1158 i_party_type
1159 from ecx_tp_details etd,
1160 ecx_ext_processes eep,
1161 ecx_standards es,
1162 ecx_transactions et,
1163 ecx_tp_headers eth
1164 where etd.tp_detail_id = i_tp_detail_id
1165 and es.standard_id = eep.standard_id
1166 and eep.ext_process_id = etd.ext_process_id
1167 and eep.transaction_id = et.transaction_id
1168 and eep.direction = 'OUT'
1169 and etd.tp_header_id = eth.tp_header_id;
1170 exception
1171 when others then
1172 ecx_debug.setErrorInfo(1,25,'ECX_NO_UNIQUE_TP_SETUP');
1173 raise ecx_utils.program_exit;
1174 end;
1175
1176 if i_hub_user_id is not null
1177 then
1178 begin
1179 select hub_entity_code,
1180 protocol_type,
1181 protocol_address,
1182 username,
1183 password
1184 into i_source_code,
1185 i_destination_type,
1186 i_destination_address,
1187 i_username,
1188 i_password
1189 from ecx_hubs eh,
1190 ecx_hub_users ehu
1191 where eh.hub_id = ehu.hub_id
1192 and ehu.hub_user_id = i_hub_user_id;
1193 exception
1194 when others then
1195 ecx_debug.setErrorInfo(1,25,'ECX_DELIVERY_HUB_NOT_SETUP');
1196 raise ecx_utils.program_exit;
1197 end;
1198 end if;
1199
1200 if i_destination_address is null
1201 then
1202 ecx_debug.setErrorInfo(1,25,'ECX_PROTOCOL_ADDR_NULL',
1203 'p_tp_location_code', i_source_code,
1204 'p_transaction_type', i_ext_type,
1205 'p_transaction_subtype', i_ext_subtype,
1206 'p_standard', i_standard_code);
1207
1208 raise ecx_utils.program_exit;
1209 end if;
1210 if (l_statementEnabled) then
1211 ecx_debug.log(l_statement,'i_standard_type',i_standard_type,i_method_name);
1212 ecx_debug.log(l_statement,'i_standard_code',i_standard_code,i_method_name);
1213 ecx_debug.log(l_statement,'i_ext_type',i_ext_type,i_method_name);
1214 ecx_debug.log(l_statement,'i_ext_subtype',i_ext_subtype,i_method_name);
1215 ecx_debug.log(l_statement,'i_int_type', i_int_type,i_method_name);
1216 ecx_debug.log(l_statement,'i_int_subtype', i_int_subtype,i_method_name);
1217 ecx_debug.log(l_statement,'i_source_code',i_source_code,i_method_name);
1218 ecx_debug.log(l_statement,'i_destination_code',i_destination_code,i_method_name);
1219 ecx_debug.log(l_statement,'i_destination_type',i_destination_type,i_method_name);
1220 ecx_debug.log(l_statement,'i_destination_address',i_destination_address,i_method_name);
1221 ecx_debug.log(l_statement,'i_username',i_username,i_method_name);
1222 ecx_debug.log(l_statement,'i_party_id',i_party_id,i_method_name);
1223 ecx_debug.log(l_statement,'i_party_site_id', i_party_site_id,i_method_name);
1224 ecx_debug.log(l_statement,'i_party_type', i_party_type,i_method_name);
1225 end if;
1226 -- call ecx_out_wf_qh.enqueue with the correct parameters
1227 wf_event_t.initialize(i_event);
1228 i_event.addParameterToList('PARTY_TYPE', i_party_type);
1229 i_event.addParameterToList('PARTYID', i_party_id);
1230 i_event.addParameterToList('PARTY_SITE_ID', i_source_code);
1231 -- added this for passthrough logging purposes in ecx_out_wf_qh
1232 i_event.addParameterToList('INT_PARTY_SITE_ID', i_party_site_id);
1233 i_event.addParameterToList('DOCUMENT_NUMBER', i_document_number);
1234 i_event.addParameterToList('MESSAGE_TYPE', i_standard_type);
1235 i_event.addParameterToList('MESSAGE_STANDARD', i_standard_code);
1236 i_event.addParameterToList('TRANSACTION_TYPE', i_ext_type);
1237 i_event.addParameterToList('TRANSACTION_SUBTYPE', i_ext_subtype);
1238 i_event.addParameterToList('INT_TRANSACTION_TYPE', i_int_type);
1239 i_event.addParameterToList('INT_TRANSACTION_SUBTYPE', i_int_subtype);
1240 i_event.addParameterToList('PROTOCOL_TYPE', i_destination_type);
1241 i_event.addParameterToList('PROTOCOL_ADDRESS', i_destination_address);
1242 i_event.addParameterToList('USERNAME', i_username);
1243 i_event.addParameterToList('PASSWORD', i_password);
1244 i_event.addParameterToList('ATTRIBUTE1', ecx_utils.g_company_name);
1245 i_event.addParameterToList('ATTRIBUTE2', null);
1246 i_event.addParameterToList('ATTRIBUTE3', i_destination_code);
1247 i_event.addParameterToList('ATTRIBUTE4', null);
1248 i_event.addParameterToList('ATTRIBUTE5', null);
1249 i_event.addParameterToList('DIRECTION', ecx_utils.g_direction);
1250 i_event.addParameterToList('LOGFILE', ecx_utils.g_logfile);
1251 i_event.addParameterToList('ECX_MSG_ID', i_msgid);
1252
1253 i_event.event_data := i_xmldoc;
1254
1255 -- set the from agent
1256 select name
1257 into i_system
1258 from wf_systems
1259 where guid = wf_core.translate('WF_SYSTEM_GUID');
1260
1261 i_from_agt.setname('ECX_OUTBOUND');
1262 i_from_agt.setsystem(i_system);
1263
1264 i_event.setFromAgent(i_from_agt);
1265
1266 if(l_statementEnabled) then
1267 ecx_debug.log(l_statement,'Calling WF_EVENT.Send for Enqueue',i_method_name);
1268 end if;
1269 wf_event.send(i_event);
1270 ecx_errorlog.outbound_log(i_event);
1271
1272 i_out_msgid := ecx_out_wf_qh.msgid;
1273
1274 -- check the retcode and retmsg. This should be populated here only
1275 -- in the case of dup val index when inserting in doclogs (since no
1276 -- exception is raised in this case)
1277 if (ecx_out_wf_qh.retmsg is not null) then
1278 --ecx_utils.error_type := 30;
1279 --ecx_utils.i_ret_code := ecx_out_wf_qh.retcode;
1280 --ecx_utils.i_errbuf := ecx_out_wf_qh.retmsg;
1281 ecx_debug.setErrorInfo(ecx_out_wf_qh.retcode,30,ecx_out_wf_qh.retmsg);
1282 if(l_statementEnabled) then
1283 ecx_debug.log(l_statement,ecx_debug.getMessage(ecx_utils.i_errbuf,
1284 ecx_utils.i_errparams),i_method_name); -- MLS
1285 end if;
1286 end if;
1287
1288 if(l_statementEnabled) then
1289 ecx_debug.log(l_statement,'Routed MsgId',i_out_msgid,i_method_name);
1290 end if;
1291 if (l_procedureEnabled) then
1292 ecx_debug.pop(i_method_name);
1293 end if;
1294 exception
1295 WHEN ECX_UTILS.PROGRAM_EXIT THEN
1296 --dbms_lob.freetemporary(i_xmldoc);
1297 if (l_procedureEnabled) then
1298 ecx_debug.pop(i_method_name);
1299 end if;
1300 raise ecx_utils.program_exit;
1301 when others then
1302 --dbms_lob.freetemporary(i_xmldoc);
1303 if (ecx_out_wf_qh.retmsg is null AND ecx_out_wf_qh.retcode = 0)
1304 then
1305 ecx_debug.setErrorInfo(2,30,SQLERRM || ' - ECX_INBOUND_TRIG.PUT_ON_OUTBOUND');
1306 else
1307 --ecx_utils.i_ret_code := ecx_out_wf_qh.retcode;
1308 --ecx_utils.i_errbuf := ecx_out_wf_qh.retmsg;
1309 ecx_debug.setErrorInfo(ecx_out_wf_qh.retcode,30,ecx_out_wf_qh.retmsg);
1310 end if;
1311 --ecx_utils.error_type := 30;
1312 if(l_unexpectedEnabled) then
1313 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,
1314 ecx_utils.i_errparams),i_method_name); -- MLS
1315 end if;
1316 raise ecx_utils.program_exit;
1317 end put_on_outbound;
1318
1319 /**
1320 Old put_on_outbound - pre BES integration
1321 Present for backward compatibility
1322 **/
1323
1324 procedure put_on_outbound
1325 (
1326 i_xmldoc IN OUT NOCOPY CLOB,
1327 i_document_number IN varchar2,
1328 i_tp_detail_id IN pls_integer
1329 )
1330 is
1331 i_method_name varchar2(2000) := 'ecx_inbound_trig.put_on_outbound';
1332 v_message system.ecxmsg;
1333 v_enqueueoptions dbms_aq.enqueue_options_t;
1334 v_messageproperties dbms_aq.message_properties_t;
1335 i_msgid raw(16);
1336 c_nummessages CONSTANT INTEGER :=1;
1337 e_qtimeout exception;
1338
1339 i_standard_type varchar2(20);
1340 i_standard_code varchar2(20);
1341 i_ext_type varchar2(200);
1342 i_ext_subtype varchar2(200);
1343 i_source_code varchar2(200);
1344 i_destination_code varchar2(200);
1345 i_destination_type varchar2(200);
1346 i_destination_address ecx_tp_details.protocol_address%TYPE;
1347 i_username varchar2(200);
1348 i_password varchar2(500);
1349 m_password varchar2(500);
1350 i_hub_user_id number;
1351 i_party_type varchar2(30) := null;
1352 o_retcode pls_integer;
1353 o_retmsg varchar2(2000);
1354 pragma exception_init(e_qtimeout,-25228);
1355 l_retcode pls_integer := 0;
1356 l_retmsg Varchar2(200) := null;
1357
1358 begin
1359 if (l_procedureEnabled) then
1360 ecx_debug.push(i_method_name);
1361 end if;
1362 if(l_statementEnabled) then
1363 ecx_debug.log(l_statement,'i_document_number',i_document_number,i_method_name);
1364 ecx_debug.log(l_statement,'i_tp_detail_id',i_tp_detail_id,i_method_name);
1365 end if;
1366
1367 begin
1368 select es.standard_type standard_type,
1369 es.standard_code standard_code,
1370 source_tp_location_code source,
1371 external_tp_location_code destination,
1372 protocol_type,
1373 protocol_address,
1374 username,
1375 password,
1376 hub_user_id,
1377 eep.ext_type ext_type,
1378 eep.ext_subtype ext_subtype
1379 into i_standard_type,
1380 i_standard_code,
1381 i_source_code,
1382 i_destination_code,
1383 i_destination_type,
1384 i_destination_address,
1385 i_username,
1386 i_password,
1387 i_hub_user_id,
1388 i_ext_type,
1389 i_ext_subtype
1390 from ecx_tp_details etd,
1391 ecx_ext_processes eep,
1392 ecx_standards es
1393 where etd.tp_detail_id = i_tp_detail_id
1394 and es.standard_id = eep.standard_id
1395 and eep.ext_process_id = etd.ext_process_id;
1396
1397 exception
1398 when others then
1399 ecx_debug.setErrorInfo(1,25,'ECX_NO_UNIQUE_TP_SETUP');
1400 raise ecx_utils.program_exit;
1401 end;
1402
1403 if i_hub_user_id is not null
1404 then
1405 begin
1406 select hub_entity_code,
1407 protocol_type,
1408 protocol_address,
1409 username,
1410 password
1411 into i_source_code,
1412 i_destination_type,
1413 i_destination_address,
1414 i_username,
1415 i_password
1416 from ecx_hubs eh,
1417 ecx_hub_users ehu
1418 where eh.hub_id = ehu.hub_id
1419 and ehu.hub_user_id = i_hub_user_id;
1420
1421 exception
1422 when others then
1423 ecx_debug.setErrorInfo(1,25,'ECX_DELIVERY_HUB_NOT_SETUP');
1424 if(l_unexpectedEnabled) then
1425 ecx_debug.log(l_unexpected,'ERROR', SQLERRM,i_method_name);
1426 end if;
1427 raise ecx_utils.program_exit;
1428 end;
1429 end if;
1430
1431
1432 if i_destination_address is null
1433 then
1434 ecx_debug.setErrorInfo(1,25,'ECX_PROTOCOL_ADDR_NULL',
1435 'p_tp_location_code', i_source_code,
1436 'p_transaction_type', i_ext_type,
1437 'p_transaction_subtype', i_ext_subtype,
1438 'p_standard', i_standard_code);
1439 raise ecx_utils.program_exit;
1440 end if;
1441
1442 ecx_obfuscate.ecx_data_encrypt
1443 (
1444 i_password,
1445 'D',
1446 m_password,
1447 o_retcode,
1448 o_retmsg
1449 );
1450
1451 if (o_retcode > 0)
1452 then
1453 --ecx_utils.i_ret_code := o_retcode;
1454 --ecx_utils.i_errbuf := o_retmsg;
1455 --ecx_utils.error_type := 30;
1456 ecx_debug.setErrorInfo(o_retcode,30,o_retmsg);
1457 raise ecx_utils.program_exit;
1458 end if;
1459 if(l_statementEnabled) then
1460 ecx_debug.log(l_statement,'i_standard_type',i_standard_type,i_method_name);
1461 ecx_debug.log(l_statement,'i_standard_code',i_standard_code,i_method_name);
1462 ecx_debug.log(l_statement,'i_ext_type',i_ext_type,i_method_name);
1463 ecx_debug.log(l_statement,'i_ext_subtype',i_ext_subtype,i_method_name);
1464 ecx_debug.log(l_statement,'i_source_code',i_source_code,i_method_name);
1465 ecx_debug.log(l_statement,'i_destination_code',i_destination_code,i_method_name);
1466 ecx_debug.log(l_statement,'i_destination_type',i_destination_type,i_method_name);
1467 ecx_debug.log(l_statement,'i_destination_address',i_destination_address,i_method_name);
1468 ecx_debug.log(l_statement,'i_username',i_username,i_method_name);
1469 end if;
1470 --ecx_debug.log(3,'i_password',i_password);
1471
1472 v_message:=system.ecxmsg
1473 (
1474 i_standard_type,
1475 i_standard_code,
1476 i_ext_type,
1477 i_ext_subtype,
1478 i_document_number,
1479 null,
1480 i_source_code,
1481 null,
1482 i_destination_type,
1483 i_destination_address,
1484 i_username,
1485 m_password,
1486 i_xmldoc,
1487 ecx_utils.g_company_name,
1488 null,
1489 i_destination_code,
1490 null,
1491 null
1492 );
1493
1494 begin
1495 select party_type
1496 into i_party_type
1497 from ecx_tp_headers eth,
1498 ecx_tp_details etd
1499 where eth.tp_header_id = etd.tp_header_id
1500 and etd.tp_detail_id = i_tp_detail_id;
1501 exception
1502 when others then
1503 ecx_debug.setErrorInfo(1,30, SQLERRM);
1504 raise ecx_utils.program_exit;
1505 end;
1506
1507 v_message.party_type := i_party_type;
1508
1509 v_messageproperties.correlation := 'OXTA';
1510 -- Enqueue
1511 dbms_aq.enqueue
1512 (
1513 queue_name=>'ECX_OUTBOUND',
1514 enqueue_options=>v_enqueueoptions,
1515 message_properties=>v_messageproperties,
1516 payload=>v_message,
1517 msgid=>i_msgid
1518 );
1519
1520 --Keep a log of the Outgoing Messages
1521 begin
1522 ecx_errorlog.log_document (
1523 l_retcode,
1524 l_retmsg,
1525 i_msgid,
1526 v_message.message_type,
1527 v_message.message_standard,
1528 v_message.transaction_type,
1529 v_message.transaction_subtype,
1530 v_message.document_number,
1531 v_message.partyid,
1532 v_message.party_site_id,
1533 v_message.party_type,
1534 v_message.protocol_type,
1535 v_message.protocol_address,
1536 v_message.username,
1537 v_message.password,
1538 v_message.attribute1,
1539 v_message.attribute2,
1540 v_message.attribute3,
1541 v_message.attribute4,
1542 v_message.attribute5,
1543 v_message.payload,
1544 null,
1545 null,
1546 'OUT'
1547 );
1548
1549 if (l_retcode = 1) then
1550 if(l_unexpectedEnabled) then
1551 ecx_debug.log(l_unexpected, l_retmsg,i_method_name);
1552 end if;
1553 elsif (l_retcode >= 2 ) then
1554 if(l_unexpectedEnabled) then
1555 ecx_debug.log(l_unexpected, l_retmsg,i_method_name);
1556 end if;
1557 raise ecx_utils.program_exit;
1558 end if;
1559 end;
1560
1561 -- maintain attachment mappings if this is a passthrough case
1562 ecx_attachment.remap_attachments(i_msgid);
1563
1564 if(l_statementEnabled) then
1565 ecx_debug.log(l_statement,'Routed MsgId',i_msgid,i_method_name);
1566 end if;
1567 if (l_procedureEnabled) then
1568 ecx_debug.pop(i_method_name);
1569 end if;
1570 exception
1571 WHEN ECX_UTILS.PROGRAM_EXIT THEN
1572 i_hub_user_id := null;
1573 if (l_procedureEnabled) then
1574 ecx_debug.pop(i_method_name);
1575 end if;
1576 raise ecx_utils.program_exit;
1577 when others then
1578 i_hub_user_id := null;
1579 ecx_debug.setErrorInfo(2,30, SQLERRM|| ' - ECX_INBOUND_TRIG.PUT_ON_OUTBOUND');
1580 if(l_unexpectedEnabled) then
1581 --ecx_debug.log(l_statement,ecx_utils.i_errbuf,i_method_name);
1582 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
1583 end if;
1584 raise ecx_utils.program_exit;
1585 end put_on_outbound;
1586
1587 --This is for Internal testing and Debugging Only. Takes the Message
1588 --off from the given Queue in the Browse Mode and processes it.
1589
1590 procedure processmsg_from_queue
1591 (
1592 i_queue_name IN varchar2,
1593 i_debug_level IN pls_integer
1594 )
1595 is
1596 i_method_name varchar2(2000) := 'ecx_inbound_trig.processmsg_from_queue';
1597 v_msgid raw(16);
1598 i_logdir varchar2(200);
1599 i_trigger_id pls_integer;
1600
1601 -- logging enabled
1602 ecx_logging_enabled boolean := false;
1603 logging_enabled varchar2(20);
1604 module varchar2(2000);
1605
1606 begin
1607 fnd_profile.get('AFLOG_ENABLED',logging_enabled);
1608 fnd_profile.get('AFLOG_MODULE',module);
1609 if ecx_debug.g_v_module_name is null then
1610 ecx_debug.module_enabled;
1611 end if;
1612
1613 if(logging_enabled = 'Y' AND ((lower(module) like 'ecx%'
1614 AND instr(lower(ecx_debug.g_v_module_name),rtrim(lower(module),'%'))> 0)
1615 OR module='%')
1616 AND FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) then
1617 ecx_logging_enabled := true;
1618 end if;
1619 -- /logging enabled
1620
1621 IF (ecx_logging_enabled ) THEN
1622 ecx_utils.getLogDirectory;
1623 ecx_debug.enable_debug_new(i_debug_level,ecx_utils.g_logdir, 'IN'||i_queue_name||'.log', 'in.'||i_queue_name||'.log');
1624 END IF;
1625
1626 /* Assign local variables with the ecx_debug global variables*/
1627 l_procedure := ecx_debug.g_procedure;
1628 l_statement := ecx_debug.g_statement;
1629 l_unexpected := ecx_debug.g_unexpected;
1630 l_procedureEnabled := ecx_debug.g_procedureEnabled;
1631 l_statementEnabled := ecx_debug.g_statementEnabled;
1632 l_unexpectedEnabled := ecx_debug.g_unexpectedEnabled;
1633
1634 if (l_procedureEnabled) then
1635 ecx_debug.push(i_method_name);
1636 end if;
1637
1638 if(l_statementEnabled) then
1639 ecx_debug.log(l_statement,'i_queue_name',i_queue_name,i_method_name);
1640 ecx_debug.log(l_statement,'i_debug_level',i_debug_level,i_method_name);
1641 end if;
1642
1643 getmsg_from_queue(i_queue_name,v_msgid);
1644
1645 --validate_message( v_msgid, i_debug_level,i_trigger_id);
1646
1647 if (l_procedureEnabled) then
1648 ecx_debug.pop(i_method_name);
1649 end if;
1650 IF (ecx_logging_enabled ) THEN
1651 ecx_debug.print_log;
1652 ecx_debug.disable_debug;
1653 END IF;
1654
1655 exception
1656 when ecx_utils.program_exit then
1657 if(l_unexpectedEnabled) then
1658 --ecx_debug.log(l_unexpected,ecx_utils.i_errbuf,i_method_name);
1659 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
1660 end if;
1661 IF (ecx_logging_enabled ) THEN
1662 ecx_debug.print_log;
1663 ecx_debug.disable_debug;
1664 END IF;
1665 when others then
1666 ecx_utils.i_errbuf := SQLERRM || ' - ECX_INBOUND_TRIG.PROCESSMSG_FROM_QUEUE';
1667 if(l_unexpectedEnabled) then
1668 --ecx_debug.log(l_unexpected,ecx_utils.i_errbuf,i_method_name);
1669 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
1670 end if;
1671 IF (ecx_logging_enabled ) THEN
1672 ecx_debug.print_log;
1673 ecx_debug.disable_debug;
1674 END IF;
1675 end processmsg_from_queue;
1676
1677
1678 procedure processmsg_from_table
1679 (
1680 i_msgid IN RAW,
1681 i_debug_level IN pls_integer
1682 )
1683 is
1684 i_method_name varchar2(2000) := 'ecx_inbound_trig.processmsg_from_table';
1685 i_logdir varchar2(200);
1686 i_trigger_id pls_integer;
1687
1688 -- logging enabled
1689 ecx_logging_enabled boolean := false;
1690 logging_enabled varchar2(20);
1691 module varchar2(2000);
1692
1693 begin
1694 fnd_profile.get('AFLOG_ENABLED',logging_enabled);
1695 fnd_profile.get('AFLOG_MODULE',module);
1696
1697 if(logging_enabled = 'Y' AND ((lower(module) like 'ecx%'
1698 AND instr(lower(ecx_debug.g_v_module_name),rtrim(lower(module),'%'))> 0)
1699 OR module='%')
1700 AND FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) then
1701 ecx_logging_enabled := true;
1702 end if;
1703 -- /logging enabled
1704
1705 IF (ecx_logging_enabled ) THEN
1706 --get the Log directory from the Profile Option.
1707 ecx_utils.getLogDirectory;
1708 ecx_debug.enable_debug_new(i_debug_level, ecx_utils.g_logdir, 'IN' ||i_msgid||'.log', 'in.'||i_msgid||'.log');
1709 END IF;
1710
1711 /* Assign local variables with the ecx_debug global variables*/
1712 l_procedure := ecx_debug.g_procedure;
1713 l_statement := ecx_debug.g_statement;
1714 l_unexpected := ecx_debug.g_unexpected;
1715 l_procedureEnabled := ecx_debug.g_procedureEnabled;
1716 l_statementEnabled := ecx_debug.g_statementEnabled;
1717 l_unexpectedEnabled := ecx_debug.g_unexpectedEnabled;
1718
1719 if (l_procedureEnabled) then
1720 ecx_debug.push(i_method_name);
1721 end if;
1722
1723 if(l_statementEnabled) then
1724 ecx_debug.log(l_statement,'i_msgid',i_msgid,i_method_name);
1725 ecx_debug.log(l_statement,'i_debug_level',i_debug_level,i_method_name);
1726 end if;
1727
1728 --validate_message( i_msgid, i_debug_level,i_trigger_id);
1729
1730 if (l_procedureEnabled) then
1731 ecx_debug.pop(i_method_name);
1732 end if;
1733
1734 IF (ecx_logging_enabled ) THEN
1735 ecx_debug.print_log;
1736 ecx_debug.disable_debug;
1737 END IF;
1738
1739 exception
1740 when ecx_utils.program_exit then
1741 if(l_unexpectedEnabled) then
1742 --ecx_debug.log(l_unexpected,ecx_utils.i_errbuf,i_method_name);
1743 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
1744 end if;
1745 IF (ecx_logging_enabled ) THEN
1746 ecx_debug.print_log;
1747 ecx_debug.disable_debug;
1748 END IF;
1749
1750 when others then
1751 ecx_utils.i_errbuf := SQLERRM || ' - ECX_INBOUND_TRIG.PROCESSMSG_FROM_TABLE';
1752 if(l_unexpectedEnabled) then
1753 --ecx_debug.log(l_unexpected,ecx_utils.i_errbuf,i_method_name);
1754 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
1755 end if;
1756
1757 IF (ecx_logging_enabled ) THEN
1758 ecx_debug.print_log;
1759 ecx_debug.disable_debug;
1760 END IF;
1761 end processmsg_from_table;
1762
1763 /** New wrap validate message for use with BES
1764 Removed AUTONOMOUS_TRANSACTION, commit and rollback
1765 **/
1766 procedure wrap_validate_message
1767 (
1768 i_msgid IN RAW,
1769 i_debug_level IN pls_integer
1770 )
1771 is
1772 g_instlmode VARCHAR2(100);
1773 i_method_name varchar2(2000) := 'ecx_inbound_trig.wrap_validate_message';
1774 i_logdir varchar2(200);
1775 i_logfile varchar2(200);
1776 msg_not_found exception;
1777
1778 m_transaction_type varchar2(200);
1779 m_transaction_subtype varchar2(200);
1780 m_message_standard varchar2(200);
1781 m_message_type varchar2(200);
1782 m_document_number varchar2(200);
1783 m_routing_ext_code varchar2(200);
1784 m_party_ext_code varchar2(200);
1785 m_payload CLOB;
1786 m_internal_control_number pls_integer;
1787
1788 cursor get_run_s
1789 is
1790 select ecx_output_runs_s.NEXTVAL
1791 from dual;
1792
1793 cursor get_msg
1794 (
1795 p_msgid in raw
1796 )
1797 is
1798 select message_standard,
1799 message_type,
1800 transaction_type,
1801 transaction_subtype,
1802 party_site_id,
1803 payload,
1804 document_number,
1805 attribute3,
1806 internal_control_number
1807 from ecx_doclogs
1808 where msgid = p_msgid
1809 for update;
1810 p_aflog_module_name VARCHAR2(2000) ;
1811
1812 -- logging enabled
1813 ecx_logging_enabled boolean := false;
1814 logging_enabled varchar2(20);
1815 module varchar2(2000);
1816
1817 begin
1818
1819 open get_msg (i_msgid);
1820 fetch get_msg
1821 into m_message_standard,
1822 m_message_type,
1823 m_transaction_type,
1824 m_transaction_subtype,
1825 m_party_ext_code,
1826 m_payload,
1827 m_document_number,
1828 m_routing_ext_code,
1829 m_internal_control_number;
1830
1831 if get_msg%NOTFOUND
1832 then
1833 close get_msg;
1834 raise msg_not_found;
1835 end if;
1836
1837 close get_msg;
1838 ecx_utils.g_direction := 'IN';
1839 ecx_utils.g_logfile :=null;
1840 ecx_debug.g_v_module_name :='ecx.plsql.';
1841 ecx_utils.g_transaction_type := m_transaction_type;
1842 ecx_utils.g_transaction_subtype := m_transaction_subtype;
1843 ecx_utils.g_msgid := i_msgid;
1844 begin
1845 select standard_id
1846 into ecx_utils.g_standard_id
1847 from ecx_standards
1848 where standard_code = m_message_standard
1849 and standard_type = nvl(m_message_type, 'XML');
1850 if(l_statementEnabled) then
1851 ecx_debug.log(l_statement,'Standard id',ecx_utils.g_standard_id,i_method_name);
1852 end if;
1853 exception
1854 when others then
1855 ecx_debug.setErrorInfo(1,30,'ECX_UNSUPPORTED_STANDARD');
1856 raise ecx_utils.program_exit;
1857 end;
1858 ecx_debug.module_enabled;
1859 g_instlmode := wf_core.translate('WF_INSTALL');
1860
1861 if(g_instlmode = 'EMBEDDED')
1862 THEN
1863 fnd_profile.get('AFLOG_ENABLED',logging_enabled);
1864 fnd_profile.get('AFLOG_MODULE',module);
1865 if(logging_enabled = 'Y' AND ((lower(module) like 'ecx%'
1866 AND instr(lower(ecx_debug.g_v_module_name),rtrim(lower(module),'%'))> 0)
1867 OR module='%')
1868 AND FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) then
1869 ecx_logging_enabled := true;
1870 end if;
1871 elsif(g_instlmode = 'STANDALONE')
1872 then
1873 if (i_debug_level > 0) then
1874 ecx_logging_enabled := true;
1875 end if;
1876 end if;
1877 IF (ecx_logging_enabled ) THEN
1878 /**
1879 Fetch the Run Id for the Transaction
1880 **/
1881 open get_run_s;
1882 fetch get_run_s
1883 into ecx_utils.g_run_id;
1884 close get_run_s;
1885
1886 --get the Log directory from the Profile Option.
1887 ecx_utils.getLogDirectory;
1888
1889 i_logfile := substr(m_message_standard,1,10)||'IN'||substr(m_transaction_type,1,20)||substr(m_transaction_subtype,1,20)||ecx_utils.g_run_id||'.log';
1890
1891 p_aflog_module_name := '';
1892 IF (m_message_standard is not null) THEN
1893 p_aflog_module_name := p_aflog_module_name||m_message_standard||'.';
1894 END IF;
1895 p_aflog_module_name := p_aflog_module_name || 'in.';
1896 IF (m_transaction_type is not null) THEN
1897 p_aflog_module_name := p_aflog_module_name||m_transaction_type||'.';
1898 END IF;
1899 IF (m_transaction_subtype is not null) THEN
1900 p_aflog_module_name := p_aflog_module_name||m_transaction_subtype||'.';
1901 END IF;
1902 IF (ecx_utils.g_run_id is not null) THEN
1903 p_aflog_module_name := p_aflog_module_name||ecx_utils.g_run_id;
1904 END IF;
1905 p_aflog_module_name := p_aflog_module_name||'.log';
1906
1907 ecx_debug.enable_debug_new(i_debug_level,ecx_utils.g_logdir,i_logfile, p_aflog_module_name);
1908 END IF;
1909
1910 /* Assign local variables with the ecx_debug global variables*/
1911 l_procedure := ecx_debug.g_procedure;
1912 l_statement := ecx_debug.g_statement;
1913 l_unexpected := ecx_debug.g_unexpected;
1914 l_procedureEnabled := ecx_debug.g_procedureEnabled;
1915 l_statementEnabled := ecx_debug.g_statementEnabled;
1916 l_unexpectedEnabled := ecx_debug.g_unexpectedEnabled;
1917
1918 if (l_procedureEnabled) then
1919 ecx_debug.push(i_method_name);
1920 end if;
1921
1922 if(l_statementEnabled) then
1923 ecx_debug.log(l_statement,'i_msgid',i_msgid,i_method_name);
1924 ecx_debug.log(l_statement,'i_debug_level',i_debug_level,i_method_name);
1925 end if;
1926 ecx_utils.g_document_id :=m_internal_control_number;
1927
1928 IF (ecx_logging_enabled and g_instlmode = 'STANDALONE') THEN
1929 ecx_utils.g_logfile :=i_logfile;
1930 END IF;
1931
1932 /*ecx_utils.g_direction := 'IN';
1933
1934 ecx_utils.g_transaction_type := m_transaction_type;
1935 ecx_utils.g_transaction_subtype := m_transaction_subtype;
1936 ecx_utils.g_msgid := i_msgid;*/
1937
1938 /*begin
1939 select standard_id
1940 into ecx_utils.g_standard_id
1941 from ecx_standards
1942 where standard_code = m_message_standard
1943 and standard_type = nvl(m_message_type, 'XML');
1944 if(l_statementEnabled) then
1945 ecx_debug.log(l_statement,'Standard id',ecx_utils.g_standard_id,i_method_name);
1946 end if;
1947 exception
1948 when others then
1949 ecx_debug.setErrorInfo(1,30,'ECX_UNSUPPORTED_STANDARD');
1950 raise ecx_utils.program_exit;
1951 enid;*/
1952 validate_message
1953 (
1954 i_msgid,
1955 m_message_standard,
1956 m_transaction_type,
1957 m_transaction_subtype,
1958 m_party_ext_code,
1959 m_document_number,
1960 m_routing_ext_code,
1961 m_payload,
1962 m_message_type
1963 );
1964
1965 if (l_procedureEnabled) then
1966 ecx_debug.pop(i_method_name);
1967 end if;
1968 IF (ecx_logging_enabled ) THEN
1969 ecx_debug.print_log;
1970 ecx_debug.disable_debug;
1971 END IF;
1972
1973 exception
1974 when ecx_utils.program_exit then
1975 --ecx_utils.g_map_id := -1;
1976 if(l_unexpectedEnabled) then
1977 --ecx_debug.log(l_unexpected,ecx_utils.i_errbuf,i_method_name);
1978 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
1979 end if;
1980 if (l_procedureEnabled) then
1981 ecx_debug.pop(i_method_name);
1982 end if;
1983
1984 IF (ecx_logging_enabled ) THEN
1985 ecx_debug.print_log;
1986 ecx_debug.disable_debug;
1987 END IF;
1988
1989 raise;
1990 when msg_not_found then
1991 --ecx_utils.g_map_id := -1;
1992 ecx_debug.setErrorInfo(1,30,'ECX_MSGID_NOT_FOUND',
1993 'p_msgid',
1994 i_msgid);
1995 close get_msg;
1996 raise;
1997 when others then
1998 --ecx_utils.g_map_id := -1;
1999 ecx_debug.setErrorInfo(2,30,SQLERRM || ' - ECX_INBOUND_TRIG.WRAP_VALIDATE_MESSAGE');
2000 if(l_unexpectedEnabled) then
2001 --ecx_debug.log(l_unexpected,ecx_utils.i_errbuf,i_method_name);
2002 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
2003 end if;
2004 if (l_procedureEnabled) then
2005 ecx_debug.pop(i_method_name);
2006 end if;
2007
2008 IF (ecx_logging_enabled ) THEN
2009 ecx_debug.print_log;
2010 ecx_debug.disable_debug;
2011 END IF;
2012
2013 raise;
2014 end wrap_validate_message;
2015
2016 /**
2017 Old wrap validate message - pre BES integration.
2018 Present for backward compatibility.
2019 **/
2020 procedure wrap_validate_message
2021 (
2022 i_msgid IN RAW,
2023 i_debug_level IN pls_integer,
2024 i_trigger_id OUT NOCOPY pls_integer
2025 )
2026 is
2027 i_method_name varchar2(2000) := 'ecx_inbound_trig.wrap_validate_message';
2028 i_logdir varchar2(200);
2029 i_logfile varchar2(200);
2030 PRAGMA AUTONOMOUS_TRANSACTION;
2031 msg_not_found exception;
2032
2033 m_transaction_type varchar2(200);
2034 m_transaction_subtype varchar2(200);
2035 m_message_standard varchar2(200);
2036 m_message_type varchar2(200);
2037 m_document_number varchar2(200);
2038 m_routing_ext_code varchar2(200);
2039 m_party_ext_code varchar2(200);
2040 m_payload CLOB;
2041 m_internal_control_number pls_integer;
2042
2043 cursor get_run_s
2044 is
2045 select ecx_output_runs_s.NEXTVAL
2046 from dual;
2047
2048
2049 cursor get_msg
2050 (
2051 p_msgid in raw
2052 )
2053 is
2054 select message_standard,
2055 message_type,
2056 transaction_type,
2057 transaction_subtype,
2058 party_site_id,
2059 payload,
2060 document_number,
2061 attribute3,
2062 internal_control_number
2063 from ecx_doclogs
2064 where msgid = p_msgid
2065 for update;
2066 p_aflog_module_name VARCHAR2(2000) ;
2067
2068 -- logging enabled
2069 ecx_logging_enabled boolean := false;
2070 logging_enabled varchar2(20);
2071 module varchar2(2000);
2072
2073 begin
2074 ecx_utils.g_logfile :=null;
2075 ecx_debug.g_v_module_name :='ecx.plsql.';
2076 fnd_profile.get('AFLOG_ENABLED',logging_enabled);
2077 fnd_profile.get('AFLOG_MODULE',module);
2078 if(logging_enabled = 'Y' AND ((lower(module) like 'ecx%'
2079 AND instr(lower(ecx_debug.g_v_module_name),rtrim(lower(module),'%'))> 0)
2080 OR module='%')
2081 AND FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) then
2082 ecx_logging_enabled := true;
2083 end if;
2084 -- /logging enabled
2085
2086 open get_msg (i_msgid);
2087 fetch get_msg
2088 into m_message_standard,
2089 m_message_type,
2090 m_transaction_type,
2091 m_transaction_subtype,
2092 m_party_ext_code,
2093 m_payload,
2094 m_document_number,
2095 m_routing_ext_code,
2096 m_internal_control_number;
2097
2098 if get_msg%NOTFOUND
2099 then
2100 close get_msg;
2101 raise msg_not_found;
2102 end if;
2103
2104 close get_msg;
2105
2106 IF (ecx_logging_enabled ) THEN
2107 /**
2108 Fetch the Run Id for the Transaction
2109 **/
2110 open get_run_s;
2111 fetch get_run_s
2112 into ecx_utils.g_run_id;
2113 close get_run_s;
2114
2115 --get the Log directory from the Profile Option.
2116 ecx_utils.getLogDirectory;
2117
2118 i_logfile := m_message_standard||'IN'||m_transaction_type||m_transaction_subtype||ecx_utils.g_run_id||'.log';
2119
2120 p_aflog_module_name := '';
2121 IF (m_message_standard is not null) THEN
2122 p_aflog_module_name := p_aflog_module_name||m_message_standard||'.';
2123 END IF;
2124 p_aflog_module_name := p_aflog_module_name || 'in.';
2125 IF (m_transaction_type is not null) THEN
2126 p_aflog_module_name := p_aflog_module_name||m_transaction_type||'.';
2127 END IF;
2128 IF (m_transaction_subtype is not null) THEN
2129 p_aflog_module_name := p_aflog_module_name||m_transaction_subtype||'.';
2130 END IF;
2131 IF (ecx_utils.g_run_id is not null) THEN
2132 p_aflog_module_name := p_aflog_module_name||ecx_utils.g_run_id;
2133 END IF;
2134 p_aflog_module_name := p_aflog_module_name||'.log';
2135
2136 ecx_debug.enable_debug_new(i_debug_level,ecx_utils.g_logdir,i_logfile, p_aflog_module_name);
2137 END IF;
2138
2139 /* Assign local variables with the ecx_debug global variables*/
2140 l_procedure := ecx_debug.g_procedure;
2141 l_statement := ecx_debug.g_statement;
2142 l_unexpected := ecx_debug.g_unexpected;
2143 l_procedureEnabled := ecx_debug.g_procedureEnabled;
2144 l_statementEnabled := ecx_debug.g_statementEnabled;
2145 l_unexpectedEnabled := ecx_debug.g_unexpectedEnabled;
2146
2147 if (l_procedureEnabled) then
2148 ecx_debug.push(i_method_name);
2149 end if;
2150
2151 if(l_statementEnabled) then
2152 ecx_debug.log(l_statement,'i_msgid',i_msgid,i_method_name);
2153 ecx_debug.log(l_statement,'i_debug_level',i_debug_level,i_method_name);
2154 end if;
2155 ecx_utils.g_document_id :=m_internal_control_number;
2156
2157 IF (ecx_logging_enabled ) THEN
2158 ecx_utils.g_logfile :=i_logfile;
2159 END IF;
2160
2161 ecx_utils.g_direction := 'IN';
2162
2163 ecx_utils.g_transaction_type := m_transaction_type;
2164 ecx_utils.g_transaction_subtype := m_transaction_subtype;
2165 ecx_utils.g_msgid := i_msgid;
2166
2167 begin
2168 select standard_id
2169 into ecx_utils.g_standard_id
2170 from ecx_standards
2171 where standard_code = m_message_standard
2172 and standard_type = nvl(m_message_type, 'XML');
2173 if(l_statementEnabled) then
2174 ecx_debug.log(l_statement,'Standard id',ecx_utils.g_standard_id,i_method_name);
2175 end if;
2176 exception
2177 when others then
2178 ecx_debug.setErrorInfo(1,30,'ECX_UNSUPPORTED_STANDARD');
2179 raise ecx_utils.program_exit;
2180 end;
2181
2182 validate_message
2183 (
2184 i_msgid,
2185 m_message_standard,
2186 m_transaction_type,
2187 m_transaction_subtype,
2188 m_party_ext_code,
2189 m_document_number,
2190 m_routing_ext_code,
2191 m_payload,
2192 m_message_type
2193 );
2194
2195 if (l_procedureEnabled) then
2196 ecx_debug.pop(i_method_name);
2197 end if;
2198 IF (ecx_logging_enabled ) THEN
2199 ecx_debug.print_log;
2200 ecx_debug.disable_debug;
2201 END IF;
2202
2203 commit;
2204 exception
2205 when ecx_utils.program_exit then
2206 --ecx_utils.g_map_id := -1;
2207 if(l_unexpectedEnabled) then
2208 --ecx_debug.log(l_unexpected,ecx_utils.i_errbuf,i_method_name);
2209 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
2210 end if;
2211 IF (ecx_logging_enabled ) THEN
2212 ecx_debug.print_log;
2213 ecx_debug.disable_debug;
2214 END IF;
2215 rollback;
2216 when msg_not_found then
2217 --ecx_utils.g_map_id := -1;
2218 ecx_debug.setErrorInfo(1,30,'ECX_MSGID_NOT_FOUND',
2219 'p_msgid',
2220 i_msgid);
2221 close get_msg;
2222 rollback;
2223 when others then
2224 --ecx_utils.g_map_id := -1;
2225 ecx_debug.setErrorInfo(2,30,SQLERRM || ' - ECX_INBOUND_TRIG.WRAP_VALIDATE_MESSAGE');
2226 if(l_unexpectedEnabled) then
2227 --ecx_debug.log(l_unexpected,ecx_utils.i_errbuf,i_method_name);
2228 ecx_debug.log(l_unexpected,ecx_debug.getMessage(ecx_utils.i_errbuf,ecx_utils.i_errparams),i_method_name);
2229 end if;
2230 IF (ecx_logging_enabled ) THEN
2231 ecx_debug.print_log;
2232 ecx_debug.disable_debug;
2233 END IF;
2234
2235 rollback;
2236 end wrap_validate_message;
2237
2238 procedure processXML
2239 (
2240 i_map_code IN varchar2,
2241 i_payload IN CLOB,
2242 i_debug_level IN pls_integer,
2243 i_ret_code OUT NOCOPY pls_integer,
2244 i_errbuf OUT NOCOPY varchar2,
2245 i_log_file OUT NOCOPY varchar2,
2246 o_payload OUT NOCOPY CLOB,
2247 i_message_standard IN varchar2,
2248 i_message_type IN varchar2
2249 )
2250 is
2251 i_method_name varchar2(2000) := 'ecx_inbound_trig.processxml';
2252 i_logdir varchar2(200);
2253 i_logfile varchar2(200);
2254 i_map_id pls_integer;
2255 g_instlmode VARCHAR2(100);
2256
2257 cursor get_run_s
2258 is
2259 select ecx_output_runs_s.NEXTVAL
2260 from dual;
2261
2262 ecx_logging_enabled boolean := false;
2263 logging_enabled varchar2(20);
2264 module varchar2(2000);
2265
2266 begin
2267 g_instlmode := wf_core.translate('WF_INSTALL');
2268
2269 if(g_instlmode = 'EMBEDDED')
2270 THEN
2271 fnd_profile.get('AFLOG_ENABLED',logging_enabled);
2272 fnd_profile.get('AFLOG_MODULE',module);
2273 if(logging_enabled = 'Y' AND ((lower(module) like 'ecx%'
2274 AND instr(lower(ecx_debug.g_v_module_name),rtrim(lower(module),'%'))> 0)
2275 OR module='%')
2276 AND FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) then
2277 ecx_logging_enabled := true;
2278 end if;
2279 elsif(g_instlmode = 'STANDALONE')
2280 then
2281 if (i_debug_level > 0) then
2282 ecx_logging_enabled := true;
2283 end if;
2284 end if;
2285
2286 IF (ecx_logging_enabled ) THEN
2287 /**
2288 Fetch the Run Id for the Transaction
2289 **/
2290 open get_run_s;
2291 fetch get_run_s
2292 into ecx_utils.g_run_id;
2293 close get_run_s;
2294
2295 --get the Log directory from the Profile Option.
2296 ecx_utils.getLogDirectory;
2297 i_logfile := 'IN'||ecx_utils.g_run_id||'.log';
2298 END IF;
2299
2300 IF g_instlmode = 'EMBEDDED' THEN
2301 IF (ecx_logging_enabled ) THEN
2302 i_log_file := ecx_debug.g_sqlprefix || 'in.'||ecx_utils.g_run_id||'.log';
2303 ELSE
2304 i_log_file := 'Please ensure that FND-Logging is enabled for module '||ecx_debug.g_sqlprefix||'%';
2305 END IF;
2306 ELSE
2307 IF (ecx_logging_enabled ) THEN
2308 i_log_file := ecx_utils.g_logdir||'/'||i_logfile;
2309 ELSE
2310 i_log_file := 'Please ensure that logging is enabled';
2311 END IF;
2312 END IF;
2313
2314 IF (ecx_logging_enabled ) THEN
2315 ecx_debug.enable_debug_new(i_debug_level,ecx_utils.g_logdir,i_logfile, 'in.'||ecx_utils.g_run_id||'.log');
2316 END IF;
2317
2318 /* Assign local variables with the ecx_debug global variables*/
2319 l_procedure := ecx_debug.g_procedure;
2320 l_statement := ecx_debug.g_statement;
2321 l_unexpected := ecx_debug.g_unexpected;
2322 l_procedureEnabled := ecx_debug.g_procedureEnabled;
2323 l_statementEnabled := ecx_debug.g_statementEnabled;
2324 l_unexpectedEnabled := ecx_debug.g_unexpectedEnabled;
2325
2326 if (l_procedureEnabled) then
2327 ecx_debug.push(i_method_name);
2328 end if;
2329
2330 if(l_statementEnabled) then
2331 ecx_debug.log(l_statement,'i_map_code',i_map_code,i_method_name);
2332 ecx_debug.log(l_statement,'i_debug_level',i_debug_level,i_method_name);
2333 end if;
2334
2335 IF (ecx_logging_enabled ) THEN
2336 ecx_utils.g_logfile :=i_logfile;
2337 END IF;
2338 ecx_utils.g_direction := 'IN';
2339
2340 begin
2341 select map_id
2342 into i_map_id
2343 from ecx_mappings
2344 where map_code = i_map_code;
2345 exception
2346 when others then
2347 ecx_debug.setErrorInfo(2,30,'ECX_MAP_NOT_FOUND',
2348 'MAP_CODE',
2349 i_map_code);
2350 raise ecx_utils.program_exit;
2351 end;
2352
2353 begin
2354 select standard_id
2355 into ecx_utils.g_standard_id
2356 from ecx_standards
2357 where standard_code = i_message_standard
2358 and standard_type = nvl(i_message_type, 'XML');
2359 if(l_statementEnabled) then
2360 ecx_debug.log(l_statement,'Standard id',ecx_utils.g_standard_id,i_method_name);
2361 end if;
2362 exception
2363 when others then
2364 ecx_debug.setErrorInfo(1,30,'ECX_UNSUPPORTED_STANDARD');
2365 raise ecx_utils.program_exit;
2366 end;
2367
2368 /*bug16442475 return status to notified and will set to complete from java*/
2369 if ecx_utils.g_from_processxml and ECX_UTIL_API.isInJavaProcessEnabled then
2370 raiseEvent(
2371 i_msgid => null,
2372 i_document_number => null,
2373 i_map_id => i_map_id,
2374 i_rcv_tp_id => null,
2375 i_payload => i_payload,
2376 i_no_routing => 'N'
2377 );
2378 if(l_statementEnabled) then
2379 ecx_debug.log(l_statement, 'ECX', 'Raised an event to process an xml at java layer',i_method_name);
2380 end if;
2381 /*set status to 0, other wise wffunction(caller of this function) will throw wf error for non zero error code */
2382 if(ecx_utils.i_ret_code = 10) then
2383 ecx_utils.i_ret_code := 0;
2384 end if;
2385 else
2386 ecx_debug.log(l_statement,'==>i_map_id',i_map_id,i_method_name);
2387 processXMLData
2388 (
2389 i_map_id,
2390 i_payload,
2391 null,
2392 null,
2393 i_message_standard,
2394 o_payload,
2395 i_message_type
2396 );
2397 --ecx_utils.i_ret_code :=0;
2398 --ecx_utils.i_errbuf := 'XML Document Successfully processed';
2399 ecx_debug.setErrorInfo(0,10,'ECX_DOCUMENT_PROCESSED');
2400 end if;
2401
2402 --ecx_utils.i_ret_code :=0;
2403 --ecx_utils.i_errbuf := 'XML Document Successfully processed';
2404 ecx_debug.setErrorInfo(0,10,'ECX_DOCUMENT_PROCESSED');
2405
2406 if(ecx_utils.i_ret_code = 0 ) then
2407 if(l_statementEnabled) then
2408 ecx_debug.log(l_statement, 'Ret Code',ecx_utils.i_ret_code,i_method_name);
2409 ecx_debug.log(l_statement, 'Ret Msg ',ecx_utils.i_errbuf,i_method_name);
2410 end if;
2411 else
2412 if(l_unexpectedEnabled) then
2413 ecx_debug.log(l_unexpected, 'Ret Code',ecx_utils.i_ret_code,i_method_name);
2414 ecx_debug.log(l_unexpected, 'Ret Msg ',ecx_utils.i_errbuf,i_method_name);
2415 end if;
2416 end if;
2417
2418 if (l_procedureEnabled) then
2419 ecx_debug.pop(i_method_name);
2420 end if;
2421
2422 IF (ecx_logging_enabled ) THEN
2423 ecx_debug.print_log;
2424 ecx_debug.disable_debug;
2425 END IF;
2426
2427 i_ret_code := ecx_utils.i_ret_code;
2428 i_errbuf := ecx_utils.i_errbuf;
2429
2430 exception
2431 when ecx_utils.program_exit then
2432 --dbms_lob.freetemporary(o_payload);
2433 --ecx_utils.g_map_id := -1;
2434 if(l_unexpectedEnabled) then
2435 ecx_debug.log(l_unexpected,'Ret Code',ecx_utils.i_ret_code,i_method_name);
2436 ecx_debug.log(l_unexpected, 'Ret Msg ',ecx_debug.getMessage(ecx_utils.i_errbuf,
2437 ecx_utils.i_errparams),i_method_name);
2438 end if;
2439 if (l_procedureEnabled) then
2440 ecx_debug.pop(i_method_name);
2441 end if;
2442 IF (ecx_logging_enabled ) THEN
2443 ecx_debug.print_log;
2444 ecx_debug.disable_debug;
2445 END IF;
2446 i_ret_code := ecx_utils.i_ret_code;
2447 i_errbuf := ecx_utils.i_errbuf;
2448
2449 when others then
2450 --dbms_lob.freetemporary(o_payload);
2451 --ecx_utils.g_map_id := -1;
2452 ecx_debug.setErrorInfo(2,30,SQLERRM || ' - ECX_INBOUND_TRIG.WRAP_VALIDATE_MESSAGE');
2453 if(l_unexpectedEnabled) then
2454 ecx_debug.log(l_unexpected,'Ret Code',ecx_utils.i_ret_code,i_method_name);
2455 ecx_debug.log(l_unexpected, 'Ret Msg ',ecx_debug.getMessage(ecx_utils.i_errbuf,
2456 ecx_utils.i_errparams),i_method_name);
2457 end if;
2458 if (l_procedureEnabled) then
2459 ecx_debug.pop(i_method_name);
2460 end if;
2461 IF (ecx_logging_enabled ) THEN
2462 ecx_debug.print_log;
2463 ecx_debug.disable_debug;
2464 END IF;
2465 i_ret_code := ecx_utils.i_ret_code;
2466 i_errbuf := ecx_utils.i_errbuf;
2467 end processXML;
2468
2469
2470 procedure reprocess
2471 (
2472 i_msgid IN RAW,
2473 i_debug_level IN pls_integer,
2474 i_trigger_id OUT NOCOPY number,
2475 i_retcode OUT NOCOPY pls_integer,
2476 i_errbuf OUT NOCOPY varchar2
2477 )
2478 is
2479 i_process_id raw(16);
2480 cursor c_ecx_trigger_id
2481 is
2482 select ecx_trigger_id_s.NEXTVAL
2483 from dual;
2484
2485 begin
2486 /* open c_ecx_trigger_id;
2487 fetch c_ecx_trigger_id into i_trigger_id;
2488 close c_ecx_trigger_id;*/
2489 ecx_debug.setErrorInfo(10,10,'ECX_REPROCESSING_MESSAGE');
2490 /* ecx_errorlog.inbound_trigger
2491 (
2492 i_trigger_id,
2493 i_msgid,
2494 null,
2495 ecx_utils.i_ret_code,
2496 ecx_utils.i_errbuf
2497 );
2498
2499 */
2500
2501 begin
2502 ecx_inbound_trig.wrap_validate_message
2503 (
2504 i_msgid,
2505 i_debug_level
2506 );
2507
2508 ecx_debug.setErrorInfo(0,10,'ECX_MESSAGE_REPROCESSED');
2509 select process_id into i_process_id from ecx_inbound_logs where msgid=i_msgid;
2510 if(i_process_id is null) -- means TP setup wrong. Message never got into transaction queue.
2511 then
2512 return;
2513 end if;
2514 ecx_errorlog.inbound_engine(i_process_id,ecx_utils.i_ret_code,
2515 ecx_utils.i_errbuf);
2516 ecx_utils.g_logfile := null;
2517 exception
2518 when others then
2519
2520 select process_id into i_process_id from ecx_inbound_logs where msgid=i_msgid; -- fix for bug 7609421 / 8629681
2521 ecx_errorlog.inbound_engine(i_process_id,ecx_utils.i_ret_code, ecx_utils.i_errbuf,ecx_utils.i_errparams);
2522 i_retcode := ecx_utils.i_ret_code;
2523 i_errbuf := ecx_utils.i_errbuf;
2524 ecx_utils.g_logfile := null;
2525 end;
2526
2527 --Changed for MLS
2528 ecx_debug.setErrorInfo(0,10,'ECX_MESSAGE_REPROCESSED');
2529 i_retcode := ecx_utils.i_ret_code;
2530 i_errbuf := ecx_utils.i_errbuf;
2531 exception
2532 when others then
2533 i_retcode := ecx_utils.i_ret_code;
2534 i_errbuf := ecx_utils.i_errbuf;
2535 raise;
2536 end reprocess;
2537 /*
2538 * Raising an event(oracle.apps.ecx.inbound.process_at_java)
2539 * which has subscription to Java function which process
2540 * the inbound message
2541 */
2542 procedure raiseEvent(i_msgid IN raw,
2543 i_document_number IN varchar2,
2544 i_map_id IN pls_integer,
2545 i_rcv_tp_id in pls_integer,
2546 i_payload IN clob,
2547 i_no_routing in varchar2)
2548 as
2549 l_method_name varchar2(200):='ecx_inbound_trig.raiseEvent';
2550 l_event wf_event_t;
2551 l_event_name varchar2(100) :='oracle.apps.ecx.inbound.process_at_java';
2552 l_event_key varchar (100);
2553 l_process_id varchar2(200);
2554 l_msg_id_null varchar2(1);
2555 begin
2556 l_event_key := i_msgid;
2557 select decode(i_msgid,null,'Y','N') into l_msg_id_null from dual;
2558 if (l_msg_id_null = 'Y') then
2559 l_event_key := TO_CHAR(sysdate,'ddmmhhmiss');
2560 end if;
2561
2562 if(l_statementEnabled) then
2563 ecx_debug.log(l_statement, 'ECX', 'Raising an event to processing an xml at middle tier',l_method_name);
2564 ecx_debug.log(l_statement, 'Event Name',l_event_name,l_method_name);
2565 ecx_debug.log(l_statement, 'Event Key',l_event_key,l_method_name);
2566 ecx_debug.log(l_statement, 'LOGFILE', ecx_utils.g_logfile,l_method_name);
2567 ecx_debug.log(l_statement, 'ecx_utils.g_item_type',ecx_utils.g_item_type,l_method_name);
2568 ecx_debug.log(l_statement, 'ITEM_TYPE', ecx_utils.g_item_type,l_method_name);
2569 ecx_debug.log(l_statement, 'ITEM_KEY', ecx_utils.g_item_key,l_method_name);
2570 ecx_debug.log(l_statement, 'ACTIVITY_ID', ecx_utils.g_activity_id,l_method_name);
2571 ecx_debug.log(l_statement, 'DOCUMENT_ID', i_document_number,l_method_name);
2572 ecx_debug.log(l_statement, 'PROCESS_ID', l_process_id,l_method_name);
2573 ecx_debug.log(l_statement, 'MSGID', i_msgid,l_method_name);
2574 ecx_debug.log(l_statement, 'i_no_routing', i_no_routing,l_method_name);
2575 end if;
2576 wf_event_t.initialize(l_event);
2577 if (l_msg_id_null = 'N') then
2578 select process_id into l_process_id from ecx_inbound_logs where msgid=i_msgid;
2579 end if;
2580 l_event.addParameterToList('ROUTING_ID', ecx_utils.g_routing_id);
2581 if(l_statementEnabled) then
2582 l_event.addParameterToList('STAMENT_LEVEL_ENABLED', 'Y');
2583 end if;
2584 ecx_debug.log(l_statement, 'ecx_utils.g_org_id',ecx_utils.g_org_id,l_method_name);
2585 l_event.addParameterToList('MSGID', i_msgid);
2586 l_event.addParameterToList('DOCUMENT_ID', i_document_number);
2587 l_event.addParameterToList('PROCESS_ID', l_process_id);
2588 l_event.addParameterToList('MAP_CODE', i_map_id);
2589 l_event.addParameterToList('ORG_ID', ecx_utils.g_org_id);
2590 l_event.addParameterToList('SENDER_TP_ID', ecx_utils.g_snd_tp_id);
2591 l_event.addParameterToList('RECV_TP_ID', i_rcv_tp_id);
2592 l_event.addParameterToList('MAP_CODE', i_map_id);
2593 l_event.addParameterToList('LOGFILE', ecx_utils.g_logfile);
2594 l_event.addParameterToList('STANDARD_ID', ecx_utils.g_standard_id);
2595 l_event.addParameterToList('ITEM_TYPE', ecx_utils.g_item_type);
2596 l_event.addParameterToList('ITEM_KEY', ecx_utils.g_item_key);
2597 l_event.addParameterToList('ACTIVITY_ID', ecx_utils.g_activity_id);
2598 l_event.addParameterToList('NO_ROUTING', i_no_routing);
2599 wf_event.raise( P_EVENT_NAME=>l_event_name , P_EVENT_KEY => l_event_key, p_event_data =>i_payload ,p_parameters => l_event.getparameterlist());
2600 ecx_debug.setErrorInfo(10, 10, 'Event(key:'||l_event_key ||') has been raised for messgae processing at java layer');
2601 end raiseEvent;
2602 /**
2603 * This api is to set the notified WF process function to error with name
2604 * and stack trace
2605 */
2606 procedure setWFFunctionErrorStatus(
2607 i_itemtype IN varchar2,
2608 i_itemkey IN varchar2,
2609 i_actid IN varchar2,
2610 i_errcode IN varchar2,
2611 i_errmsg IN varchar2,
2612 i_errparams IN varchar2,
2613 i_logfile IN varchar2,
2614 i_errorstack IN varchar2
2615 )as
2616 begin
2617 wf_core.clear;
2618 wf_core.token('ECX_ERRMSG',ecx_debug.getMessage(i_errmsg,i_errparams));
2619 wf_core.token('ECX_LOGFILE',i_logfile);
2620 begin
2621 if i_errcode = '1' then
2622 wf_core.raise('ECX_PROCESS_XMLERROR');
2623 else
2624 wf_core.raise('ECX_PROGRAM_EXIT');
2625 end if;
2626 exception
2627 when others then
2628 wf_core.context('oracle.apps.ecx.engine.in','InboundMsgProcesser', i_errorstack);
2629 WF_ITEM_ACTIVITY_STATUS.Set_Error(i_itemtype,
2630 i_itemkey,
2631 i_actid,
2632 i_errcode );
2633 end;
2634 end setWFFunctionErrorStatus;
2635
2636 end ecx_inbound_trig;
2637