DBA Data[Home] [Help]

PACKAGE BODY: APPS.ECECATI

Source


1 package body ececati as
2 -- $Header: ECWCATIB.pls 120.4 2006/03/06 00:23:35 arsriniv ship $
3 procedure process_cati_docs
4 	(
5 	i_transaction_type	IN	varchar2,
6 	i_run_id		IN	number,
7 	o_po_batch_id		OUT NOCOPY	number
8 	)
9 is
10 m_stack_pos	number;
11 m_plsql_pos	number;
12 m_var_found	BOOLEAN := FALSE;
13 BEGIN
14 if EC_DEBUG.G_debug_level >= 2 then
15 ec_debug.push('ECECATI.PROCESS_CATI_DOCS');
16 ec_debug.pl(3,'i_transaction_type',i_transaction_type);
17 ec_debug.pl(3,'i_run_id',i_run_id);
18 END IF;
19 	/**
20         Initialize the Stack Table
21         **/
22         ec_utils.g_stack.DELETE;
23         if EC_DEBUG.G_debug_level >= 1 then
24 	ec_debug.pl(1,'EC','ECE_START_GENERIC_INBOUND','TRANSACTION_TYPE',i_transaction_type);
25         END IF;
26         ece_inbound.process_run_inbound
27                 (
28                 i_transaction_type => i_transaction_type,
29                 i_run_id => i_run_id
30                 );
31        if EC_DEBUG.G_debug_level >= 1 then
32 	ec_debug.pl(1,'EC','ECE_FINISH_GENERIC_INBOUND','TRANSACTION_TYPE',i_transaction_type);
33        END IF;
34         ---Get out variables from the Stack .
35 	m_var_found := ec_utils.find_variable
36 			(
37 			0,
38 			'P_PO_BATCH_ID',
39 			m_stack_pos,
40 			m_plsql_pos
41 			);
42 	if ( m_var_found )
43 	then
44 		o_po_batch_id := ec_utils.g_stack(m_stack_pos).variable_value;
45 	else
46             if EC_DEBUG.G_debug_level >= 3 then
47 		ec_debug.pl(3,'EC','ECE_VARIABLE_NOT_ON_STACK','VARIABLE_NAME','P_PO_BATCH_ID');
48             end if;
49 		ec_utils.i_ret_code :=2;
50 		raise ec_utils.program_exit;
51 	end if;
52 if EC_DEBUG.G_debug_level >= 2 then
53 ec_debug.pl(3,'o_po_batch_id',o_po_batch_id);
54 ec_debug.pop('ECECATI.PROCESS_CATI_DOCS');
55 end if;
56 EXCEPTION
57 WHEN EC_UTILS.PROGRAM_EXIT then
58 	raise;
59 WHEN OTHERS THEN
60         ec_debug.pl(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','ECECATI.PROCESS_CATI_DOCS');
61         ec_debug.pl(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
62 	ec_utils.i_ret_code :=2;
63 	raise ec_utils.program_exit;
64 end process_cati_docs;
65 
66 procedure process_cati_inbound
67 	(
68 	errbuf			OUT NOCOPY	varchar2,
69 	retcode			OUT NOCOPY	varchar2,
70 	i_file_path             IN      varchar2,
71         i_file_name             IN      varchar2,
72         i_run_import            IN      varchar2,
73 	i_default_buyer		IN	varchar2,
74 	i_po_document_type	IN	varchar2,
75 	i_po_document_sub_type	IN	varchar2,
76 	i_po_create_item_flag	IN	varchar2,
77 	i_po_sourcing_rules	IN	varchar2,
78 	i_po_approval_status	IN	varchar2,
79 	i_po_release_method	In	varchar2,
80 	i_transaction_type      IN	varchar2,
81 	i_map_id		IN	number,
82 	i_debug_mode		IN	number,
83         i_source_charset        IN      varchar2
84         )
85 is
86 i_submit_id		number;
87 i_run_id		number;
88 o_po_batch_id		number;
89 i_map_type		varchar2(40);
90       cEnabled                   VARCHAR2(1)          := 'Y';
91       ece_transaction_disabled   EXCEPTION;
92 begin
93 ec_debug.enable_debug(i_debug_mode);
94 if EC_DEBUG.G_debug_level >= 1 then
95 ec_debug.pl(1,'EC','ECE_START_INBOUND','TRANSACTION_TYPE',i_transaction_type);
96 ec_debug.push('ECECATI.PROCESS_CATI_INBOUND');
97 ec_debug.pl(3,'i_file_path',i_file_path);
98 ec_debug.pl(3,'i_file_name',i_file_name);
99 ec_debug.pl(3,'i_run_import',i_run_import);
100 ec_debug.pl(3,'i_default_buyer',i_default_buyer);
101 ec_debug.pl(3,'i_po_document_type',i_po_document_type);
102 ec_debug.pl(3,'i_po_document_sub_type',i_po_document_sub_type);
103 ec_debug.pl(3,'i_po_create_item_flag',i_po_create_item_flag);
104 ec_debug.pl(3,'i_po_sourcing_rules',i_po_sourcing_rules);
105 ec_debug.pl(3,'i_po_approval_status',i_po_approval_status);
106 ec_debug.pl(3,'i_po_release_method',i_po_release_method);
107 ec_debug.pl(3,'i_map_id',i_map_id);
108 ec_debug.pl(3,'i_debug_mode',i_debug_mode);
109 ec_debug.pl(3,'i_source_charset',i_source_charset);
110 end if;
111          /* Check to see if the transaction is enabled. If not, abort */
112          fnd_profile.get('ECE_' || i_transaction_type || '_ENABLED',cEnabled);
113          IF cEnabled = 'N' THEN
114             RAISE ece_transaction_disabled;
115          END IF;
116         if EC_DEBUG.G_debug_level >= 1 then
117 	ec_debug.pl(1,'EC','ECE_BEGIN_STAGING','TRANSACTION_TYPE',i_transaction_type);
118         end if;
119 	select map_type into i_map_type
120         from ece_mappings
121         where map_id = i_map_id
122           and enabled ='Y';
123 
124         /* bug 2110652 : Set the global variable for the characterset based on the input characterset */
125 
126         ec_inbound_stage.g_source_charset:= i_source_charset;
127 
128         IF i_map_type = 'XML' THEN
129 
130 
131         ec_xml_utils.ec_xml_processor_in_generic
132                 (
133                 i_map_id,
134                 i_run_id,
135                 i_file_path,
136                 i_file_name
137                 );
138         ELSE
139         ec_inbound_stage.load_data
140                 (
141                 i_transaction_type,
142                 i_file_name,
143                 i_file_path,
144                 i_map_id,
145                 i_run_id
146                 );
147         END IF;
148         if EC_DEBUG.G_debug_level >= 1 then
149 	ec_debug.pl(1,'EC','ECE_END_STAGING','TRANSACTION_TYPE',i_transaction_type);
150         end if;
151 
152 	process_cati_docs
153 		(
154 		i_transaction_type,
155 		i_run_id,
156 		o_po_batch_id
157 		);
158 
159 	if i_run_import = 'Y'
160 	then
161 
162         /* bug2321102: Modified the Argument for batch_id from Argument8 to Argument9 */
163 	/* Bug 2513695: Added the argument9(Org_id) to the following submit request */
164 
165 	        ec_debug.pl(3,'o_PO_batch_id',o_PO_batch_id);
166 
167 		i_submit_id := fnd_request.submit_request
168 				(
169                            	application => 'PO',
170                            	program     => 'POXPDOI',
171                            	Start_Time  =>  NULL,
172                            	Sub_Request =>  FALSE,
173                            	Argument1   =>  i_default_buyer,
174                            	Argument2   =>  i_PO_document_type,
175                            	Argument3   =>  i_PO_document_sub_type,
176                            	Argument4   =>  i_PO_create_item_flag,
177                            	Argument5   =>  i_PO_sourcing_rules,
178                            	Argument6   =>  i_PO_approval_status,
182                                 Argument10  =>  NULL,
179                            	Argument7   =>  i_PO_release_method,
180                            	Argument8   =>  o_PO_batch_id,
181                            	Argument9   =>  NULL,
183 				Argument11  =>  NULL,
184 				Argument12  =>  NULL,
185 				Argument13  =>  NULL,
186 				Argument14  =>  NULL,
187 				Argument15  =>  NULL,
188                                 Argument16   => NULL,
189                                 Argument17  =>  NULL,
190                                 Argument18  =>  NULL,
191                                 Argument19  =>  NULL,
192                                 Argument20  =>  NULL,
193                                 Argument21  =>  NULL,
194                                 Argument22  =>  NULL,
195 				Argument23   => NULL,
196                                 Argument24  =>  NULL,
197                                 Argument25  =>  NULL,
198                                 Argument26  =>  NULL,
199                                 Argument27  =>  NULL,
200                                 Argument28  =>  NULL,
201                                 Argument29  =>  NULL,
202                                 Argument30   => NULL,
203                                 Argument31  =>  NULL,
204                                 Argument32  =>  NULL,
205                                 Argument33  =>  NULL,
206                                 Argument34  =>  NULL,
207                                 Argument35  =>  NULL,
208                                 Argument36  =>  NULL,
209 				Argument37   => NULL,
210                                 Argument38  =>  NULL,
211                                 Argument39  =>  NULL,
212                                 Argument40  =>  NULL,
213                                 Argument41  =>  NULL,
214                                 Argument42  =>  NULL,
215                                 Argument43  =>  NULL,
216 				Argument44   => NULL,
217                                 Argument45  =>  NULL,
218                                 Argument46  =>  NULL,
219                                 Argument47  =>  NULL,
220                                 Argument48  =>  NULL,
221                                 Argument49  =>  NULL,
222                                 Argument50  =>  NULL,
223 				Argument51   => NULL,
224                                 Argument52  =>  NULL,
225                                 Argument53  =>  NULL,
226                                 Argument54  =>  NULL,
227                                 Argument55  =>  NULL,
228                                 Argument56  =>  NULL,
229                                 Argument57  =>  NULL,
230                                 Argument58  =>  NULL,
231                                 Argument59  =>  NULL,
232                                 Argument60  =>  NULL,
233                                 Argument61  =>  NULL,
234                                 Argument62  =>  NULL,
235                                 Argument63  =>  NULL,
236 				Argument64   => NULL,
237                                 Argument65  =>  NULL,
238                                 Argument66  =>  NULL,
239                                 Argument67  =>  NULL,
240                                 Argument68  =>  NULL,
241                                 Argument69  =>  NULL,
242                                 Argument70  =>  NULL,
243 				Argument71  =>  NULL,
244                                 Argument72  =>  NULL,
245                                 Argument73  =>  NULL,
246 				Argument74   => NULL,
247                                 Argument75  =>  NULL,
248                                 Argument76  =>  NULL,
249                                 Argument77  =>  NULL,
250                                 Argument78  =>  NULL,
251                                 Argument79  =>  NULL,
255                                 Argument83  =>  NULL,
252                                 Argument80  =>  NULL,
253 				Argument81   => NULL,
254                                 Argument82  =>  NULL,
256                                 Argument84  =>  NULL,
257                                 Argument85  =>  NULL,
258                                 Argument86  =>  NULL,
259                                 Argument87  =>  NULL,
260                                 Argument88  =>  NULL,
261                                 Argument89  =>  NULL,
262                                 Argument90  =>  NULL,
263                                 Argument91  =>  NULL,
264                                 Argument92  =>  NULL,
265                                 Argument93  =>  NULL,
266 				Argument94   => NULL,
267                                 Argument95  =>  NULL,
268                                 Argument96  =>  NULL,
269                                 Argument97  =>  NULL,
270                                 Argument98  =>  NULL,
271                                 Argument99  =>  NULL,
272                                 Argument100 =>  NULL
273 				);
274 
275                 if EC_DEBUG.G_debug_level >= 1 then
276 		ec_debug.pl(1,'EC','ECE_EXECUTE_OPEN_INTERFACE','TRANSACTION_TYPE',i_transaction_type,
277                                 'REQUEST_ID',i_Submit_Id);
278                 end if;
279 
280 	end if;
281 commit;
282 
283 retcode := ec_utils.i_ret_code;
284 
285 IF ec_mapping_utils.ec_get_trans_upgrade_status(i_transaction_type, i_map_id)  = 'U' THEN
286    ec_debug.pl(0,'EC','ECE_REC_TRANS_PENDING',NULL);
287    retcode := 1;
288 END IF;
289 if EC_DEBUG.G_debug_level >= 1 then
290 ec_debug.pl(3,'i_submit_id',i_submit_id);
291 ec_debug.pl(3,'retcode',retcode);
292 ec_debug.pl(3,'errbuf',errbuf);
293 ec_debug.pop('ECECATI.PROCESS_CATI_INBOUND');
294 ec_debug.pl(1,'EC','ECE_END_INBOUND','TRANSACTION_TYPE',i_transaction_type);
295 end if;
296 ec_debug.disable_debug;
297 EXCEPTION
298       WHEN ece_transaction_disabled THEN
299          ec_debug.pl(0,'EC','ECE_TRANSACTION_DISABLED','TRANSACTION',i_transaction_type);
300          retcode := 1;
301          ec_debug.disable_debug;
302          ROLLBACK WORK;
303 
304 WHEN EC_UTILS.PROGRAM_EXIT then
305 	rollback work;
306 	retcode := ec_utils.i_ret_code;
307 	ece_flatfile_pvt.print_attributes;
308 	ec_debug.disable_debug;
309 WHEN OTHERS THEN
310 	rollback work;
311         ec_debug.pl(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','ECECATI.PROCESS_CATI_INBOUND');
312         ec_debug.pl(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
313 	ece_flatfile_pvt.print_attributes;
314 	retcode :=2;
315 	ec_debug.disable_debug;
316 end process_cati_inbound;
317 
318 procedure process_rrqi_inbound
319 	(
320 	errbuf			OUT NOCOPY	varchar2,
321 	retcode			OUT NOCOPY	varchar2,
322 	i_file_path             IN      varchar2,
323         i_file_name             IN      varchar2,
324         i_run_import            IN      varchar2,
325 	i_default_buyer		IN	varchar2,
326 	i_po_document_type	IN	varchar2,
327 	i_po_document_sub_type	IN	varchar2,
328 	i_po_create_item_flag	IN	varchar2,
329 	i_po_sourcing_rules	IN	varchar2,
330 	i_po_approval_status	IN	varchar2,
331 	i_po_release_method	In	varchar2,
332 	i_transaction_type	IN	varchar2,
333 	i_map_id		IN	number,
334 	i_debug_mode		IN	number,
335 	i_source_charset        IN      varchar2
336         )
337 is
338 i_submit_id		number;
339 i_run_id		number;
340 o_po_batch_id		number;
341 i_map_type		varchar2(40);
342       cEnabled                   VARCHAR2(1)          := 'Y';
343       ece_transaction_disabled   EXCEPTION;
344 
345 begin
346 ec_debug.enable_debug(i_debug_mode);
347 ec_debug.pl(0,'EC','ECE_START_INBOUND','TRANSACTION_TYPE',i_transaction_type);
348 ec_debug.push('ECECATI.PROCESS_RRQI_INBOUND');
349 if EC_DEBUG.G_debug_level >= 3 then
350 ec_debug.pl(3,'i_file_path',i_file_path);
351 ec_debug.pl(3,'i_file_name',i_file_name);
352 ec_debug.pl(3,'i_run_import',i_run_import);
353 ec_debug.pl(3,'i_default_buyer',i_default_buyer);
354 ec_debug.pl(3,'i_po_document_type',i_po_document_type);
355 ec_debug.pl(3,'i_po_document_sub_type',i_po_document_sub_type);
356 ec_debug.pl(3,'i_po_create_item_flag',i_po_create_item_flag);
357 ec_debug.pl(3,'i_po_sourcing_rules',i_po_sourcing_rules);
358 ec_debug.pl(3,'i_po_approval_status',i_po_approval_status);
359 ec_debug.pl(3,'i_po_release_method',i_po_release_method);
360 ec_debug.pl(3,'i_map_id',i_map_id);
361 ec_debug.pl(3,'i_debug_mode',i_debug_mode);
362 end if;
363          /* Check to see if the transaction is enabled. If not, abort */
364          fnd_profile.get('ECE_' || i_transaction_type || '_ENABLED',cEnabled);
365          IF cEnabled = 'N' THEN
366             RAISE ece_transaction_disabled;
367          END IF;
368 
369 	ec_debug.pl(0,'EC','ECE_BEGIN_STAGING','TRANSACTION_TYPE',i_transaction_type);
370 	select map_type into i_map_type
371         from ece_mappings
372         where map_id = i_map_id
373           and enabled ='Y';
374 
375 	/* bug 2162062 : Set the global variable for the characterset based on the input characterset */
376 
377 	ec_inbound_stage.g_source_charset:= i_source_charset;
378 
379         IF i_map_type = 'XML' THEN
380         ec_xml_utils.ec_xml_processor_in_generic
381                 (
382                 i_map_id,
383                 i_run_id,
384                 i_file_path,
385                 i_file_name
386                 );
387         ELSE
388         ec_inbound_stage.load_data
389                 (
390                 i_transaction_type,
391                 i_file_name,
392                 i_file_path,
393                 i_map_id,
397 	ec_debug.pl(0,'EC','ECE_END_STAGING','TRANSACTION_TYPE',i_transaction_type);
394                 i_run_id
395                 );
396         END IF;
398 
399 	process_cati_docs
400 		(
401 		i_transaction_type,
402 		i_run_id,
403 		o_po_batch_id
404 		);
405 
406 	if i_run_import = 'Y'
407 	then
408 
409 	/* bug2321102: Modified the Argument for batch_id from Argument8 to Argument9 */
410 	/* Bug 2513695: Added the argument8(Org_id) to the following submit request */
411 
412 	        ec_debug.pl(3,'o_PO_batch_id',o_PO_batch_id);
413 
414 		i_submit_id := fnd_request.submit_request
415 				(
416                            	application => 'PO',
417                            	program     => 'POXPDOI',
418                            	Start_Time  =>  NULL,
419                            	Sub_Request =>  FALSE,
420                            	Argument1   =>  i_default_buyer,
421                            	Argument2   =>  i_PO_document_type,
422                            	Argument3   =>  i_PO_document_sub_type,
423                            	Argument4   =>  i_PO_create_item_flag,
424                            	Argument5   =>  i_PO_sourcing_rules,
425                            	Argument6   =>  i_PO_approval_status,
426                            	Argument7   =>  i_PO_release_method,
427                            	Argument8   =>  o_PO_batch_id,
428                                 Argument9   =>  NULL,
429                                 Argument10  =>  NULL,
430                                 Argument11  =>  NULL,
431                                 Argument12  =>  NULL,
432                                 Argument13  =>  NULL,
433                                 Argument14  =>  NULL,
434                                 Argument15  =>  NULL,
435                                 Argument16   => NULL,
436                                 Argument17  =>  NULL,
437                                 Argument18  =>  NULL,
438                                 Argument19  =>  NULL,
439                                 Argument20  =>  NULL,
440                                 Argument21  =>  NULL,
441                                 Argument22  =>  NULL,
442 				Argument23   => NULL,
443                                 Argument24  =>  NULL,
444                                 Argument25  =>  NULL,
445                                 Argument26  =>  NULL,
446                                 Argument27  =>  NULL,
447                                 Argument28  =>  NULL,
448                                 Argument29  =>  NULL,
449                                 Argument30   => NULL,
450                                 Argument31  =>  NULL,
451                                 Argument32  =>  NULL,
452                                 Argument33  =>  NULL,
453                                 Argument34  =>  NULL,
454                                 Argument35  =>  NULL,
455                                 Argument36  =>  NULL,
456 				Argument37   => NULL,
460                                 Argument41  =>  NULL,
457                                 Argument38  =>  NULL,
458                                 Argument39  =>  NULL,
459                                 Argument40  =>  NULL,
461                                 Argument42  =>  NULL,
462                                 Argument43  =>  NULL,
463 				Argument44   => NULL,
464                                 Argument45  =>  NULL,
465                                 Argument46  =>  NULL,
466                                 Argument47  =>  NULL,
467                                 Argument48  =>  NULL,
468                                 Argument49  =>  NULL,
469                                 Argument50  =>  NULL,
470 				Argument51   => NULL,
471                                 Argument52  =>  NULL,
472                                 Argument53  =>  NULL,
473                                 Argument54  =>  NULL,
474                                 Argument55  =>  NULL,
475                                 Argument56  =>  NULL,
476                                 Argument57  =>  NULL,
477                                 Argument58  =>  NULL,
481                                 Argument62  =>  NULL,
478                                 Argument59  =>  NULL,
479                                 Argument60  =>  NULL,
480                                 Argument61  =>  NULL,
482                                 Argument63  =>  NULL,
483 				Argument64   => NULL,
484                                 Argument65  =>  NULL,
485                                 Argument66  =>  NULL,
486                                 Argument67  =>  NULL,
487                                 Argument68  =>  NULL,
488                                 Argument69  =>  NULL,
489                                 Argument70  =>  NULL,
490 				Argument71  =>  NULL,
491                                 Argument72  =>  NULL,
492                                 Argument73  =>  NULL,
493 				Argument74   => NULL,
494                                 Argument75  =>  NULL,
495                                 Argument76  =>  NULL,
496                                 Argument77  =>  NULL,
497                                 Argument78  =>  NULL,
498                                 Argument79  =>  NULL,
499                                 Argument80  =>  NULL,
500 				Argument81   => NULL,
501                                 Argument82  =>  NULL,
502                                 Argument83  =>  NULL,
503                                 Argument84  =>  NULL,
504                                 Argument85  =>  NULL,
505                                 Argument86  =>  NULL,
506                                 Argument87  =>  NULL,
507                                 Argument88  =>  NULL,
508                                 Argument89  =>  NULL,
509                                 Argument90  =>  NULL,
510                                 Argument91  =>  NULL,
511                                 Argument92  =>  NULL,
512                                 Argument93  =>  NULL,
513 				Argument94   => NULL,
514                                 Argument95  =>  NULL,
515                                 Argument96  =>  NULL,
516                                 Argument97  =>  NULL,
517                                 Argument98  =>  NULL,
518                                 Argument99  =>  NULL,
519                                 Argument100 =>  NULL
520                                 );
521 
522 		ec_debug.pl(0,'EC','ECE_EXECUTE_OPEN_INTERFACE','TRANSACTION_TYPE',i_transaction_type,
523                                 'REQUEST_ID',i_Submit_Id);
524 
525 	end if;
526 commit;
527 
528 retcode := ec_utils.i_ret_code;
529 
530 IF ec_mapping_utils.ec_get_trans_upgrade_status(i_transaction_type, i_map_id)  = 'U' THEN
531    ec_debug.pl(0,'EC','ECE_REC_TRANS_PENDING',NULL);
532    retcode := 1;
533 END IF;
534 if EC_DEBUG.G_debug_level >= 3 then
535 ec_debug.pl(3,'i_submit_id',i_submit_id);
536 ec_debug.pl(3,'retcode',retcode);
537 ec_debug.pl(3,'errbuf',errbuf);
538 end if;
539 ec_debug.pop('ECECATI.PROCESS_RRQI_INBOUND');
540 ec_debug.pl(0,'EC','ECE_END_INBOUND','TRANSACTION_TYPE',i_transaction_type);
541 ec_debug.disable_debug;
542 EXCEPTION
543       WHEN ece_transaction_disabled THEN
544          ec_debug.pl(0,'EC','ECE_TRANSACTION_DISABLED','TRANSACTION',i_transaction_type);
545          retcode := 1;
546          ec_debug.disable_debug;
547          ROLLBACK WORK;
548 
549 WHEN EC_UTILS.PROGRAM_EXIT then
550 	rollback work;
551 	retcode := ec_utils.i_ret_code;
552 	ece_flatfile_pvt.print_attributes;
553 	ec_debug.disable_debug;
554 WHEN OTHERS THEN
555 	rollback work;
556         ec_debug.pl(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','ECECATI.PROCESS_RRQI_INBOUND');
557         ec_debug.pl(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
558 	ece_flatfile_pvt.print_attributes;
559 	retcode :=2;
560 	ec_debug.disable_debug;
561 end process_rrqi_inbound;
562 
563 end ececati;