DBA Data[Home] [Help]

PACKAGE BODY: APPS.ECEINI

Source


1 PACKAGE BODY eceini AS
2 -- $Header: ECWINIB.pls 120.2 2005/09/30 07:34:31 arsriniv ship $
3 
4 l_group_id  	number;     --Bug 2598743
5 
6    PROCEDURE process_invoice_inbound(
7    	errbuf        		OUT NOCOPY VARCHAR2,
8    	retcode       		OUT NOCOPY VARCHAR2,
9    	i_file_path   		IN  VARCHAR2,
10    	i_file_name   		IN  VARCHAR2,
11    	i_run_import  		IN  VARCHAR2,
12    	i_batch_name  		IN  VARCHAR2,
13    	i_hold_name   		IN  VARCHAR2,
14    	i_hold_reason 		IN  VARCHAR2,
15    	i_gl_date     		IN  varchar2,
16    	i_purge       		IN  VARCHAR2,
17 	i_summarize_flag	IN  VARCHAR2,
18 	i_transaction_type	IN  VARCHAR2,
19 	i_map_id		IN  NUMBER,
20    	i_debug_mode  		IN  NUMBER,
21 	i_source_charset	IN  VARCHAR2
22 				) IS
23 
24      o_group_id               VARCHAR2(240):= NULL;     --Bug 2101935
25      o_invoice_id             NUMBER(15);               --Bug 2204431
26      i_submit_id              NUMBER;
27       i_run_id                 NUMBER;
28       i_map_type               VARCHAR2(40);
29       m_stack_pos              NUMBER;
30       m_plsql_pos              NUMBER;
31       m_var_found              BOOLEAN      := FALSE;
32       cEnabled                 VARCHAR2(1)  := 'Y';
33       ece_transaction_disabled EXCEPTION;
34 
35       BEGIN
36          ec_debug.enable_debug(i_debug_mode);
37          ec_debug.push('ECEINI.PROCESS_INVOICE_INBOUND');
38          ec_debug.pl(3,'i_file_path',i_file_path);
39          ec_debug.pl(3,'i_file_name',i_file_name);
40          ec_debug.pl(3,'i_run_import',i_run_import);
41          ec_debug.pl(3,'i_debug_mode',i_debug_mode);
42          ec_debug.pl(3,'i_batch_name',i_batch_name);
43          ec_debug.pl(3,'i_hold_name',i_hold_name);
44          ec_debug.pl(3,'i_hold_reason',i_hold_reason);
45          ec_debug.pl(3,'i_gl_date',i_gl_date);
46          ec_debug.pl(3,'i_purge',i_purge);
47          ec_debug.pl(3,'i_summarize_flag',i_summarize_flag);
48          ec_debug.pl(3,'i_map_id',i_map_id);
49          ec_debug.pl(3,'i_debug_mode',i_debug_mode);
50          ec_debug.pl(3,'i_source_charset',i_source_charset);
51 
52          /* Check to see if the transaction is enabled. If not, abort */
53          fnd_profile.get('ECE_' || i_transaction_type || '_ENABLED',cEnabled);
54          IF cEnabled = 'N' THEN
55             RAISE ece_transaction_disabled;
56          END IF;
57 
58       	ec_debug.pl(0,'EC','ECE_BEGIN_STAGING','TRANSACTION_TYPE',i_transaction_type);
59 
60 	select map_type into i_map_type
61         from ece_mappings
62         where map_id = i_map_id
63           and enabled ='Y';
64 
65 	/* bug 2162062 : Set the global variable for the characterset based on the input characterset */
66 
67         ec_inbound_stage.g_source_charset:= i_source_charset;
68 
69 	IF i_map_type = 'XML' THEN
70         ec_xml_utils.ec_xml_processor_in_generic
71                 (
72                 i_map_id,
73                 i_run_id,
74                 i_file_path,
75                 i_file_name
76                 );
77         ELSE
78         ec_inbound_stage.load_data
79                 (
80                 i_transaction_type,
81                 i_file_name,
82                 i_file_path,
83                 i_map_id,
84                 i_run_id
85                 );
86         END IF;
87       	ec_debug.pl(0,'EC','ECE_END_STAGING','TRANSACTION_TYPE',i_transaction_type);
88 
89 	      -- Initialize the Stack Table
90          ec_utils.g_stack.DELETE;
91 
92       	--- Put the IN Variables on the Stack.
93       	--- None for INI
94 
95 	      ec_debug.pl(0,'EC','ECE_START_GENERIC_INBOUND','TRANSACTION_TYPE',i_transaction_type);
96          ece_inbound.process_run_inbound
97 		(i_transaction_type => i_transaction_type,
98 		 i_run_id => i_run_id);
99 
100 	      ec_debug.pl(0,'EC','ECE_FINISH_GENERIC_INBOUND','TRANSACTION_TYPE',i_transaction_type);
101 
102          --- Get out variables from the Stack .
103 /* Bug 2204431    start.
104    Get the Invoice Id and derive Group Id,
105    since Group id at Variable level 1 will be overwritten
106    in g_file_tbl
107    Do this only if i_run_import = 'Y'
108    or else no need to derive.
109  */
110 
111  IF i_run_import = 'Y' THEN
112    m_var_found := ec_utils.find_variable(0,'L_HEADER_ID',m_stack_pos,m_plsql_pos);
113 
114          IF m_var_found THEN
115             o_invoice_id := ec_utils.g_stack(m_stack_pos).variable_value;
116             ec_debug.pl(0,'o_invoice_id ',o_invoice_id);
117          ELSE
118             ec_debug.pl(3,'EC','ECE_VARIABLE_NOT_ON_STACK','VARIABLE_NAME','L_HEADER_ID');
119             ec_utils.i_ret_code :=2;
120             raise EC_UTILS.PROGRAM_EXIT;
121          END IF;
122 
123         begin
124         select group_id
125         into o_group_id
126         from ap_invoices_interface
127         where  invoice_id = o_invoice_id;
128         ec_debug.pl(0,'o_group_id ',o_group_id);
129         exception
130         when no_data_found then
131         ec_debug.pl(3,'o_group_id ',o_group_id);
132         ec_debug.pl(3,'Group id not found for invoice id');
133         raise EC_UTILS.PROGRAM_EXIT;
134         when others then
135         ec_debug.pl(3,'Unable to derive Group id from invoice id');
136         ec_debug.pl(3,'o_group_id ',o_group_id);
137         end;
138 
139 
140 /*   	   --- Get the GROUP_ID
141 
142 	      m_var_found := ec_utils.find_variable(0,'L_GROUP_ID',m_stack_pos,m_plsql_pos);
143   	      Bug No: 2101935 Commented the If condition and modified the search for group_id.
144 
145              ec_utils.find_pos(1,'GROUP_ID',m_plsql_pos);
146              o_group_id := ec_utils.g_file_tbl(m_plsql_pos).value;
147 
148          IF m_var_found THEN
149             o_group_id := ec_utils.g_stack(m_stack_pos).variable_value;
150          ELSE
151             ec_debug.pl(3,'EC','ECE_VARIABLE_NOT_ON_STACK','VARIABLE_NAME','L_GROUP_ID');
152             ec_utils.i_ret_code :=2;
153             raise EC_UTILS.PROGRAM_EXIT;
154          END IF;
155 
156 	      IF i_run_import = 'Y' THEN
157 Bug 2204431 end
158  */
159 		      i_submit_id := fnd_request.submit_request(
160 				                  application => 'SQLAP',
161                            	program     => 'APXIIMPT',
162                            	argument1   => 'EDI GATEWAY',  -- Source Name
163                            	argument2   =>  o_Group_id,
164                            	argument3   =>  i_Batch_name,
165                            	argument4   =>  i_Hold_Name,
166                            	argument5   =>  i_Hold_Reason,
167                            	argument6   =>  i_gl_date,
168                            	argument7   =>  i_Purge,
169                            	argument8   =>  null,
170                            	argument9   =>  null,
171                            	argument10   =>  i_summarize_flag
172 				);
173                            	----argument6   =>  i_gl_date,to_char(i_Date,'YYYY/MM/DD HH24:MI:SS'),
174 
175 		      ec_debug.pl(0,'EC','ECE_EXECUTE_OPEN_INTERFACE','TRANSACTION_TYPE',i_transaction_type,'REQUEST_ID',i_Submit_Id);
176 	      END IF;
177 
178          COMMIT;
179 
180          retcode := ec_utils.i_ret_code;
181 
182          IF ec_mapping_utils.ec_get_trans_upgrade_status(i_transaction_type, i_map_id)  = 'U' THEN
183             ec_debug.pl(0,'EC','ECE_REC_TRANS_PENDING',NULL);
184             retcode := 1;
185          END IF;
186 
187          ec_debug.pl(3,'retcode',retcode);
188          ec_debug.pl(3,'errbuf',errbuf);
189          ec_debug.pl(3,'i_submit_id',i_submit_id);
190          ec_debug.pop('ECEINI.PROCESS_INVOICE_INBOUND');
191          ec_debug.pl(0,'EC','ECE_END_INBOUND','TRANSACTION_TYPE',i_transaction_type);
192          ec_debug.disable_debug;
193 
194       EXCEPTION
195          WHEN ece_transaction_disabled THEN
196             ec_debug.pl(0,'EC','ECE_TRANSACTION_DISABLED','TRANSACTION',i_transaction_type);
197             retcode := 1;
198             ec_debug.disable_debug;
199             ROLLBACK WORK;
200 
201          WHEN ec_utils.program_exit then
202          	retcode := ec_utils.i_ret_code;
203          	ece_flatfile_pvt.print_attributes;
204          	ROLLBACK WORK;
205          	ec_debug.disable_debug;
206 
207          WHEN OTHERS THEN
208 	         ROLLBACK WORK;
209             ec_debug.pl(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','ECEINI.PROCESS_INVOICE_INBOUND');
210             ec_debug.pl(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
211          	ece_flatfile_pvt.print_attributes;
212          	retcode := 2;
213          	ec_debug.disable_debug;
214 
215       END process_invoice_inbound;
216 
217 /* Bug 2598743 */
218 
219       PROCEDURE get_group_id
220       IS
221         plsql_pos               pls_integer;
222       BEGIN
223         ec_debug.push('ECEINI.GET_GROUP_ID');
224 
225         if l_group_id IS NULL then
226             select AP_INTERFACE_GROUPS_S.NEXTVAL
227             into   l_group_id
228             from dual;
229         end if;
230         ec_debug.pl(3,'l_group_id',l_group_id);
231 
232         ec_utils.find_pos(1,'GROUP_ID',plsql_pos);
233         ec_utils.g_file_tbl(plsql_pos).value:=to_char(l_group_id);
234 
235         ec_debug.pop('ECEINI.GET_GROUP_ID');
236 
237       EXCEPTION
238       WHEN OTHERS then
239         ec_debug.pl(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','EC_UTILS.GET_NEXTVAL_SEQ');
240         ec_debug.pl(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
241         ec_utils.i_ret_code := 2;
242         raise EC_UTILS.PROGRAM_EXIT;
243       END get_group_id;
244 
245 END eceini;
246