- 最后登录
- 2015-5-21
- 在线时间
- 100 小时
- 威望
- 0
- 金钱
- 345
- 注册时间
- 2012-12-19
- 阅读权限
- 10
- 帖子
- 99
- 精华
- 0
- 积分
- 0
- UID
- 824
|
2#
发表于 2013-1-24 11:33:01
我把原始语句也贴上
原语句中where- WHERE S.salesrep_id(+) = CTLGD.cust_trx_line_salesrep_id
- AND AVT.vat_tax_id(+) = CTL.vat_tax_id
- AND RR.rule_id(+) = CTL.accounting_rule_id
- AND MUOM.uom_code(+) = CTL.uom_code
- AND L2.lookup_code(+) = CTL.line_type
- AND CT.exchange_rate_type = GLCT.conversion_type(+)
- AND L2.lookup_type(+) = 'STD_LINE_TYPE'
- AND AVT.org_id(+)=CTL.org_id
- AND CT.doc_sequence_id = FD.doc_sequence_id(+)
- AND CTLGD.org_id = CTL.org_id(+)
- AND CTL.org_id =CTL2.org_id(+)
- And L6.lookup_code = 'DETAIL_LINE'
- AND L6.lookup_type = 'VIEW_ACCOUNTING'
- AND L5.lookup_code = 'LINE'
- AND L5.lookup_type = 'VIEW_ACCOUNTING'
- AND L3.lookup_type = decode(ctlgd.collected_tax_ccid,
- null,
- 'AUTOGL_TYPE',
- 'DISTRIBUTION_SOURCE_TYPE')
- AND L3.lookup_code = decode(ctlgd.collected_tax_ccid,
- null,
- nvl(CTLGD.account_class, 'REV'),
- 'DEFERRED_TAX')
- AND CT.org_id =decode(S.salesrep_id, null,CT.org_id,S.org_id)
- AND L4.lookup_code = decode(ctlgd.posting_control_id, -3, 'N', 'Y')
- AND L4.lookup_type = 'YES/NO'
- AND L1.lookup_code = CTT.type
- AND L1.lookup_type = 'INV/CM'
- AND CT.cust_trx_type_id = CTT.cust_trx_type_id
- AND CT.org_id =CTT.org_id
- AND CT.bill_to_site_use_id = SU.site_use_id
- AND CT.bill_to_customer_id = CUST_ACCT.cust_account_id
- AND CUST_ACCT.party_id = party.party_id
- AND CT.batch_source_id = BS.batch_source_id
- AND CT.org_id = BS.org_id
- AND CTL.link_to_cust_trx_line_id = CTL2.customer_trx_line_id(+)
- AND CTLGD.customer_trx_line_id = CTL.customer_trx_line_id(+)
- AND CTLGD.account_set_flag = 'N'
- AND CT.customer_trx_id = CTLGD.customer_trx_id
- AND CT.org_id = CTLGD.org_id;
复制代码 修改过后- From ra_customer_trx_all CT
- left join fnd_document_sequences FD on CT.doc_sequence_id =
- FD.doc_sequence_id
- left join gl_daily_conversion_types GLCT on CT.exchange_rate_type =
- GLCT.conversion_type,
- ra_customer_trx_lines_all CTL
- left join ra_customer_trx_lines_all CTL2 on CTL.link_to_cust_trx_line_id =
- CTL2.customer_trx_line_id
- And CTL.org_id = CTL2.org_id
- Left join ar_vat_tax_all AVT on AVT.vat_tax_id =CTL.vat_tax_id
- AND AVT.org_id = ctl.org_id
- Left join mtl_units_of_measure MUOM on MUOM.uom_code = CTL.uom_code
- Left join ra_rules RR on RR.rule_id =CTL.accounting_rule_id
- Left join ar_lookups L2 on L2.lookup_code = CTL.line_type
- Right join
- ra_cust_trx_line_gl_dist_all CTLGD on CTLGD.org_id = CTL.org_id and CTLGD.customer_trx_line_id =CTL.customer_trx_line_id
- left join ra_salesreps_all S on S.salesrep_id = CTLGD.cust_trx_line_salesrep_id,
- ra_cust_trx_types_all CTT,
- hz_cust_site_uses_all SU,
- hz_cust_accounts CUST_ACCT,
- hz_parties PARTY,
- ra_batch_sources_all BS,
- ar_lookups L6, ar_lookups L5,
- ar_lookups L1, ar_lookups L3,
- ar_lookups L4
- where L6.lookup_code = 'DETAIL_LINE'
- AND L6.lookup_type = 'VIEW_ACCOUNTING'
- AND L5.lookup_code = 'LINE'
- AND L5.lookup_type = 'VIEW_ACCOUNTING'
- AND L3.lookup_type = decode(ctlgd.collected_tax_ccid,
- null,
- 'AUTOGL_TYPE',
- 'DISTRIBUTION_SOURCE_TYPE')
- AND L3.lookup_code = decode(ctlgd.collected_tax_ccid,
- null,
- nvl(CTLGD.account_class, 'REV'),
- 'DEFERRED_TAX')
- AND CT.org_id = decode(S.salesrep_id, null, CT.org_id, S.org_id)
- AND L4.lookup_code = decode(ctlgd.posting_control_id, -3, 'N', 'Y')
- AND L4.lookup_type = 'YES/NO'
- AND L1.lookup_code = CTT.type
- AND L1.lookup_type = 'INV/CM'
- AND CT.cust_trx_type_id = CTT.cust_trx_type_id
- AND CT.org_id = CTT.org_id
- AND CT.bill_to_site_use_id = SU.site_use_id
- AND CT.bill_to_customer_id = CUST_ACCT.cust_account_id
- AND CUST_ACCT.party_id = party.party_id
- AND CT.batch_source_id = BS.batch_source_id
- AND CT.org_id = BS.org_id
- AND CTL.org_id = CTL2.org_id
- AND CT.customer_trx_id = CTLGD.customer_trx_id
- AND CT.org_id = CTLGD.org_id
- AND L2.lookup_type= 'STD_LINE_TYPE'
复制代码 |
|