189: h_chart_of_acct_id NUMBER;
190:
191: begin
192:
193: fa_rx_util_pkg.enable_debug;
194:
195:
196: fa_rx_util_pkg.log('***** START JG_RX_IR_PKG.AP_RX_INVOICE_RUN *****');
197:
192:
193: fa_rx_util_pkg.enable_debug;
194:
195:
196: fa_rx_util_pkg.log('***** START JG_RX_IR_PKG.AP_RX_INVOICE_RUN *****');
197:
198: /* Print debug parameters */
199: fa_rx_util_pkg.log('p_reporting_level :'||p_reporting_level);
200: fa_rx_util_pkg.log('p_reporting_entity_id :'||p_reporting_entity_id);
195:
196: fa_rx_util_pkg.log('***** START JG_RX_IR_PKG.AP_RX_INVOICE_RUN *****');
197:
198: /* Print debug parameters */
199: fa_rx_util_pkg.log('p_reporting_level :'||p_reporting_level);
200: fa_rx_util_pkg.log('p_reporting_entity_id :'||p_reporting_entity_id);
201: fa_rx_util_pkg.log('p_request_id :'||p_request_id);
202: fa_rx_util_pkg.log('p_login_id :'||p_login_id);
203: fa_rx_util_pkg.log('p_set_of_book_id :'||p_set_of_book_id);
196: fa_rx_util_pkg.log('***** START JG_RX_IR_PKG.AP_RX_INVOICE_RUN *****');
197:
198: /* Print debug parameters */
199: fa_rx_util_pkg.log('p_reporting_level :'||p_reporting_level);
200: fa_rx_util_pkg.log('p_reporting_entity_id :'||p_reporting_entity_id);
201: fa_rx_util_pkg.log('p_request_id :'||p_request_id);
202: fa_rx_util_pkg.log('p_login_id :'||p_login_id);
203: fa_rx_util_pkg.log('p_set_of_book_id :'||p_set_of_book_id);
204: fa_rx_util_pkg.log('p_chart_of_acct_id :'||p_chart_of_acct_id);
197:
198: /* Print debug parameters */
199: fa_rx_util_pkg.log('p_reporting_level :'||p_reporting_level);
200: fa_rx_util_pkg.log('p_reporting_entity_id :'||p_reporting_entity_id);
201: fa_rx_util_pkg.log('p_request_id :'||p_request_id);
202: fa_rx_util_pkg.log('p_login_id :'||p_login_id);
203: fa_rx_util_pkg.log('p_set_of_book_id :'||p_set_of_book_id);
204: fa_rx_util_pkg.log('p_chart_of_acct_id :'||p_chart_of_acct_id);
205: fa_rx_util_pkg.log('p_line_inv :'||p_line_inv);
198: /* Print debug parameters */
199: fa_rx_util_pkg.log('p_reporting_level :'||p_reporting_level);
200: fa_rx_util_pkg.log('p_reporting_entity_id :'||p_reporting_entity_id);
201: fa_rx_util_pkg.log('p_request_id :'||p_request_id);
202: fa_rx_util_pkg.log('p_login_id :'||p_login_id);
203: fa_rx_util_pkg.log('p_set_of_book_id :'||p_set_of_book_id);
204: fa_rx_util_pkg.log('p_chart_of_acct_id :'||p_chart_of_acct_id);
205: fa_rx_util_pkg.log('p_line_inv :'||p_line_inv);
206: fa_rx_util_pkg.log('p_acct_date_min :'||p_acct_date_min);
199: fa_rx_util_pkg.log('p_reporting_level :'||p_reporting_level);
200: fa_rx_util_pkg.log('p_reporting_entity_id :'||p_reporting_entity_id);
201: fa_rx_util_pkg.log('p_request_id :'||p_request_id);
202: fa_rx_util_pkg.log('p_login_id :'||p_login_id);
203: fa_rx_util_pkg.log('p_set_of_book_id :'||p_set_of_book_id);
204: fa_rx_util_pkg.log('p_chart_of_acct_id :'||p_chart_of_acct_id);
205: fa_rx_util_pkg.log('p_line_inv :'||p_line_inv);
206: fa_rx_util_pkg.log('p_acct_date_min :'||p_acct_date_min);
207: fa_rx_util_pkg.log('p_acct_date_max :'||p_acct_date_max);
200: fa_rx_util_pkg.log('p_reporting_entity_id :'||p_reporting_entity_id);
201: fa_rx_util_pkg.log('p_request_id :'||p_request_id);
202: fa_rx_util_pkg.log('p_login_id :'||p_login_id);
203: fa_rx_util_pkg.log('p_set_of_book_id :'||p_set_of_book_id);
204: fa_rx_util_pkg.log('p_chart_of_acct_id :'||p_chart_of_acct_id);
205: fa_rx_util_pkg.log('p_line_inv :'||p_line_inv);
206: fa_rx_util_pkg.log('p_acct_date_min :'||p_acct_date_min);
207: fa_rx_util_pkg.log('p_acct_date_max :'||p_acct_date_max);
208: fa_rx_util_pkg.log('p_batch_id :'||p_batch_id);
201: fa_rx_util_pkg.log('p_request_id :'||p_request_id);
202: fa_rx_util_pkg.log('p_login_id :'||p_login_id);
203: fa_rx_util_pkg.log('p_set_of_book_id :'||p_set_of_book_id);
204: fa_rx_util_pkg.log('p_chart_of_acct_id :'||p_chart_of_acct_id);
205: fa_rx_util_pkg.log('p_line_inv :'||p_line_inv);
206: fa_rx_util_pkg.log('p_acct_date_min :'||p_acct_date_min);
207: fa_rx_util_pkg.log('p_acct_date_max :'||p_acct_date_max);
208: fa_rx_util_pkg.log('p_batch_id :'||p_batch_id);
209: fa_rx_util_pkg.log('p_invoice_type :'||p_invoice_type);
202: fa_rx_util_pkg.log('p_login_id :'||p_login_id);
203: fa_rx_util_pkg.log('p_set_of_book_id :'||p_set_of_book_id);
204: fa_rx_util_pkg.log('p_chart_of_acct_id :'||p_chart_of_acct_id);
205: fa_rx_util_pkg.log('p_line_inv :'||p_line_inv);
206: fa_rx_util_pkg.log('p_acct_date_min :'||p_acct_date_min);
207: fa_rx_util_pkg.log('p_acct_date_max :'||p_acct_date_max);
208: fa_rx_util_pkg.log('p_batch_id :'||p_batch_id);
209: fa_rx_util_pkg.log('p_invoice_type :'||p_invoice_type);
210: fa_rx_util_pkg.log('p_entry_person :'||p_entry_person_id);
203: fa_rx_util_pkg.log('p_set_of_book_id :'||p_set_of_book_id);
204: fa_rx_util_pkg.log('p_chart_of_acct_id :'||p_chart_of_acct_id);
205: fa_rx_util_pkg.log('p_line_inv :'||p_line_inv);
206: fa_rx_util_pkg.log('p_acct_date_min :'||p_acct_date_min);
207: fa_rx_util_pkg.log('p_acct_date_max :'||p_acct_date_max);
208: fa_rx_util_pkg.log('p_batch_id :'||p_batch_id);
209: fa_rx_util_pkg.log('p_invoice_type :'||p_invoice_type);
210: fa_rx_util_pkg.log('p_entry_person :'||p_entry_person_id);
211: fa_rx_util_pkg.log('p_doc_sequence_name :'||p_doc_sequence_id);
204: fa_rx_util_pkg.log('p_chart_of_acct_id :'||p_chart_of_acct_id);
205: fa_rx_util_pkg.log('p_line_inv :'||p_line_inv);
206: fa_rx_util_pkg.log('p_acct_date_min :'||p_acct_date_min);
207: fa_rx_util_pkg.log('p_acct_date_max :'||p_acct_date_max);
208: fa_rx_util_pkg.log('p_batch_id :'||p_batch_id);
209: fa_rx_util_pkg.log('p_invoice_type :'||p_invoice_type);
210: fa_rx_util_pkg.log('p_entry_person :'||p_entry_person_id);
211: fa_rx_util_pkg.log('p_doc_sequence_name :'||p_doc_sequence_id);
212: fa_rx_util_pkg.log('p_doc_sequence_value_min :'||p_doc_sequence_value_min);
205: fa_rx_util_pkg.log('p_line_inv :'||p_line_inv);
206: fa_rx_util_pkg.log('p_acct_date_min :'||p_acct_date_min);
207: fa_rx_util_pkg.log('p_acct_date_max :'||p_acct_date_max);
208: fa_rx_util_pkg.log('p_batch_id :'||p_batch_id);
209: fa_rx_util_pkg.log('p_invoice_type :'||p_invoice_type);
210: fa_rx_util_pkg.log('p_entry_person :'||p_entry_person_id);
211: fa_rx_util_pkg.log('p_doc_sequence_name :'||p_doc_sequence_id);
212: fa_rx_util_pkg.log('p_doc_sequence_value_min :'||p_doc_sequence_value_min);
213: fa_rx_util_pkg.log('p_doc_sequence_value_max :'||p_doc_sequence_value_max);
206: fa_rx_util_pkg.log('p_acct_date_min :'||p_acct_date_min);
207: fa_rx_util_pkg.log('p_acct_date_max :'||p_acct_date_max);
208: fa_rx_util_pkg.log('p_batch_id :'||p_batch_id);
209: fa_rx_util_pkg.log('p_invoice_type :'||p_invoice_type);
210: fa_rx_util_pkg.log('p_entry_person :'||p_entry_person_id);
211: fa_rx_util_pkg.log('p_doc_sequence_name :'||p_doc_sequence_id);
212: fa_rx_util_pkg.log('p_doc_sequence_value_min :'||p_doc_sequence_value_min);
213: fa_rx_util_pkg.log('p_doc_sequence_value_max :'||p_doc_sequence_value_max);
214: fa_rx_util_pkg.log('p_supplier_min :'||p_supplier_min);
207: fa_rx_util_pkg.log('p_acct_date_max :'||p_acct_date_max);
208: fa_rx_util_pkg.log('p_batch_id :'||p_batch_id);
209: fa_rx_util_pkg.log('p_invoice_type :'||p_invoice_type);
210: fa_rx_util_pkg.log('p_entry_person :'||p_entry_person_id);
211: fa_rx_util_pkg.log('p_doc_sequence_name :'||p_doc_sequence_id);
212: fa_rx_util_pkg.log('p_doc_sequence_value_min :'||p_doc_sequence_value_min);
213: fa_rx_util_pkg.log('p_doc_sequence_value_max :'||p_doc_sequence_value_max);
214: fa_rx_util_pkg.log('p_supplier_min :'||p_supplier_min);
215: fa_rx_util_pkg.log('p_supplier_max :'||p_supplier_max);
208: fa_rx_util_pkg.log('p_batch_id :'||p_batch_id);
209: fa_rx_util_pkg.log('p_invoice_type :'||p_invoice_type);
210: fa_rx_util_pkg.log('p_entry_person :'||p_entry_person_id);
211: fa_rx_util_pkg.log('p_doc_sequence_name :'||p_doc_sequence_id);
212: fa_rx_util_pkg.log('p_doc_sequence_value_min :'||p_doc_sequence_value_min);
213: fa_rx_util_pkg.log('p_doc_sequence_value_max :'||p_doc_sequence_value_max);
214: fa_rx_util_pkg.log('p_supplier_min :'||p_supplier_min);
215: fa_rx_util_pkg.log('p_supplier_max :'||p_supplier_max);
216: fa_rx_util_pkg.log('p_liability_min :'||p_liability_min);
209: fa_rx_util_pkg.log('p_invoice_type :'||p_invoice_type);
210: fa_rx_util_pkg.log('p_entry_person :'||p_entry_person_id);
211: fa_rx_util_pkg.log('p_doc_sequence_name :'||p_doc_sequence_id);
212: fa_rx_util_pkg.log('p_doc_sequence_value_min :'||p_doc_sequence_value_min);
213: fa_rx_util_pkg.log('p_doc_sequence_value_max :'||p_doc_sequence_value_max);
214: fa_rx_util_pkg.log('p_supplier_min :'||p_supplier_min);
215: fa_rx_util_pkg.log('p_supplier_max :'||p_supplier_max);
216: fa_rx_util_pkg.log('p_liability_min :'||p_liability_min);
217: fa_rx_util_pkg.log('p_liability_max :'||p_liability_max);
210: fa_rx_util_pkg.log('p_entry_person :'||p_entry_person_id);
211: fa_rx_util_pkg.log('p_doc_sequence_name :'||p_doc_sequence_id);
212: fa_rx_util_pkg.log('p_doc_sequence_value_min :'||p_doc_sequence_value_min);
213: fa_rx_util_pkg.log('p_doc_sequence_value_max :'||p_doc_sequence_value_max);
214: fa_rx_util_pkg.log('p_supplier_min :'||p_supplier_min);
215: fa_rx_util_pkg.log('p_supplier_max :'||p_supplier_max);
216: fa_rx_util_pkg.log('p_liability_min :'||p_liability_min);
217: fa_rx_util_pkg.log('p_liability_max :'||p_liability_max);
218: fa_rx_util_pkg.log('p_dist_acct_min :'||p_dist_acct_min);
211: fa_rx_util_pkg.log('p_doc_sequence_name :'||p_doc_sequence_id);
212: fa_rx_util_pkg.log('p_doc_sequence_value_min :'||p_doc_sequence_value_min);
213: fa_rx_util_pkg.log('p_doc_sequence_value_max :'||p_doc_sequence_value_max);
214: fa_rx_util_pkg.log('p_supplier_min :'||p_supplier_min);
215: fa_rx_util_pkg.log('p_supplier_max :'||p_supplier_max);
216: fa_rx_util_pkg.log('p_liability_min :'||p_liability_min);
217: fa_rx_util_pkg.log('p_liability_max :'||p_liability_max);
218: fa_rx_util_pkg.log('p_dist_acct_min :'||p_dist_acct_min);
219: fa_rx_util_pkg.log('p_dist_acct_max :'||p_dist_acct_max);
212: fa_rx_util_pkg.log('p_doc_sequence_value_min :'||p_doc_sequence_value_min);
213: fa_rx_util_pkg.log('p_doc_sequence_value_max :'||p_doc_sequence_value_max);
214: fa_rx_util_pkg.log('p_supplier_min :'||p_supplier_min);
215: fa_rx_util_pkg.log('p_supplier_max :'||p_supplier_max);
216: fa_rx_util_pkg.log('p_liability_min :'||p_liability_min);
217: fa_rx_util_pkg.log('p_liability_max :'||p_liability_max);
218: fa_rx_util_pkg.log('p_dist_acct_min :'||p_dist_acct_min);
219: fa_rx_util_pkg.log('p_dist_acct_max :'||p_dist_acct_max);
220: fa_rx_util_pkg.log('p_dist_amount_min :'||p_dist_amount_min);
213: fa_rx_util_pkg.log('p_doc_sequence_value_max :'||p_doc_sequence_value_max);
214: fa_rx_util_pkg.log('p_supplier_min :'||p_supplier_min);
215: fa_rx_util_pkg.log('p_supplier_max :'||p_supplier_max);
216: fa_rx_util_pkg.log('p_liability_min :'||p_liability_min);
217: fa_rx_util_pkg.log('p_liability_max :'||p_liability_max);
218: fa_rx_util_pkg.log('p_dist_acct_min :'||p_dist_acct_min);
219: fa_rx_util_pkg.log('p_dist_acct_max :'||p_dist_acct_max);
220: fa_rx_util_pkg.log('p_dist_amount_min :'||p_dist_amount_min);
221: fa_rx_util_pkg.log('p_dist_amount_max :'||p_dist_amount_max);
214: fa_rx_util_pkg.log('p_supplier_min :'||p_supplier_min);
215: fa_rx_util_pkg.log('p_supplier_max :'||p_supplier_max);
216: fa_rx_util_pkg.log('p_liability_min :'||p_liability_min);
217: fa_rx_util_pkg.log('p_liability_max :'||p_liability_max);
218: fa_rx_util_pkg.log('p_dist_acct_min :'||p_dist_acct_min);
219: fa_rx_util_pkg.log('p_dist_acct_max :'||p_dist_acct_max);
220: fa_rx_util_pkg.log('p_dist_amount_min :'||p_dist_amount_min);
221: fa_rx_util_pkg.log('p_dist_amount_max :'||p_dist_amount_max);
222: fa_rx_util_pkg.log('p_entered_date_min :'||p_entered_date_min);
215: fa_rx_util_pkg.log('p_supplier_max :'||p_supplier_max);
216: fa_rx_util_pkg.log('p_liability_min :'||p_liability_min);
217: fa_rx_util_pkg.log('p_liability_max :'||p_liability_max);
218: fa_rx_util_pkg.log('p_dist_acct_min :'||p_dist_acct_min);
219: fa_rx_util_pkg.log('p_dist_acct_max :'||p_dist_acct_max);
220: fa_rx_util_pkg.log('p_dist_amount_min :'||p_dist_amount_min);
221: fa_rx_util_pkg.log('p_dist_amount_max :'||p_dist_amount_max);
222: fa_rx_util_pkg.log('p_entered_date_min :'||p_entered_date_min);
223: fa_rx_util_pkg.log('p_entered_date_max :'||p_entered_date_max);
216: fa_rx_util_pkg.log('p_liability_min :'||p_liability_min);
217: fa_rx_util_pkg.log('p_liability_max :'||p_liability_max);
218: fa_rx_util_pkg.log('p_dist_acct_min :'||p_dist_acct_min);
219: fa_rx_util_pkg.log('p_dist_acct_max :'||p_dist_acct_max);
220: fa_rx_util_pkg.log('p_dist_amount_min :'||p_dist_amount_min);
221: fa_rx_util_pkg.log('p_dist_amount_max :'||p_dist_amount_max);
222: fa_rx_util_pkg.log('p_entered_date_min :'||p_entered_date_min);
223: fa_rx_util_pkg.log('p_entered_date_max :'||p_entered_date_max);
224:
217: fa_rx_util_pkg.log('p_liability_max :'||p_liability_max);
218: fa_rx_util_pkg.log('p_dist_acct_min :'||p_dist_acct_min);
219: fa_rx_util_pkg.log('p_dist_acct_max :'||p_dist_acct_max);
220: fa_rx_util_pkg.log('p_dist_amount_min :'||p_dist_amount_min);
221: fa_rx_util_pkg.log('p_dist_amount_max :'||p_dist_amount_max);
222: fa_rx_util_pkg.log('p_entered_date_min :'||p_entered_date_min);
223: fa_rx_util_pkg.log('p_entered_date_max :'||p_entered_date_max);
224:
225: /* Added for MOAC change */
218: fa_rx_util_pkg.log('p_dist_acct_min :'||p_dist_acct_min);
219: fa_rx_util_pkg.log('p_dist_acct_max :'||p_dist_acct_max);
220: fa_rx_util_pkg.log('p_dist_amount_min :'||p_dist_amount_min);
221: fa_rx_util_pkg.log('p_dist_amount_max :'||p_dist_amount_max);
222: fa_rx_util_pkg.log('p_entered_date_min :'||p_entered_date_min);
223: fa_rx_util_pkg.log('p_entered_date_max :'||p_entered_date_max);
224:
225: /* Added for MOAC change */
226: if p_reporting_level is null then
219: fa_rx_util_pkg.log('p_dist_acct_max :'||p_dist_acct_max);
220: fa_rx_util_pkg.log('p_dist_amount_min :'||p_dist_amount_min);
221: fa_rx_util_pkg.log('p_dist_amount_max :'||p_dist_amount_max);
222: fa_rx_util_pkg.log('p_entered_date_min :'||p_entered_date_min);
223: fa_rx_util_pkg.log('p_entered_date_max :'||p_entered_date_max);
224:
225: /* Added for MOAC change */
226: if p_reporting_level is null then
227: h_reporting_level := '3000'; -- OU level
253: p_dist_org_where := XLA_MO_REPORTING_API.GET_PREDICATE(p_alias => 'DIST');
254: --* AP_INVOICE_LINES_ALL (Alias = INV_LINE)
255: p_line_org_where := XLA_MO_REPORTING_API.GET_PREDICATE(p_alias => 'INV_LINE');
256:
257: fa_rx_util_pkg.debug('p_inv_org_where :'||p_inv_org_where);
258: fa_rx_util_pkg.debug('p_dist_org_where :'||p_dist_org_where);
259: fa_rx_util_pkg.debug('p_line_org_where :'||p_line_org_where);
260:
261: -- Bug 11700123 -- Start
254: --* AP_INVOICE_LINES_ALL (Alias = INV_LINE)
255: p_line_org_where := XLA_MO_REPORTING_API.GET_PREDICATE(p_alias => 'INV_LINE');
256:
257: fa_rx_util_pkg.debug('p_inv_org_where :'||p_inv_org_where);
258: fa_rx_util_pkg.debug('p_dist_org_where :'||p_dist_org_where);
259: fa_rx_util_pkg.debug('p_line_org_where :'||p_line_org_where);
260:
261: -- Bug 11700123 -- Start
262: -- Get set_of_books_id value
255: p_line_org_where := XLA_MO_REPORTING_API.GET_PREDICATE(p_alias => 'INV_LINE');
256:
257: fa_rx_util_pkg.debug('p_inv_org_where :'||p_inv_org_where);
258: fa_rx_util_pkg.debug('p_dist_org_where :'||p_dist_org_where);
259: fa_rx_util_pkg.debug('p_line_org_where :'||p_line_org_where);
260:
261: -- Bug 11700123 -- Start
262: -- Get set_of_books_id value
263: if p_reporting_level = 1000 then
274: from hr_operating_units
275: where organization_id = p_reporting_entity_id;
276: end if;
277:
278: fa_rx_util_pkg.debug('h_set_of_books_id :'||h_set_of_books_id);
279:
280: -- Bug 11700123 -- End
281:
282: /*Get Functoinal currncy code */
290: h_chart_of_acct_id
291: From GL_LEDGERS
292: where ledger_id = h_set_of_books_id;
293:
294: fa_rx_util_pkg.debug('h_currency_code :'||h_currency_code);
295: fa_rx_util_pkg.debug('h_book_short_name :'||h_book_short_name);
296: fa_rx_util_pkg.debug('h_mrc_sob_type_code :'||h_mrc_sob_type_code);
297: fa_rx_util_pkg.debug('h_chart_of_acct_id :'||h_chart_of_acct_id);
298:
291: From GL_LEDGERS
292: where ledger_id = h_set_of_books_id;
293:
294: fa_rx_util_pkg.debug('h_currency_code :'||h_currency_code);
295: fa_rx_util_pkg.debug('h_book_short_name :'||h_book_short_name);
296: fa_rx_util_pkg.debug('h_mrc_sob_type_code :'||h_mrc_sob_type_code);
297: fa_rx_util_pkg.debug('h_chart_of_acct_id :'||h_chart_of_acct_id);
298:
299: /* Switch User Context */
292: where ledger_id = h_set_of_books_id;
293:
294: fa_rx_util_pkg.debug('h_currency_code :'||h_currency_code);
295: fa_rx_util_pkg.debug('h_book_short_name :'||h_book_short_name);
296: fa_rx_util_pkg.debug('h_mrc_sob_type_code :'||h_mrc_sob_type_code);
297: fa_rx_util_pkg.debug('h_chart_of_acct_id :'||h_chart_of_acct_id);
298:
299: /* Switch User Context */
300: if h_mrc_sob_type_code = 'R' then
293:
294: fa_rx_util_pkg.debug('h_currency_code :'||h_currency_code);
295: fa_rx_util_pkg.debug('h_book_short_name :'||h_book_short_name);
296: fa_rx_util_pkg.debug('h_mrc_sob_type_code :'||h_mrc_sob_type_code);
297: fa_rx_util_pkg.debug('h_chart_of_acct_id :'||h_chart_of_acct_id);
298:
299: /* Switch User Context */
300: if h_mrc_sob_type_code = 'R' then
301: fnd_client_info.set_currency_context(h_set_of_books_id);
318: exception when others then
319: h_sort_by_alternate := 'N';
320: end;
321:
322: fa_rx_util_pkg.debug('h_sort_by_alternate :'||h_sort_by_alternate);
323:
324: /* ==================================================
325: Create sql statement:
326: From parameters, create sql statment
338: l_acct_date_where :=
339: ' and DIST.ACCOUNTING_DATE between :c_acct_date_min and :c_acct_date_max ';
340: end if;
341:
342: fa_rx_util_pkg.debug('l_acct_date_where :'||l_acct_date_where);
343:
344: /* Entered by */
345: if p_entry_person_id is null then
346: l_entry_person_where := to_char(null);
347: else
348: l_entry_person_where := 'and AP_INV.CREATED_BY = :c_entry_person_id '; -- ||p_entry_person_id;
349: end if;
350:
351: fa_rx_util_pkg.debug('l_entry_person_where :'||l_entry_person_where);
352:
353: /*Invoice Type */
354: if p_invoice_type is null then
355: l_inv_type_where := to_char(null);
358: ' and AP_INV.INVOICE_TYPE_LOOKUP_CODE= :c_invoice_type '; -- '''||p_invoice_type||'''
359:
360: end if;
361:
362: fa_rx_util_pkg.debug('l_inv_type_where :'||l_inv_type_where);
363:
364: /* Batch ID */
365: if p_batch_id is null then
366: l_batch_id_where := to_char(null);
368: l_batch_id_where := ' and AP_INV.BATCH_ID = :c_batch_id '; -- '''||p_batch_id||'''
369:
370: end if;
371:
372: fa_rx_util_pkg.debug('l_batch_id_where :'||l_batch_id_where);
373:
374: /* Document Sequence Id */
375: if p_doc_sequence_id is null then
376: l_doc_seq_id_where := to_char(null);
377: else
378: l_doc_seq_id_where := ' and AP_INV.DOC_SEQUENCE_ID= :c_doc_sequence_id '; --||p_doc_sequence_id;
379: end if;
380:
381: fa_rx_util_pkg.debug('l_doc_seq_id_where :'||l_doc_seq_id_where);
382:
383: /* Document Sequence value range */
384: if p_doc_sequence_value_min is null and p_doc_sequence_value_max is null then
385: l_doc_seq_value_where := to_char(null);
394: ' and AP_INV.DOC_SEQUENCE_VALUE between :c_doc_sequence_value_min and :c_doc_sequence_value_max ';
395: -- || p_doc_sequence_value_min||' and '||p_doc_sequence_value_max;
396: end if;
397:
398: fa_rx_util_pkg.debug('l_doc_seq_value_where :'||l_doc_seq_value_where);
399:
400: /* Supplier name range */
401: if p_supplier_min is null and p_supplier_max is null then
402: l_supplier_where := to_char(null);
409: ' and PO_PV.VENDOR_NAME between :c_supplier_min and :c_supplier_max ';
410: -- '''||p_supplier_min||''' and '''||p_supplier_max||''' ';
411: end if;
412:
413: fa_rx_util_pkg.debug('l_supplier_where :'||l_supplier_where);
414:
415: /* Liability account range */
416: if p_liability_min is null or p_liability_max is null then
417: l_liability_range_where := to_char(null);
420: fa_rx_flex_pkg.flex_sql(101,'GL#', h_chart_of_acct_id,
421: 'GC2','WHERE', 'ALL', 'BETWEEN',p_liability_min,p_liability_max)||' ';
422: end if;
423:
424: fa_rx_util_pkg.debug('l_liability_range_where :'||l_liability_range_where);
425:
426: /* Distribution account range */
427:
428: if p_dist_acct_min is null or p_dist_acct_max is null then
432: fa_rx_flex_pkg.flex_sql(101,'GL#', h_chart_of_acct_id,
433: 'GC1','WHERE', 'ALL', 'BETWEEN',p_dist_acct_min, p_dist_acct_max) ||' ';
434: end if;
435:
436: fa_rx_util_pkg.debug('l_dist_acct_range_where :'||l_dist_acct_range_where);
437:
438: /* Invoice Currency Code */
439: if p_inv_currency_code is null then
440: l_inv_currency_code_where := to_char(null);
442: l_inv_currency_code_where :=
443: ' and AP_INV.INVOICE_CURRENCY_CODE = :c_inv_currency_code '; -- '''||p_inv_currency_code||''
444: end if;
445:
446: fa_rx_util_pkg.debug('l_inv_currency_code_where :'||l_inv_currency_code_where);
447:
448: /* Distribution mount range */
449: if p_dist_amount_min is null and p_dist_amount_max is null then
450: l_dist_amount_range_where := to_char(null);
459: ' and DIST.AMOUNT between :c_dist_amount_min and :c_dist_amount_max ';
460: -- '||p_dist_amount_min||' and '||p_dist_amount_max;
461: end if;
462:
463: fa_rx_util_pkg.debug('l_dist_amount_range_where :'||l_dist_amount_range_where);
464:
465: /* Entered date range */
466: if p_entered_date_min is null and p_entered_date_max is null then
467: l_entered_date_where := to_char(null);
472: elsif p_entered_date_min is not null and p_entered_date_max is not null then
473: l_entered_date_where := ' and trunc(AP_INV.CREATION_DATE) between :c_entered_date_min and :c_entered_date_max ';
474: end if;
475:
476: fa_rx_util_pkg.debug('l_entered_date_where :'||l_entered_date_where);
477:
478: /* Cancelled Invoice only */
479: if p_cancelled_inv = true then
480: l_cancelled_where := ' and AP_INV.CANCELLED_DATE is not null ';
481: else
482: l_cancelled_where := to_char(null);
483: end if;
484:
485: fa_rx_util_pkg.debug('l_cancelled_where :'||l_cancelled_where);
486:
487: /* Unapproved Invoice only */
488: if p_unapproved_inv = true then
489: l_unapproved_inv_where :=
491: else
492: l_unapproved_inv_where :=to_char(null);
493: end if;
494:
495: fa_rx_util_pkg.debug('l_unapproved_inv_where :'||l_unapproved_inv_where);
496:
497: /* Parameter 'Line or INVOICE', WHERE PHASE */
498:
499: if p_line_inv ='I' then /* 'Line or INVOICE' = Invoice */
541: l_line_inv_where := l_dist_acct_range_where || l_dist_amount_range_where
542: ||l_acct_date_where||l_unapproved_inv_where;
543: end if;
544:
545: fa_rx_util_pkg.debug('l_line_inv_where :'||l_line_inv_where);
546:
547: if h_mrc_sob_type_code = 'R' then
548: l_main_from := 'AP_INVOICES_MRC_V AP_INV,
549: AP_INVOICE_LINES_MRC_V INV_LINE, -- Added for AP Invoice Line Project
605: decode(:c_sort_by_alternate, ''Y'', upper(po_pv.vendor_name_alt), upper(po_pv.vendor_name)),
606: ap_inv.invoice_num,
607: dist.distribution_line_number';
608:
609: fa_rx_util_pkg.debug('Main SQL:');
610: fa_rx_util_pkg.debug(l_main_sql);
611:
612: /* Open v_MainCursor */
613: v_MainCursor :=DBMS_SQL.OPEN_CURSOR;
606: ap_inv.invoice_num,
607: dist.distribution_line_number';
608:
609: fa_rx_util_pkg.debug('Main SQL:');
610: fa_rx_util_pkg.debug(l_main_sql);
611:
612: /* Open v_MainCursor */
613: v_MainCursor :=DBMS_SQL.OPEN_CURSOR;
614: fa_rx_util_pkg.debug('***** OPEN CURSOR: v_MainCursor *****');
610: fa_rx_util_pkg.debug(l_main_sql);
611:
612: /* Open v_MainCursor */
613: v_MainCursor :=DBMS_SQL.OPEN_CURSOR;
614: fa_rx_util_pkg.debug('***** OPEN CURSOR: v_MainCursor *****');
615: fa_rx_util_pkg.debug('v_MainCursor :'||v_MainCursor);
616:
617: /* PARSE v_MainCursor */
618: DBMS_SQL.PARSE (v_MainCursor,l_main_sql,DBMS_SQL.V7);
611:
612: /* Open v_MainCursor */
613: v_MainCursor :=DBMS_SQL.OPEN_CURSOR;
614: fa_rx_util_pkg.debug('***** OPEN CURSOR: v_MainCursor *****');
615: fa_rx_util_pkg.debug('v_MainCursor :'||v_MainCursor);
616:
617: /* PARSE v_MainCursor */
618: DBMS_SQL.PARSE (v_MainCursor,l_main_sql,DBMS_SQL.V7);
619: fa_rx_util_pkg.debug('***** PARSE: v_MainCursor *****');
615: fa_rx_util_pkg.debug('v_MainCursor :'||v_MainCursor);
616:
617: /* PARSE v_MainCursor */
618: DBMS_SQL.PARSE (v_MainCursor,l_main_sql,DBMS_SQL.V7);
619: fa_rx_util_pkg.debug('***** PARSE: v_MainCursor *****');
620:
621: /* DEFINE COLUMN v_MainCursor */
622: DBMS_SQL.DEFINE_COLUMN(v_MainCursor,1,h_invoice_id);
623: DBMS_SQL.DEFINE_COLUMN(v_MainCursor,2,h_liability_ccid);
629: DBMS_SQL.DEFINE_COLUMN(v_MainCursor,8,h_dist_acct_date); -- Newly Added
630: DBMS_SQL.DEFINE_COLUMN(v_MainCursor,9,h_line_number); -- Newly Added
631: DBMS_SQL.DEFINE_COLUMN(v_MainCursor,10,h_line_type,25); -- Newly Added
632:
633: fa_rx_util_pkg.debug('***** DEFINE COLUMN: v_MainCursor *****');
634:
635: /* BIND BARIABLE v_MainCursor */
636: if p_acct_date_min is not null then
637: DBMS_SQL.BIND_VARIABLE(v_MainCursor,':c_acct_date_min',p_acct_date_min);
727: /* MOAC Change - bind p_reporting_entity_id */
728: -- bug: 9914839 Bind variable set for reporting Level : Legal Entity as well
729: if p_reporting_level = '3000' or p_reporting_level = '2000' then
730: DBMS_SQL.BIND_VARIABLE(v_MainCursor,':p_reporting_entity_id', h_reporting_entity_id);
731: fa_rx_util_pkg.debug('h_reporting_entity_id :'||h_reporting_entity_id);
732: end if;
733:
734: fa_rx_util_pkg.debug('***** BIND VARIABLE: v_MainCursor *****');
735:
730: DBMS_SQL.BIND_VARIABLE(v_MainCursor,':p_reporting_entity_id', h_reporting_entity_id);
731: fa_rx_util_pkg.debug('h_reporting_entity_id :'||h_reporting_entity_id);
732: end if;
733:
734: fa_rx_util_pkg.debug('***** BIND VARIABLE: v_MainCursor *****');
735:
736:
737: v_MainReturn := DBMS_SQL.EXECUTE(v_MainCursor);
738: fa_rx_util_pkg.debug('***** EXECUTE: v_MainCursor *****');
734: fa_rx_util_pkg.debug('***** BIND VARIABLE: v_MainCursor *****');
735:
736:
737: v_MainReturn := DBMS_SQL.EXECUTE(v_MainCursor);
738: fa_rx_util_pkg.debug('***** EXECUTE: v_MainCursor *****');
739: fa_rx_util_pkg.debug('v_MainReturn :'||v_MainReturn);
740:
741: /* Loop and Fetch v_MainCursor */
742: Loop
735:
736:
737: v_MainReturn := DBMS_SQL.EXECUTE(v_MainCursor);
738: fa_rx_util_pkg.debug('***** EXECUTE: v_MainCursor *****');
739: fa_rx_util_pkg.debug('v_MainReturn :'||v_MainReturn);
740:
741: /* Loop and Fetch v_MainCursor */
742: Loop
743:
741: /* Loop and Fetch v_MainCursor */
742: Loop
743:
744: v_MainFetch := DBMS_SQL.FETCH_ROWS(v_MainCursor);
745: fa_rx_util_pkg.debug('***** FETCH ROWS: v_MainCursor *****');
746: fa_rx_util_pkg.debug('v_MainFetch :'||v_MainFetch);
747:
748: If v_MainFetch =0 then
749: Exit;
742: Loop
743:
744: v_MainFetch := DBMS_SQL.FETCH_ROWS(v_MainCursor);
745: fa_rx_util_pkg.debug('***** FETCH ROWS: v_MainCursor *****');
746: fa_rx_util_pkg.debug('v_MainFetch :'||v_MainFetch);
747:
748: If v_MainFetch =0 then
749: Exit;
750: end if;
759: DBMS_SQL.COLUMN_VALUE(v_MainCursor,8,h_dist_acct_date); -- Newly Added
760: DBMS_SQL.COLUMN_VALUE(v_MainCursor,9,h_line_number); -- Newly Added
761: DBMS_SQL.COLUMN_VALUE(v_MainCursor,10,h_line_type); -- Newly Added
762:
763: fa_rx_util_pkg.debug('h_invoice_id: '||h_invoice_id);
764: fa_rx_util_pkg.debug('h_liability_ccid: '||h_liability_ccid);
765: fa_rx_util_pkg.debug('h_invoice_type: '||h_invoice_type);
766: fa_rx_util_pkg.debug('h_inv_dist_id :'||h_inv_dist_id);
767: fa_rx_util_pkg.debug('h_dist_number :'||h_dist_number); -- Changed to DIST NUMBER
760: DBMS_SQL.COLUMN_VALUE(v_MainCursor,9,h_line_number); -- Newly Added
761: DBMS_SQL.COLUMN_VALUE(v_MainCursor,10,h_line_type); -- Newly Added
762:
763: fa_rx_util_pkg.debug('h_invoice_id: '||h_invoice_id);
764: fa_rx_util_pkg.debug('h_liability_ccid: '||h_liability_ccid);
765: fa_rx_util_pkg.debug('h_invoice_type: '||h_invoice_type);
766: fa_rx_util_pkg.debug('h_inv_dist_id :'||h_inv_dist_id);
767: fa_rx_util_pkg.debug('h_dist_number :'||h_dist_number); -- Changed to DIST NUMBER
768: fa_rx_util_pkg.debug('h_dist_type :'||h_dist_type); -- Changed to DIST Type
761: DBMS_SQL.COLUMN_VALUE(v_MainCursor,10,h_line_type); -- Newly Added
762:
763: fa_rx_util_pkg.debug('h_invoice_id: '||h_invoice_id);
764: fa_rx_util_pkg.debug('h_liability_ccid: '||h_liability_ccid);
765: fa_rx_util_pkg.debug('h_invoice_type: '||h_invoice_type);
766: fa_rx_util_pkg.debug('h_inv_dist_id :'||h_inv_dist_id);
767: fa_rx_util_pkg.debug('h_dist_number :'||h_dist_number); -- Changed to DIST NUMBER
768: fa_rx_util_pkg.debug('h_dist_type :'||h_dist_type); -- Changed to DIST Type
769: fa_rx_util_pkg.debug('h_dist_ccid :'||h_inv_dist_id);
762:
763: fa_rx_util_pkg.debug('h_invoice_id: '||h_invoice_id);
764: fa_rx_util_pkg.debug('h_liability_ccid: '||h_liability_ccid);
765: fa_rx_util_pkg.debug('h_invoice_type: '||h_invoice_type);
766: fa_rx_util_pkg.debug('h_inv_dist_id :'||h_inv_dist_id);
767: fa_rx_util_pkg.debug('h_dist_number :'||h_dist_number); -- Changed to DIST NUMBER
768: fa_rx_util_pkg.debug('h_dist_type :'||h_dist_type); -- Changed to DIST Type
769: fa_rx_util_pkg.debug('h_dist_ccid :'||h_inv_dist_id);
770: fa_rx_util_pkg.debug('h_line_number :'||h_line_number); -- Newly Added
763: fa_rx_util_pkg.debug('h_invoice_id: '||h_invoice_id);
764: fa_rx_util_pkg.debug('h_liability_ccid: '||h_liability_ccid);
765: fa_rx_util_pkg.debug('h_invoice_type: '||h_invoice_type);
766: fa_rx_util_pkg.debug('h_inv_dist_id :'||h_inv_dist_id);
767: fa_rx_util_pkg.debug('h_dist_number :'||h_dist_number); -- Changed to DIST NUMBER
768: fa_rx_util_pkg.debug('h_dist_type :'||h_dist_type); -- Changed to DIST Type
769: fa_rx_util_pkg.debug('h_dist_ccid :'||h_inv_dist_id);
770: fa_rx_util_pkg.debug('h_line_number :'||h_line_number); -- Newly Added
771: fa_rx_util_pkg.debug('h_line_type :'||h_line_type); -- Newly Added
764: fa_rx_util_pkg.debug('h_liability_ccid: '||h_liability_ccid);
765: fa_rx_util_pkg.debug('h_invoice_type: '||h_invoice_type);
766: fa_rx_util_pkg.debug('h_inv_dist_id :'||h_inv_dist_id);
767: fa_rx_util_pkg.debug('h_dist_number :'||h_dist_number); -- Changed to DIST NUMBER
768: fa_rx_util_pkg.debug('h_dist_type :'||h_dist_type); -- Changed to DIST Type
769: fa_rx_util_pkg.debug('h_dist_ccid :'||h_inv_dist_id);
770: fa_rx_util_pkg.debug('h_line_number :'||h_line_number); -- Newly Added
771: fa_rx_util_pkg.debug('h_line_type :'||h_line_type); -- Newly Added
772: fa_rx_util_pkg.debug('h_dist_acct_date :'|| h_dist_acct_date); -- Newly Added
765: fa_rx_util_pkg.debug('h_invoice_type: '||h_invoice_type);
766: fa_rx_util_pkg.debug('h_inv_dist_id :'||h_inv_dist_id);
767: fa_rx_util_pkg.debug('h_dist_number :'||h_dist_number); -- Changed to DIST NUMBER
768: fa_rx_util_pkg.debug('h_dist_type :'||h_dist_type); -- Changed to DIST Type
769: fa_rx_util_pkg.debug('h_dist_ccid :'||h_inv_dist_id);
770: fa_rx_util_pkg.debug('h_line_number :'||h_line_number); -- Newly Added
771: fa_rx_util_pkg.debug('h_line_type :'||h_line_type); -- Newly Added
772: fa_rx_util_pkg.debug('h_dist_acct_date :'|| h_dist_acct_date); -- Newly Added
773:
766: fa_rx_util_pkg.debug('h_inv_dist_id :'||h_inv_dist_id);
767: fa_rx_util_pkg.debug('h_dist_number :'||h_dist_number); -- Changed to DIST NUMBER
768: fa_rx_util_pkg.debug('h_dist_type :'||h_dist_type); -- Changed to DIST Type
769: fa_rx_util_pkg.debug('h_dist_ccid :'||h_inv_dist_id);
770: fa_rx_util_pkg.debug('h_line_number :'||h_line_number); -- Newly Added
771: fa_rx_util_pkg.debug('h_line_type :'||h_line_type); -- Newly Added
772: fa_rx_util_pkg.debug('h_dist_acct_date :'|| h_dist_acct_date); -- Newly Added
773:
774: /* Get Liability account and description, natural account and description */
767: fa_rx_util_pkg.debug('h_dist_number :'||h_dist_number); -- Changed to DIST NUMBER
768: fa_rx_util_pkg.debug('h_dist_type :'||h_dist_type); -- Changed to DIST Type
769: fa_rx_util_pkg.debug('h_dist_ccid :'||h_inv_dist_id);
770: fa_rx_util_pkg.debug('h_line_number :'||h_line_number); -- Newly Added
771: fa_rx_util_pkg.debug('h_line_type :'||h_line_type); -- Newly Added
772: fa_rx_util_pkg.debug('h_dist_acct_date :'|| h_dist_acct_date); -- Newly Added
773:
774: /* Get Liability account and description, natural account and description */
775:
768: fa_rx_util_pkg.debug('h_dist_type :'||h_dist_type); -- Changed to DIST Type
769: fa_rx_util_pkg.debug('h_dist_ccid :'||h_inv_dist_id);
770: fa_rx_util_pkg.debug('h_line_number :'||h_line_number); -- Newly Added
771: fa_rx_util_pkg.debug('h_line_type :'||h_line_type); -- Newly Added
772: fa_rx_util_pkg.debug('h_dist_acct_date :'|| h_dist_acct_date); -- Newly Added
773:
774: /* Get Liability account and description, natural account and description */
775:
776: if h_liability_ccid is not null then
809: h_liability_natacct := to_char(null);
810: h_liability_natdesc := to_char(null);
811: end if;
812:
813: fa_rx_util_pkg.debug('h_liability_acct : '||h_liability_acct);
814: fa_rx_util_pkg.debug('h_liability_desc : '||h_liability_desc);
815: fa_rx_util_pkg.debug('h_liability_natacct : '||h_liability_natacct);
816: fa_rx_util_pkg.debug('h_liability_natdesc : '||h_liability_natdesc);
817:
810: h_liability_natdesc := to_char(null);
811: end if;
812:
813: fa_rx_util_pkg.debug('h_liability_acct : '||h_liability_acct);
814: fa_rx_util_pkg.debug('h_liability_desc : '||h_liability_desc);
815: fa_rx_util_pkg.debug('h_liability_natacct : '||h_liability_natacct);
816: fa_rx_util_pkg.debug('h_liability_natdesc : '||h_liability_natdesc);
817:
818: /*Get Distribution account and description, natural account and description */
811: end if;
812:
813: fa_rx_util_pkg.debug('h_liability_acct : '||h_liability_acct);
814: fa_rx_util_pkg.debug('h_liability_desc : '||h_liability_desc);
815: fa_rx_util_pkg.debug('h_liability_natacct : '||h_liability_natacct);
816: fa_rx_util_pkg.debug('h_liability_natdesc : '||h_liability_natdesc);
817:
818: /*Get Distribution account and description, natural account and description */
819:
812:
813: fa_rx_util_pkg.debug('h_liability_acct : '||h_liability_acct);
814: fa_rx_util_pkg.debug('h_liability_desc : '||h_liability_desc);
815: fa_rx_util_pkg.debug('h_liability_natacct : '||h_liability_natacct);
816: fa_rx_util_pkg.debug('h_liability_natdesc : '||h_liability_natdesc);
817:
818: /*Get Distribution account and description, natural account and description */
819:
820: if h_dist_ccid is not null then
853: h_dist_natacct := to_char(null);
854: h_dist_natdesc := to_char(null);
855: end if;
856:
857: fa_rx_util_pkg.debug('h_dist_acct : '||h_dist_acct);
858: fa_rx_util_pkg.debug('h_dist_desc : '||h_dist_desc);
859: fa_rx_util_pkg.debug('h_dist_natacct : '||h_dist_natacct);
860: fa_rx_util_pkg.debug('h_dist_natdesc : '||h_dist_natdesc);
861:
854: h_dist_natdesc := to_char(null);
855: end if;
856:
857: fa_rx_util_pkg.debug('h_dist_acct : '||h_dist_acct);
858: fa_rx_util_pkg.debug('h_dist_desc : '||h_dist_desc);
859: fa_rx_util_pkg.debug('h_dist_natacct : '||h_dist_natacct);
860: fa_rx_util_pkg.debug('h_dist_natdesc : '||h_dist_natdesc);
861:
862:
855: end if;
856:
857: fa_rx_util_pkg.debug('h_dist_acct : '||h_dist_acct);
858: fa_rx_util_pkg.debug('h_dist_desc : '||h_dist_desc);
859: fa_rx_util_pkg.debug('h_dist_natacct : '||h_dist_natacct);
860: fa_rx_util_pkg.debug('h_dist_natdesc : '||h_dist_natdesc);
861:
862:
863: /* Insert to JG_ZZ_AP_IR_REP_ITF */
856:
857: fa_rx_util_pkg.debug('h_dist_acct : '||h_dist_acct);
858: fa_rx_util_pkg.debug('h_dist_desc : '||h_dist_desc);
859: fa_rx_util_pkg.debug('h_dist_natacct : '||h_dist_natacct);
860: fa_rx_util_pkg.debug('h_dist_natdesc : '||h_dist_natdesc);
861:
862:
863: /* Insert to JG_ZZ_AP_IR_REP_ITF */
864: Insert into JG_ZZ_AP_IR_REP_ITF (
917: h_dist_natacct,
918: h_dist_natdesc
919: );
920:
921: fa_rx_util_pkg.debug('Inserted invoice_id: '||h_invoice_id||' inv_dist_id : '||h_inv_dist_id);
922:
923: End Loop;
924:
925: DBMS_SQL.CLOSE_CURSOR(v_MainCursor);
923: End Loop;
924:
925: DBMS_SQL.CLOSE_CURSOR(v_MainCursor);
926:
927: fa_rx_util_pkg.debug('***** Close Cursor v_MainCursor *****');
928:
929: commit;
930:
931: Exception