Вы находитесь на странице: 1из 3

"FSCM_OLTP".

"Connection Pool"
Select GLH.JE_SOURCE,GLH.POSTED_DATE, GLH.RUNNING_TOTAL_ACCOUNTED_DR,
GLH.RUNNING_TOTAL_ACCOUNTED_CR, GLLN.STATUS, GLLN.ACCOUNTED_DR,
GLLN.ACCOUNTED_CR,
GLC.SEGMENT1, GLC.SEGMENT2, GLC.SEGMENT3, GLC.SEGMENT4, GLC.SEGMENT5
from GL_JE_HEADERS GLH, GL_JE_LINES GLLN, GL_CODE_COMBINATIONS GLC
where GLLN.JE_HEADER_ID = GLH.JE_HEADER_ID
and GLLN.PERIOD_NAME = GLH.PERIOD_NAME
and GLC.CODE_COMBINATION_ID = GLLN.CODE_COMBINATION_ID
AND GLLN.LEDGER_ID = GLH.LEDGER_ID
and GLH.PERIOD_NAME = '10-2016'
order by GLH.JE_HEADER_ID, GLLN.JE_LINE_NUM
union all
SELECT Distinct
BusinessUnit.BU_NAME AS BusinessUnitName,
Supplier.SEGMENT1 AS SupplierNumber,
Party.PARTY_NAME AS SupplierName,
'''' ||InvoiceHeader.INVOICE_NUM AS InvoiceNumber,
InvoiceHeader.INVOICE_DATE AS InvoiceDate,
InvoiceHeader.INVOICE_CURRENCY_CODE AS InvoiceCurrency,
InvoiceHeader.DESCRIPTION AS InvoiceDescription,
decode(GLCODECOMBINATIONS.SEGMENT1,'9999','
',GLCODECOMBINATIONS.SEGMENT1) AS CompanyCode,
decode(GLCODECOMBINATIONS.SEGMENT4,'9999',' ',
GLCODECOMBINATIONS.SEGMENT4) AS CostCenterCode,
decode(GLCODECOMBINATIONS.SEGMENT2,'999999','
',GLCODECOMBINATIONS.SEGMENT2) AS AccountCode,
decode(GLCODECOMBINATIONS.SEGMENT3,'99','
',GLCODECOMBINATIONS.SEGMENT3) AS GLFunction,
decode(GLCODECOMBINATIONS.SEGMENT5,'999999','
',GLCODECOMBINATIONS.SEGMENT5) AS ProjectCode,
(NVL(Xladistlink.UNROUNDED_ACCOUNTED_DR,0) -
NVL(Xladistlink.UNROUNDED_ACCOUNTED_CR, 0) ) AS GLAmount ,
(NVL(Xladistlink.UNROUNDED_ENTERED_DR , 0) -
NVL(Xladistlink.UNROUNDED_ENTERED_CR, 0)) AS InvoicedAmount,
InvoiceHeader.INVOICE_AMOUNT AS InvoiceHeaderAMOUNT,
InvoiceHeader.Total_Tax_Amount AS TotalTaxAmount,
FiscalDay.FISCAL_PERIOD_NAME AS FiscalPeriod,
InvoiceHeader.DOC_SEQUENCE_VALUE AS VoucherNumber,
InvoiceHeader.SOURCE AS InvoicSourceCode,
InvoiceLine.ATTRIBUTE1 AS MerchantName,
ltrim(rtrim(InvoiceLine.DESCRIPTION,'"'),'"') AS InvoiceLineDescription
,
InvoiceDistribution.AMOUNT As DistributionAmount,
InvoiceLine.QUANTITY_INVOICED AS InvoiceQuantity,
Uom.UNIT_OF_MEASURE AS UnitOfMeasure,
Xlalines.ACCOUNTING_DATE as AccountingDate,

(ap_invoices_utility_pkg.get_accounting_status(InvoiceHeader.INVOICE_ID)) AS
AccountingStatus,
(gl_flexfields_pkg.get_description_sql
(GLCODECOMBINATIONS.CHART_OF_ACCOUNTS_ID, 2,GLCODECOMBINATIONS.SEGMENT2 )) AS
AccountDescription,
Xladistlink.UNROUNDED_ACCOUNTED_CR AS AccountedAmountCredit,
Xladistlink.UNROUNDED_ACCOUNTED_DR AS AccountedAmountDebit,
Xladistlink.UNROUNDED_ENTERED_CR AS EnteredAmountCredit,
Xladistlink.UNROUNDED_ENTERED_DR AS EnteredAmountDebit ,
GLH.JE_SOURCE,
GLH.POSTED_DATE,
GLH.RUNNING_TOTAL_ACCOUNTED_DR,
GLH.RUNNING_TOTAL_ACCOUNTED_CR,
GLLN.STATUS,
GLLN.ACCOUNTED_DR,
GLLN.ACCOUNTED_CR,
GLC.SEGMENT1,
GLC.SEGMENT2,
GLC.SEGMENT3,
GLC.SEGMENT4,
GLC.SEGMENT5
FROM
AP_INVOICE_DISTRIBUTIONS_ALL InvoiceDistribution,
AP_INVOICE_LINES_ALL InvoiceLine,
AP_INVOICES_ALL InvoiceHeader,
FUN_ALL_BUSINESS_UNITS_V BusinessUnit,
INV_UNITS_OF_MEASURE_VL Uom ,
POZ_SUPPLIERS Supplier,
HZ_PARTIES Party,
XLA_DISTRIBUTION_LINKS Xladistlink,
XLA_AE_LINES Xlalines,
GL_FISCAL_DAY_V FiscalDay,
GL_LEDGERS Ledger,
GL_CODE_COMBINATIONS GLCODECOMBINATIONS,
GL_JE_HEADERS GLH,
GL_JE_LINES GLLN,
GL_CODE_COMBINATIONS GLC
WHERE
InvoiceDistribution.INVOICE_ID = InvoiceLine.INVOICE_ID
AND InvoiceDistribution.INVOICE_LINE_NUMBER = InvoiceLine.LINE_NUMBER
AND InvoiceLine.INVOICE_ID = InvoiceHeader.INVOICE_ID
AND InvoiceDistribution.MATCHED_UOM_LOOKUP_CODE = Uom.UOM_CODE(+)
AND InvoiceDistribution.ORG_ID = BusinessUnit.BU_ID
AND Supplier.PARTY_ID = Party.PARTY_ID
AND Supplier.VENDOR_ID = InvoiceHeader.VENDOR_ID
AND Xladistlink.AE_HEADER_ID = Xlalines.AE_HEADER_ID
AND Xladistlink.AE_LINE_NUM = Xlalines.AE_LINE_NUM
AND Xladistlink.APPLICATION_ID = Xlalines.APPLICATION_ID
AND Xladistlink.SOURCE_DISTRIBUTION_ID_NUM_1 =
InvoiceDistribution.INVOICE_DISTRIBUTION_ID
AND GLCODECOMBINATIONS.CODE_COMBINATION_ID =
Xlalines.CODE_COMBINATION_ID
AND Xlalines.ACCOUNTING_DATE = FiscalDay.REPORT_DATE (+)
AND FiscalDay.FISCAL_PERIOD_SET_NAME = Ledger.PERIOD_SET_NAME
AND FiscalDay.FISCAL_PERIOD_TYPE = Ledger.ACCOUNTED_PERIOD_TYPE
AND Xlalines.LEDGER_ID = Ledger.LEDGER_ID
AND Ledger.CHART_OF_ACCOUNTS_ID =
GLCODECOMBINATIONS.CHART_OF_ACCOUNTS_ID
AND FiscalDay.ADJUSTMENT_PERIOD_FLAG = 'N'
AND Xlalines.CODE_COMBINATION_ID <> -1
AND Ledger.LEDGER_ID = GLH.LEDGER_ID(+)
AND GLLN.LEDGER_ID = GLH.LEDGER_ID
AND GLLN.JE_HEADER_ID = GLH.JE_HEADER_ID
AND GLLN.PERIOD_NAME = GLH.PERIOD_NAME
AND GLC.CODE_COMBINATION_ID = GLLN.CODE_COMBINATION_ID
And FiscalDay.FISCAL_PERIOD_NAME = '10-2016'
AND GLH.PERIOD_NAME = '10-2016'
AND GLCODECOMBINATIONS.SEGMENT2 in ( '451010')
AND GLC.SEGMENT2 in ( '451010')
And GLCODECOMBINATIONS.SEGMENT1 = :P_CompanyCode
AND GLCODECOMBINATIONS.SEGMENT2 in ( :P_Account)
And FiscalDay.FISCAL_PERIOD_NAME = :P_Period
And GLC.SEGMENT1 = :P_CompanyCode
AND GLC.SEGMENT2 in ( :P_Account)
AND GLH.PERIOD_NAME = :P_Period
order by GLH.JE_HEADER_ID, GLLN.JE_LINE_NUM

And BusinessUnit.BU_NAME in ( :P_BusinessUnitName)


And (ap_invoices_utility_pkg.get_accounting_status(InvoiceHeader.INVOICE_ID)) =
:P_ACCOUNTSTATUS