DBA Data[Home] [Help]

PACKAGE BODY: APPS.ECX_DOCUMENT

Source


1 PACKAGE BODY ecx_document AS
2 -- $Header: ECXSENDB.pls 120.10.12020000.4 2013/01/22 09:35:21 dhragarw 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 /**
12 Get COnfirmation Document Data
13 **/
14 /* Bug 2122579 */
15 procedure getConfirmation
16 	(
17 	p_transaction_type	in	varchar2,
18 	p_transaction_subtype	in	varchar2,
19         p_party_type            in      varchar2 ,--Bug #2183619
20 	p_document_id		in	varchar2,
21 	i_party_id		OUT	NOCOPY number,
22 	i_party_site_id		OUT     NOCOPY number
23 	)
24 is
25 
26 i_method_name   varchar2(2000) := 'ecx_document.getConfirmation';
27 
28 i_location_code		varchar2(200);
29 i_transaction_type	varchar2(200);
30 i_transaction_subtype   varchar2(200);
31 i_confirmation		pls_integer;
32 begin
33 if (l_procedureEnabled) then
34  ecx_debug.push(i_method_name);
35 end if;
36 if(l_statementEnabled) then
37   ecx_debug.log(l_statement,'transaction_type',p_transaction_type,i_method_name);
38   ecx_debug.log(l_statement,'transaction_subtype',p_transaction_subtype,i_method_name);
39   ecx_debug.log(l_statement,'party type', p_party_type,i_method_name);
40   ecx_debug.log(l_statement,'document_id',p_document_id,i_method_name);
41 end if;
42 
43 
44 	begin
45                 select  party_site_id,
46                         transaction_type,
47                         transaction_subtype,
48                         field8
49                 into    i_location_code,
50                         i_transaction_type,
51                         i_transaction_subtype,
52                         i_confirmation
53                 from    ecx_doclogs
54                 where   internal_control_number = p_document_id;
55 	exception
56 	when no_data_found then
57                 ecx_debug.setErrorInfo(2,30,'ECX_CONFIRM_DOC_NOT_FOUND');
58 	        raise ecx_utils.program_exit;
59 	end;
60 
61 	if i_transaction_type = 'BOD'
62 	then
63                 ecx_debug.setErrorInfo(2,30,'ECX_CONFIRM_GENERATE_FAILED');
64 		raise ecx_utils.program_exit;
65 	end if;
66 
67         if(l_statementEnabled) then
68             ecx_debug.log(l_statement, 'Document Confirmation',i_confirmation,i_method_name);
69 	end if;
70 
71         /* Here we are checking to see if the sender of the inbound requested confirmation
72            for the document */
73         if i_confirmation = 0
74         then
75                ecx_debug.setErrorInfo(0,10,'ECX_CONFIRM_NOT_REQUESTED',
76                                             'p_transaction_type',
77                                              i_transaction_type,
78                                              'p_transaction_subtype',
79                                              i_transaction_subtype,
80                                              'p_document_id',
81                                              p_document_id,
82                                              'p_location_code',
83                                              i_location_code);
84                raise ecx_no_delivery_required;
85         end if;
86 
87 	begin
88            -- Added check for party type for bug #2183619
89 	   select  	party_id,
90 			party_site_id,
91 			confirmation
92 	   into		i_party_id,
93 			i_party_site_id,
94 			i_confirmation
95 	   from    	ecx_ext_processes eep,
96                         ecx_transactions et,
97 		   	ecx_standards es,
98 			ecx_tp_headers eth,
99 			ecx_tp_details etd
100            where        et.transaction_type = p_transaction_type
101            and          et.transaction_subtype = p_transaction_subtype
102            and          (p_party_type is null or eth.party_type = p_party_type)
103            and          eep.transaction_id = et.transaction_id
104 	   and     	eep.direction = 'OUT'
105 	   and     	eep.standard_id = es.standard_id
106 	   and     	es.standard_code = 'OAG'
107 	   and		etd.source_tp_location_code = i_location_code
108 	   and		etd.tp_header_id = eth.tp_header_id
109 	   and		etd.ext_process_id = eep.ext_process_id;
110 	   --and		rownum < 2;
111 
112 	exception
113 	when no_data_found then
114                 ecx_debug.setErrorInfo(2,30,'ECX_CONFIRM_TP_NOT_SETUP',
115                                             'p_transaction_type',
116                                              p_transaction_type,
117                                              'p_transaction_subtype',
118                                              p_transaction_subtype,
119                                              'p_location_code',
120                                              i_location_code);
121 		raise ecx_utils.program_exit;
122 
123       /* Start of bug #2183619*/
124        when too_many_rows then
125                 ecx_debug.setErrorInfo(2,30,'ECX_PARTY_TYPE_NOT_SET ');
126 		raise ecx_utils.program_exit;
127       /* End of bug #2183619 */
128 
129 	end;
130 if(l_statementEnabled) then
131   ecx_debug.log(l_statement,'i_party_id',i_party_id,i_method_name);
132   ecx_debug.log(l_statement,'i_party_site_id',i_party_site_id,i_method_name);
133 end if;
134 if (l_procedureEnabled) then
135   ecx_debug.pop(i_method_name);
136 end if;
137 exception
138 when ecx_no_delivery_required then
139         if (l_procedureEnabled) then
140          ecx_debug.pop(i_method_name);
141         end if;
142         raise;
143 when ecx_utils.program_exit then
144         if (l_procedureEnabled) then
145          ecx_debug.pop(i_method_name);
146         end if;
147         raise ecx_utils.program_exit;
148 when others then
149         ecx_debug.setErrorInfo(2,30,SQLERRM ||'- ECX_DOCUMENT.getConfirmation');
150 	if (l_procedureEnabled) then
151          ecx_debug.pop(i_method_name);
152         end if;
153 	raise ecx_utils.program_exit;
154 end getConfirmation;
155 
156 /**
157 Format and Queue the Outbound Engine Object for delivery
158 **/
159 procedure put_on_engqueue
160 	(
161 	p_queue_name			in	varchar2,
162 	p_transaction_type		in	varchar2,
163 	p_transaction_subtype		in	varchar2,
164 	p_document_id			in	varchar2,
165 	p_map_code			in	varchar2,
166 	p_message_type			in	varchar2,
167 	p_message_standard		in	varchar2,
168 	p_party_id			in	varchar2,
169 	p_party_site_id			in	varchar2,
170 	p_party_type			in	varchar2,
171 	p_ext_type			in	varchar2,
172 	p_ext_subtype			in	varchar2,
173 	p_party_source_location_code	in	varchar2,
174 	p_destination_type		in	varchar2,
175 	p_destination_address		in	varchar2,
176 	p_username			in	varchar2,
177 	p_password			in	varchar2,
178 	p_attribute1			IN	varchar2,
179 	p_attribute2			IN	varchar2,
180 	p_party_target_location_code	IN	varchar2,
181 	p_attribute4			IN	varchar2,
182 	p_attribute5			IN	varchar2,
183 	p_param1			IN	varchar2,
184 	p_param2			IN	varchar2,
185 	p_param3			IN	varchar2,
186 	p_param4			IN	varchar2,
187 	p_param5			IN	varchar2,
188 	o_msgid				out	NOCOPY raw
189 	)
190 is
191 
192 i_method_name   varchar2(2000) := 'ecx_document.put_on_engqueue';
193 
194 v_message		system.ecx_outengobj;
195 v_enqueueoptions     	dbms_aq.enqueue_options_t;
196 v_messageproperties  	dbms_aq.message_properties_t;
197 
198 begin
199 if (l_procedureEnabled) then
200  ecx_debug.push(i_method_name);
201 end if;
202 
203 if(l_statementEnabled) then
204   ecx_debug.log(l_statement,'p_queue_name',p_queue_name,i_method_name);
205   ecx_debug.log(l_statement,'p_transaction_type',p_transaction_type,i_method_name);
206   ecx_debug.log(l_statement,'p_transaction_subtype',p_transaction_subtype,i_method_name);
207   ecx_debug.log(l_statement,'p_document_id',p_document_id,i_method_name);
208   ecx_debug.log(l_statement,'p_map_code',p_map_code,i_method_name);
209   ecx_debug.log(l_statement,'p_message_type',p_message_type,i_method_name);
210   ecx_debug.log(l_statement,'p_message_standard',p_message_standard,i_method_name);
211   ecx_debug.log(l_statement,'p_party_id',p_party_id,i_method_name);
212   ecx_debug.log(l_statement,'p_party_site_id',p_party_site_id,i_method_name);
213   ecx_debug.log(l_statement,'p_party_type',p_party_type,i_method_name);
214   ecx_debug.log(l_statement,'p_ext_type',p_ext_type,i_method_name);
215   ecx_debug.log(l_statement,'p_ext_subtype',p_ext_subtype,i_method_name);
216   ecx_debug.log(l_statement,'p_party_source_location_code',p_party_source_location_code,i_method_name);
217   ecx_debug.log(l_statement,'p_destination_type',p_destination_type,i_method_name);
218   ecx_debug.log(l_statement,'p_destination_address',p_destination_address,i_method_name);
219   ecx_debug.log(l_statement,'p_username',p_username,i_method_name);
220   ecx_debug.log(l_statement,'p_password',p_password,i_method_name);
221   ecx_debug.log(l_statement,'p_attribute1',p_attribute1,i_method_name);
222   ecx_debug.log(l_statement,'p_attribute2',p_attribute2,i_method_name);
223   ecx_debug.log(l_statement,'p_party_target_location_code',p_party_target_location_code,i_method_name);
224   ecx_debug.log(l_statement,'p_attribute4',p_attribute4,i_method_name);
225   ecx_debug.log(l_statement,'p_attribute5',p_attribute5,i_method_name);
226   ecx_debug.log(l_statement,'p_param1',p_param1,i_method_name);
227   ecx_debug.log(l_statement,'p_param2',p_param2,i_method_name);
228   ecx_debug.log(l_statement,'p_param3',p_param3,i_method_name);
229   ecx_debug.log(l_statement,'p_param4',p_param4,i_method_name);
230   ecx_debug.log(l_statement,'p_param5',p_param5,i_method_name);
231 end if;
232 
233 			v_message := system.ecx_outengobj
234 				(
235 				p_transaction_type,
236 				p_transaction_subtype,
237 				p_document_id,
238 				p_map_code,
239 				p_message_type,
240 				p_message_standard,
241 				p_party_id,
242 				p_party_site_id,
243 				p_party_type,
244 				p_ext_type,
245 				p_ext_subtype,
246 				p_party_source_location_code,
247 				p_destination_type,
248 				p_destination_address,
249 				p_username,
250 				p_password,
251 				p_attribute1,
252 				p_attribute2,
253 				p_party_target_location_code,
254 				p_attribute4,
255 				p_attribute5,
256 				p_param1,
257 				p_param2,
258 				p_param3,
259 				p_param4,
260 				p_param5
261 				);
262 
263    				dbms_aq.enqueue
264 					(
265    					queue_name => p_queue_name,
266    					enqueue_options => v_enqueueoptions,
267    					message_properties => v_messageproperties,
268    					payload => v_message,
269    					msgid => o_msgid
270 					);
271 if(l_statementEnabled) then
272  ecx_debug.log(l_statement,'o_msgid',o_msgid,i_method_name);
273 end if;
274 if (l_procedureEnabled) then
275   ecx_debug.pop(i_method_name);
276 end if;
277 exception
278 when others then
279         ecx_debug.setErrorInfo(2,30,SQLERRM ||'- ECX_DOCUMENT.PUT_ON_ENGQUEUE');
280 	if (l_procedureEnabled) then
281           ecx_debug.pop(i_method_name);
282         end if;
283 	raise ecx_utils.program_exit;
284 end put_on_engqueue;
285 
286 /* Get Delivery Attributes */
287 PROCEDURE get_delivery_attribs
288 		(
289 		i_transaction_type	IN	varchar2,
290 		i_transaction_subtype	IN	varchar2,
291 		i_party_id 		IN 	varchar2,
292 		i_party_site_id		IN	varchar2,
293 		i_party_type		IN OUT	NOCOPY varchar2,--bug #2183619
294 		i_standard_type		OUT	NOCOPY varchar2,
295 		i_standard_code		OUT	NOCOPY varchar2,
296 		i_ext_type		OUT	NOCOPY varchar2,
297 		i_ext_subtype		OUT	NOCOPY varchar2,
298 		i_source_code		OUT	NOCOPY varchar2,
299 		i_destination_code	OUT	NOCOPY varchar2,
300 		i_destination_type	OUT	NOCOPY varchar2,
301 		i_destination_address	OUT	NOCOPY varchar2,
302 		i_username		OUT	NOCOPY varchar2,
303 		i_password		OUT	NOCOPY varchar2,
304 		i_map_code		OUT	NOCOPY varchar2,
305 		i_queue_name		OUT	NOCOPY varchar2,
306 		i_tp_header_id		OUT	NOCOPY pls_integer
307 		)
308 IS
309 
310 i_method_name   varchar2(2000) := 'ecx_document.get_delivery_attribs';
311 
312 i_hub_user_id		number;
316 BEGIN
313 i_transaction_id        number;
314 i_hub_id                number;
315 i_connection_type       varchar2(30);
317 if (l_procedureEnabled) then
318   ecx_debug.push(i_method_name);
319 end if;
320 
321 if(l_statementEnabled) then
322   ecx_debug.log(l_statement,'i_transaction_type',i_transaction_type,i_method_name);
323   ecx_debug.log(l_statement,'i_transaction_subtype',i_transaction_subtype,i_method_name);
324   ecx_debug.log(l_statement,'i_party_id',i_party_id,i_method_name);
325   ecx_debug.log(l_statement,'i_party_site_id',i_party_site_id,i_method_name);
326   ecx_debug.log(l_statement,'party_type',i_party_type,i_method_name);
327 end if;
328 
329         /** Validate whether the transaction exists ... **/
330       Begin
331         /* Added check for party type for bug #2183619 */
332         select  transaction_id
333         into    i_transaction_id
334         from    ecx_transactions
335         where   transaction_type = i_transaction_type
336           and   transaction_subtype = i_transaction_subtype
337           and   (i_party_type is null or party_type = i_party_type);
338       Exception
339       /* Start of bug #2183619*/
340        when too_many_rows then
341                 ecx_debug.setErrorInfo(2,30,'ECX_PARTY_TYPE_NOT_SET');
342 		raise ecx_utils.program_exit;
343       /* End of bug #2183619 */
344       When Others then
345                  /** Email goes to Sys Admin***/
346                 ecx_debug.setErrorInfo(1,30,'ECX_TRANSACTION_NOT_FOUND',
347                                             'p_transaction_type',
348                                             i_transaction_type,
349                                             'p_transaction_subtype',
350                                             i_transaction_subtype,
351                                             'p_party_type',
352                                             i_party_type);
353 		raise ecx_transaction_not_defined;
354       End;
355       begin
356       -- Added check for party type for bug #2183619
357 	select	es.standard_type		standard_type,
358 		es.standard_code		standard_code,
359 		source_tp_location_code 	source,
360 		external_tp_location_code 	destination,
361 		protocol_type,
362                 protocol_address,
363 		username,
364 		password,
365 		hub_user_id,
366                 connection_type,
367                 hub_id ,
368 		map_code,
369 		eep.queue_name	queue_name,
370 		eep.ext_type	ext_type,
371 		eep.ext_subtype	ext_subtype,
372 		eth.party_type  party_type,
373 		eth.tp_header_id	tp_header_id,
374 		etd.tp_detail_id
375         into    i_standard_type,
376 		i_standard_code,
377 		i_source_code,
378 		i_destination_code,
379 		i_destination_type,
380                 i_destination_address,
381 		i_username,
382 		i_password,
383 		i_hub_user_id,
384                 i_connection_type,
385                 i_hub_id,
386 		i_map_code,
387 		i_queue_name,
388 		i_ext_type,
389 		i_ext_subtype,
390 		i_party_type,
391 		i_tp_header_id,
392 		ecx_utils.g_tp_dtl_id
393 	from 	ecx_tp_details 		etd,
394 		ecx_tp_headers  	eth,
395 		ecx_ext_processes 	eep,
396 		ecx_transactions	et,
397 		ecx_standards		es,
398 		ecx_mappings		em
399         where   ( eth.party_id	= i_party_id or i_party_id is null )
400 	and	eth.party_site_id = i_party_site_id
401 	and	eth.party_type = et.party_type
402 	and	eth.tp_header_id = etd.tp_header_id
403 	and	et.transaction_type = i_transaction_type
404 	and	et.transaction_subtype = i_transaction_subtype
405         and     (i_party_type is null or et.party_type = i_party_type)
406 	and	et.transaction_id = eep.transaction_id
407 	and	es.standard_id = eep.standard_id
408 	and	eep.ext_process_id = etd.ext_process_id
409 	and	eep.direction = 'OUT'
410 	and	em.map_id = etd.map_id;
411 exception
412 /* Start of bug #2183619*/
413        when too_many_rows then
414                 ecx_debug.setErrorInfo(2,30,'ECX_PARTY_TYPE_NOT_SET');
415 		raise ecx_utils.program_exit;
416       /* End of bug #2183619 */
417 when others then
418                   /** Email goes to Sys Admin***/
419                 ecx_debug.setErrorInfo(1,30,'ECX_DELIVERY_TP_NOT_SETUP',
420                                             'p_transaction_type',
421                                              i_transaction_type,
422                                             'p_transaction_subtype',
423                                              i_transaction_subtype,
424                                             'p_party_site_id',
425                                              i_party_site_id,
426                                             'p_party_id',
427                                              i_party_id,
428                                             'p_party_type',
429                                              i_party_type);
430 
431 		raise ecx_no_party_setup;
432 end;
433         -- Bug #2449729
434         /* If the connection type is not DIRECT get the protocol_type,
435            protocol_address from ecx_hubs and username,password
436            from ecx_hub_users */
437         if (i_connection_type <> 'DIRECT')
438 	then
439               begin
440                    select protocol_type,
441                           protocol_address
442                    into   i_destination_type,
443                           i_destination_address
444                    from ecx_hubs
445                         where hub_id=i_hub_id;
446 
447                    if (i_hub_user_id is not null) then
448 
449                       select hub_entity_code,
450                              username,
451                              password
452                       into   i_source_code,
456                       where hub_user_id = i_hub_user_id;
453                              i_username,
454                              i_password
455                       from ecx_hub_users
457 
458                    end if;
459 
460 		exception
461 		when others then
462                          /** Email goes to Sys Admin***/
463                       ecx_debug.setErrorInfo(1,30,'ECX_DELIVERY_HUB_NOT_SETUP');
464 		      raise ecx_delivery_setup_error;
465 		end;
466 	end if;
467 
468 if(l_statementEnabled) then
469   ecx_debug.log(l_statement,'i_party_type',i_party_type,i_method_name);
470   ecx_debug.log(l_statement,'i_standard_type',i_standard_type,i_method_name);
471   ecx_debug.log(l_statement,'i_standard_code',i_standard_code,i_method_name);
472   ecx_debug.log(l_statement,'i_ext_type',i_ext_type,i_method_name);
473   ecx_debug.log(l_statement,'i_ext_subtype',i_ext_subtype,i_method_name);
474   ecx_debug.log(l_statement,'i_source_code',i_source_code,i_method_name);
475   ecx_debug.log(l_statement,'i_destination_code',i_destination_code,i_method_name);
476   ecx_debug.log(l_statement,'i_destination_type',i_destination_type,i_method_name);
477   ecx_debug.log(l_statement,'i_destination_address',i_destination_address,i_method_name);
478   ecx_debug.log(l_statement,'i_username',i_username,i_method_name);
479   ecx_debug.log(l_statement,'i_password',i_password,i_method_name);
480   ecx_debug.log(l_statement,'i_queue_name',i_queue_name,i_method_name);
481   ecx_debug.log(l_statement,'i_map_code',i_map_code,i_method_name);
482   ecx_debug.log(l_statement,'i_tp_header_id',i_tp_header_id,i_method_name);
483 end if;
484 if (l_procedureEnabled) then
485  ecx_debug.pop(i_method_name);
486 end if;
487 EXCEPTION
488 when ecx_transaction_not_defined then
489         if (l_procedureEnabled) then
490          ecx_debug.pop(i_method_name);
491         end if;
492         raise;
493 when ecx_no_party_setup then
494         if (l_procedureEnabled) then
495          ecx_debug.pop(i_method_name);
496         end if;
497 	raise;
498 when ecx_no_delivery_required then
499         if (l_procedureEnabled) then
500          ecx_debug.pop(i_method_name);
501         end if;
502 	raise;
503 when ecx_delivery_setup_error then
504         if (l_procedureEnabled) then
505          ecx_debug.pop(i_method_name);
506         end if;
507 	raise;
508 WHEN ECX_UTILS.PROGRAM_EXIT THEN
509 	if (l_procedureEnabled) then
510          ecx_debug.pop(i_method_name);
511         end if;
512 	raise ecx_utils.program_exit;
513 WHEN OTHERS THEN
514         ecx_debug.setErrorInfo(2,30,SQLERRM ||'- ECX_DOCUMENT.GET_DELIVERY_ATTRIBS');
515 	if (l_procedureEnabled) then
516          ecx_debug.pop(i_method_name);
517         end if;
518 	raise ecx_utils.program_exit;
519 END get_delivery_attribs;
520 
521 /* This SEND is used by the CM */
522 /*PROCEDURE send_cm(
523 	retcode		      OUT    NOCOPY number,
524 	errmsg		      OUT    NOCOPY VARCHAR2,
525         transaction_type      IN     VARCHAR2,
526         transaction_subtype   IN     VARCHAR2,
527 	party_id	      IN     varchar2,
528 	party_site_id	      IN     varchar2,
529         document_id           IN     varchar2,
530 	parameter1	      IN     varchar2,
531 	parameter2	      IN     varchar2,
532 	parameter3	      IN     varchar2,
533 	parameter4	      IN     varchar2,
534 	parameter5	      IN     varchar2,
535 	call_type	      IN     varchar2,
536         debug_mode            IN     number
537 ) IS
538 i_trigger_id number;
539 i_msgid		RAW(16);
540 BEGIN
541 	if call_type = 'ASYNC'
542 	then
543        		send(
544 			transaction_type,
545 			transaction_subtype,
546 			party_id,
547 			party_site_id,
548 			document_id,
549 			parameter1,
550 			parameter2,
551 			parameter3,
552 			parameter4,
553 			parameter5,
554             		debug_mode,
555 			i_trigger_id,
556 			retcode,
557 			errmsg
558 			);
559 
560 	elsif call_type = 'SYNC'
561 	then
562 		senddirect
563 			(
564 			transaction_type,
565 			transaction_subtype,
566 			party_id,
567 			party_site_id,
568 			document_id,
569 			parameter1,
570 			parameter2,
571 			parameter3,
572 			parameter4,
573 			parameter5,
574             	debug_mode,
575 			i_msgid,
576 			retcode,
577 			errmsg
578 			);
579 	end if;
580 
581 exception
582   when others then
583        null;
584 END;
585 */
586 
587 
588 /**
589   Helper method. This procedure will call getConfirmation, outbound_trigger and
590   get_delivery_attribs
591 **/
592 procedure trigger_outbound (transaction_type 	    IN	varchar2,
593                             transaction_subtype     IN  varchar2,
594                             party_id 		    IN  varchar2,
595                             party_site_id 	    IN  varchar2,
596                             document_id	 	    IN  varchar2,
597                             status 		    IN  varchar2,
598                             errmsg		    IN  varchar2,
599                             trigger_id 		    IN  varchar2,
600                             p_party_type 	    IN OUT NOCOPY varchar2,
601                             p_party_id		    OUT NOCOPY varchar2,
602                             p_party_site_id 	    OUT NOCOPY varchar2,
603                             p_message_type 	    OUT NOCOPY varchar2,
604                             p_message_standard 	    OUT NOCOPY varchar2,
605 	                    p_ext_type 		    OUT NOCOPY varchar2,
606                             p_ext_subtype 	    OUT NOCOPY varchar2,
607                             p_source_code	    OUT NOCOPY varchar2,
611 	                    p_username 		    OUT NOCOPY varchar2,
608 	                    p_destination_code 	    OUT NOCOPY varchar2,
609                             p_destination_type 	    OUT NOCOPY varchar2,
610                             p_destination_address   OUT NOCOPY varchar2,
612                             p_password 		    OUT NOCOPY varchar2,
613                             p_map_code		    OUT NOCOPY varchar2,
614 	                    p_queue_name 	    OUT NOCOPY varchar2,
615                             p_tp_header_id          OUT NOCOPY varchar2
616 		            )
617 is
618 i_method_name   varchar2(2000) := 'ecx_document.trigger_outbound';
619 begin
620 --   if (logging_mode = 'Y') then
621       ecx_errorlog.outbound_trigger (
622                                  trigger_id,
623                                  transaction_type,
624                                  transaction_subtype,
625                                  party_id,
626                                  party_site_id,
627                                  p_party_type, --Bug #2183619
628                                  document_id,
629                                  status, --'10',
630                                  errmsg --'Triggering outbound...'
631                                 );
632 --   end if;
633 
634    /** Check for COnfirmation BOD **/
635    if 	transaction_type = 'ECX'
636    	and transaction_subtype = 'CBODO'
637    then
638       getConfirmation (
639 		      transaction_type,
640 		      transaction_subtype,
641                       p_party_type , --Bug #2183619
642 		      document_id,
643 		      p_party_id,
644 		      p_party_site_id
645 		      );
646    else
647       p_party_id := party_id;
648       p_party_site_id := party_site_id;
649    end if;
650 
651       get_delivery_attribs (
652 	   		transaction_type,
653 			transaction_subtype,
654 			p_party_id,
655 			p_party_site_id,
656 			p_party_type,
657 			p_message_type,
658 			p_message_standard,
659 			p_ext_type,
660 			p_ext_subtype,
661 			p_source_code,
662 			p_destination_code,
663 			p_destination_type,
664 			p_destination_address,
665 			p_username,
666 			p_password,
667 			p_map_code,
668 			p_queue_name,
669 			p_tp_header_id
670 			);
671 exception
672 /* raised only by getConfirmation at this point */
673 WHEN ECX_NO_DELIVERY_REQUIRED THEN
674    if (l_procedureEnabled) then
675     ecx_debug.pop(i_method_name);
676    end if;
677    raise;
678 when ecx_transaction_not_defined then
679    if (l_procedureEnabled) then
680     ecx_debug.pop(i_method_name);
681    end if;
682    raise;
683 when ecx_no_party_setup then
684    if (l_procedureEnabled) then
685     ecx_debug.pop(i_method_name);
686    end if;
687    raise;
688 when ecx_delivery_setup_error then
689    if (l_procedureEnabled) then
690     ecx_debug.pop(i_method_name);
691    end if;
692    raise;
693 when ecx_utils.program_exit then
694    if (l_procedureEnabled) then
695     ecx_debug.pop(i_method_name);
696    end if;
697    raise ecx_utils.program_exit;
698 when others then
699    ecx_debug.setErrorInfo(2,30,SQLERRM ||'- ECX_DOCUMENT.TRIGGER_OUTBOUND');
700    if (l_procedureEnabled) then
701     ecx_debug.pop(i_method_name);
702    end if;
703    raise ecx_utils.program_exit;
704 end trigger_outbound;
705 
706 
707 /* The SEND routine A-Synchronous Call */
708 PROCEDURE send(
709         transaction_type      IN     VARCHAR2,
710         transaction_subtype   IN     VARCHAR2,
711 	party_id	      IN     varchar2,
712 	party_site_id	      IN     varchar2,
713         party_type            IN     varchar2 , --bug #2183619
714         document_id           IN     varchar2,
715 	parameter1	      IN     varchar2 ,
716 	parameter2	      IN     varchar2 ,
717 	parameter3	      IN     varchar2 ,
718 	parameter4	      IN     varchar2 ,
719 	parameter5	      IN     varchar2 ,
720         debug_mode            IN     PLS_INTEGER ,
721 	trigger_id	      OUT    NOCOPY PLS_INTEGER,
722 	retcode		      OUT    NOCOPY PLS_INTEGER,
723 	errmsg		      OUT    NOCOPY VARCHAR2
724 ) IS
725 g_instlmode         VARCHAR2(100);
726 i_debug_level		pls_integer;
727 i_method_name   varchar2(2000) := 'ecx_document.send';
728 
729 i_path 			varchar2(80);
730 v_message            	system.ecx_outengobj;
731 
732 p_message_type		varchar2(200);
733 p_message_standard	varchar2(200);
734 p_ext_type		varchar2(200);
735 p_ext_subtype		varchar2(200);
736 p_destination_type	varchar2(200);
737 p_destination_address	ecx_tp_details.protocol_address%TYPE;
738 p_username		ecx_tp_details.username%TYPE;
739 p_password		ecx_tp_details.password%TYPE;
740 p_map_code		varchar2(200);
741 p_queue_name		varchar2(200);
742 p_attribute1		varchar2(200);
743 p_attribute2		varchar2(200);
744 p_attribute3		varchar2(200);
745 p_attribute4		varchar2(200);
746 p_attribute5		varchar2(200);
747 p_source_code		varchar2(200);
748 p_destination_code	varchar2(200);
749 
750 p_party_id	        number; /* BUg 2122579 */
751 p_party_site_id	        number;
752 i_msgid			raw(16);
753 i_count			pls_integer:=0;
754 p_party_type            varchar2(200);
755 p_aflog_module_name         VARCHAR2(2000) ;
756 
757 
758 cursor c1
759 is
760 select	ecx_trigger_id_s.NEXTVAL
761 from	dual;
762 
763 -- logging enabled
764 ecx_logging_enabled boolean := false;
765 logging_enabled varchar2(20);
766 module varchar2(2000);
767 
768 begin
769 --before calling this API we need to re-initialize ecx_debug.g_v_module_name
773 
770 ecx_debug.g_v_module_name :='ecx.plsql.';
771 ecx_debug.module_enabled(transaction_type,transaction_subtype,document_id);
772   g_instlmode := wf_core.translate('WF_INSTALL');
774   if(g_instlmode = 'EMBEDDED')
775   then
776     fnd_profile.get('AFLOG_ENABLED',logging_enabled);
777     fnd_profile.get('AFLOG_MODULE',module);
778     if(logging_enabled = 'Y' AND ((lower(module) like 'ecx%'
779 	AND instr(lower(ecx_debug.g_v_module_name),rtrim(lower(module),'%'))> 0)
780 	OR module='%')
781        AND FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) then
782       ecx_logging_enabled := true;
783     end if;
784   elsif(g_instlmode = 'STANDALONE')
785   then
786     if (i_debug_level > 0) then
787       ecx_logging_enabled := true;
788     end if;
789   end if;
790 -- /logging enabled
791 
792 --Get the Trigger Id
793 open 	c1;
794 fetch	c1 into trigger_id;
795 close	c1;
796 
797 p_party_type := party_type ; --bug #2183619
798 
799 IF (ecx_logging_enabled ) THEN
800 
801 	--- Sets the Log Directory in both Standalone and the Embedded mode
802 	ecx_utils.getLogDirectory;
803 	p_aflog_module_name := 'trig.';
804 	IF (transaction_type is not null) THEN
805 		p_aflog_module_name := p_aflog_module_name||transaction_type||'.';
806 	END IF;
807 	IF (transaction_subtype is not null) THEN
808 		p_aflog_module_name := p_aflog_module_name||transaction_subtype||'.';
809 	END IF;
810 	IF (document_id is not null) THEN
811 		p_aflog_module_name := p_aflog_module_name||document_id||'.';
812 	END IF;
813 	IF (trigger_id is not null) THEN
814 		p_aflog_module_name := p_aflog_module_name||trigger_id;
815 	END IF;
816 	p_aflog_module_name := p_aflog_module_name||'.log';
817 
818 	ecx_debug.enable_debug_new(debug_mode, ecx_utils.g_logdir, 'TRIG'||transaction_type||transaction_subtype||
819 		document_id||trigger_id||'.log', p_aflog_module_name);
820 END IF;
821 
822 /* Assign local variables with the ecx_debug global variables*/
823 l_procedure          := ecx_debug.g_procedure;
824 l_statement          := ecx_debug.g_statement;
825 l_unexpected         := ecx_debug.g_unexpected;
826 l_procedureEnabled   := ecx_debug.g_procedureEnabled;
827 l_statementEnabled   := ecx_debug.g_statementEnabled;
828 l_unexpectedEnabled  := ecx_debug.g_unexpectedEnabled;
829 
830 if (l_procedureEnabled) then
831      ecx_debug.push(i_method_name);
832 end if;
833 
834 if(l_statementEnabled) then
835   ecx_debug.log(l_statement,'transaction_type', transaction_type,i_method_name);
836   ecx_debug.log(l_statement,'transaction_subtype', transaction_subtype,i_method_name);
837   ecx_debug.log(l_statement,'party_id', party_id,i_method_name);
838   ecx_debug.log(l_statement,'party_site_id', party_site_id,i_method_name);
839   ecx_debug.log(l_statement,'document_id', document_id,i_method_name);
840   ecx_debug.log(l_statement,'parameter1', parameter1,i_method_name);
841   ecx_debug.log(l_statement,'parameter2', parameter2,i_method_name);
842   ecx_debug.log(l_statement,'parameter3', parameter3,i_method_name);
843   ecx_debug.log(l_statement,'parameter4', parameter4,i_method_name);
844   ecx_debug.log(l_statement,'parameter5', parameter5,i_method_name);
845   ecx_debug.log(l_statement,'debug_mode',debug_mode,i_method_name);
846 end if;
847 
848 /**
849 Initialize the ecx_utils.i_ret_code and i_errbuf variables;
850 **/
851 ecx_utils.i_ret_code :=0;
852 ecx_utils.i_errbuf := null;
853 --MLS
854 ecx_utils.i_errparams := null;
855 i_count :=0;
856 
857 -- invoke trigger_outbound which will invoke outbound_trigger, getConfirmation and
858 -- get_delivery_attribs
859 ecx_debug.setErrorInfo(10,10,'ECX_TRIGGER_OUTBOUND');
860 trigger_outbound (transaction_type, transaction_subtype,
861                   party_id, party_site_id,
862                   document_id, ecx_utils.i_ret_code,
863                   ecx_utils.i_errbuf, trigger_id,
864                   p_party_type, p_party_id, p_party_site_id, p_message_type,
865                   p_message_standard, p_ext_type, p_ext_subtype, p_source_code,
866 	          p_destination_code, p_destination_type, p_destination_address,
867 	          p_username, p_password, p_map_code,
868 	          p_queue_name, ecx_utils.g_rec_tp_id);
869 
870 -- take appropriate action for destination_type
871 If p_destination_type = 'NONE' Then
872     /** No email Action required **/
873        ecx_debug.setErrorInfo(0,10,'ECX_DELIVERY_NOT_REQUIRED');
874        raise ecx_no_delivery_required;
875 Elsif p_destination_address is null
876 then
877    /** Email goes to Sys Admin***/
878 
879    ecx_debug.setErrorInfo(1,30,'ECX_DESTINATION_ADDR_NULL',
880                                'p_party_site_id',
881                                 p_party_site_id,
882                                 'p_source_code',
883                                 p_source_code);
884    raise ecx_delivery_setup_error;
885 end if;
886 
887 			put_on_engqueue
888 				(
889 				p_queue_name,
890 				transaction_type,
891 				transaction_subtype,
892 				document_id,
893 				p_map_code,
894 				p_message_type,
895 				p_message_standard,
896 				p_party_id,
897 				p_party_site_id,
898 				p_party_type,
899 				p_ext_type,
900 				p_ext_subtype,
901 				p_source_code,
902 				p_destination_type,
903 				p_destination_address,
904 				p_username,
905 				p_password,
906 				null,
907 				null,
908 				p_destination_code,
909 				null,
910 				null,
911 				parameter1,
912 				parameter2,
913 				parameter3,
914 				parameter4,
915 				parameter5,
916 				i_msgid
917 				);
918 
919 --- Assign the values back to the program OUT variables.
923 if(l_statementEnabled) then
920 retcode := ecx_utils.i_ret_code;
921 errmsg := ecx_utils.i_errbuf;
922 
924   ecx_debug.log(l_statement,'trigger_id',trigger_id,i_method_name);
925 end if;
926 if(l_unexpectedEnabled) then
927   ecx_debug.log(l_unexpected,'retcode',retcode,i_method_name);
928   ecx_debug.log(l_unexpected,'errmsg',ecx_debug.getMessage(errmsg,
929                         ecx_utils.i_errparams),i_method_name); --MLS
930 end if;
931 
932 if (l_procedureEnabled) then
933   ecx_debug.pop(i_method_name);
934 end if;
935 
936 IF (ecx_logging_enabled ) THEN
937 	ecx_debug.print_log;
938 	ecx_debug.disable_debug;
939 END IF;
940 
941 EXCEPTION
942 /* raised only by getConfirmation at this point */
943 WHEN ECX_NO_DELIVERY_REQUIRED THEN
944         retcode := ecx_utils.i_ret_code;
945         errmsg := ecx_utils.i_errbuf;
946         if(l_unexpectedEnabled) then
947            ecx_debug.log(l_unexpected,'i_ret_code',ecx_utils.i_ret_code,i_method_name);
948            ecx_debug.log(l_unexpected,'i_errmsg',ecx_utils.i_errbuf || ' at ECX_DOCUMENT.SEND',
949 	                i_method_name);
950            ecx_debug.log(l_unexpected,'retcode',retcode,i_method_name);
951            ecx_debug.log(l_unexpected,'errmsg',ecx_debug.getMessage(errmsg,
952                                 ecx_utils.i_errparams),i_method_name); --MLS
953            ecx_debug.log(l_unexpected,'errtype',ecx_utils.error_type,i_method_name);
954 	end if;
955         if (l_procedureEnabled) then
956          ecx_debug.pop(i_method_name);
957         end if;
958 
959 	IF (ecx_logging_enabled ) THEN
960 		ecx_debug.print_log;
961 		ecx_debug.disable_debug;
962 	END IF;
963 
964         ecx_errorlog.outbound_trigger
965                                 (
966                                 trigger_id,
967                                 transaction_type,
968                                 transaction_subtype,
969                                 party_id,
970                                 party_site_id,
971                                 p_party_type, --bug #2183619
972                                 document_id,
973                                 ecx_utils.i_ret_code,
974                                 ecx_utils.i_errbuf,
975                                 ecx_utils.i_errparams --MLS
976                                 );
977 WHEN ECX_UTILS.PROGRAM_EXIT THEN
978 	retcode := ecx_utils.i_ret_code;
979 	errmsg := ecx_utils.i_errbuf;
980 	if(l_unexpectedEnabled) then
981            ecx_debug.log(l_unexpected,'i_ret_code',ecx_utils.i_ret_code,i_method_name);
982 	   ecx_debug.log(l_unexpected,'i_errmsg',ecx_utils.i_errbuf ||SQLERRM||' at ECX_DOCUMENT.SEND',
983 	                i_method_name);
984            ecx_debug.log(l_unexpected,'retcode',retcode,i_method_name);
985            ecx_debug.log(l_unexpected,'errmsg',ecx_debug.getMessage(errmsg,
986                                 ecx_utils.i_errparams),i_method_name); --MLS
987 	end if;
988         if (l_procedureEnabled) then
989          ecx_debug.pop(i_method_name);
990         end if;
991 
992 	IF (ecx_logging_enabled ) THEN
993 		ecx_debug.print_log;
994 		ecx_debug.disable_debug;
995 	END IF;
996 
997 
998         ecx_errorlog.outbound_trigger
999                                 (
1000                                 trigger_id,
1001                                 transaction_type,
1002                                 transaction_subtype,
1003                                 party_id,
1004                                 party_site_id,
1005                    	        p_party_type, --bug #2183619
1006                                 document_id,
1007                                 ecx_utils.i_ret_code,
1008                                 ecx_utils.i_errbuf,
1009                                 ecx_utils.i_errparams --MLS
1010                                 );
1011 
1012 WHEN OTHERS THEN
1013         ecx_debug.setErrorInfo(2,30,SQLERRM||' - ECX_DOCUMENT.SEND');
1014 	retcode := ecx_utils.i_ret_code;
1015 	errmsg  := ecx_utils.i_errbuf;
1016 	if(l_unexpectedEnabled) then
1017            ecx_debug.log(l_unexpected,'i_ret_code',ecx_utils.i_ret_code,i_method_name);
1018 	   ecx_debug.log(l_unexpected,'i_errmsg',SQLERRM||' at ECX_DOCUMENT.SEND',i_method_name);
1019 	   ecx_debug.log(l_unexpected,'retcode',retcode,i_method_name,i_method_name);
1020            ecx_debug.log(l_unexpected,'errmsg',errmsg,i_method_name,i_method_name);
1021 	end if;
1022         if (l_procedureEnabled) then
1023          ecx_debug.pop(i_method_name);
1024         end if;
1025 
1026 	IF (ecx_logging_enabled ) THEN
1027 		ecx_debug.print_log;
1028 		ecx_debug.disable_debug;
1029 	END IF;
1030 
1031         ecx_errorlog.outbound_trigger
1032                                 (
1033                                 trigger_id,
1034                                 transaction_type,
1035                                 transaction_subtype,
1036                                 party_id,
1037                                 party_site_id,
1038                                 p_party_type, --bug #2183619
1039                                 document_id,
1040                                 ecx_utils.i_ret_code,
1041                                 ecx_utils.i_errbuf,
1042                                 ecx_utils.i_errparams
1043                                 );
1044 end send;
1045 
1046 
1047 /* The SEND routine Synchronous Call */
1048 PROCEDURE sendDirect(
1049         transaction_type      IN     VARCHAR2,
1050         transaction_subtype   IN     VARCHAR2,
1051 	party_id	      IN     varchar2,
1052 	party_site_id	      IN     varchar2,
1053         party_type            IN     VARCHAR2 ,--bug #2183619
1054         document_id           IN     varchar2,
1055         debug_mode            IN     PLS_INTEGER ,
1059 ) IS
1056 	i_msgid		      OUT    NOCOPY RAW,
1057 	retcode		      OUT    NOCOPY PLS_INTEGER,
1058 	errmsg		      OUT    NOCOPY VARCHAR2
1060 g_instlmode         VARCHAR2(100);
1061 i_debug_level		pls_integer;
1062 i_method_name   varchar2(2000) := 'ecx_document.sendDirect';
1063 i_path 			varchar2(80);
1064 v_message            	system.ecx_outengobj;
1065 
1066 p_message_type		varchar2(200);
1067 p_message_standard	varchar2(200);
1068 p_ext_type		varchar2(200);
1069 p_ext_subtype		varchar2(200);
1070 p_destination_type	varchar2(200);
1071 p_username		ecx_tp_details.username%TYPE;
1072 p_password		ecx_tp_details.password%TYPE;
1073 p_map_code		varchar2(200);
1074 p_queue_name		varchar2(200);
1075 p_attribute1		varchar2(200);
1076 p_attribute2		varchar2(200);
1077 p_attribute3		varchar2(200);
1078 p_attribute4		varchar2(200);
1079 p_attribute5		varchar2(200);
1080 p_source_code		varchar2(2000);
1081 p_destination_code		varchar2(200);
1082 p_destination_address		ecx_tp_details.protocol_address%TYPE;
1083 
1084 p_party_id		number; /* Bug 2122579 */
1085 p_party_site_id		number;
1086 i_count			pls_integer:=0;
1087 trigger_id		pls_integer;
1088 /* Start changes for Bug 2120165 */
1089 i_paramCount Number;
1090 i_parameterList		wf_parameter_list_t;
1091 i_parameter		wf_parameter_t;
1092 /* End of changes for Bug 2120165 */
1093 
1094 cursor c1
1095 is
1096 select	ecx_trigger_id_s.NEXTVAL
1097 from	dual;
1098 
1099 p_party_type varchar2(200);
1100 p_aflog_module_name         VARCHAR2(2000) ;
1101 
1102 -- logging enabled
1103 ecx_logging_enabled boolean := false;
1104 logging_enabled varchar2(20);
1105 module varchar2(2000);
1106 
1107 begin
1108 --before calling this API we need to re-initialize ecx_debug.g_v_module_name
1109 ecx_debug.g_v_module_name :='ecx.plsql.';
1110 ecx_debug.module_enabled(transaction_type,transaction_subtype,document_id);
1111   g_instlmode := wf_core.translate('WF_INSTALL');
1112 
1113   if(g_instlmode = 'EMBEDDED')
1114   then
1115     fnd_profile.get('AFLOG_ENABLED',logging_enabled);
1116     fnd_profile.get('AFLOG_MODULE',module);
1117      if(logging_enabled = 'Y' AND ((lower(module) like 'ecx%'
1118 	AND instr(lower(ecx_debug.g_v_module_name),rtrim(lower(module),'%'))> 0)
1119 	OR module='%')
1120        AND FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_UNEXPECTED) then
1121       ecx_logging_enabled := true;
1122     end if;
1123   elsif(g_instlmode = 'STANDALONE')
1124   then
1125     if (i_debug_level > 0) then
1126       ecx_logging_enabled := true;
1127     end if;
1128   end if;
1129 -- /logging enabled
1130 p_party_type := party_type; --bug #2183619
1131 --p_party_type :=  Wf_Engine.GetActivityAttrText('2120165', 21,279943, 'ECX_PARTY_TYPE', ignore_notfound => true);
1132 
1133 --Get the Run Id
1134 	open 	c1;
1135 	fetch	c1 into trigger_id;
1136 	close	c1;
1137 
1138 IF (ecx_logging_enabled ) THEN
1139 
1140 	--- Sets the Log Directory in both Standalone and the Embedded mode
1141 	ecx_utils.getLogDirectory;
1142 	ecx_utils.g_logfile := 'TRIG'||transaction_type||transaction_subtype||document_id||trigger_id||'.log';
1143 
1144 	p_aflog_module_name := 'trig.';
1145 	IF (transaction_type is not null) THEN
1146 		p_aflog_module_name := p_aflog_module_name||transaction_type||'.';
1147 	END IF;
1148 	IF (transaction_subtype is not null) THEN
1149 		p_aflog_module_name := p_aflog_module_name||transaction_subtype||'.';
1150 	END IF;
1151 	IF (document_id is not null) THEN
1152 		p_aflog_module_name := p_aflog_module_name||document_id||'.';
1153 	END IF;
1154 	IF (trigger_id is not null) THEN
1155 		p_aflog_module_name := p_aflog_module_name||trigger_id;
1156 	END IF;
1157 
1158 	p_aflog_module_name := p_aflog_module_name||'.log';
1159 
1160 	ecx_debug.enable_debug_new(debug_mode, ecx_utils.g_logdir,ecx_utils.g_logfile, p_aflog_module_name);
1161 END IF;
1162 
1163 /* Assign local variables with the ecx_debug global variables*/
1164 l_procedure          := ecx_debug.g_procedure;
1165 l_statement          := ecx_debug.g_statement;
1166 l_unexpected         := ecx_debug.g_unexpected;
1167 l_procedureEnabled   := ecx_debug.g_procedureEnabled;
1168 l_statementEnabled   := ecx_debug.g_statementEnabled;
1169 l_unexpectedEnabled  := ecx_debug.g_unexpectedEnabled;
1170 
1171 if (l_procedureEnabled) then
1172      ecx_debug.push(i_method_name);
1173 end if;
1174 
1175 if(l_statementEnabled) then
1176  ecx_debug.log(l_statement,'transaction_type', transaction_type,i_method_name);
1177  ecx_debug.log(l_statement,'transaction_subtype', transaction_subtype,i_method_name);
1178  ecx_debug.log(l_statement,'party_id', party_id,i_method_name);
1179  ecx_debug.log(l_statement,'party_site_id', party_site_id,i_method_name);
1180  ecx_debug.log(l_statement,'document_id', document_id,i_method_name);
1181  ecx_debug.log(l_statement,'party_type', party_type,i_method_name);
1182  ecx_debug.log(l_statement,'debug_mode',debug_mode,i_method_name);
1183 end if;
1184 
1185 /** check for the Event Object. If null , initialize it **/
1186 if ecx_utils.g_event is null
1187 then
1188 	wf_event_t.initialize(ecx_utils.g_event);
1189 end if;
1190 i_parameterlist := wf_event_t.getParameterList(ecx_utils.g_event);
1191 if(l_statementEnabled) then
1192 	if i_parameterList is not null
1193 	then
1194 		for i in i_parameterList.FIRST..i_parameterList.LAST
1195 		loop
1196 			i_parameter := i_parameterList(i);
1197 			ecx_debug.log(l_statement,i_parameter.getName(),i_parameter.getValue(),i_method_name);
1198 		end loop;
1199 		end if;
1200 end if;
1201 
1202 /**
1203 Initialize the ecx_utils.i_ret_code and i_errbuf variables;
1204 **/
1205 ecx_utils.i_ret_code :=0;
1206 ecx_utils.i_errbuf := null;
1207 --MLS
1208 ecx_utils.i_errparams := null;
1209 
1213 trigger_outbound (transaction_type, transaction_subtype,
1210 -- make a new procedure which will invoke outbound_trigger, getConfirmation and
1211 -- get_delivery_attribs
1212 ecx_debug.setErrorInfo(10,10,'ECX_TRIGGER_OUTBOUND');
1214                   party_id, party_site_id,
1215                   document_id, ecx_utils.i_ret_code,
1216                   ecx_utils.i_errbuf,  trigger_id,
1217                   p_party_type, p_party_id, p_party_site_id, p_message_type,
1218                   p_message_standard, p_ext_type, p_ext_subtype, p_source_code,
1219       	          p_destination_code, p_destination_type, p_destination_address,
1220 	          p_username, p_password, p_map_code,
1221 	          p_queue_name, ecx_utils.g_rec_tp_id);
1222 
1223 -- take appropriate action for destination_type
1224 If p_destination_type = 'NONE' Then
1225    /** No email Action required **/
1226        ecx_debug.setErrorInfo(0,10,'ECX_DELIVERY_NOT_REQUIRED');
1227        raise ecx_no_delivery_required;
1228 Elsif p_destination_address is null
1229 then
1230    ecx_debug.setErrorInfo(1,30,'ECX_DESTINATION_ADDR_NULL',
1231                                'p_party_site_id',
1232                                 p_party_site_id,
1233                                 'p_source_code',
1234                                 p_source_code);
1235    raise ecx_delivery_setup_error;
1236 end if;
1237 
1238 			ECX_OUTBOUND.putmsg
1239 				(
1240 				transaction_type,
1241 				transaction_subtype,
1242 				p_party_id,
1243 				p_party_site_id,
1244 				p_party_type,
1245 				document_id,
1246 				p_map_code,
1247 				p_message_type,
1248 				p_message_standard,
1249 				p_ext_type,
1250 				p_ext_subtype,
1251 				p_source_code,
1252 				p_destination_type,
1253 				p_destination_address,
1254 				p_username,
1255 				p_password,
1256 				ecx_utils.g_company_name,
1257 				null,
1258 				p_destination_code,
1259 				null,
1260 				null,
1261 				debug_mode,
1262                                 trigger_id,
1263 				i_msgid
1264 				);
1265 
1266 --- Assign the values back to the program OUT variables.
1267 retcode := ecx_utils.i_ret_code;
1268 errmsg := ecx_utils.i_errbuf;
1269 
1270 if(l_unexpectedEnabled) then
1271   ecx_debug.log(l_unexpected,'retcode',retcode,i_method_name);
1272   ecx_debug.log(l_unexpected,'errmsg',ecx_debug.getMessage(errmsg,
1273                         ecx_utils.i_errparams),i_method_name); --MLS
1274 end if;
1275 if(l_statementEnabled) then
1276   ecx_debug.log(l_statement,'i_msgid',i_msgid,i_method_name);
1277 end if;
1278 
1279 if (l_procedureEnabled) then
1280   ecx_debug.pop(i_method_name);
1281 end if;
1282 
1283 IF (ecx_logging_enabled ) THEN
1284 	ecx_debug.print_log;
1285 	ecx_debug.disable_debug;
1286 END IF;
1287 
1288 
1289 EXCEPTION
1290 /* raised only by getConfirmation at this point */
1291 WHEN ECX_NO_DELIVERY_REQUIRED THEN
1292         retcode := ecx_utils.i_ret_code;
1293         errmsg := ecx_utils.i_errbuf;
1294         if(l_unexpectedEnabled) then
1295             ecx_debug.log(l_unexpected,'i_ret_code',ecx_utils.i_ret_code,i_method_name);
1296             ecx_debug.log(l_unexpected,'i_errmsg',ecx_utils.i_errbuf || ' at ECX_DOCUMENT.SENDDIRECT',
1297 	             i_method_name);
1298             ecx_debug.log(l_unexpected,'retcode',retcode,i_method_name);
1299             ecx_debug.log(l_unexpected,'errmsg',ecx_debug.getMessage(errmsg,
1300                                 ecx_utils.i_errparams),i_method_name); --MLS
1301             ecx_debug.log(l_unexpected,'errtype',ecx_utils.error_type,i_method_name);
1302 	end if;
1303         if (l_procedureEnabled) then
1304           ecx_debug.pop(i_method_name);
1305         end if;
1306 
1307 	IF (ecx_logging_enabled ) THEN
1308 		ecx_debug.print_log;
1309 		ecx_debug.disable_debug;
1310 	END IF;
1311 
1312         ecx_errorlog.outbound_trigger
1313                                 (
1314                                 trigger_id,
1315                                 transaction_type,
1316                                 transaction_subtype,
1317                                 party_id,
1318                                 party_site_id,
1319                                 p_party_type, --bug #2183619
1320                                 document_id,
1321                                 ecx_utils.i_ret_code,
1322                                 ecx_utils.i_errbuf,
1323                                 ecx_utils.i_errparams --MLS
1324                                 );
1325 WHEN ECX_TRANSACTION_NOT_DEFINED THEN
1326         retcode := ecx_utils.i_ret_code;
1327         errmsg := ecx_utils.i_errbuf;
1328          if(l_unexpectedEnabled) then
1329             ecx_debug.log(l_unexpected,'i_ret_code',ecx_utils.i_ret_code,i_method_name);
1330             ecx_debug.log(l_unexpected,'i_errmsg',ecx_utils.i_errbuf || ' at ECX_DOCUMENT.SENDDIRECT',
1331 	             i_method_name);
1332             ecx_debug.log(l_unexpected,'retcode',retcode,i_method_name);
1333             ecx_debug.log(l_unexpected,'errmsg',ecx_debug.getMessage(errmsg,
1334                                 ecx_utils.i_errparams),i_method_name); --MLS
1335             ecx_debug.log(l_unexpected,'errtype',ecx_utils.error_type,i_method_name);
1336 	 end if;
1337          if (l_procedureEnabled) then
1338           ecx_debug.pop(i_method_name);
1339         end if;
1340 
1341 	IF (ecx_logging_enabled ) THEN
1342 		ecx_debug.print_log;
1343 		ecx_debug.disable_debug;
1344 	END IF;
1345 
1346         ecx_errorlog.outbound_trigger
1347                                 (
1348                                 trigger_id,
1349                                 transaction_type,
1350                                 transaction_subtype,
1351                                 party_id,
1352                                 party_site_id,
1356                                 ecx_utils.i_errbuf,
1353                                 p_party_type, --bug #2183619
1354                                 document_id,
1355                                 ecx_utils.i_ret_code,
1357                                 ecx_utils.i_errparams --MLS
1358                                 );
1359 
1360 WHEN ECX_NO_PARTY_SETUP THEN
1361         retcode := ecx_utils.i_ret_code;
1362         errmsg := ecx_utils.i_errbuf;
1363 
1364         if(l_unexpectedEnabled) then
1365             ecx_debug.log(l_unexpected,'i_ret_code',ecx_utils.i_ret_code,i_method_name);
1366             ecx_debug.log(l_unexpected,'i_errmsg',ecx_utils.i_errbuf || ' at ECX_DOCUMENT.SENDDIRECT',
1367 	             i_method_name);
1368             ecx_debug.log(l_unexpected,'retcode',retcode,i_method_name);
1369             ecx_debug.log(l_unexpected,'errmsg',ecx_debug.getMessage(errmsg,
1370                                 ecx_utils.i_errparams),i_method_name); --MLS
1371             ecx_debug.log(l_unexpected,'errtype',ecx_utils.error_type,i_method_name);
1372 	end if;
1373          if (l_procedureEnabled) then
1374           ecx_debug.pop(i_method_name);
1375         end if;
1376 
1377 	IF (ecx_logging_enabled ) THEN
1378 		ecx_debug.print_log;
1379 		ecx_debug.disable_debug;
1380 	END IF;
1381 
1382 
1383         ecx_errorlog.outbound_trigger
1384                                 (
1385                                 trigger_id,
1386                                 transaction_type,
1387                                 transaction_subtype,
1388                                 party_id,
1389                                 party_site_id,
1390                                 p_party_type, --bug #2183619
1391                                 document_id,
1392                                 ecx_utils.i_ret_code,
1393                                 ecx_utils.i_errbuf,
1394                                 ecx_utils.i_errparams --MLS
1395                                 );
1396 
1397 WHEN ECX_DELIVERY_SETUP_ERROR THEN
1398         retcode := ecx_utils.i_ret_code;
1399         errmsg := ecx_utils.i_errbuf;
1400 
1401         if(l_unexpectedEnabled) then
1402             ecx_debug.log(l_unexpected,'i_ret_code',ecx_utils.i_ret_code,i_method_name);
1403             ecx_debug.log(l_unexpected,'i_errmsg',ecx_utils.i_errbuf || ' at ECX_DOCUMENT.SENDDIRECT',
1404 	             i_method_name);
1405             ecx_debug.log(l_unexpected,'retcode',retcode,i_method_name);
1406             ecx_debug.log(l_unexpected,'errmsg',ecx_debug.getMessage(errmsg,
1407                                 ecx_utils.i_errparams),i_method_name); --MLS
1408             ecx_debug.log(l_unexpected,'errtype',ecx_utils.error_type,i_method_name);
1409 	end if;
1410          if (l_procedureEnabled) then
1411           ecx_debug.pop(i_method_name);
1412         end if;
1413 
1414 	IF (ecx_logging_enabled ) THEN
1415 		ecx_debug.print_log;
1416 		ecx_debug.disable_debug;
1417 	END IF;
1418 
1419         ecx_errorlog.outbound_trigger
1420                                 (
1421                                 trigger_id,
1422                                 transaction_type,
1423                                 transaction_subtype,
1424                                 party_id,
1425                                 party_site_id,
1426                                 p_party_type, --bug #2183619
1427                                 document_id,
1428                                 ecx_utils.i_ret_code,
1429                                 ecx_utils.i_errbuf,
1430                                 ecx_utils.i_errparams --MLS
1431                                 );
1432 WHEN ECX_UTILS.PROGRAM_EXIT THEN
1433 	retcode := ecx_utils.i_ret_code;
1434         errmsg := ecx_utils.i_errbuf;
1435 
1436 	if(l_unexpectedEnabled) then
1437             ecx_debug.log(l_unexpected,'i_ret_code',ecx_utils.i_ret_code,i_method_name);
1438             ecx_debug.log(l_unexpected,'i_errmsg',ecx_utils.i_errbuf || ' at ECX_DOCUMENT.SENDDIRECT',
1439 	             i_method_name);
1440             ecx_debug.log(l_unexpected,'retcode',retcode,i_method_name);
1441             ecx_debug.log(l_unexpected,'errmsg',ecx_debug.getMessage(errmsg,
1442                                 ecx_utils.i_errparams),i_method_name); --MLS
1443             ecx_debug.log(l_unexpected,'errtype',ecx_utils.error_type,i_method_name);
1444 	end if;
1445          if (l_procedureEnabled) then
1446           ecx_debug.pop(i_method_name);
1447         end if;
1448 
1449 	IF (ecx_logging_enabled ) THEN
1450 		ecx_debug.print_log;
1451 		ecx_debug.disable_debug;
1452 	END IF;
1453 
1454         ecx_errorlog.outbound_trigger
1455                                 (
1456                                 trigger_id,
1457                                 transaction_type,
1458                                 transaction_subtype,
1459                                 party_id,
1460                                 party_site_id,
1461                                 p_party_type, --bug #2183619
1462                                 document_id,
1463                                 ecx_utils.i_ret_code,
1464                                 ecx_utils.i_errbuf,
1465                                 ecx_utils.i_errparams --MLS
1466                                 );
1467 WHEN OTHERS THEN
1468         ecx_debug.setErrorInfo(2,30, SQLERRM||' - ECX_DOCUMENT.SENDDIRECT');
1469 	retcode := ecx_utils.i_ret_code;
1470         errmsg := ecx_utils.i_errbuf;
1471 	if(l_unexpectedEnabled) then
1472             ecx_debug.log(l_unexpected,'i_ret_code',ecx_utils.i_ret_code,i_method_name);
1473             ecx_debug.log(l_unexpected,'i_errmsg',ecx_utils.i_errbuf || ' at ECX_DOCUMENT.SENDDIRECT',
1474 	             i_method_name);
1475             ecx_debug.log(l_unexpected,'retcode',retcode,i_method_name);
1476             ecx_debug.log(l_unexpected,'errmsg',ecx_debug.getMessage(errmsg,
1480          if (l_procedureEnabled) then
1477                                 ecx_utils.i_errparams),i_method_name); --MLS
1478             ecx_debug.log(l_unexpected,'errtype',ecx_utils.error_type,i_method_name);
1479 	end if;
1481           ecx_debug.pop(i_method_name);
1482         end if;
1483 
1484 	IF (ecx_logging_enabled ) THEN
1485 		ecx_debug.print_log;
1486 		ecx_debug.disable_debug;
1487 	END IF;
1488 
1489         ecx_errorlog.outbound_trigger
1490                                 (
1491                                 trigger_id,
1492                                 transaction_type,
1493                                 transaction_subtype,
1494                                 party_id,
1495                                 party_site_id,
1496                                 p_party_type, --bug #2183619
1497                                 document_id,
1498                                 ecx_utils.i_ret_code,
1499                                 ecx_utils.i_errbuf,
1500                                 ecx_utils.i_errparams --MLS
1501                                 );
1502 end senddirect;
1503 
1504 procedure isDeliveryRequired
1505 	(
1506         transaction_type      IN     VARCHAR2,
1507         transaction_subtype   IN     VARCHAR2,
1508 	party_id	      IN     varchar2,
1509 	party_site_id	      IN     varchar2,
1510         party_type            IN     varchar2 , --bug #2183619
1511         resultout             OUT    NOCOPY boolean,
1512 	retcode		      OUT    NOCOPY PLS_INTEGER,
1513 	errmsg		      OUT    NOCOPY VARCHAR2
1514 	)
1515 is
1516 p_message_type		varchar2(200);
1517 p_message_standard	varchar2(200);
1518 p_ext_type		varchar2(200);
1519 p_ext_subtype		varchar2(200);
1520 p_destination_type	varchar2(200);
1521 p_username		ecx_tp_details.username%TYPE;
1522 p_password		ecx_tp_details.password%TYPE;
1523 p_map_code		varchar2(200);
1524 p_queue_name		varchar2(200);
1525 p_source_code		varchar2(2000);
1526 p_destination_code	varchar2(200);
1527 p_destination_address	 ecx_tp_details.protocol_address%TYPE;
1528 p_party_type            varchar2(200);
1529 
1530 begin
1531 p_party_type := party_type; --bug #2183619
1532 	begin
1533 		get_delivery_attribs
1534 			(
1535 			transaction_type,
1536 			transaction_subtype,
1537 			party_id,
1538 			party_site_id,
1539 			p_party_type,
1540 			p_message_type,
1541 			p_message_standard,
1542 			p_ext_type,
1543 			p_ext_subtype,
1544 			p_source_code,
1545 			p_destination_code,
1546 			p_destination_type,
1547 			p_destination_address,
1548 			p_username,
1549 			p_password,
1550 			p_map_code,
1551 			p_queue_name,
1552 			ecx_utils.g_rec_tp_id
1553 			);
1554 		-- take appropriate action for destination_type
1555 		If p_destination_type = 'NONE' Then
1556                         /** No email Action required **/
1557                       ecx_debug.setErrorInfo(0,10,'ECX_DELIVERY_NOT_REQUIRED');
1558            	      resultout := FALSE;
1559 	   	      raise ecx_no_delivery_required;
1560 		Elsif p_destination_address is null and p_destination_type not in ('IAS', 'ITG03')
1561 		then
1562                         ecx_debug.setErrorInfo(1,30,'ECX_DESTINATION_ADDR_NULL',
1563                                'p_party_site_id',
1564                                 party_site_id,
1565                                 'p_source_code',
1566                                 p_source_code);
1567 		        resultout := FALSE;
1568 	   		raise ecx_delivery_setup_error;
1569 		end if;
1570 
1571                 resultout := TRUE;
1572 		exception
1573                 when ecx_transaction_not_defined then
1574 			resultout := FALSE;
1575 			raise;
1576 		when ecx_no_party_setup then
1577 			resultout := FALSE;
1578 		when ecx_no_delivery_required then
1579 			resultout := FALSE;
1580 		when ecx_delivery_setup_error then
1581 			resultout := FALSE;
1582 			raise;
1583                 when ecx_utils.program_exit then
1584          		resultout := FALSE;
1585                         raise;
1586 		when others then
1587 			resultout := FALSE;
1588 			raise ecx_utils.program_exit;
1589 		end;
1590                 -- Changed for MLS
1591                 ecx_debug.setErrorInfo(0,10,'ECX_SUCCESSFUL_TP_LKP');
1592                 errmsg:=ecx_utils.i_errbuf;
1593 		retcode :=ecx_utils.i_ret_code;
1594 
1595 exception
1596 when ecx_transaction_not_defined then
1597         retcode := ecx_utils.i_ret_code;
1598         errmsg := ecx_utils.i_errbuf;
1599 	raise;
1600 when ecx_delivery_setup_error then
1601         retcode := ecx_utils.i_ret_code;
1602         errmsg := ecx_utils.i_errbuf;
1603 	raise;
1604 when ecx_utils.program_exit then
1605 	retcode := ecx_utils.i_ret_code;
1606 	errmsg := ecx_utils.i_errbuf;
1607 	raise ecx_utils.program_exit;
1608 when others then
1609 	retcode := 2;
1610 	errmsg := SQLERRM;
1611 	raise;
1612 end isDeliveryRequired;
1613 
1614 procedure getExtPartyInfo
1615 	(
1616         transaction_type      IN     VARCHAR2,
1617         transaction_subtype   IN     VARCHAR2,
1618 	party_id	      IN     varchar2,
1619 	party_site_id	      IN     varchar2,
1620         party_type            IN     VARCHAR2 ,--bug #2183619
1621 	ext_type	      OUT    NOCOPY varchar2,
1622 	ext_subtype	      OUT    NOCOPY varchar2,
1623 	source_code	      OUT    NOCOPY varchar2,
1624 	destination_code      OUT    NOCOPY varchar2,
1625 	retcode		      OUT    NOCOPY PLS_INTEGER,
1626 	errmsg		      OUT    NOCOPY VARCHAR2
1627 	)
1628 is
1629 p_message_type		varchar2(200);
1630 p_message_standard	varchar2(200);
1631 p_destination_type	varchar2(200);
1632 p_username		ecx_tp_details.username%TYPE;
1633 p_password		ecx_tp_details.password%TYPE;
1637 p_party_type            varchar2(200);
1634 p_map_code		varchar2(200);
1635 p_queue_name		varchar2(200);
1636 p_destination_address	ecx_tp_details.protocol_address%TYPE;
1638 
1639 begin
1640 p_party_type := party_type; --bug #2183619
1641 	get_delivery_attribs
1642 		(
1643 		transaction_type,
1644 		transaction_subtype,
1645 		party_id,
1646 		party_site_id,
1647 		p_party_type,
1648 		p_message_type,
1649 		p_message_standard,
1650 		ext_type,
1651 		ext_subtype,
1652 		source_code,
1653 		destination_code,
1654 		p_destination_type,
1655 		p_destination_address,
1656 		p_username,
1657 		p_password,
1658 		p_map_code,
1659 		p_queue_name,
1660 		ecx_utils.g_rec_tp_id
1661 		);
1662 
1663 	-- take appropriate action for destination_type
1664 	If p_destination_type = 'NONE' Then
1665                 /** No email Action required **/
1666                 ecx_debug.setErrorInfo(0,10,'ECX_DELIVERY_NOT_REQUIRED');
1667 		raise ecx_no_delivery_required;
1668 	Elsif p_destination_address is null
1669 	then
1670                 ecx_debug.setErrorInfo(1,30,'ECX_DESTINATION_ADDR_NULL',
1671                                'p_party_site_id',
1672                                 party_site_id,
1673                                 'p_source_code',
1674                                 source_code);
1675 	   	raise ecx_delivery_setup_error;
1676 	end if;
1677 
1678         --Changed for MLS
1679         ecx_debug.setErrorInfo(0,10,'ECX_SUCCESSFUL_TP_LKP');
1680 	retcode:=ecx_utils.i_ret_code;
1681 	errmsg:=ecx_utils.i_errbuf;
1682 exception
1683 when ecx_no_party_setup then
1684 	retcode := ecx_utils.i_ret_code;
1685 	errmsg := ecx_utils.i_errbuf;
1686 when ecx_no_delivery_required then
1687 	retcode := ecx_utils.i_ret_code;
1688 	errmsg := ecx_utils.i_errbuf;
1689 when ecx_delivery_setup_error then
1690 	retcode := ecx_utils.i_ret_code;
1691 	errmsg := ecx_utils.i_errbuf;
1692 when ecx_utils.program_exit then
1693 	retcode := ecx_utils.i_ret_code;
1694 	errmsg := ecx_utils.i_errbuf;
1695 when others then
1696 	retcode := 2;
1697 	errmsg := SQLERRM;
1698 end getExtPartyInfo;
1699 
1700 PROCEDURE get_delivery_attribs
1701 	(
1702 	transaction_type      IN      varchar2,
1703 	transaction_subtype   IN      varchar2,
1704 	party_id              IN      varchar2,
1705 	party_site_id         IN      varchar2,
1706 	party_type            IN OUT  NOCOPY varchar2, --bug #2183619
1707 	standard_type         OUT     NOCOPY varchar2,
1708 	standard_code         OUT     NOCOPY varchar2,
1709 	ext_type              OUT     NOCOPY varchar2,
1710 	ext_subtype           OUT     NOCOPY varchar2,
1711 	source_code           OUT     NOCOPY varchar2,
1712 	destination_code      OUT     NOCOPY varchar2,
1713 	destination_type      OUT     NOCOPY varchar2,
1714 	destination_address   OUT     NOCOPY varchar2,
1715 	username              OUT     NOCOPY varchar2,
1716 	password              OUT     NOCOPY varchar2,
1717 	map_code              OUT     NOCOPY varchar2,
1718 	queue_name            OUT     NOCOPY varchar2,
1719 	tp_header_id          OUT     NOCOPY pls_integer,
1720 	retcode               OUT     NOCOPY pls_integer,
1721 	retmsg                OUT     NOCOPY varchar2
1722 	)
1723 is
1724 begin
1725 		get_delivery_attribs
1726 			(
1727 			transaction_type,
1728 			transaction_subtype,
1729 			party_id,
1730 			party_site_id,
1731 			party_type,
1732 			standard_type,
1733 			standard_code,
1734 			ext_type,
1735 			ext_subtype,
1736 			source_code,
1737 			destination_code,
1738 			destination_type,
1739 			destination_address,
1740 			username,
1741 			password,
1742 			map_code,
1743 			queue_name,
1744 			tp_header_id
1745 			);
1746 --Changed for MLS
1747 ecx_debug.setErrorInfo(0,10,'ECX_SUCCESSFUL_TP_LKP');
1748 retcode:=ecx_utils.i_ret_code;
1749 retmsg:=ecx_utils.i_errbuf;
1750 exception
1751 when ecx_no_party_setup then
1752 	retcode := ecx_utils.i_ret_code;
1753 	retmsg := ecx_utils.i_errbuf;
1754 when ecx_no_delivery_required then
1755 	retcode := ecx_utils.i_ret_code;
1756 	retmsg := ecx_utils.i_errbuf;
1757 when ecx_delivery_setup_error then
1758 	retcode := ecx_utils.i_ret_code;
1759 	retmsg := ecx_utils.i_errbuf;
1760 when ecx_utils.program_exit then
1761 	retcode := ecx_utils.i_ret_code;
1762 	retmsg := ecx_utils.i_errbuf;
1763 when others then
1764 	retcode := 2;
1765 	retmsg := SQLERRM;
1766 end get_delivery_attribs;
1767 
1768 PROCEDURE resend
1769 	(
1770 	i_msgid		IN	RAW,
1771 	retcode		OUT	NOCOPY PLS_INTEGER,
1772 	errmsg		OUT	NOCOPY VARCHAR2,
1773         i_flag          IN      varchar2
1774 	) IS
1775 
1776   Cursor c1(l_msgid in RAW) is
1777 	Select	msgid,
1778                	message_type,
1779    		message_standard,
1780 		transaction_type,
1781 		transaction_subtype,
1782 		document_number,
1783                 party_type,
1784 		partyid,
1785 		party_site_id,
1786 		protocol_type,
1787 		protocol_address,
1788 		username,
1789 		password,
1790 		attribute1,
1791 		attribute2,
1792 		attribute3,
1793 		attribute4,
1794 		attribute5,
1795 		payload,
1796 		time_stamp,
1797 		status,
1798 		direction
1799 	From	ECX_DOCLOGS
1800 	Where	msgid = l_msgid ;
1801 
1802   cursor c_tp_details
1803         (
1804         p_ext_type              IN      varchar2,
1805         p_ext_subtype           IN      varchar2,
1806         p_party_ext_code        in      varchar2,
1807         p_message_standard      in      varchar2,
1808         p_message_type          in      varchar2
1809         )
1810         is
1814                 etd.password,
1811         select  etd.protocol_type,
1812                 etd.protocol_address,
1813                 etd.username,
1815                 etd.connection_type,
1816                 hub_id,
1817                 hub_user_id
1818         from    ecx_tp_details etd,
1819                 ecx_ext_processes eep,
1820                 ecx_standards es
1821         where   etd.source_tp_location_code     = p_party_ext_code
1822         and     eep.ext_type                    = p_ext_type
1823         and     eep.ext_subtype                 = p_ext_subtype
1824         and     eep.ext_process_id              = etd.ext_process_id
1825         and     eep.standard_id                 = es.standard_id
1826         and     es.standard_code                = p_message_standard
1827         and     es.standard_type                = nvl(p_message_type, 'XML')
1828         and     eep.direction                   = 'OUT';
1829 
1830 	c1_rec  c1%ROWTYPE;
1831 
1832   	o_retcode             pls_integer;
1833   	o_retmsg              varchar2(2000):= null;
1834         i_event               wf_event_t;
1835         i_from_agt            wf_agent_t := wf_agent_t(NULL, NULL);
1836         i_system              varchar2(200);
1837         l_protocol_type       varchar2(2000);
1838         l_protocol_address    varchar2(2000);
1839         l_username            varchar2(2000);
1840         l_password            varchar2(2000);
1841         l_use_old_info        boolean := false;
1842         l_connection_type     varchar2(200);
1843         l_hub_user_id         number;
1844         l_hub_id              number;
1845 
1846 
1847 Begin
1848   --- Pick the messagefrom ECX_DOCLOGS and put it on the ECX_OUTBOUND
1849   --- ue again
1850   --- k the latest info for communication method updates if any
1851   --- ate ecx_external_retry table before enqueueing
1852 
1853   If ( i_msgid is  NULL ) Then
1854     -- MLS
1855     ecx_debug.setErrorInfo(1,30,'ECX_MSGID_NOT_NULL');
1856     retcode   := ecx_utils.i_ret_code;
1857     errmsg    := ecx_utils.i_errbuf;
1858     return;
1859   End If;
1860 
1861   Open c1(i_msgid);
1862   Fetch c1 into c1_rec;
1863 
1864   If c1%NOTFOUND Then
1865     -- MLS
1866     ecx_debug.setErrorInfo(1,30,'ECX_MSGID_NOT_FOUND','p_msgid',i_msgid);
1867     retcode    :=  ecx_utils.i_ret_code;
1868     errmsg     :=  ecx_utils.i_errbuf;
1869     Close c1;
1870     return;
1871   End If;
1872 
1873   Close c1;
1874 
1875   If ( c1_rec.party_site_id is NULL       OR
1876        c1_rec.transaction_type is NULL    OR
1877        c1_rec.transaction_subtype is NULL	 )
1878   Then
1879            -- MLS
1880     ecx_debug.setErrorInfo(1,30,'ECX_INVALID_TXN_PARAMS');
1881     retcode := ecx_utils.i_ret_code;
1882     errmsg  := ecx_utils.i_errbuf;
1883     return;
1884   End IF;
1885 
1886   open c_tp_details
1887   (
1888     c1_rec.transaction_type,
1889     c1_rec.transaction_subtype,
1890     c1_rec.party_site_id,
1891     c1_rec.message_standard,
1892     c1_rec.message_type
1893   );
1894 
1895   fetch c_tp_details into
1896     l_protocol_type,
1897     l_protocol_address,
1898     l_username,
1899     l_password,
1900     l_connection_type,
1901     l_hub_id,
1902     l_hub_user_id;
1903 
1904   if c_tp_details%NOTFOUND then
1905      -- Using old Information
1906      l_use_old_info := true;
1907   end if;
1908   close c_tp_details;
1909 
1910   /* If the connection type is not DIRECT get the protocol_type,
1911      protocol_address from ecx_hubs and username,password
1912      from ecx_hub_users */
1913    if ((not l_use_old_info) AND (l_connection_type <> 'DIRECT')) then
1914    begin
1915      select protocol_type,
1916             protocol_address
1917      into   l_protocol_type,
1918             l_protocol_address
1919      from ecx_hubs
1920      where hub_id=l_hub_id;
1921 
1922      if (l_hub_user_id is not null) then
1923          select username,
1924                 password
1925          into   l_username,
1926                 l_password
1927          from   ecx_hub_users
1928          where hub_user_id = l_hub_user_id;
1929      end if;
1930 
1931      exception
1932        when no_data_found then
1933        -- Using old Information
1934           l_use_old_info := true;
1935        end;
1936    end if;
1937 
1938    if l_use_old_info then
1939       l_protocol_type := c1_rec.protocol_type;
1940       l_protocol_address := c1_rec.protocol_address;
1941       l_username := c1_rec.username;
1942       l_password := c1_rec.password;
1943    end if;
1944 
1945         -- call wf_ecx_qh.enqueue with the correct parameters
1946         wf_event_t.initialize(i_event);
1947         i_event.addParameterToList('RESEND', 'Y');
1948         i_event.addParameterToList('ECX_MSG_ID', c1_rec.msgid);
1949         i_event.addParameterToList('MESSAGE_TYPE', c1_rec.message_type);
1950         i_event.addParameterToList('MESSAGE_STANDARD', c1_rec.message_standard);
1951         i_event.addParameterToList('TRANSACTION_TYPE', c1_rec.transaction_type);
1952         i_event.addParameterToList('TRANSACTION_SUBTYPE', c1_rec.transaction_subtype);
1953         i_event.addParameterToList('DOCUMENT_NUMBER', c1_rec.document_number);
1954         i_event.addParameterToList('PARTY_TYPE', c1_rec.party_type);
1955         i_event.addParameterToList('PARTYID', c1_rec.partyid);
1956         i_event.addParameterToList('PARTY_SITE_ID', c1_rec.party_site_id);
1957         i_event.addParameterToList('PROTOCOL_TYPE', l_protocol_type);
1958         i_event.addParameterToList('PROTOCOL_ADDRESS', l_protocol_address);
1959         i_event.addParameterToList('USERNAME', l_username);
1960         i_event.addParameterToList('PASSWORD', l_password);
1964         i_event.addParameterToList('ATTRIBUTE4', c1_rec.attribute4);
1961         i_event.addParameterToList('ATTRIBUTE1', c1_rec.attribute1);
1962         i_event.addParameterToList('ATTRIBUTE2', c1_rec.attribute2);
1963         i_event.addParameterToList('ATTRIBUTE3', c1_rec.attribute3);
1965         i_event.addParameterToList('ATTRIBUTE5', c1_rec.attribute5);
1966         i_event.addParameterToList('DIRECTION', c1_rec.direction);
1967         i_event.event_data := c1_rec.payload;
1968 
1969         -- set the from agent
1970         if (upper(l_protocol_type) = 'SOAP') then
1971           i_from_agt.setname('WF_WS_JMS_OUT');
1972 
1973           -- set default Web Services related attributes^M
1974 		  i_event.setEventName('oracle.apps.fnd.wf.ws.resend');
1975 		  i_event.setEventKey(abs(dbms_utility.get_time()));
1976 
1977           i_event.addParameterToList('WS_SERVICE_NAMESPACE',
1978                            'http://xmlns.oracle.com/apps/fnd/XMLGateway');
1979           i_event.addParameterToList('WS_PORT_OPERATION',
1980                             'ReceiveDocument');
1981           i_event.addParameterToList('WS_HEADER_IMPL_CLASS',
1982                             'oracle.apps.fnd.wf.ws.client.DefaultHeaderGenerator');
1983           i_event.addParameterToList('WS_RESPONSE_IMPL_CLASS',
1984                             'oracle.apps.fnd.wf.ws.client.WfWsResponse');
1985 
1986         else
1987 
1988           if (upper(l_protocol_type) = 'JMS') then
1989 	    if(l_protocol_address is null) then
1990                 i_from_agt.setname('WF_JMS_OUT');
1991 	    else
1992                 i_from_agt.setname(l_protocol_address);
1993             end if;
1994 	  else
1995             i_from_agt.setname('ECX_OUTBOUND');
1996           end if;
1997         end if;
1998 
1999         select  name
2000         into    i_system
2001         from    wf_systems
2002         where   guid = wf_core.translate('WF_SYSTEM_GUID');
2003 
2004         i_from_agt.setsystem(i_system);
2005         i_event.setFromAgent(i_from_agt);
2006         wf_event.send(i_event);
2007         -- MLS
2008         ecx_debug.setErrorInfo(0,10,'ECX_RESEND_TRIGGERED');
2009         retcode    := ecx_utils.i_ret_code;
2010 	errmsg     := ecx_utils.i_errbuf;
2011 
2012         ecx_errorlog.outbound_log(i_event);
2013 
2014         if (i_flag <> 'Y') then
2015           commit;
2016         end if;
2017 
2018   Exception
2019 	When Others Then
2020 	If c1%ISOPEN Then
2021 	   Close c1;
2022 	End IF;
2023 
2024         if (ecx_out_wf_qh.retmsg is null AND ecx_out_wf_qh.retcode = 0)
2025         then
2026                 -- MLS
2027                 ecx_debug.setErrorInfo(2,30,SQLERRM||' - ECX_DOCUMENT.RESEND');
2028 		retcode := ecx_utils.i_ret_code;
2029 		errmsg  := ecx_utils.i_errbuf;
2030 	else
2031                 -- MLS
2032                 ecx_debug.setErrorInfo(ecx_out_wf_qh.retcode,30,
2033                                        ecx_out_wf_qh.retmsg);
2034 		retcode := ecx_utils.i_ret_code;
2035           	errmsg := ecx_utils.i_errbuf;
2036 	end if;
2037 
2038         if (i_flag <> 'Y') then
2039            rollback;
2040         end if;
2041   End Resend;
2042 
2043 /* new API added for bug #2215677 to return trading partner
2044    confirmation status */
2045 procedure getConfirmationStatus
2046 (
2047         i_transaction_type    IN     VARCHAR2,
2048         i_transaction_subtype IN     VARCHAR2,
2049 	i_party_id	      IN     varchar2,
2050 	i_party_site_id	      IN     varchar2,
2051         i_party_type          IN     varchar2 ,
2052 	o_confirmation	      OUT    NOCOPY number
2053 	)
2054 as
2055 begin
2056 
2057 
2058 	select	etd.confirmation into o_confirmation
2059 	from 	ecx_tp_details 		etd,
2060 		ecx_tp_headers  	eth,
2061 		ecx_ext_processes 	eep,
2062 		ecx_transactions	et,
2063 		ecx_standards		es,
2064 		ecx_mappings		em
2065         where   ( eth.party_id	= i_party_id or i_party_id is null )
2066 	and	eth.party_site_id = i_party_site_id
2067 	and	eth.party_type = et.party_type
2068 	and	eth.tp_header_id = etd.tp_header_id
2069 	and	et.transaction_type = i_transaction_type
2070 	and	et.transaction_subtype = i_transaction_subtype
2071       	and   (i_party_type is null or et.party_type = i_party_type)
2072 	and	et.transaction_id = eep.transaction_id
2073 	and	es.standard_id = eep.standard_id
2074 	and	eep.ext_process_id = etd.ext_process_id
2075 	and	eep.direction = 'OUT'
2076 	and	em.map_id = etd.map_id;
2077 
2078 
2079 
2080 exception
2081 	when no_data_found then
2082                ecx_debug.setErrorInfo(2,30,'ECX_CONFIRM_STATUS_NOT_FOUND');
2083                raise ecx_utils.program_exit;
2084 
2085 
2086        when too_many_rows then
2087                 ecx_debug.setErrorInfo(2,30,'ECX_PARTY_TYPE_NOT_SET ');
2088 		raise ecx_utils.program_exit;
2089 
2090 
2091 	when others then
2092                  ecx_debug.setErrorInfo(2,30, SQLERRM ||'- ECX_DOCUMENT.getConfirmationstatus');
2093 		raise ecx_utils.program_exit;
2094 end getConfirmationstatus;
2095 
2096 end ecx_document;