DBA Data[Home] [Help]

PACKAGE BODY: APPS.ECEINI

Source


1 PACKAGE BODY eceini AS
2 -- $Header: ECWINIB.pls 120.3 2010/07/15 19:35:48 akemiset 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 -- Fixed the bug 9589919
160                       i_submit_id := fnd_request.submit_request(
161                                 application => 'SQLAP',
162                                 program     => 'APXIIMPT',
163                                 argument1   => mo_global.get_current_org_id,
164                                 argument2   => 'EDI GATEWAY',  -- Source Name
165                                 argument3   =>  o_Group_id,
166                                 argument4   =>  i_Batch_name,
167                                 argument5   =>  i_Hold_Name,
168                                 argument6   =>  i_Hold_Reason,
169                                 argument7   =>  i_gl_date,
170                                 argument8   =>  i_Purge,
171                                 argument9   =>  null,
172                                 argument10   =>  i_summarize_flag
173                                 );
174                                 ----argument6   =>  i_gl_date,to_char(i_Date,'YYYY/MM/DD HH24:MI:SS'),
175 
176                       ec_debug.pl(0,'EC','ECE_EXECUTE_OPEN_INTERFACE','TRANSACTION_TYPE',i_transaction_type,'REQUEST_ID',i_Submit_Id);
177               END IF;
178 
179          COMMIT;
180 
181          retcode := ec_utils.i_ret_code;
182 
183          IF ec_mapping_utils.ec_get_trans_upgrade_status(i_transaction_type, i_map_id)  = 'U' THEN
184             ec_debug.pl(0,'EC','ECE_REC_TRANS_PENDING',NULL);
185             retcode := 1;
186          END IF;
187 
188          ec_debug.pl(3,'retcode',retcode);
189          ec_debug.pl(3,'errbuf',errbuf);
190          ec_debug.pl(3,'i_submit_id',i_submit_id);
191          ec_debug.pop('ECEINI.PROCESS_INVOICE_INBOUND');
192          ec_debug.pl(0,'EC','ECE_END_INBOUND','TRANSACTION_TYPE',i_transaction_type);
193          ec_debug.disable_debug;
194 
195       EXCEPTION
196          WHEN ece_transaction_disabled THEN
197             ec_debug.pl(0,'EC','ECE_TRANSACTION_DISABLED','TRANSACTION',i_transaction_type);
198             retcode := 1;
199             ec_debug.disable_debug;
200             ROLLBACK WORK;
201 
202          WHEN ec_utils.program_exit then
203                 retcode := ec_utils.i_ret_code;
204                 ece_flatfile_pvt.print_attributes;
205                 ROLLBACK WORK;
206                 ec_debug.disable_debug;
207 
208          WHEN OTHERS THEN
209                  ROLLBACK WORK;
210             ec_debug.pl(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','ECEINI.PROCESS_INVOICE_INBOUND');
211             ec_debug.pl(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
212                 ece_flatfile_pvt.print_attributes;
213                 retcode := 2;
214                 ec_debug.disable_debug;
215 
216       END process_invoice_inbound;
217 
218 /* Bug 2598743 */
219 
220       PROCEDURE get_group_id
221       IS
222         plsql_pos               pls_integer;
223       BEGIN
224         ec_debug.push('ECEINI.GET_GROUP_ID');
225 
226         if l_group_id IS NULL then
227             select AP_INTERFACE_GROUPS_S.NEXTVAL
228             into   l_group_id
229             from dual;
230         end if;
231         ec_debug.pl(3,'l_group_id',l_group_id);
232 
233         ec_utils.find_pos(1,'GROUP_ID',plsql_pos);
234         ec_utils.g_file_tbl(plsql_pos).value:=to_char(l_group_id);
235 
236         ec_debug.pop('ECEINI.GET_GROUP_ID');
237 
238       EXCEPTION
239       WHEN OTHERS then
240         ec_debug.pl(0,'EC','ECE_PROGRAM_ERROR','PROGRESS_LEVEL','EC_UTILS.GET_NEXTVAL_SEQ');
241         ec_debug.pl(0,'EC','ECE_ERROR_MESSAGE','ERROR_MESSAGE',SQLERRM);
242         ec_utils.i_ret_code := 2;
243         raise EC_UTILS.PROGRAM_EXIT;
244       END get_group_id;
245 
246 END eceini;
247