You are on page 1of 17

SQL> show con_name

CON_NAME
------------------------------
PGPFISS1
SQL> @/tmpgap/ReportingSITMigration/APTB/ddl_FIN_RPT_COMMON_ERR.sql
SQL> /*
******************************************************************************
SQL> * Table : FIN_RPT_COMMON_ERR
SQL> * Script : FIN_RPT_COMMON_ERR.sql
SQL> * Purpose : This table is used to log error messages for reports
SQL> *
SQL> * Author Date Ver
SQL> * ------- --------- ----------------- ---------
SQL> * Infosys 15-Jun-2021 1.0
SQL>
*******************************************************************************/
SQL> CREATE TABLE "FINGAP"."FIN_RPT_COMMON_ERR"
2 (
3 seq_no NUMBER,
4 user_name VARCHAR2(100),
5 report_name VARCHAR2(200),
6 pkg_name VARCHAR2(100),
7 input_param VARCHAR2(1000),
8 creation_date DATE,
9 error_msg VARCHAR2(1000)
10 );

Table created.

SQL> /
CREATE TABLE "FINGAP"."FIN_RPT_COMMON_ERR"
*
ERROR at line 1:
ORA-00955: name is already used by an existing object

SQL>
SQL> CREATE OR REPLACE PUBLIC SYNONYM FIN_RPT_COMMON_ERR FOR
FINGAP.FIN_RPT_COMMON_ERR;

Synonym created.

SQL> /

Synonym created.

SQL>
SQL> GRANT DELETE, INSERT, SELECT, UPDATE ON FINGAP.FIN_RPT_COMMON_ERR TO FINUSER;

Grant succeeded.

SQL> /

Grant succeeded.

SQL>
SQL> GRANT SELECT ON FINGAP.FIN_RPT_COMMON_ERR TO FINUSER_READONLY;
Grant succeeded.

SQL> /

Grant succeeded.

SQL> CREATE SEQUENCE fingap.fin_error_log_id_s


2 START WITH 1
3 INCREMENT BY 1;

Sequence created.

SQL> /
CREATE SEQUENCE fingap.fin_error_log_id_s
*
ERROR at line 1:
ORA-00955: name is already used by an existing object

SQL> @/tmpgap/ReportingSITMigration/APTB/FIN_AP_REPORTS_PKG_sql_b.sql
SQL> CREATE OR REPLACE PACKAGE BODY FINGAP.FIN_AP_REPORTS_PKG AS
2
3 -- =========================================================
4 -- Global Constants
5 -- =========================================================
6 gd_start_date DATE := '01-Jan-2019';--to_date('2014-01-01','yyyy-mm-dd');
7 gd_request_id_seq NUMBER;
8 gd_error_msg VARCHAR2(1000);
9 gd_input_params VARCHAR2(5000);
10 gd_return BOOLEAN;
11
12 --- =========================================================
13 -- Private Functions
14 -- =========================================================
15
/**********************************************************************************
***
16 Function: FIN_AP_TB_ACCT_SMRY_FUN
17 Purpose : The Funciton is used to display key account details and
respective totals
18 Called by: Gap Accounts Trial Balance Report
19 Calls : None
20
21 Modification History
22 25/05/2021 Pullareddy M Initial Version
23
***********************************************************************************
***/
24 FUNCTION FIN_AP_TB_ACCT_SMRY_FUN (
25 i_seq_id IN NUMBER,
26 i_offset_account1 IN VARCHAR2,
27 i_offset_account2 IN VARCHAR2,
28 i_accounting_date IN DATE,
29 i_account_id IN NUMBER,
30 i_display IN VARCHAR2 DEFAULT 'S',
31 i_account_type IN VARCHAR2,
32 xdo_user_name IN VARCHAR2
33 ) RETURN BOOLEAN;
34
35 --- =========================================================
36 -- Private Functions
37 -- =========================================================
38
/**********************************************************************************
***
39 Function: FIN_AP_TB_DETAIL_FUN
40 Purpose : The Funciton is used to display Invoice details and resptective
totals
41 Called by: Gap Accounts Trial Balance Report
42 Calls : None
43
44 Modification History
45 25/05/2021 Pullareddy M Initial Version
46
***********************************************************************************
***/
47 FUNCTION fin_ap_tb_detail_fun (
48 i_seq_id IN NUMBER,
49 i_offset_account1 IN VARCHAR2,
50 i_offset_account2 IN VARCHAR2,
51 i_accounting_date IN DATE,
52 i_account_id IN NUMBER,
53 i_display IN VARCHAR2 DEFAULT 'S',
54 i_account_type IN VARCHAR2,
55 xdo_user_name IN VARCHAR2
56 ) RETURN BOOLEAN;
57
58 --- =========================================================
59 -- Private Functions
60 -- =========================================================
61
/**********************************************************************************
***
62 Function: FIN_AP_TB_COA_FUN
63 Purpose : The Funciton is used to display code combination segments and
respective total
64 Called by: Gap Accounts Trial Balance Report
65 Calls : None
66
67 Modification History
68 25/05/2021 Pullareddy M Initial Version
69
***********************************************************************************
***/
70 FUNCTION fin_ap_tb_coa_fun (
71 i_seq_id IN NUMBER,
72 i_offset_account1 IN VARCHAR2,
73 i_offset_account2 IN VARCHAR2,
74 i_accounting_date IN DATE,
75 i_account_id IN NUMBER,
76 i_display IN VARCHAR2 DEFAULT 'S',
77 i_account_type IN VARCHAR2,
78 xdo_user_name IN VARCHAR2
79 ) RETURN BOOLEAN;
80
81
82 --- =========================================================
83 -- Private Functions
84 -- =========================================================
85
/**********************************************************************************
***
86 Function: FIN_AP_TB_ACCT_INV_SUP_FUN
87 Purpose : The Funciton is used to display Key Accounts along with Inv and
Supplier details
88 Called by: Gap Accounts Trial Balance Report
89 Calls : None
90
91 Modification History
92 25/05/2021 Pullareddy M Initial Version
93
***********************************************************************************
***/
94 FUNCTION FIN_AP_TB_ACCT_INV_SUP_FUN(
95 i_seq_id IN NUMBER,
96 i_offset_account1 IN VARCHAR2,
97 i_offset_account2 IN VARCHAR2,
98 i_Accounting_date IN DATE,
99 i_account_id IN NUMBER,
100 i_display IN VARCHAR2 DEFAULT 'S',
101 i_account_type IN VARCHAR2,
102 xdo_user_name IN VARCHAR2
103 ) RETURN BOOLEAN;
104
105 --- =========================================================
106 -- Public Functions
107 -- =========================================================
108
/**********************************************************************************
***
109 Function: FIN_AP_TRIAL_BALANCE_FN
110 Purpose : The Funciton is used for Gap Accounts Trial Balance Report to
display
111 trial balance for a Liability CoA string
112
113 Called by: Gap Accounts Trial Balance Report
114 Calls : None
115
116 Modification History
117 25/05/2021 Pullareddy M Initial Version
118
***********************************************************************************
***/
119
120 FUNCTION FIN_AP_TRIAL_BALANCE_FN
121 (i_offset_account1 IN VARCHAR2,
122
i_offset_account2 IN VARCHAR2,
123
i_Accounting_date IN DATE,
124
i_account_id IN NUMBER,
125 i_display
IN VARCHAR2 Default 'S',
126
i_account_type IN VARCHAR2,
127
xdo_user_name IN VARCHAR2
128 ) RETURN
BOOLEAN IS
129
130 LV_LIABILITY_COA varchar2(100);
131
132 BEGIN
133 gd_request_id_seq:="FINGAP"."FIN_AP_TRIAL_BAL_S".NEXTVAL;
134
135 SELECT segment1||'.'||segment2||'.'||segment3||'.'||segment4||'.'||
136 segment5||'.'||segment6||'.'||segment7||'.'||segment8
137 INTO lv_liability_CoA
138 FROM findas.gl_code_combinations
139 WHERE code_combination_id = i_account_id;
140
141 gd_input_params:=(nvl(to_char(to_date
(i_Accounting_date,'YYYY/MM/DD'),'DD-MON-RRRR'), ' ')||','||nvl(lv_liability_CoA,'
')||','||nvl(i_display,' ')||','||nvl(i_offset_account1,' ')||','||
nvl(i_offset_account2,' ')||','||nvl(i_account_type,' ')||','||nvl(xdo_user_name,'
'));
142
143
144 INSERT INTO "FINGAP"."FIN_AP_LIABILITY_TOT_GT"(
145 REQUEST_ID,
146 LIABILITY_ACCOUNT,
147 INVOICE_AMOUNT,
148 REMAINING_AMOUNT)
149 SELECT
150 gd_request_id_seq,
151 lv_liability_CoA,
152 sum(tiv.base_amount) invoice_amount,
153 sum(tb.acctd_unrounded_rem_amount)
remaining_amount
154 --sum((tb.acctd_unrounded_rem_amount + NVL
(aia.cancelled_amount, 0))) remaining_amount
155 FROM
156 findas.AP_SLA_INVOICES_TRANSACTION_V tiv,
157 findas.xla_transaction_entities xte,
158 findas.gl_ledgers gl,
159 findas.hr_operating_units hou,
160 findas.ap_invoices_all aia,
161 -- inline view
162 (SELECT
163 xtb.code_combination_id ,
164 xtb.party_id,
165 xtb.ledger_id,
166 xtb.invoice_id,
167 SUM (Nvl(xtb.accounted_cr,0)) - SUM
(Nvl(xtb.accounted_dr,0)) acctd_unrounded_rem_amount
168 FROM findas.ap_trial_balances xtb
169 where 1=1
170 and xtb.ACCOUNTING_CLASS_CODE
= 'LIABILITY'
171 and trunc(xtb.accounting_date)
between gd_start_date AND i_Accounting_date
172 and xtb.code_combination_id =
i_account_id
173 GROUP BY xtb.code_combination_id ,
174 xtb.ledger_id,
175 xtb.party_id,
176 xtb.invoice_id
177 HAVING SUM (Nvl(xtb.accounted_cr,0))
<> SUM (Nvl(xtb.accounted_dr,0))
178 ) tb
179 --end of inline view
180 where 1=1
181 and xte.application_id=200
182 and xte.entity_code='AP_INVOICES'
183 and xte.SECURITY_ID_INT_1 = aia.org_id
184 and xte.transaction_number = tiv.invoice_num
185 and xte.ledger_id=tb.ledger_id
186 and gl.ledger_id=hou.set_of_books_id
187 and nvl(xte.source_id_int_1,-
99)=tiv.invoice_id
188 and tb.ledger_id=gl.ledger_id
189 and aia.invoice_id = tiv.invoice_id
190 and tb.invoice_id = tiv.invoice_id
191 and hou.organization_id = aia.org_id
192 group by tb.code_combination_id ;
193
194 COMMIT;
195 /*IF i_display = 'S' THEN
196 gd_return := FIN_AP_TB_ACCT_SMRY_FUN(
197
gd_request_id_seq,
198
i_offset_account1,
199 i_offset_account2,
200 i_Accounting_date,
201 i_account_id,
202 i_display,
203 i_account_type,
204 xdo_user_name);
205 END IF;*/
206
207 IF i_display = 'DI' THEN
208 gd_return :=
FIN_AP_TB_DETAIL_FUN(gd_request_id_seq,
209
i_offset_account1,
210 i_offset_account2,
211 i_Accounting_date,
212 i_account_id,
213 i_display,
214 i_account_type,
215 xdo_user_name);
216 END IF;
217
218 IF i_display = 'DS' THEN
219 gd_return :=
FIN_AP_TB_DETAIL_FUN(gd_request_id_seq,
220
i_offset_account1,
221 i_offset_account2,
222 i_Accounting_date,
223 i_account_id,
224 i_display,
225 i_account_type,
226 xdo_user_name);
227
228 END IF;
229
230 IF i_display = 'COA' THEN
231 gd_return :=
FIN_AP_TB_COA_FUN(gd_request_id_seq,
232
i_offset_account1,
233 i_offset_account2,
234 i_Accounting_date,
235 i_account_id,
236 i_display,
237 i_account_type,
238 xdo_user_name);
239
240 END IF;
241
242 IF i_display = 'ACCOUNT' THEN
243 gd_return :=
FIN_AP_TB_ACCT_SMRY_FUN(gd_request_id_seq,
244
i_offset_account1,
245 i_offset_account2,
246 i_Accounting_date,
247 i_account_id,
248 i_display,
249 i_account_type,
250 xdo_user_name);
251
252 END IF;
253
254 IF i_display = 'ADS' THEN
255 gd_return := FIN_AP_TB_ACCT_INV_SUP_FUN(
256
gd_request_id_seq,
257
i_offset_account1,
258 i_offset_account2,
259 i_Accounting_date,
260 i_account_id,
261 i_display,
262 i_account_type,
263 xdo_user_name);
264 END IF;
265
266 COMMIT;
267
268 RETURN TRUE;
269 EXCEPTION
270 WHEN no_data_found THEN
271 gd_error_msg:=SQLERRM;
272
273 INSERT INTO
"FINGAP"."FIN_RPT_COMMON_ERR"(SEQ_NO,USER_NAME,REPORT_NAME,PKG_NAME,INPUT_PARAM,cre
ation_date,ERROR_MSG)
274 VALUES (gd_request_id_seq,xdo_user_name,'Gap Accounts Payable
Trial Balance
Report','FIN_AP_REPORTS_PKG.FIN_AP_TRIAL_BALANCE_FN',gd_input_params,sysdate,gd_err
or_msg); --commit;
275 COMMIT;
276 RETURN TRUE;
277 WHEN OTHERS THEN
278 gd_error_msg:=SQLERRM;
279 NULL;
280 INSERT INTO
"FINGAP"."FIN_RPT_COMMON_ERR"(SEQ_NO,USER_NAME,REPORT_NAME,PKG_NAME,INPUT_PARAM,cre
ation_date,ERROR_MSG)
281 VALUES (gd_request_id_seq,xdo_user_name,'Gap Accounts Payable
Trial Balance
Report','FIN_AP_REPORTS_PKG.FIN_AP_TRIAL_BALANCE_FN',gd_input_params,sysdate,gd_err
or_msg);
282 COMMIT;
283 RETURN TRUE;
284
285 END FIN_AP_TRIAL_BALANCE_FN;
286
287 FUNCTION FIN_AP_TB_ACCT_SMRY_FUN( i_seq_id IN NUMBER,
288 i_offset_account1 IN VARCHAR2,
289
i_offset_account2 IN VARCHAR2,
290
i_Accounting_date IN DATE,
291
i_account_id IN NUMBER,
292 i_display
IN VARCHAR2 Default 'S',
293
i_account_type IN VARCHAR2,
294
xdo_user_name IN VARCHAR2) RETURN BOOLEAN IS
295
296 TYPE c_sum_bal_t IS
297 TABLE OF FINGAP.FIN_AP_ACCOUNTS_SMRY_BAL_GT%rowtype index by
binary_integer;
298 c_sum_bal_tab c_sum_bal_t;
299
300 BEGIN
301
302 INSERT
303 INTO "FINGAP"."FIN_AP_ACCOUNTS_SMRY_GT"
304 (REQUEST_ID,
305 ACCOUNT,
306 ACCOUNT_DESC,
307 ACCOUNT_TYPE,
308 ACCOUNT_BALANCE)
309 SELECT i_seq_id,
310 fv.VALUE,
311 (SELECT REPLACE(description,',',' ') FROM
findas.fnd_flex_values_tl WHERE FLEX_VALUE_ID = fv.value_id AND LANGUAGE = 'US'),
312 DECODE(fv.FLEX_VALUE_ATTRIBUTE3,'R','Revenue','A','Asset','E',
'Expense', 'L', 'Liablility',
313 'O', 'Ownerhip or Stockholders Equity',null),
314 NULL
315 FROM findas.FND_VS_VALUES_B fv,
316 findas.fnd_flex_value_sets vs,
317 findas.fnd_id_flex_segments seg,
318 findas.fnd_id_flex_structures_vl str
319 WHERE str.application_id = 101
320 AND str.id_flex_code = 'GL#'
321 AND str.ID_FLEX_STRUCTURE_CODE = 'XX_COA_SI'
322 AND str.application_id = seg.application_id
323 AND str.id_flex_num = seg.id_flex_num
324 AND str.id_flex_code = seg.id_flex_code
325 AND seg.flex_value_set_id = vs.flex_value_set_id
326 AND vs.flex_value_set_name = 'XX_GL_ACCOUNT'
327 AND vs.flex_value_set_id = fv.VALUE_SET_ID
328 AND fv.summary_flag = 'N'
329 AND fv.FLEX_VALUE_ATTRIBUTE3 IS NOT NULL
330 AND fv.VALUE between NVL(i_offset_account1,
fv.VALUE)
331 AND NVL(i_offset_account2, fv.VALUE)
332 AND fv.FLEX_VALUE_ATTRIBUTE3 =
NVL(i_account_type,fv.FLEX_VALUE_ATTRIBUTE3)
333 ORDER BY fv.VALUE;
334
335
336 INSERT INTO
"FINGAP"."FIN_AP_ACCOUNTS_SMRY_BAL_GT"(REQUEST_ID,ACCOUNT,ACCOUNT_BALANCE)
337 SELECT i_seq_id,
338 gcc.segment3,
339 SUM(DECODE(exchange_rate,
340 NULL, apid.amount,
341 apid.base_amount))
342 FROM findas.ap_invoice_distributions_all apid,
343 findas.gl_code_combinations gcc,
344 (SELECT
345 tiv.invoice_id invoice_id,
346 tiv.invoice_num,
347 tb.party_id vendor_id,
348 tb.ledger_id set_of_books_id,
349 tb.code_combination_id code_combination_id,
350 hou.organization_id org_id,
351 tiv.base_amount invoice_amount,
352 tb.acctd_unrounded_rem_amount remaining_amount
353 --(tb.acctd_unrounded_rem_amount + NVL (aia.cancelled_amount, 0))
remaining_amount
354 FROM
355 findas.ap_sla_invoices_transaction_v tiv,
356 findas.xla_transaction_entities xte,
357 findas.gl_ledgers gl,
358 findas.hr_operating_units hou,
359 findas.ap_invoices_all aia,
360 -- inline view
361 (SELECT
362 xtb.code_combination_id ,
363 xtb.party_id,
364 xtb.ledger_id,
365 xtb.invoice_id,
366 SUM (Nvl(xtb.accounted_cr,0)) - SUM (Nvl(xtb.accounted_dr,0))
acctd_unrounded_rem_amount
367 FROM findas.ap_trial_balances xtb --in Saas ap_trial_balances
368 where 1=1
369 and xtb.accounting_class_code = 'LIABILITY'
370 and trunc(xtb.accounting_date) between gd_start_date AND
i_Accounting_date
371 and xtb.code_combination_id = i_account_id
372 GROUP BY xtb.code_combination_id ,
373 xtb.ledger_id,
374 xtb.party_id,
375 xtb.invoice_id
376 HAVING SUM (Nvl(xtb.accounted_cr,0)) <> SUM
(Nvl(xtb.accounted_dr,0))
377 ) tb
378 --end of inline view
379 where 1=1
380 and xte.application_id=200
381 and xte.entity_code='AP_INVOICES'
382 and xte.SECURITY_ID_INT_1 = aia.org_id
383 and xte.transaction_number = tiv.invoice_num
384 and xte.ledger_id=tb.ledger_id
385 and gl.ledger_id=hou.set_of_books_id
386 and nvl(xte.source_id_int_1,-99)=tiv.invoice_id
387 and tb.ledger_id=gl.ledger_id
388 and aia.invoice_id = tiv.invoice_id
389 and tb.invoice_id = tiv.invoice_id
390 and hou.organization_id = aia.org_id
391 ) ap_tb
392 WHERE gcc.segment3 BETWEEN NVL(i_offset_account1,
gcc.segment3) AND NVL(i_offset_account2, gcc.segment3)
393 AND gcc.code_combination_id = apid.dist_code_combination_id
394 AND apid.accounting_date BETWEEN gd_start_date AND
i_Accounting_date
395 AND apid.invoice_id = ap_tb.invoice_id
396 GROUP BY gcc.segment3;
397
398
399 SELECT * BULK COLLECT INTO c_sum_bal_tab FROM
"FINGAP"."FIN_AP_ACCOUNTS_SMRY_BAL_GT" WHERE REQUEST_ID = i_seq_id;
400
401 FORALL indx IN 1..c_sum_bal_tab.COUNT
402 UPDATE "FINGAP"."FIN_AP_ACCOUNTS_SMRY_GT" A
403 SET ACCOUNT_BALANCE =
c_sum_bal_tab(indx).ACCOUNT_BALANCE
404 WHERE A.REQUEST_ID = c_sum_bal_tab(indx).REQUEST_ID
405 AND A.ACCOUNT = c_sum_bal_tab(indx).ACCOUNT;
406
407
408 RETURN TRUE;
409
410 EXCEPTION
411 WHEN OTHERS THEN
412 gd_error_msg:=SQLERRM;
413 INSERT INTO
"FINGAP"."FIN_RPT_COMMON_ERR"(SEQ_NO,USER_NAME,REPORT_NAME,PKG_NAME,INPUT_PARAM,cre
ation_date,ERROR_MSG)
414 VALUES (i_seq_id,xdo_user_name,'Gap Accounts Payable Trial Balance
Report','FIN_AP_REPORTS_PKG.FIN_AP_TRIAL_BALANCE_FN.FIN_AP_TB_ACCT_SMRY_FUN',gd_inp
ut_params,sysdate,gd_error_msg);
415 COMMIT;
416 RETURN TRUE;
417 END FIN_AP_TB_ACCT_SMRY_FUN;
418
419 FUNCTION FIN_AP_TB_DETAIL_FUN(i_seq_id IN NUMBER,
420 i_offset_account1 IN VARCHAR2,
421
i_offset_account2 IN VARCHAR2,
422
i_Accounting_date IN DATE,
423
i_account_id IN NUMBER,
424 i_display
IN VARCHAR2 DEFAULT 'S',
425
i_account_type IN VARCHAR2,
426
xdo_user_name IN VARCHAR2) RETURN BOOLEAN IS
427
428 BEGIN
429 INSERT INTO "FINGAP"."FIN_AP_INV_SUP_DETAIL_GT"
430 (REQUEST_ID,
431 --ACCOUNT,
432 INVOICE_ID,
433 INVOICE_NUM,
434 INVOICE_SOURCE,
435 INVOICE_TYPE,
436 INVOICE_AMOUNT,
437 INVOICE_DATE,
438 VENDOR_NUMBER,
439 VENDOR_NAME,
440 VENDOR_TYPE,
441 --INVOICE_ACCOUNT_AMOUNT,
442 DESCRIPTION,
443 AMOUNT_REMAINING
444 )
445 SELECT
446 i_seq_id,
447 /*(SELECT gcc.segment3
448 FROM findas.ap_invoice_distributions apid,
449 findas.gl_code_combinations gcc
450 WHERE gcc.segment3 between NVL(i_offset_account1,
gcc.segment3) and NVL(i_offset_account2, gcc.segment3)
451 AND gcc.code_combination_id = apid.dist_code_combination_id
452 AND apid.accounting_date between gd_start_date
453 and i_Accounting_date
454 AND apid.invoice_id = ap_tb.invoice_id
455 GROUP BY gcc.segment3),*/
456 ap_tb.invoice_id,
457 ap.invoice_num,
458 ap.source,
459 ap.invoice_type_lookup_code,
460 ap_tb.invoice_amount,
461 ap.invoice_date,
462 pv.segment1,
463 ap_tb.PARTY_NAME,
464 pv.vendor_type_lookup_code,
465 ap.description,
466 ap_tb.remaining_amount
467 FROM
468 (
469 SELECT
470 tiv.invoice_id invoice_id,
471 tiv.invoice_num,
472 tiv.PARTY_NAME,
473 tb.party_id vendor_id,
474 tb.ledger_id set_of_books_id,
475 tb.code_combination_id code_combination_id,
476 hou.organization_id org_id,
477 tiv.base_amount invoice_amount,
478 tb.acctd_unrounded_rem_amount remaining_amount
479 --(tb.acctd_unrounded_rem_amount + NVL (aia.cancelled_amount, 0))
remaining_amount
480 FROM
481 findas.ap_sla_invoices_transaction_v tiv,
482 findas.xla_transaction_entities xte,
483 findas.gl_ledgers gl,
484 findas.hr_operating_units hou,
485 findas.ap_invoices_all aia,
486 -- inline view
487 (SELECT
488 xtb.code_combination_id ,
489 xtb.party_id,
490 xtb.ledger_id,
491 xtb.invoice_id,
492 SUM (Nvl(xtb.accounted_cr,0)) - SUM (Nvl(xtb.accounted_dr,0))
acctd_unrounded_rem_amount
493 FROM findas.ap_trial_balances xtb
494 where 1=1
495 and xtb.ACCOUNTING_CLASS_CODE = 'LIABILITY'
496 and trunc(xtb.accounting_date) between gd_start_date AND
i_Accounting_date
497 and xtb.code_combination_id = i_account_id
498 GROUP BY xtb.code_combination_id ,
499 xtb.ledger_id,
500 xtb.party_id,
501 xtb.invoice_id
502 HAVING SUM (Nvl(xtb.accounted_cr,0)) <> SUM
(Nvl(xtb.accounted_dr,0))
503 ) tb
504 --end of inline view
505 where 1=1
506 and xte.application_id=200
507 and xte.entity_code='AP_INVOICES'
508 and xte.SECURITY_ID_INT_1 = aia.org_id
509 and xte.transaction_number = tiv.invoice_num
510 and xte.ledger_id=tb.ledger_id
511 and gl.ledger_id=hou.set_of_books_id
512 and nvl(xte.source_id_int_1,-99)=tiv.invoice_id
513 and tb.ledger_id=gl.ledger_id
514 and aia.invoice_id = tiv.invoice_id
515 and tb.invoice_id = tiv.invoice_id
516 and hou.organization_id = aia.org_id
517 ) ap_tb,
518 findas.ap_invoices_all ap,
519 findas.poz_suppliers pv
520 WHERE
521 ap.invoice_id = ap_tb.invoice_id
522 AND pv.party_id = ap_tb.vendor_id
523 AND ap.vendor_id = pv.vendor_id
524 ;
525
526 RETURN TRUE;
527
528 EXCEPTION
529 WHEN OTHERS THEN
530 gd_error_msg:=SQLERRM;
531 INSERT INTO "FINGAP"."FIN_RPT_COMMON_ERR" (
532 seq_no,
533 user_name,
534 report_name,
535 pkg_name,
536 input_param,
537 creation_date,
538 error_msg
539 ) VALUES (
540 i_seq_id,
541 xdo_user_name,
542 'Gap Accounts Payable Trial Balance Report',
543 'FIN_AP_REPORTS_PKG.FIN_AP_TRIAL_BALANCE_FN.FIN_AP_TB_DETAIL_FUN',
544 gd_input_params,
545 sysdate,
546 gd_error_msg
547 );
548
549 COMMIT;
550 RETURN true;
551 END FIN_AP_TB_DETAIL_FUN;
552
553 FUNCTION FIN_AP_TB_COA_FUN (
554 i_seq_id IN NUMBER,
555 i_offset_account1 IN VARCHAR2,
556 i_offset_account2 IN VARCHAR2,
557 i_accounting_date IN DATE,
558 i_account_id IN NUMBER,
559 i_display IN VARCHAR2 DEFAULT 'S',
560 i_account_type IN VARCHAR2,
561 xdo_user_name IN VARCHAR2
562 ) RETURN BOOLEAN IS
563 BEGIN
564 INSERT INTO "FINGAP"."FIN_AP_TRBAL_COA_GT"(
565 request_id,
566 legal_entity,
567 division,
568 account,
569 dept,
570 area,
571 mdse,
572 account_desc,
573 account_type,
574 account_balance
575 )
576 SELECT
577 i_seq_id,
578 gcc.segment1,
579 gcc.segment2,
580 gcc.segment3,
581 gcc.segment4,
582 gcc.segment5,
583 gcc.segment6,
584 acct_type.description,
585 acct_type.flex_value_attribute3,
586 SUM(gcc.account_bal) account_balance
587 FROM
588 (SELECT
589 tiv.invoice_id invoice_id,
590 tiv.invoice_num,
591 tb.code_combination_id
code_combination_id,
592 tb.party_id vendor_id,
593 tb.ledger_id set_of_books_id,
594 hou.organization_id org_id,
595 tiv.base_amount invoice_amount,
596 tb.acctd_unrounded_rem_amount
remaining_amount
597 --(tb.acctd_unrounded_rem_amount + NVL
(aia.cancelled_amount, 0)) remaining_amount
598 FROM
599 findas.ap_sla_invoices_transaction_v
tiv,
600 findas.xla_transaction_entities xte,
601 findas.gl_ledgers gl,
602 findas.hr_operating_units hou,
603 findas.ap_invoices_all aia,
604 -- inline view
605 (SELECT
606 xtb.code_combination_id ,
607 xtb.party_id,
608 xtb.ledger_id,
609 xtb.invoice_id,
610 SUM (Nvl(xtb.accounted_cr,0)) - SUM
(Nvl(xtb.accounted_dr,0)) acctd_unrounded_rem_amount
611 FROM findas.ap_trial_balances xtb
612 where 1=1
613 and
xtb.ACCOUNTING_CLASS_CODE = 'LIABILITY'
614 and
trunc(xtb.accounting_date) between gd_start_date AND i_Accounting_date
615 and
xtb.code_combination_id = i_account_id
616 GROUP BY
xtb.code_combination_id ,
617 xtb.ledger_id,
618 xtb.party_id,
619 xtb.invoice_id
620 HAVING SUM
(Nvl(xtb.accounted_cr,0)) <> SUM (Nvl(xtb.accounted_dr,0))
621 ) tb
622 where 1=1--tb.entity_id=xte.entity_id
623 and xte.application_id=200
624 and xte.entity_code='AP_INVOICES'
625 and xte.SECURITY_ID_INT_1 = aia.org_id
626 and xte.ledger_id=tb.ledger_id
627 and xte.transaction_number =
tiv.invoice_num
628 and gl.ledger_id=hou.set_of_books_id
629 and nvl(xte.source_id_int_1,-
99)=tiv.invoice_id
630 and tb.ledger_id=gl.ledger_id
631 and aia.invoice_id = tiv.invoice_id
632 and tb.invoice_id = tiv.invoice_id
633 and hou.organization_id = aia.org_id)
tb,
634 (
635 SELECT
636 apid.invoice_id,
637 gcc1.segment1,
638 gcc1.segment2,
639 gcc1.segment3,
640 gcc1.segment4,
641 gcc1.segment5,
642 gcc1.segment6,
643 decode(apid.exchange_rate, NULL, nvl(apid.amount, 0),
nvl(apid.base_amount, 0)) account_bal
644 FROM
645 findas.ap_invoice_distributions_all apid,
646 findas.gl_code_combinations gcc1
647 WHERE
648 gcc1.segment3 BETWEEN nvl(i_offset_account1,
gcc1.segment3) AND nvl(i_offset_account2, gcc1.segment3)
649 AND gcc1.code_combination_id =
apid.dist_code_combination_id
650 AND apid.accounting_date BETWEEN gd_start_date AND
i_Accounting_date
651 ) gcc,
652 (
653 SELECT
654 fv.value acct,
655 replace(fft.description, ',', ' ') description,--
Replace(fv.description,',',' '),
656 decode(fv.flex_value_attribute3, 'R', 'Revenue', 'A',
'Asset',
657 'E', 'Expense', 'L', 'Liablility', 'O',
658 'Ownerhip or Stockholders Equity')
flex_value_attribute3
659 FROM
660 findas.fnd_vs_values_b fv,
661 findas.fnd_flex_values_tl fft,
662 findas.fnd_flex_value_sets vs,
663 findas.fnd_id_flex_segments seg,
664 findas.fnd_id_flex_structures_vl str
665 WHERE
666 str.application_id = 101
667 AND str.id_flex_code = 'GL#'
668 AND str.id_flex_structure_code = 'XX_COA_SI'
669 AND str.application_id = seg.application_id
670 AND str.id_flex_num = seg.id_flex_num
671 AND str.id_flex_code = seg.id_flex_code
672 AND seg.flex_value_set_id = vs.flex_value_set_id
673 AND vs.flex_value_set_name = 'XX_GL_ACCOUNT'
674 AND vs.flex_value_set_id = fv.value_set_id
675 AND fft.flex_value_id = fv.value_id
676 AND fft.language = 'US'
677 AND fv.summary_flag = 'N'
678 AND fv.flex_value_attribute3 = NVL(i_account_type,
fv.flex_value_attribute3)
679 ) acct_type
680 WHERE 1=1
681 AND tb.invoice_id = gcc.invoice_id
682 AND acct_type.acct = gcc.segment3
683 GROUP BY
684 gcc.segment1,
685 gcc.segment2,
686 gcc.segment3,
687 gcc.segment4,
688 gcc.segment5,
689 gcc.segment6,
690 acct_type.description,
691 acct_type.flex_value_attribute3;
692
693 RETURN TRUE;
694
695 EXCEPTION
696 WHEN OTHERS THEN
697 gd_error_msg:=SQLERRM;
698 INSERT INTO "FINGAP"."FIN_RPT_COMMON_ERR" (
699 seq_no,
700 user_name,
701 report_name,
702 pkg_name,
703 input_param,
704 creation_date,
705 error_msg
706 ) VALUES (
707 i_seq_id,
708 xdo_user_name,
709 'Gap Accounts Payable Trial Balance Report',
710
'FIN_AP_REPORTS_PKG.FIN_AP_TRIAL_BALANCE_FN.FIN_AP_TB_COA_FUN',
711 gd_input_params,
712 sysdate,
713 gd_error_msg
714 );
715
716 COMMIT;
717 RETURN true;
718 END FIN_AP_TB_COA_FUN;
719
720 FUNCTION FIN_AP_TB_ACCT_INV_SUP_FUN(
721 i_seq_id IN NUMBER,
722 i_offset_account1 IN VARCHAR2,
723 i_offset_account2 IN VARCHAR2,
724 i_accounting_date IN DATE,
725 i_account_id IN NUMBER,
726 i_display IN VARCHAR2 DEFAULT 'S',
727 i_account_type IN VARCHAR2,
728 xdo_user_name IN VARCHAR2
729 ) RETURN BOOLEAN IS
730
731
732 BEGIN
733
734
gd_return:=fin_ap_tb_acct_smry_fun(i_seq_id,i_offset_account1,i_offset_account2,i_a
ccounting_date,i_account_id,'ACCOUNT',i_account_type,xdo_user_name);
735
gd_return:=fin_ap_tb_detail_fun(i_seq_id,i_offset_account1,i_offset_account2,i_acco
unting_date,i_account_id,'DS',i_account_type,xdo_user_name);
736
737 EXCEPTION
738 WHEN OTHERS THEN
739 gd_error_msg:=SQLERRM;
740 INSERT INTO "FINGAP"."FIN_RPT_COMMON_ERR" (
741 seq_no,
742 user_name,
743 report_name,
744 pkg_name,
745 input_param,
746 creation_date,
747 error_msg
748 ) VALUES (
749 i_seq_id,
750 xdo_user_name,
751 'Gap Accounts Payable Trial Balance Report',
752
'FIN_AP_REPORTS_PKG.FIN_AP_TRIAL_BALANCE_FN.FIN_AP_TB_ACCT_INV_SUP_FUN',
753 gd_input_params,
754 sysdate,
755 gd_error_msg
756 );
757
758 COMMIT;
759 RETURN true;
760
761 END FIN_AP_TB_ACCT_INV_SUP_FUN;
762
763 END FIN_AP_REPORTS_PKG;
764 /

Package body created.

SQL> SHOW ERRORS;


No errors.
SQL>

You might also like