Ra_customer_trx_lines_all
Hi
In AR - Transaction form , lines block for line number =2 has 3 tax records(when we press tax button for perticular line),
can any one give in which table these records will store....
Hi;
If you ar on r12.1.1 level please check below threads:
Find Table name in R12.1.1
Re: What is Best Way to Get Table Name in Oracle Applications : 12.1.1 (web)
table and column name in R12 web screen
Check the table and column name in R12 web screen
Regard
Helios
Similar Messages
-
hi experts
i need to join mtl_system_items_b with ra_customer_trx_lines_all, and it seems very easy but problem is .. my ra_customer_trx_lines_all.inventory_item_id is null and doesnt record any code but description is there.. what is this??? is this a kind of implimentation error ??
can anybody tell me what to with that problem.
regards
anwerThere can be different sources from where invoices can be created e.g. OM, Project etc. Also there can be different types of invoices. For all invoices Item number is not a mandatory column and description can be a free text.
when creating a join between ra_customer_trx_lines and mtl_system_items make sure they have a outer join to get correct data.
http://sureshvaishya.blogspot.com -
Hi We're using Oracle Applications 11.5.10.2
Is partitioning the ra_customer_trx_lines_all table by time as well as its indexes safe?
It's getting huge and we wanted to cut down on query time. Someone here told me that partitioning it could be bad because Applications doesn't expect that table or its indexes to be partitioned and had queries tuned to query that table as a non-partitioned table with non-partitioned indexes.
Is this true?Hi,
Please also see this related thread.
Partitioning GL_BALANCES
Partitioning GL_BALANCES
Please note that using partitioning requires extra license.
Thanks,
Hussein -
Help with AP_Invoice Tables in SQL
Hi Gurus,
I am working on a report where i created a view. This query pulls data from SO,PO,ITEMS,AP and AR tables. The problem I am having is when I add a AP tables or a field from that table some of the Order Numbers are disappearing. Could someone please shed some light this. Here is the query
SELECT DISTINCT trxl.CUSTOMER_TRX_LINE_ID,
pv.vendor_name,
api.invoice_num AP_Invoice_Num,
trx.trx_date AR_Invoice_Date,
trx.trx_number AR_Invoice_Number,
pll.quantity_received,
pll.quantity_billed,
ool.shipped_quantity,
mtlb.segment1 NSN,
poh.closed_date po_close_date,
gl.gl_date
FROM apps.oe_order_headers_all ooh,
apps.oe_order_lines_all ool,
apps.oe_drop_ship_sources odss,
apps.po_headers_all poh,
apps.po_lines_all pol,
apps.po_line_locations_all pll,
apps.po_vendors pv,
inv.mtl_system_items_b mtlb,
ar.Ra_customer_trx_all trx,
ar.ra_customer_trx_lines_all trxl,
ar.hz_parties hzp,
ar.hz_cust_accounts hzc,
ap.ap_invoices_all api,
ap.ap_invoice_lines_all apl,
apps.RA_CUST_TRX_LINE_GL_DIST_ALL gl
WHERE odss.header_id = ooh.header_id
AND odss.line_id = ool.line_id
AND odss.po_header_id = poh.po_header_id
AND odss.po_line_id = pol.po_line_id
AND odss.line_location_id = pll.line_location_id
AND pv.vendor_id = poh.vendor_id
AND mtlb.inventory_item_id = ool.inventory_item_id
AND trxl.customer_trx_id = trx.customer_trx_id
AND trxl.inventory_item_id = mtlb.inventory_item_id
AND hzc.cust_account_id = ooh.sold_to_org_id
AND hzc.party_id = hzp.party_id
AND apl.invoice_id = api.invoice_id
AND apl.po_header_id = poh.po_header_id
AND apl.inventory_item_id = mtlb.inventory_item_id
AND api.vendor_id = poh.vendor_id
AND ool.line_id = trxl.interface_line_attribute6
AND to_char(ooh.order_number)= trx.interface_header_attribute1
AND trxl.CUSTOMER_TRX_LINE_ID = gl.CUSTOMER_TRX_LINE_ID
AND gl.gl_date IS NOT NULL
ORDER BY trxl.CUSTOMER_TRX_LINE_ID DESC;
Really appreciate your help
Thank You,Hi ,
Need to place outer join for AP Tables .
Regards
Muthu -
Query for Sales order and corr.AR Invoice Info
Hi,
I need to write a query which gives the flollowing sales order info along with the coressponding AR invoices info
Sales Order columns reqd:
OPERATING_UNIT
ORDER_NUMBER
CUSTOMER_NUM
CUSTOMER_NAME
ORDERED_DATE
FLOW_STATUS_CODE
TOTAL_ORDER_AMOUNT
AR invoice columns reqd for the sales orders:
Invoice number,
Invoice date,
Invoice Total.
Can anyone help me out with this?
Thanks,
AshHi Ash,
There are some issues that must be defined before you have the exact query.
Do you have freight charges or non-inclusive tax? If you have, freight charges and tax amounts must be included?
Depending on you grouping rule, you can have lines from more than one order in a single invoice. In this case, as invoice amount you want the sum of all lines, or only the lines from that order?
Below is an example using two views. It assumes that grouping rules split lines from different order into different invoices.
Hope it helps,
Ketter Ohnes
create or replace view order_summary as
select oh.org_id,
oh.ORDER_NUMBER,
oh.header_id,
ott.name tt_name,
ca.account_number,
p.party_name,
oh.ordered_date,
oh.flow_status_code,
sum(ol.ordered_quantity*ol.unit_selling_price) total,
sum(ol.tax_value) tax,
(select sum(operand)
from OE_PRICE_ADJUSTMENTS_v x
where x.header_id = oh.header_id
and x.adjustment_type_code='FREIGHT_CHARGE') freight_charge
from oe_order_headers_all oh,
oe_order_lines_all ol,
hz_cust_accounts ca,
hz_parties p,
oe_transaction_types_tl ott
where ol.header_id=oh.header_id
and oh.sold_to_org_id = ca.cust_account_id
and ca.party_id = p.party_id
and oh.order_type_id = ott.transaction_type_id
and ott.language =
(select language_code
from fnd_languages
where installed_flag = 'B')
group by oh.org_id,
oh.header_id,
oh.ORDER_NUMBER ,
ott.name,
ca.account_number,
p.party_name,
oh.ordered_date,
oh.flow_status_code;
create or replace view invoice_summary as
select a.interface_header_context,
a.trx_date,
a.trx_number,
b.interface_line_attribute1,
b.interface_line_attribute2 tt_name,
a.customer_trx_id,
sum(b.extended_amount) invoice_total
from ra_customer_trx_all a,
ra_customer_trx_lines_all b
where a.customer_trx_id = b.customer_trx_id
and b.interface_line_context = 'ORDER ENTRY'
and b.line_type in ('LINE','FREIGHT')
group by a.interface_header_context,
a.trx_date, a.trx_number,
b.interface_line_attribute1,
b.interface_line_attribute2,
a.customer_trx_id;
select *
from order_summary o,
invoice_summary i
where o.order_number between :1 and :2
and o.order_number = i.interface_line_attribute1
and o.tt_name = i.tt_name; -
Query for Sales Order and AR Invoice Information
Hi,
I need to write a query which gives the flollowing sales order info along with the coressponding AR invoices info
Sales Order columns reqd:
OPERATING_UNIT
ORDER_NUMBER
CUSTOMER_NUM
CUSTOMER_NAME
ORDERED_DATE
FLOW_STATUS_CODE
TOTAL_ORDER_AMOUNT
AR invoice columns reqd for the sales orders:
Invoice number,
Invoice date,
Invoice Total.
Can anyone help me out with this?
Thanks,
AshHi Ash,
Table RA_CUSTOMER_TRX_ALL can be joined to RA_CUSTOMER_TRX_LINES_ALL table through CUSTOMER_TRX_ID column. The table RA_CUSTOMER_TRX_LINES_ALL.INTERFACE_LINE_ATTRIBUTE6 = OE_ORDER_LINES_ALL.LINE_ID. And from the LineId, you can get the HeaderId os the OE_ORDER_HEADERS_ALL table.
You must have visualized the query by now.
Thanks
Sumit -
Hi Gurus,
I am working on a report where i created a view. This query pulls data from SO,PO,ITEMS,AP and AR tables. The problem I am having is when I add a AP tables or a field from that table some of the Order Numbers are disappearing. Could someone please shed some light this. Here is the query
SELECT DISTINCT trxl.CUSTOMER_TRX_LINE_ID,
pv.vendor_name,
api.invoice_num AP_Invoice_Num,
trx.trx_date AR_Invoice_Date,
trx.trx_number AR_Invoice_Number,
pll.quantity_received,
pll.quantity_billed,
ool.shipped_quantity,
mtlb.segment1 NSN,
poh.closed_date po_close_date,
gl.gl_date
FROM apps.oe_order_headers_all ooh,
apps.oe_order_lines_all ool,
apps.oe_drop_ship_sources odss,
apps.po_headers_all poh,
apps.po_lines_all pol,
apps.po_line_locations_all pll,
apps.po_vendors pv,
inv.mtl_system_items_b mtlb,
ar.Ra_customer_trx_all trx,
ar.ra_customer_trx_lines_all trxl,
ar.hz_parties hzp,
ar.hz_cust_accounts hzc,
ap.ap_invoices_all api,
ap.ap_invoice_lines_all apl,
apps.RA_CUST_TRX_LINE_GL_DIST_ALL gl
WHERE odss.header_id = ooh.header_id
AND odss.line_id = ool.line_id
AND odss.po_header_id = poh.po_header_id
AND odss.po_line_id = pol.po_line_id
AND odss.line_location_id = pll.line_location_id
AND pv.vendor_id = poh.vendor_id
AND mtlb.inventory_item_id = ool.inventory_item_id
AND trxl.customer_trx_id = trx.customer_trx_id
AND trxl.inventory_item_id = mtlb.inventory_item_id
AND hzc.cust_account_id = ooh.sold_to_org_id
AND hzc.party_id = hzp.party_id
AND apl.invoice_id = api.invoice_id
AND apl.po_header_id = poh.po_header_id
AND apl.inventory_item_id = mtlb.inventory_item_id
AND api.vendor_id = poh.vendor_id
AND ool.line_id = trxl.interface_line_attribute6
AND to_char(ooh.order_number)= trx.interface_header_attribute1
AND trxl.CUSTOMER_TRX_LINE_ID = gl.CUSTOMER_TRX_LINE_ID
AND gl.gl_date IS NOT NULL
ORDER BY trxl.CUSTOMER_TRX_LINE_ID DESC;
Really appreciate your help
Thank You,
Edited by: 792011 on Feb 16, 2012 11:43 AM
Edited by: 792011 on Feb 16, 2012 11:44 AMTry this,
1 select col1
2 ,Substr(col1,1,Instr(col1,',')-1)
3 ,Substr(col1,1,Instr(col1,',')-4) || Substr(col1, Instr(col1,',')+1, 3)
4 ,Substr(col1,1,Instr(col1,',')-4) || Substr(col1, -3)
5* from test
NewDev>/
COL1
SUBSTR(COL1,1,INSTR(COL1,',')-1)
SUBSTR(COL1,1,INSTR(COL1,',')-4)||SUBSTR(COL1,INSTR(COL1,',')+1,3)
SUBSTR(COL1,1,INSTR(COL1,',')-4)||SUBSTR(COL1,-3)
200602/48/02/00229,226,223
200602/48/02/00229
200602/48/02/00226
200602/48/02/00223
Shailender -
Hello,
I am working on a implementation project. The legacy system is oracle apps 11.5.10 and new is R12. I have to work on AR Invoice conversion where we have to select all the open invoices and convert them over. Can i get a query for all the open invoices?? Also we are using a DB link can i get a sample code as well?? I am new in oracle apps. Any help is appreciated.
BhargaviHello,
This is the basic query you might be looking for. I have not selected the columns. This is just the condition, you can add the columns by adding the alias name of the table.
FROM ar_payment_schedules_all@R11I_APPS.DBLINK aps,
ra_customer_trx_all@R11I_APPS.DBLINK rct,
ra_cust_trx_types_all@R11I_APPS.DBLINK rctt,
hz_customer_profiles@R11I_APPS.DBLINK hcp,
hz_cust_site_uses_all@R11I_APPS.DBLINK hcsu,
hz_cust_accounts@R11I_APPS.DBLINK rac_bill,
hz_parties@R11I_APPS.DBLINK party,
hz_party_sites@R11I_APPS.DBLINK party_site
,hz_locations@R11I_APPS.DBLINK loc
,hz_cust_acct_sites_all@R11I_APPS.DBLINK acct_site
,(select lgd.customer_trx_id customer_trx_id
,lgd.customer_trx_line_id customer_trx_line_id
,lgd.amount amount
,gcc.segment1 segment1
,gcc.segment3 segment3
from ra_customer_trx_all@R11I_APPS.DBLINK rct,
ra_cust_trx_line_gl_dist_all@R11I_APPS.DBLINK lgd,
gl_code_combinations@R11I_APPS.DBLINK gcc
where
rct.customer_trx_id = lgd.customer_trx_id
and lgd.code_combination_id = gcc.code_combination_id(+)
and lgd.account_class = 'REC') seg
,(select rctla.description description
,rctla.customer_trx_id customer_trx_id
,rctla.customer_trx_line_id customer_trx_line_id
,rctla.vat_tax_id vat_tax_id
,vat.avt_tax_code avt_tax_code
from ra_customer_trx_lines_all@R11I_APPS.DBLINK rctla
,ar_tax_lines_v@R11I_APPS.DBLINK vat
where rctla.line_type = 'LINE'
and rctla.CUSTOMER_TRX_LINE_ID = vat.link_to_cust_trx_line_id
and rctla.line_number =1 ) lines
where rct.customer_trx_id(+) = aps.customer_trx_id
and rctt.cust_trx_type_id = rct.cust_trx_type_id
and rctt.org_id = rct.org_id
and hcp.site_use_id(+) = rct.bill_to_site_use_id
and rct.bill_to_site_use_id = hcsu.site_use_id(+)
and rac_bill.cust_account_id(+) = rct.bill_to_customer_id
and rac_bill.party_id = party.party_id(+)
and party_site.party_site_id = acct_site.party_site_id
and hcsu.cust_acct_site_id = acct_site.cust_acct_site_id
and party.party_id = party_site.party_id
and party_site.location_id = loc.location_id
and rct.customer_trx_id = seg.customer_trx_id
and rct.customer_trx_id = lines.customer_trx_id(+)
and aps.status = 'OP'
and aps.class <> 'PMT'
and edit the db link part according to your custom DB link
Edited by: obiapps on 27-Jan-2012 07:14
Edited by: obiapps on 27-Jan-2012 07:14 -
Hi,
i am getting this error please resolve ..it is great help..
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
The following tags were not closed: AR_INVOICE_PRINTING, LIST_G_AR_INVOICE_PRINTING. Error processing resource 'http://orau...
this is my code ...please resolve i am not figured out wher the error lies...........
<?xml version="1.0" encoding="UTF-8" ?>
- <dataTemplate name="AR_INVOICE_PRINTING" dataSourceRef="test64" version="1.0">
- <parameters>
<parameter name="p_org_id" datatype="number" defaultvalue="" />
<parameter name="p_invoice_type" datatype="varchar2" defaultvalue="" />
<parameter name="p_FROM_date" datatype="varchar2" defaultvalue="" />
<parameter name="p_to_date" datatype="varchar2" defaultvalue="" />
<parameter name="p_invoice_number_from" datatype="number" defaultvalue="" />
<parameter name="p_invoice_number_to" datatype="number" defaultvalue="" />
<parameter name="p_customer_number_from" datatype="number" defaultvalue="" />
<parameter name="p_authorized_dealer" datatype="varchar2" defaultvalue="" />
</parameters>
- <DATAQUERY>
- <sqlStatement name="Q_OPERATING_UNIT_ADD">
- <![CDATA[
/*SELECT po.profile_option_name nme , po.user_profile_option_name , pov.profile_option_value VALUE , fnd_global.resp_id , org_add.name operating_unit_name , org_add.address_line_1||' '||org_add.address_line_2||' '||org_add.address_line_3||' '||loc_information14||', '||loc_information15||', '||loc_information16||', '||postal_code operating_unit_address FROM fnd_profile_options_vl po , fnd_profile_option_values pov , fnd_user usr , fnd_application app , fnd_responsibility rsp , fnd_nodes svr , hr_operating_units org , hr_organization_units_v org_add WHERE 1 = 1 AND po.profile_option_name in ('ORG_ID', 'DEFAULT_ORG_ID') AND pov.application_id = po.application_id AND pov.profile_option_id = po.profile_option_id AND usr.user_id
= pov.level_value AND rsp.application_id
= pov.level_value_application_id AND rsp.responsibility_id
= pov.level_value AND app.application_id
= pov.level_value AND svr.node_id
= pov.level_value AND org.organization_id
= pov.level_value AND rsp.responsibility_id = fnd_global.resp_id AND TO_NUMBER(pov.profile_option_value) = org_add.organization_id ORDER BY nme, pov.level_id, value*/ SELECT name organization_name , organization_id , address_line_1||' '||address_line_2||' '||address_line_3||' '||loc_information15||' '||postal_code||' '||loc_information16 operating_unit_address FROM hr_organization_units_v org_add WHERE 1 = 1 AND organization_id = :p_org_id
]]>
</sqlStatement>
- <sqlStatement name="Q_MAILING_ADDRESS">
- <![CDATA[
SELECT po.profile_option_name nme , po.user_profile_option_name , fnd_global.resp_id , pov.profile_option_value business_grp_id , org_add.name business_group , org_add.address_line_1||' '||org_add.address_line_2||' '||org_add.address_line_3||' '||loc_information14||DECODE(loc_information14, NULL, '',', ')||loc_information15||DECODE(loc_information15, NULL, '',', ')||loc_information16||DECODE(loc_information16, NULL, '',', ')||postal_code business_grp_address FROM fnd_profile_options_vl po , fnd_profile_option_values pov , fnd_user usr , fnd_application app , fnd_responsibility rsp , fnd_nodes svr , hr_operating_units org , hr_organization_units_v org_add WHERE 1 = 1 AND po.profile_option_name = 'PER_BUSINESS_GROUP_ID' AND pov.application_id = po.application_id AND pov.profile_option_id = po.profile_option_id AND usr.user_id
= pov.level_value AND app.application_id
= pov.level_value AND rsp.application_id
= pov.level_value_application_id AND rsp.responsibility_id
= pov.level_value AND svr.node_id
= pov.level_value AND org.organization_id
= pov.level_value AND rsp.responsibility_id = fnd_global.resp_id AND TO_NUMBER(pov.profile_option_value) = org_add.organization_id ORDER BY NME, pov.level_id, business_grp_id
]]>
</sqlStatement>
- <sqlStatement name="Q_AUTHORIZED_DEALER">
- <![CDATA[
SELECT meaning FROM fnd_lookups WHERE 1 = 1 AND lookup_type = 'AUTHORIZED_DEALER' AND lookup_code = nvl(:p_authorized_dealer, lookup_code)
]]>
</sqlStatement>
- <sqlStatement name="Q_BANK_ACCOUNT_COUNT">
- <![CDATA[
SELECT COUNT(ceba.bank_account_id)ACCOUNT_COUNT FROM ce_banks_v ceb , ce_bank_branches_v cebb , ce_bank_accounts ceba WHERE 1 = 1 AND ceb.bank_party_id = cebb.bank_party_id AND ceb.bank_party_id = ceba.bank_id AND ceba.bank_branch_id = cebb.branch_party_id AND ceb.bank_party_id = :p_bank_id HAVING COUNT(ceba.bank_account_id) > 1 GROUP BY ceb.bank_party_id
]]>
</sqlStatement>
- <sqlStatement name="Q1">
- <![CDATA[
SELECT inv.inv_number as main_invoice_number , inv.previous_invoice_number , inv.org_id as inv_org_id , inv.org_country , inv.organization_name , inv.legal_entity_name , inv.trx_date , inv.invoice_currency_code , inv.project_name , inv.project_number , inv.invoice_class , inv.term , inv.ie_code , inv.purchase_order , inv.customer_name , inv.location , inv.address1 , inv.address2 , inv.address3 , inv.address4 , inv.city , inv.postal_code , inv.state , inv.country , inv.bill_to_address , inv.item , inv.text , inv.unit_of_measure , inv.quantity , inv.bill_rate , inv.bill_amount , inv.SOW , inv.msa , inv.ar_balance_due , inv.payments_credits , inv.balance , inv.line_number , inv.line_num , inv.event_num FROM ( SELECT DISTINCT ra.trx_number inv_number , ra1.trx_number previous_invoice_number , ra.org_id , ou_add.country org_country , org.name organization_name , leg_ent.name legal_entity_name , to_char(ra.trx_date, 'MM/DD/YYYY') trx_date , ra.invoice_currency_code , pa.name project_name , pa.segment1 project_number , decode(nvl(pa1.draft_invoice_num_credited, 0), 0, 'INVOICE', 'CREDIT_MEMO') invoice_class , trm.name term , '0405000910/11.4.05' ie_code , agr.customer_order_number purchase_order , hp.party_name customer_name , cust_site.location , hz_loc.address1 , hz_loc.address2 , hz_loc.address3 , hz_loc.address4 , hz_loc.city , hz_loc.postal_code , hz_loc.state , DECODE(hz_loc.country, 'IN','India',hz_loc.country) country , hz_loc.address1||' '||hz_loc.address2||' '||hz_loc.address3||' '||hz_loc.address4||DECODE(hz_loc.address4, NULL, '',', ')||hz_loc.city||', '||hz_loc.postal_code||', '||hz_loc.state||', '||DECODE(hz_loc.country, 'IN','India',hz_loc.country) bill_to_address , '' item , NVL( item.translated_text , NVL( decode (pa_line_dtl.system_linkage_m, 'Usages', lbr_res.description) , decode ( decode( (select 1 from pa_invoice_formats where name like '%Employee%' and invoice_format_id =inv_format .invoice_format_id) , 1 , 1 , (select 2 from pa_invoice_formats where name like '%Job%' and invoice_format_id =inv_format .invoice_format_id) , 2 , 2 , 0 ) , 1 , nvl( (select full_name from per_people_f where full_name like ltrim(rtrim(substr(item.text,1,21)))||'%' and rownum = 1), item.text) , 2 , substr(item.text,1,25) , item.text ) )) text , pa_line_dtl.unit_of_measure_m unit_of_measure , decode(pa_line_dtl.unit_of_measure_m, 'Currency', null, qty.quantity) quantity , pa_line_dtl.bill_rate bill_rate --, brate.bill_rate bill_rate , decode( pa_line_dtl.bill_rate, null, item.inv_amount , qty.quantity * pa_line_dtl.bill_rate ) bill_amount , ra.interface_header_attribute3||' '||agr.start_date SOW , agr.attribute1 msa , ar.amount_due_remaining ar_balance_due , nvl(ar.amount_applied,to_number(0)) - nvl(ar.amount_credited,to_number(0)) + nvl(ar.discount_taken_earned,to_number(0)) + nvl(ar.discount_taken_unearned,to_number(0)) - (nvl(ar.amount_adjusted,to_number(0)) - nvl(ar.receivables_charges_charged,to_number(0))) payments_credits /*, to_char(nvl(ar.amount_applied,to_number(0)) - nvl(ar.amount_credited,to_number(0)) + nvl(ar.discount_taken_earned,to_number(0)) + nvl(ar.discount_taken_unearned,to_number(0)) - (nvl(ar.amount_adjusted,to_number(0)) - nvl(ar.receivables_charges_charged,to_number(0))) , fnd_currency.get_format_mask(ra.invoice_currency_code,40)) payments_credits */ , ABS(nvl(rec.amount,0) + nvl(ar.amount_credited,0) + nvl(amount_adjusted,0) + nvl( discount_original, 0)) balance , ra_lines.line_number , item.line_num , item.event_num FROM ra_customer_trx_lines_all ra_lines , ra_customer_trx_all ra , ra_customer_trx_all ra1 , hr_organization_units_v ou_add , xle_entity_profiles leg_ent --, ra_customer_trx_lines_all ra_lines1 , ra_terms_tl trm , hz_cust_accounts hca , hz_parties hp , ar_payment_schedules_all ar , ar_cash_receipts_all rec , hz_cust_site_uses_all cust_site , hz_cust_acct_sites_all acct_site , hz_party_sites party_site , hz_locations hz_loc , hr_operating_units org , pa_projects_all pa , pa_draft_invoices_all pa1 , pa_draft_invoice_items item , pa_draft_inv_line_details_v pa_line_dtl , pa_agreements agr , pa_non_labor_resources lbr_res , (SELECT SUM(dtl.quantity) quantity , draft_invoice_item_line_num , project_id , draft_invoice_num FROM pa_draft_inv_line_details_v dtl GROUP BY draft_invoice_item_line_num, project_id, draft_invoice_num ) qty /*, (SELECT SUM(dtl.bill_rate) bill_rate , draft_invoice_item_line_num , project_id , draft_invoice_num FROM pa_draft_inv_line_details_v dtl GROUP BY draft_invoice_item_line_num, project_id, draft_invoice_num ) brate */ , (SELECT pa.name project_name , pa.project_id , pif.invoice_format_id , pif.invoice_group_id , pif.name invoice_format , pifd.invoice_format_detail_id , pifd.invoice_group_column_id , pigc.name Invoice_column_group , pigc.column_code FROM pa_invoice_formats pif , pa_invoice_format_details pifd , pa_invoice_group_columns pigc , pa_projects_all pa WHERE 1 = 1 AND pif.invoice_format_id = pifd.invoice_format_id AND pif.invoice_group_id = pigc.invoice_group_id AND pigc.invoice_group_column_id = pifd.invoice_group_column_id AND pa.labor_invoice_format_id = pif.invoice_format_id )inv_format WHERE 1 = 1 AND ra.batch_source_id IN (20, 21) AND ra.interface_header_context IN ('PROJECTS INVOICES', 'PA Internal Invoices') AND ra_lines.interface_line_context IN ('PROJECTS INVOICES', 'PA Internal Invoices') AND ra_lines.customer_trx_id = ra.customer_trx_id AND ra.customer_trx_id BETWEEN nvl(:p_invoice_number_from, ra.customer_trx_id) AND nvl(:p_invoice_number_to, ra.customer_trx_id) AND ra.trx_date BETWEEN nvl(to_date(:p_FROM_date, 'YYYY/MM/DD HH24:MI:SS'), ra.trx_date) AND nvl(to_date(:p_to_date, 'YYYY/MM/DD HH24:MI:SS'), ra.trx_date) AND ra.org_id = ou_add.organization_id AND ra.legal_entity_id = leg_ent.legal_entity_id AND ra.previous_customer_trx_id = ra1.customer_trx_id(+) AND ra.term_id = trm.term_id(+) AND ra.bill_to_customer_id = hca.cust_account_id AND hca.party_id = hp.party_id AND ra.customer_trx_id = ar.customer_trx_id(+) AND ra.interface_header_attribute3 = agr.agreement_num(+) AND ar.cash_receipt_id = rec.cash_receipt_id(+) AND hca.cust_account_id = nvl(:p_customer_number_from, hca.cust_account_id) AND cust_site.site_use_code = 'BILL_TO' AND ra.bill_to_site_use_id = cust_site.site_use_id AND cust_site.cust_acct_site_id = acct_site.cust_acct_site_id AND acct_site.party_site_id = party_site.party_site_id AND party_site.location_id = hz_loc.location_id AND ra.org_id = org.organization_id AND ra.org_id = :p_org_id AND ra_lines.interface_line_attribute1 = pa.segment1(+) AND pa.project_id = inv_format.project_id --AND pa.invoice_group_id = inv_format.invoice_group_id AND pa.labor_invoice_format_id = inv_format.invoice_format_id AND ra.trx_number = pa1.ra_invoice_number AND pa1.org_id = ra.org_id AND pa.project_id = item.project_id AND ra_lines.line_number = item.line_num AND pa1.draft_invoice_num = item.draft_invoice_num AND pa.project_id = pa_line_dtl.project_id AND pa1.draft_invoice_num = pa_line_dtl.draft_invoice_num AND item.line_num= pa_line_dtl.draft_invoice_item_line_num AND pa_line_dtl.non_labor_resource = lbr_res.non_labor_resource(+) AND pa_line_dtl.project_id = qty.project_id AND pa_line_dtl.draft_invoice_item_line_num = qty.draft_invoice_item_line_num AND item.line_num = qty.draft_invoice_item_line_num AND pa1.draft_invoice_num = qty.draft_invoice_num /* AND pa_line_dtl.project_id = brate.project_id AND pa_line_dtl.draft_invoice_item_line_num = brate.draft_invoice_item_line_num AND item.line_num = brate.draft_invoice_item_line_num AND pa1.draft_invoice_num = brate.draft_invoice_num */ UNION SELECT DISTINCT ra.trx_number inv_number , ra1.trx_number previous_invoice_number , ra.org_id , ou_add.country org_country , org.name organization_name , leg_ent.name legal_entity_name , to_char(ra.trx_date, 'MM/DD/YYYY') trx_date , ra.invoice_currency_code , pa.name project_name , pa.segment1 project_number , DECODE(nvl(pa1.draft_invoice_num_credited, 0), 0, 'INVOICE', 'CREDIT_MEMO') invoice_class , trm.name term , '0405000910/11.4.05' ie_code , agr.customer_order_number purchase_order , hp.party_name customer_name , cust_site.location , hz_loc.address1 , hz_loc.address2 , hz_loc.address3 , hz_loc.address4 , hz_loc.city , hz_loc.postal_code , hz_loc.state , DECODE(hz_loc.country, 'IN','India',hz_loc.country) country , hz_loc.address1||' '||hz_loc.address2||' '||hz_loc.address3||' '||hz_loc.address4||DECODE(hz_loc.address4, NULL, '',', ')||hz_loc.city||', '||hz_loc.postal_code||', '||hz_loc.state||', '||DECODE(hz_loc.country, 'IN','India',hz_loc.country) bill_to_address , '' item , nvl( item.translated_text , item.text ) text , eve.attribute3 unit_of_measure , decode(eve.attribute3, 'Currency', null, decode(nvl(pa1.draft_invoice_num_credited, 0), 0,TO_NUMBER(eve.attribute1), (-1*TO_NUMBER(eve.attribute1)))) quantity , TO_NUMBER(eve.attribute2) bill_rate , decode( TO_NUMBER(eve.attribute2) , null , item.inv_amount , decode( eve.attribute3, 'Currency', null , decode(nvl(pa1.draft_invoice_num_credited, 0) , 0, (TO_NUMBER(eve.attribute1) * TO_NUMBER(eve.attribute2) ) , (-1 * TO_NUMBER(eve.attribute1) * TO_NUMBER(eve.attribute2) ) ) ) ) bill_amount , ra.interface_header_attribute3||' '||agr.start_date SOW , agr.attribute1 msa , ar.amount_due_remaining ar_balance_due , nvl(ar.amount_applied,to_number(0)) - nvl(ar.amount_credited,to_number(0)) + nvl(ar.discount_taken_earned,to_number(0)) + nvl(ar.discount_taken_unearned,to_number(0)) - (nvl(ar.amount_adjusted,to_number(0)) - nvl(ar.receivables_charges_charged,to_number(0))) payments_credits /*, to_char(nvl(ar.amount_applied,to_number(0)) - nvl(ar.amount_credited,to_number(0)) + nvl(ar.discount_taken_earned,to_number(0)) + nvl(ar.discount_taken_unearned,to_number(0)) - (nvl(ar.amount_adjusted,to_number(0)) - nvl(ar.receivables_charges_charged,to_number(0))) , fnd_currency.get_format_mask(ra.invoice_currency_code,40)) payments_credits */, ABS(nvl(rec.amount,0) + nvl(ar.amount_credited,0) + nvl(amount_adjusted,0) + nvl( discount_original, 0)) balance , ra_lines.line_number , item.line_num , item.event_num FROM ra_customer_trx_lines_all ra_lines , ra_terms_tl trm , ra_customer_trx_all ra , ra_customer_trx_all ra1 , hr_organization_units_v ou_add , xle_entity_profiles leg_ent , hz_cust_accounts hca , hz_parties hp , ar_payment_schedules_all ar , ar_cash_receipts_all rec -- , mtl_system_items mtl , hz_cust_site_uses_all cust_site , hz_cust_acct_sites_all acct_site , hz_party_sites party_site , hz_locations hz_loc , hr_operating_units org , pa_projects_all pa , pa_agreements agr , pa_events eve , pa_draft_invoice_items item , pa_draft_invoices_all pa1 --, pa_cust_event_rev_dist_lines rev_eve WHERE 1 = 1 AND ra.batch_source_id IN (20, 21) AND ra.interface_header_context IN ('PROJECTS INVOICES', 'PA Internal Invoices') AND ra_lines.interface_line_context IN ('PROJECTS INVOICES', 'PA Internal Invoices') AND ra_lines.customer_trx_id = ra.customer_trx_id AND ra.customer_trx_id BETWEEN nvl(:p_invoice_number_from, ra.customer_trx_id) AND nvl(:p_invoice_number_to, ra.customer_trx_id) AND ra.trx_date BETWEEN nvl(to_date(:p_from_date, 'YYYY/MM/DD HH24:MI:SS'), ra.trx_date) AND nvl(to_date(:p_to_date, 'YYYY/MM/DD HH24:MI:SS'), ra.trx_date) AND ra.org_id = ou_add.organization_id AND ra.legal_entity_id = leg_ent.legal_entity_id AND ra.term_id = trm.term_id(+) AND ra.previous_customer_trx_id = ra1.customer_trx_id(+) AND ra.bill_to_customer_id = hca.cust_account_id AND hca.party_id = hp.party_id AND ra.customer_trx_id = ar.customer_trx_id(+) AND ar.cash_receipt_id = rec.cash_receipt_id(+) --AND ra_lines.inventory_item_id(+) = mtl.inventory_item_id --AND mtl.organization_id = 204 AND hca.cust_account_id = nvl(:p_customer_number_from, hca.cust_account_id) AND cust_site.site_use_code = 'BILL_TO' AND ra.bill_to_site_use_id = cust_site.site_use_id AND cust_site.cust_acct_site_id = acct_site.cust_acct_site_id AND acct_site.party_site_id = party_site.party_site_id AND party_site.location_id = hz_loc.location_id AND ra.org_id = org.organization_id AND ra.org_id = :p_org_id AND ra_lines.interface_line_attribute1 = pa.segment1 AND ra.trx_number = pa1.ra_invoice_number AND pa1.org_id = ra.org_id AND pa1.draft_invoice_num = item.draft_invoice_num --AND agr.attribute_category(+) = 'Additional Attributes' AND ra.interface_header_attribute3 = agr.agreement_num(+) AND pa.project_id = eve.project_id AND pa.project_id = item.project_id AND ra_lines.line_number = item.line_num AND item.event_num = eve.event_num AND nvl(item.event_task_id, -1) = nvl(eve.task_id, -1) ) INV ORDER BY inv.inv_number, inv.line_number, inv.line_num
]]>
</sqlStatement>
- <sqlStatement name="Q_TAX_DETAILS">
- <![CDATA[
SELECT tax.invoice_number1 , tax.tax_total , tax.tax_name FROM ( SELECT DISTINCT ra.trx_number invoice_number1 , ra.customer_trx_id , tax_total.tax_total , tax.TAX_NAME FROM ra_customer_trx_lines_all ra_lines , ra_customer_trx_all ra , hz_cust_accounts hca , hz_parties hp , ar_payment_schedules_all ar , ar_cash_receipts_all rec , hz_cust_site_uses_all cust_site , hz_cust_acct_sites_all acct_site , hz_party_sites party_site , hz_locations hz_loc , hr_operating_units org , (SELECT DISTINCT SUM(tax.tax_amount) tax_total , rac.customer_trx_id , tax_id FROM jai_ar_trx_tax_lines tax , ra_customer_trx_lines_all ral , ra_customer_trx_all rac WHERE 1 = 1 AND tax.customer_trx_line_id(+) = ral.customer_trx_line_id AND ral.customer_trx_id = rac.customer_trx_id AND batch_source_id IN (20, 21) AND interface_header_context IN ('PROJECTS INVOICES', 'PA Internal Invoices') AND interface_line_context IN ('PROJECTS INVOICES', 'PA Internal Invoices') AND rac.trx_number = :main_invoice_number GROUP BY tax_id , rac.customer_trx_id --, ral.customer_trx_line_id, ral.line_number ) tax_total , jai_cmn_taxes_all tax WHERE 1 = 1 AND ra.batch_source_id IN (20, 21) AND ra.interface_header_context IN ('PROJECTS INVOICES', 'PA Internal Invoices') AND ra_lines.interface_line_context IN ('PROJECTS INVOICES', 'PA Internal Invoices') AND ra_lines.customer_trx_id = ra.customer_trx_id --AND ra.customer_trx_id BETWEEN nvl(:p_invoice_number_from, ra.customer_trx_id) AND nvl(:p_invoice_number_to, ra.customer_trx_id) --AND ra.trx_date BETWEEN nvl(to_date(:p_FROM_date, 'YYYY/MM/DD HH24:MI:SS'), ra.trx_date) AND nvl(to_date(:p_to_date, 'YYYY/MM/DD HH24:MI:SS'), ra.trx_date) AND ra.bill_to_customer_id = hca.cust_account_id AND hca.party_id = hp.party_id AND ra.customer_trx_id = ar.customer_trx_id(+) -- AND ra.interface_header_attribute3 = agr.agreement_num(+) AND ar.cash_receipt_id = rec.cash_receipt_id(+) --AND hca.cust_account_id = nvl(:p_customer_number_from, hca.cust_account_id) AND cust_site.site_use_code = 'BILL_TO' AND ra.bill_to_site_use_id = cust_site.site_use_id AND cust_site.cust_acct_site_id = acct_site.cust_acct_site_id AND acct_site.party_site_id = party_site.party_site_id AND party_site.location_id = hz_loc.location_id AND ra.org_id = org.organization_id AND ra.org_id = :p_org_id AND tax_total.customer_trx_id = ra.customer_trx_id AND ra_lines.customer_trx_id = tax_total.customer_trx_id AND tax_total.tax_id = tax.tax_id AND ra.trx_number = :main_invoice_number ) tax WHERE 1 =1 AND tax.invoice_number1 = :main_invoice_number ORDER BY tax.tax_name
]]>
</sqlStatement>
- <sqlStatement name="Q_BANK_DETAILS">
- <![CDATA[
SELECT ceb.bank_name , ceb.bank_party_id , cebb.bank_branch_name , cebb.branch_party_id , ceba.bank_account_id , ceba.bank_account_name , ceba.bank_account_num , ceba.bank_branch_id , ceba.bank_id , fnd_global.org_id FROM ce_banks_v ceb , ce_bank_branches_v cebb , ce_bank_accounts ceba , ce_bank_acct_uses_all cbau WHERE 1 = 1 AND ceb.bank_party_id = cebb.bank_party_id AND ceb.bank_party_id = ceba.bank_id AND ceba.bank_branch_id = cebb.branch_party_id AND ceba.bank_account_id = cbau.bank_account_id AND cbau.org_id = :inv_org_id
]]>
</sqlStatement>
- <sqlStatement name="Q_ORG_NAME">
- <![CDATA[
SELECT name organization_name FROM hr_operating_units org WHERE 1 = 1 AND org.organization_id = :inv_org_id
]]>
</sqlStatement>
</DATAQUERY>
- <!-- <link name="L_1" parentGroup="G_TAX_DETAILS" parentColumn="INVOICE_NUMBER1" childQuery="Q1" childColumn="invoice_number" />condition="eq" sqlClause="where"/>
-->
- <DATASTRUCTURE>
- <GROUP name="G_AR_INVOICE_PRINTING" source="Q1">
<element name="LEGAL_ENTITY_NAME" dataType="VARACHAR2" value="LEGAL_ENTITY_NAME" />
<element name="ORG_COUNTRY" dataType="VARACHAR2" value="ORG_COUNTRY" />
<element name="ADDRESS1" dataType="VARACHAR2" value="ADDRESS1" />
<element name="ADDRESS2" dataType="VARACHAR2" value="ADDRESS2" />
<element name="ADDRESS3" dataType="VARACHAR2" value="ADDRESS3" />
<element name="ADDRESS4" dataType="VARACHAR2" value="ADDRESS4" />
<element name="CITY" dataType="VARACHAR2" value="CITY" />
<element name="POSTAL_CODE" dataType="VARACHAR2" value="POSTAL_CODE" />
<element name="STATE" dataType="VARACHAR2" value="STATE" />
<element name="COUNTRY" dataType="VARACHAR2" value="COUNTRY" />
<element name="BILL_TO_ADDRESS" dataType="VARACHAR2" value="BILL_TO_ADDRESS" />
<element name="TRX_DATE" dataType="DATE" value="TRX_DATE" />
<element name="INV_ORG_ID" dataType="VARACHAR2" value="inv_org_id" />
<element name="ORGANIZATION_NAME" dataType="VARACHAR2" value="organization_name" />
<element name="INVOICE_NUMBER" dataType="VARCHAR2" value="main_invoice_number" />
<element name="INVOICE_CLASS" dataType="VARCHAR2" value="INVOICE_CLASS" />
<element name="PREVIOUS_INVOICE_NUMBER" dataType="NUMBER" value="PREVIOUS_INVOICE_NUMBER" />
<element name="PROJECT_NAME" dataType="VARCHAR2" value="PROJECT_NAME" />
<element name="TERM" dataType="VARCHAR2" value="TERM" />
<element name="IE_CODE" datatype="VARCHAR2" value="IE_CODE" />
<element name="PURCHASE_ORDER" dataType="VARCHAR2" value="PURCHASE_ORDER" />
<element name="CUSTOMER_NAME" dataType="VARCHAR2" value="CUSTOMER_NAME" />
<element name="MSA" dataType="VARCHAR2" value="MSA" />
<element name="SOW" dataType="VARCHAR2" value="SOW" />
<element name="PAYMENTS_CREDITS" dataType="NUMBER" value="PAYMENTS_CREDITS" />
<element name="INVOICE_CURRENCY_CODE" dataType="VARACHAR2" value="INVOICE_CURRENCY_CODE" />
- <GROUP name="G_INVOICE_LINE_DETAILS" source="Q1">
<element name="ITEM" dataType="VARACHAR2" value="ITEM" />
<element name="DESCRIPTION" dataType="VARACHAR2" value="TEXT" />
<element name="UNIT" dataType="NUMBER" value="UNIT_OF_MEASURE" />
<element name="QUANTITY" dataType="NUMBER" value="QUANTITY" />
<element name="RATE" dataType="NUMBER" value="BILL_RATE" />
<element name="AMOUNT" dataType="NUMBER" value="BILL_AMOUNT" />
</GROUP>
- <GROUP name="G_OPERATING_UNIT_ADD" source="Q_OPERATING_UNIT_ADD">
<element name="OPERATING_UNIT_ADDRESS" dataType="VARACHAR2" value="operating_unit_address" />
</GROUP>
- <GROUP name="G_MAILING_ADDRESS" source="Q_MAILING_ADDRESS">
<element name="RESPONSIBILITY_ID" dataType="VARACHAR2" value="RESP_ID" />
<element name="BUSINESS_GROUP" dataType="VARACHAR2" value="business_group" />
<element name="BUSINESS_GROUP_ADDRESS" dataType="VARACHAR2" value="business_grp_address" />
</GROUP>
- <GROUP name="G_AUTHORIZED_DEALER" source="Q_AUTHORIZED_DEALER">
<element name="AUTHORIZED_DEALER" dataType="VARACHAR2" value="meaning" />
</GROUP>
- <GROUP name="G_TAX_DETAILS" source="Q_TAX_DETAILS">
<element name="INVOICE_NUMBER" dataType="VARCHAR2" value="INVOICE_NUMBER1" />
<element name="TAX_NAME" dataType="VARACHAR2" value="TAX_NAME" />
<element name="TAX_TOTAL" dataType="NUMBER" value="TAX_TOTAL" />
</GROUP>
</GROUP>
</DATASTRUCTURE>
</dataTemplate>
thanks,
praveen.Please see if the following docs help.
Warning:The Following Tags Were Not Closed ; Packing Slip XML Report (Doc ID 751641.1)
Cannot Create XML Input Using XSL Style Sheet (Doc ID 559357.1)
Thanks,
Hussein -
Ar Aging Report based on transaction lines
Hi all,
I am trying to write a query to calculate aging report at line level. The user needs a query which calculates the aging value at at line level because the ra_customer_trx_lines_all has attribute1 populated with a value from (A,B,C,D).I need get the aging value for each group(attribute).
select sum(nvl(lines.line_recoverable,0)+nvl(adj.adj_amt,0)-nvl(rec.rec_amt,0)),lines.attribute1
from ra_customer_trx_lines_all lines,
(select CUSTOMER_TRX_LINE_ID trx_line,
sum(amount) adj_amt
from ar_adjustments_all
where status = 'A'
group by CUSTOMER_TRX_LINE_ID) adj
,(select REF_CUSTOMER_TRX_LINE_ID trx_line,
sum(nvl(amount_cr,0))-sum(nvl(amount_dr,0)) rec_amt
from ar_distributions_all
where source_table='RA'
and source_type='REC'
group by ref_customer_trx_line_id) rec
where lines.CUSTOMER_TRX_LINE_ID=adj.trx_line(+)
and lines.CUSTOMER_TRX_LINE_ID=rec.trx_line(+)
and lines.customer_trx_line_id in ('18293')
group by lines.attribute1
Also I dint yet add the as of date parameter.I suppose the tables have to change in that case.Can any one help me with that tooo.
The above query kinda generated the value I was looking for.But when I ran the query for just a few more lines included.The query took forever to run.
Can you please help me on this ASAP.
Thanks for all your tips in advance.
Mach
Edited by: krismach_85 on Oct 27, 2009 8:38 AMHi,
You can run the Transaction Register report for specific Transaction reason/ a range and see the related material transactions.
Karthik. -
Convert oracle cursor statements along with validations to XML
Hi Gurus/Odie,
I've one current in pl/sql report which is generating output as text format, but users are expecting to see the same output in excel format. In oracle apps we can generate XML tags and those tags can be produced to template so as to generate them in excel file.
My current procedure as shown below.Currently it is displaying output in one line concatenating all the data. But i want keep the same logic like that and change into xml tags. How can we do that. Please provide me your valueable inputs in this regard.
CREATE OR REPLACE PROCEDURE APPS.ACCTALS (
errbuf OUT VARCHAR2,
retcode OUT NUMBER,
p_st_date IN VARCHAR2,
p_end_date IN VARCHAR2,
p_set_of_book IN NUMBER,
p_chart_of_acnt IN NUMBER,
p_min_flex IN VARCHAR2,
p_max_flex IN VARCHAR2,
p_transaction_type IN VARCHAR2
IS
TYPE flex_tbl_type IS TABLE OF VARCHAR2 (10)
INDEX BY BINARY_INTEGER;
CURSOR c_acct (
p_period_num_low NUMBER,
p_period_num_high NUMBER,
p_min_flex_tbl flex_tbl_type,
p_max_flex_tbl flex_tbl_type
IS
SELECT gjh.period_name period_name,
sat.user_je_source_name SOURCE,
cat.user_je_category_name CATEGORY,gjb.NAME batch_name,
gjh.NAME journal_name, gcc.segment1, gcc.segment2, gcc.segment3,
gcc.segment4, gcc.segment5, gcc.segment6, gcc.segment7,
gcc.segment8, gjl.je_line_num,
gjl.description je_line_description, gjl.reference_1 party_name,
(SELECT pv.segment1
FROM ap_invoices_all aia, po_vendors pv
WHERE aia.invoice_id =TO_NUMBER(DECODE(NVL(LENGTH(LTRIM (TRANSLATE (gjl.reference_2,'1234567890','3'),'3')),0),0, TO_NUMBER (gjl.reference_2),-999))
AND pv.vendor_id = aia.vendor_id) party_number,
NULL trx_number, -- invoice_num,
NULL trx_line_number, -- invoice_line_num,
CASE
WHEN gjh.je_category = 'Purchase Invoices'
THEN (SELECT pha.segment1
FROM apps.ap_invoice_distributions_all aid,
apps.po_headers_all pha,
apps.po_lines_all pla,
apps.po_distributions_all pda
WHERE aid.po_distribution_id =
pda.po_distribution_id
AND pda.po_line_id = pla.po_line_id
AND pla.po_header_id = pha.po_header_id
AND aid.invoice_id = TO_NUMBER (gjl.reference_2)
AND aid.distribution_line_number =
TO_NUMBER (gjl.reference_3))
ELSE ''
END po_number,
CASE
WHEN gjh.je_category = 'Purchase Invoices'
AND gjl.reference_3 IS NOT NULL
THEN (SELECT pla.line_num
FROM apps.ap_invoice_distributions_all aid,
apps.po_headers_all pha,
apps.po_lines_all pla,
apps.po_distributions_all pda
WHERE aid.po_distribution_id =
pda.po_distribution_id
AND pda.po_line_id = pla.po_line_id
AND pla.po_header_id = pha.po_header_id
AND aid.invoice_id = TO_NUMBER (gjl.reference_2)
AND aid.distribution_line_number =
TO_NUMBER (gjl.reference_3))
ELSE TO_NUMBER ('')
END po_line,
CASE
WHEN gjh.je_category = 'Purchase Invoices'
AND gjl.reference_3 IS NOT NULL
THEN (SELECT mc.segment1
FROM apps.ap_invoice_distributions_all aid,
apps.po_headers_all pha,
apps.po_lines_all pla,
apps.po_distributions_all pda,
apps.mtl_categories mc
WHERE aid.po_distribution_id =
pda.po_distribution_id
AND pda.po_line_id = pla.po_line_id
AND mc.category_id = pla.category_id
AND pla.po_header_id = pha.po_header_id
AND aid.invoice_id = TO_NUMBER (gjl.reference_2)
AND aid.distribution_line_number =
TO_NUMBER (gjl.reference_3))
ELSE ''
END po_category,
gjl.accounted_dr debit, gjl.accounted_cr credit,
NVL (gjl.accounted_dr, 0) - NVL (gjl.accounted_cr, 0)
net_amount,
-- Added by Murali for bug 10405
gjh.currency_code entered_currency,
gjl.entered_dr entered_debit, gjl.entered_cr entered_credit,
NVL (gjl.entered_dr, 0)
- NVL (gjl.entered_cr, 0) net_entered_amount,
gjl.attribute1 bank_account_number,
gjl.attribute2 bank_account_name,
gjl.attribute3 it2_nl_posting_ref,
gjl.attribute4 bank_transaction_date,
gjl.attribute5 it2_transaction_number,
gjl.attribute6 funds_subtype_name,
CASE
WHEN gjh.je_category = 'Purchase Invoices'
THEN
CASE
WHEN (SELECT NVL (aid.po_distribution_id,-999)
FROM ap_invoice_distributions_all aid
WHERE aid.invoice_id =TO_NUMBER (gjl.reference_2)
AND aid.distribution_line_number =
TO_NUMBER (gjl.reference_3)) =
-999
THEN
(SELECT aia.attribute5
FROM apps.ap_invoices_all aia
WHERE aia.invoice_id =
TO_NUMBER(DECODE(NVL(LENGTH(LTRIM(TRANSLATE(gjl.reference_2,'1234567890','3'),'3')),0),0, TO_NUMBER(gjl.reference_2),-999))
AND ROWNUM = 1)
ELSE
--For PO Matched Invoice ,Pickup Proj code from PO header project DFF
(SELECT pha.attribute1
FROM apps.ap_invoice_distributions_all aid,
apps.po_headers_all pha,
apps.po_lines_all pla,
apps.po_distributions_all pda
WHERE aid.po_distribution_id = pda.po_distribution_id
AND pda.po_line_id = pla.po_line_id
AND pla.po_header_id = pha.po_header_id
AND aid.invoice_id = TO_NUMBER (gjl.reference_2)
AND aid.distribution_line_number =
TO_NUMBER (gjl.reference_3)
AND ROWNUM = 1)
END
ELSE
-- Invoice (Header) is not PO-Matched, so pickup Proj Code from invoice DFF --CHG0030444
(SELECT aia.attribute5
FROM apps.ap_invoices_all aia
WHERE aia.invoice_id =TO_NUMBER(DECODE(NVL(LENGTH(LTRIM (TRANSLATE (gjl.reference_2,'1234567890','3'),'3')),0),0, TO_NUMBER (gjl.reference_2),-999))
AND ROWNUM = 1)
END proj_code,
gjh.posted_date post_date, gjl.effective_date gl_date,
DECODE (gjh.je_category,
'Purchase Invoices', 'AP Invoice',
'Payments', 'AP Payment'
) transaction_class,
gjl.reference_3, gjl.reference_4, gjl.reference_5,
gjl.reference_1, gjl.reference_7,
gjl.attribute7, gjl.attribute8,
gjl.attribute9
FROM apps.gl_code_combinations gcc,
apps.gl_je_lines gjl,
apps.gl_je_headers gjh,
apps.gl_je_batches gjb,
apps.gl_period_statuses per,
apps.gl_je_categories_tl cat, -- Added by Murali for Bug 10405
apps.gl_je_sources_tl sat -- Added by Murali for Bug 10405
WHERE gcc.segment1 >= p_min_flex_tbl (1)
AND gcc.segment1 <= p_max_flex_tbl (1)
AND gcc.segment2 >= p_min_flex_tbl (2)
AND gcc.segment2 <= p_max_flex_tbl (2)
AND gcc.segment3 >= p_min_flex_tbl (3)
AND gcc.segment3 <= p_max_flex_tbl (3)
AND gcc.segment4 >= p_min_flex_tbl (4)
AND gcc.segment4 <= p_max_flex_tbl (4)
AND gcc.segment5 >= p_min_flex_tbl (5)
AND gcc.segment5 <= p_max_flex_tbl (5)
AND gcc.segment6 >= p_min_flex_tbl (6)
AND gcc.segment6 <= p_max_flex_tbl (6)
AND gjl.set_of_books_id = NVL (p_set_of_book, 1001)
AND per.effective_period_num BETWEEN p_period_num_low
AND p_period_num_high
AND gjl.code_combination_id = gcc.code_combination_id
AND gjl.status || '' = 'P'
AND gjb.average_journal_flag = 'N'
AND gjh.actual_flag =
DECODE (p_transaction_type,
'Actual', 'A',
'Budget', 'B',
gjh.actual_flag
AND gjh.je_header_id = gjl.je_header_id
AND gjb.je_batch_id = gjh.je_batch_id
AND per.application_id = 101
AND per.set_of_books_id = gjl.set_of_books_id
AND per.period_name = gjl.period_name
AND gjh.period_name = gjl.period_name
AND per.period_name = gjb.default_period_name
AND gjb.set_of_books_id = per.set_of_books_id
AND gjh.je_source = 'Payables'
AND cat.je_category_name = gjh.je_category
AND cat.LANGUAGE = 'US'
AND sat.je_source_name = gjh.je_source
AND sat.LANGUAGE = 'US'
main_rec c_acct%ROWTYPE;
l_min_flex_tbl flex_tbl_type;
l_max_flex_tbl flex_tbl_type;
l_min_flex VARCHAR2 (100);
l_max_flex VARCHAR2 (100);
min_flex_count NUMBER;
max_flex_count NUMBER;
i NUMBER;
v_display_str VARCHAR2 (1000);
v_header_str VARCHAR2 (1000);
l_proj_code VARCHAR2 (240);
rf_period_cur sys_refcursor;
l_period_num_low NUMBER := '';
l_period_num_high NUMBER := '';
-- l_vendor_name varchar2(1000);
l_party_name VARCHAR2 (1000);
l_party_number VARCHAR2 (1000);
l_trx_number VARCHAR2 (1000);
l_trx_line_number VARCHAR2 (50);
--Added by Bharat.K for CHG0035496
l_contract_number VARCHAR2 (30);
l_contract_modified VARCHAR2 (30);
l_order_number VARCHAR2 (30);
l_statement_date VARCHAR2 (30);
l_billed_from VARCHAR2 (30);
l_billed_to VARCHAR2 (30);
l_start_date VARCHAR2 (30);
l_reference_number VARCHAR2 (30);
BEGIN
fnd_file.put_line (fnd_file.LOG, 'set of book id: ' || p_set_of_book);
l_min_flex := p_min_flex;
i := 1;
LOOP
IF INSTR (l_min_flex, '-') = 0
THEN
EXIT;
END IF;
l_min_flex_tbl (i) := SUBSTR (l_min_flex, 1, INSTR (l_min_flex, '-') - 1);
l_min_flex :=SUBSTR (l_min_flex,INSTR (l_min_flex, '-') + 1,LENGTH (l_min_flex) - INSTR (l_min_flex, '-'));
i := i + 1;
END LOOP;
l_min_flex_tbl (i) := l_min_flex;
min_flex_count := i;
l_max_flex := p_max_flex;
i := 1;
LOOP
IF INSTR (l_max_flex, '-') = 0
THEN
EXIT;
END IF;
l_max_flex_tbl (i) := SUBSTR (l_max_flex, 1, INSTR (l_max_flex, '-') - 1);
l_max_flex :=SUBSTR (l_max_flex,INSTR (l_max_flex, '-') + 1,LENGTH (l_max_flex) - INSTR (l_max_flex, '-'));
i := i + 1;
END LOOP;
l_max_flex_tbl (i) := l_max_flex;
max_flex_count := i;
v_header_str := '';
v_header_str :=
'Period'|| '^'|| 'Source'|| '^'|| 'Category'|| '^'|| 'Batch Name'|| '^'|| 'Journal Name'|| '^'|| 'Company'|| '^'|| 'IBX'|| '^'|| 'Dept'|| '^'|| 'Account'
|| '^'|| 'Intercompany'|| '^'|| 'Product'|| '^'|| 'Future2'|| '^'|| 'Future3'|| '^'|| 'JE Line Num'|| '^'|| 'Description'|| '^'|| 'GL Date'|| '^'|| 'GL Post Date'
|| '^'|| 'Party Name'|| '^'|| 'Party Number'|| '^'|| 'Transaction Class'|| '^'|| 'Transaction Number'|| '^'|| 'Transaction Line Number' --bug#9819
|| '^'|| 'PO Number'|| '^'|| 'PO Line Num'|| '^'|| 'PO Category'|| '^'|| 'Project Code'|| '^'|| 'Converted Debit'|| '^'|| 'Converted Credit'
|| '^'|| 'Converted Net Amount (Dr - Cr)'|| '^'|| 'Entered Currency'|| '^'|| 'Entered Debit'|| '^'|| 'Entered Credit'|| '^'
|| 'Entered Net Amount (Dr - Cr)'|| '^'|| 'BANK ACCOUNT NUMBER'|| '^'|| 'BANK ACCOUNT NAME'|| '^'
|| 'IT2 NL POSTING REF'|| '^'|| 'BANK TRANSACTION DATE'|| '^'|| 'IT2 TRANSACTION NUMBER'|| '^'|| 'FUNDS SUBTYPE NAME'|| '^'
|| 'PCard Merchant Name'|| '^'|| 'PCard Posting Date'|| '^'|| 'PCard Transaction Date'|| '^'|| 'Contract Number'
|| '^'|| 'Contract Modified Number'|| '^'|| 'Order Number'|| '^'|| 'Statement Date'|| '^'|| 'Billed From'
|| '^'|| 'Billed To'|| '^'|| 'Start Date'|| '^'|| 'Reference Number';
fnd_file.put_line (fnd_file.output, v_header_str);
fnd_file.put_line (fnd_file.LOG, 'get effective period number');
OPEN rf_period_cur FOR
SELECT MIN (effective_period_num), MAX (effective_period_num)
FROM gl_period_statuses
WHERE start_date >= fnd_date.canonical_to_date (p_st_date)
AND end_date <= fnd_date.canonical_to_date (p_end_date)
AND set_of_books_id = p_set_of_book
AND application_id = 101;
FETCH rf_period_cur
INTO l_period_num_low, l_period_num_high;
CLOSE rf_period_cur;
IF l_period_num_low IS NOT NULL AND l_period_num_high IS NOT NULL
THEN
fnd_file.put_line (fnd_file.LOG,'effective period number low: '|| l_period_num_low|| ' period number high: '|| l_period_num_high);
i := 0;
OPEN c_acct (l_period_num_low,l_period_num_high,l_min_flex_tbl,l_max_flex_tbl);
LOOP
FETCH c_acct
INTO main_rec;
EXIT WHEN c_acct%NOTFOUND;
l_contract_number := NULL;
l_contract_modified := NULL;
l_order_number := NULL;
l_statement_date := NULL;
l_billed_from := NULL;
l_billed_to := NULL;
l_start_date := NULL;
l_reference_number := NULL;
--Do All the Processing for customer number and customer name--bug#9819
IF main_rec.CATEGORY = 'Adjustment'
THEN
BEGIN
SELECT hp.party_name, rc.account_number
INTO l_party_name, l_party_number
FROM ar_adjustments_all adj,
ra_customer_trx_all trx,
-- ra_customers rc
hz_cust_accounts rc,
hz_parties hp
WHERE adj.customer_trx_id = trx.customer_trx_id
AND trx.bill_to_customer_id = rc.cust_account_id
AND rc.party_id = hp.party_id
AND trx.set_of_books_id = NVL (p_set_of_book, 1001)
AND adj.adjustment_number = main_rec.reference_5;
EXCEPTION
WHEN OTHERS
THEN
l_party_name := NULL;
l_party_number := NULL;
END;
ELSIF main_rec.SOURCE = 'Payables'
THEN
l_party_name := main_rec.reference_1;
BEGIN
SELECT segment1
INTO l_party_number
FROM po_vendors
WHERE UPPER (vendor_name) = UPPER (l_party_name);
EXCEPTION
WHEN OTHERS
THEN
l_party_number := NULL;
END;
ELSIF main_rec.CATEGORY = 'Payments'
THEN
BEGIN
SELECT pv.vendor_name, pv.segment1
INTO l_party_name, l_party_number
FROM ap_checks_all ac, po_vendors pv
WHERE pv.vendor_id = ac.vendor_id
AND ac.check_id = main_rec.reference_3;
EXCEPTION
WHEN OTHERS
THEN
l_party_name := NULL;
l_party_number := NULL;
END;
-- Commented End for Bug 10405
ELSIF ( main_rec.CATEGORY = 'Debit Memos'
OR main_rec.CATEGORY = 'Credit Memos'
OR main_rec.CATEGORY = 'Sales Invoices'
THEN
BEGIN
SELECT hp.party_name, rc.account_number
INTO l_party_name, l_party_number
FROM apps.ra_cust_trx_line_gl_dist_all dist,
-- apps.ra_customer_trx_lines_all line,
apps.ra_customer_trx_all trx,
-- apps.ra_customers rc
apps.hz_cust_accounts rc,
hz_parties hp -- /*bug#7534 */
WHERE cust_trx_line_gl_dist_id = main_rec.reference_3
--and dist.CUSTOMER_TRX_LINE_ID=line.CUSTOMER_TRX_LINE_ID
AND trx.customer_trx_id = dist.customer_trx_id
AND trx.bill_to_customer_id = rc.cust_account_id
AND rc.party_id = hp.party_id
AND trx.set_of_books_id = NVL (p_set_of_book, 1001);
EXCEPTION
WHEN OTHERS
THEN
l_party_name := NULL;
l_party_number := NULL;
l_reference_number := NULL;
END;
ELSIF ( main_rec.CATEGORY = 'Misc Receipts'
OR main_rec.CATEGORY = 'Trade Receipts'
THEN
BEGIN
SELECT hp.party_name, hca.account_number
INTO l_party_name, l_party_number
FROM hz_parties hp, hz_cust_accounts hca
WHERE hp.party_id = hca.party_id
AND hca.cust_account_id = main_rec.reference_7;
EXCEPTION
WHEN OTHERS
THEN
l_party_name := NULL;
l_party_number := NULL;
END;
ELSE
l_party_name := main_rec.party_name;
l_party_number := main_rec.party_number;
l_reference_number := NULL;
END IF;
IF main_rec.SOURCE = 'Receivables' THEN
IF ( main_rec.CATEGORY = 'Debit Memos'
OR main_rec.CATEGORY = 'Credit Memos'
OR main_rec.CATEGORY = 'Sales Invoices'
THEN
BEGIN
SELECT DECODE (line.interface_line_context,
'OKS CONTRACTS', line.interface_line_attribute1, 'EQIX METERED POWER',line.interface_line_attribute3,
NULL
) contract_number,
DECODE (line.interface_line_context,
'OKS CONTRACTS', line.interface_line_attribute2,
NULL
) contract_modified,
DECODE (line.interface_line_context,
'ORDER ENTRY', line.interface_line_attribute1,
NULL
) order#,
(SELECT aci.cut_off_date
FROM apps.ar_cons_inv_all aci,
(SELECT DISTINCT customer_trx_id, cons_inv_id
FROM apps.ar_cons_inv_trx_lines_all) acit
WHERE aci.cons_inv_id = acit.cons_inv_id
AND dist.customer_trx_id = acit.customer_trx_id)
statement_date,
CASE line.interface_line_context
when 'OKS CONTRACTS' then
TO_CHAR
(TO_DATE (line.interface_line_attribute4,'YYYY/MM/DD' ),
'DD-MON-YYYY')
when 'EQIX METERED POWER' then line.interface_line_attribute4
else null
end as billed_from,
CASE line.interface_line_context
when 'OKS CONTRACTS' then
TO_CHAR
(TO_DATE (line.interface_line_attribute5,'YYYY/MM/DD' ),
'DD-MON-YYYY')
when 'EQIX METERED POWER' then line.interface_line_attribute5
else null
end as billed_to,
TO_CHAR(TO_DATE (DECODE (line.interface_line_context, 'OKS CONTRACTS', line.interface_line_attribute8, NULL ),'YYYY/MM/DD'),'DD-MON-YYYY') start_date
INTO l_contract_number,
l_contract_modified,
l_order_number,
l_statement_date,
l_billed_from,
l_billed_to,
l_start_date
FROM
apps.ra_customer_trx_all trx,
ra_customer_trx_lines_all line,
apps.ra_cust_trx_line_gl_dist_all dist,
apps.hz_cust_accounts rc,
hz_parties hp
WHERE cust_trx_line_gl_dist_id = main_rec.reference_3
AND trx.customer_trx_id = line.customer_trx_id
AND dist.customer_trx_line_id=line.customer_trx_line_id
AND trx.bill_to_customer_id = rc.cust_account_id
AND rc.party_id = hp.party_id
AND trx.set_of_books_id = NVL (p_set_of_book, 1001)
AND line.line_type = 'LINE';
EXCEPTION
WHEN OTHERS
THEN
l_contract_number := NULL;
l_contract_modified := NULL;
l_order_number := NULL;
l_statement_date := NULL;
l_billed_from := NULL;
l_billed_to := NULL;
l_start_date := NULL;
END;
END IF;
END IF;
--do processing to get line number , trx_number
IF ( main_rec.CATEGORY = 'Debit Memos'
OR main_rec.CATEGORY = 'Credit Memos'
OR main_rec.CATEGORY = 'Sales Invoices'
THEN
BEGIN
SELECT TO_CHAR (line_number), line.interface_line_attribute1
INTO l_trx_line_number, l_reference_number
FROM ra_cust_trx_line_gl_dist_all dist,
ra_customer_trx_lines_all line,
ra_customer_trx_all trx
WHERE cust_trx_line_gl_dist_id = main_rec.reference_3
AND dist.customer_trx_line_id = line.customer_trx_line_id
AND trx.customer_trx_id = line.customer_trx_id;
EXCEPTION
WHEN OTHERS
THEN
l_trx_line_number := NULL;
END;
l_trx_number := main_rec.reference_4;
ELSIF ( main_rec.CATEGORY = 'Misc Receipts'
OR main_rec.CATEGORY = 'Trade Receipts'
THEN
l_trx_number := main_rec.reference_4;
l_trx_line_number := NULL;
ELSIF main_rec.CATEGORY = 'Adjustment'
THEN
l_trx_number := main_rec.reference_5;
l_trx_line_number := NULL;
ELSIF main_rec.CATEGORY = 'Purchase Invoices'
THEN
l_trx_number := main_rec.reference_5;
l_trx_line_number := main_rec.reference_3;
ELSIF main_rec.CATEGORY = 'Payments'
THEN
--l_trx_number:=main_rec.reference_3;
l_trx_number := main_rec.reference_4;
-- change by dody CHG0030444
l_trx_line_number := NULL;
ELSE
l_trx_number := main_rec.trx_number;
l_trx_line_number := main_rec.trx_line_number;
END IF;
v_display_str :=
main_rec.period_name| '^'|| main_rec.SOURCE|| '^'|| main_rec.CATEGORY|| '^'|| main_rec.batch_name|| '^'|| main_rec.journal_name
|| '^'|| main_rec.segment1|| '^'|| main_rec.segment2|| '^'|| main_rec.segment3|| '^'|| main_rec.segment4|| '^'|| main_rec.segment5
|| '^'|| main_rec.segment6|| '^'|| main_rec.segment7|| '^'|| main_rec.segment8|| '^'| main_rec.je_line_num|| '^'|| main_rec.je_line_description
|| '^'|| main_rec.gl_date|| '^'|| main_rec.post_date|| '^'|| l_party_name|| '^'|| l_party_number|| '^'|| main_rec.transaction_class
|| '^'|| l_trx_number|| '^'|| l_trx_line_number|| '^'|| main_rec.po_number|| '^'|| main_rec.po_line|| '^'|| main_rec.po_category --Added for Bug # 11741
|| '^'|| main_rec.proj_code|| '^'|| main_rec.debit|| '^'|| main_rec.credit|| '^'|| main_rec.net_amount|| '^'|| main_rec.entered_currency
|| '^'|| main_rec.entered_debit|| '^'|| main_rec.entered_credit|| '^'|| main_rec.net_entered_amount|| '^'|| main_rec.bank_account_number
|| '^'|| main_rec.bank_account_name|| '^'|| main_rec.it2_nl_posting_ref|| '^'|| main_rec.bank_transaction_date|| '^'|| main_rec.it2_transaction_number
|| '^'|| main_rec.funds_subtype_name| '^'|| main_rec.attribute7|| '^'|| main_rec.attribute8|| '^'|| main_rec.attribute9|| '^'
|| l_contract_number|| '^'|| l_contract_modified|| '^'|| l_order_number|| '^'|| l_statement_date
|| '^'|| l_billed_from|| '^'|| l_billed_to|| '^'|| l_start_date|| '^'|| l_reference_number;
i := i + 1;
fnd_file.put_line (fnd_file.output, v_display_str);
END LOOP;
CLOSE c_acct;
ELSE
END IF;
EXCEPTION
WHEN OTHERS THEN
fnd_file.put_line (fnd_file.LOG, 'account analysis process error out - ' || SQLERRM );
retcode := 2;
errbuf := SUBSTR (SQLERRM, 1, 120);
RAISE;
END ACCTALS;
/Thanks in advance,
Nag
Edited by: 838961 on Apr 12, 2013 1:29 AM
Edited by: 838961 on Apr 12, 2013 2:02 AMYou are probably looking for the SQL/XML functions that have been in Oracle for several major releases now. Here is the latest Oracle documentation on them
[url http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb13gen.htm]Generating XML Data from the Database
You can also find some examples at [url http://www.oracle-base.com/articles/misc/sqlxml-sqlx-generating-xml-content-using-sql.php]SQL/XML (SQLX) : Generating XML using SQL in Oracle. There are plenty of examples on the forums and web in general.
Note: It is a lower case "code" in your formatting tags, not "CODE" -
How to pass parameter in where clause in custom folder?
I have the follow query
blue color are the parameters
i have paste this to a custom folder
and
select last_update_date, creation_date
from ra_customer_trx_all
where trunc(last_update_date)='29-SEP-2012'
and customer_trx_id=1109
to another custom folder returning 1 row only and create another worksheet in the same workbook and create
3 parameter and 2 of them pointing to the 1 row query and create calcualtion
SET_CONTEXT('Date_From',TO_CHAR(:Date From)) and SET_CONTEXT('Date_TO',TO_CHAR(:Date To))
and 1 condition 1= SET_PARAM3(:Period)
but this doesnt work for me, no data return please help
select m.party_name TENANT_NAME
, b.interface_line_attribute10 lease_num
--, b.interface_line_attribute12 "PPS Number"
,b.interface_line_attribute2 LOCATION_CODE
,flexv.description property_name
, a2.trx_number INVOICE_NUMBER
--, t.name "Transaction Type"
--, e.attribute15 "AS400 Key"
, b2.description "BILL_ITEM_INVOCIE_DESCRIPTION"
,case when gcc.segment5 like '6%' then 'P/L'
when gcc.segment5 like '7%' then 'P/L'
when gcc.segment5 like '8%' then 'P/L'
when gcc.segment5 like '9%' then 'P/L'
else 'B/S'
end as account_nature
--, gcc.concatenated_segments as "Charge Account"
,gcc.segment1 company_code
,gcc.segment2 department_code
,gcc.segment3 property_code
,gcc.segment4 business_segment
,gcc.segment5 account_code
,gcc.segment6 project_code
,gcc.segment7 intercom_code
,gcc.segment8 spare1
,gcc.segment9 spare2
, b2.extended_amount BILL_ITEM_INVOICE_AMOUNT
,to_char(substr(ps.gl_date,4,8)) gl_period
, b.interface_line_attribute11 bill_start_date
, b.interface_line_attribute14 bill_end_date
, decode(a2.invoicing_rule_id, '-2',
DECODE(TO_CHAR(b.RULE_START_DATE, 'YYYYMM'), to_char(to_date(to_char(TRUNC(to_date(SETPARAM.GET_PARAM3,'yyyymm') , 'Month')-1),'DD-MON-YYYY'),'YYYYMM'), 'Current', 'In Advance'),
'Current') bill_nature
, to_char(a2.trx_date, 'DD-MON-YYYY') invoice_date
,pal.lease_commencement_date
,pal.lease_termination_date
,h.user_name created_by
--, NULL as remarks
from ra_customer_trx_all a
, ra_customer_trx_lines_all b
, pn_leases_all d
, pn_tenancies_all e
, hz_cust_accounts l
, hz_parties m
, fnd_user h
, ar_payment_schedules_all ps
, RA_CUST_TRX_LINE_GL_DIST_ALL dist
, gl_code_combinations_kfv gcc
, AR_RECEIVABLE_APPLICATIONS_all app
, ra_customer_trx_all a2
, ra_customer_trx_lines_all b2
, RA_CUST_TRX_TYPES_all t
, fnd_flex_values_vl flexv
,pn_lease_details_all pal
where
app.APPLICATION_TYPE = 'CM'
and flexv.flex_value=gcc.segment3
and flexv.FLEX_VALUE_SET_ID=1014916
and pal.lease_id=d.lease_id
and app.applied_customer_trx_id = a.customer_trx_id
and app.customer_trx_id = a2.customer_trx_id
and a2.cust_trx_type_id = t.cust_trx_type_id(+)
and a2.org_id = t.org_id(+)
and b.customer_trx_line_id = b2.previous_customer_trx_line_id
and dist.CUSTOMER_TRX_LINE_ID = b2.CUSTOMER_TRX_LINE_ID
and dist.account_class = 'REV'
and dist.account_set_flag = DECODE(NVL(a2.invoicing_rule_id,1), -2, 'Y', 'N')
and gcc.CODE_COMBINATION_ID(+) = dist.CODE_COMBINATION_ID
and b.interface_line_attribute10 = d.lease_num
and d.lease_id = e.lease_id
and e.primary_flag = 'Y'
and b2.customer_trx_id = a2.customer_trx_id
and a2.bill_to_customer_id = l.cust_account_id
and l.party_id = m.party_id
and a2.created_by = h.user_id
and ps.customer_trx_id = app.customer_trx_id
and ps.gl_date between trunc(trunc(TO_DATE(SYS_CONTEXT('DISCO_CONTEXT','Date_From')),'MM')-1,'MM') and trunc(TO_DATE(SYS_CONTEXT('DISCO_CONTEXT','Date_To')),'MM')-1What exactly is wrong with the results? Can you make the report include the gl_date so that you can see exactly what is being included?
The only way to troubleshoot this is to go back to basics. You have to be 100% certain that the parameter and calculations for the dates are working. You have granted execute permission over the function to your EUL owner - yes? What I did was create the function in a package owned by EUL_US then I had no issue with grants or permissions.
Also, gl_date is a DATE and not a string right? I ask because if it is not a date but a string then some dates might be left out.
Assuming you are 100% certain of the building blocks you should start by including only the gl_date and primary key from the table you are using. Once you are sure you are getting the right data you can start to add in more fields.
I do notice you are using E-Business Suite objects. I copied the code into my system where I am not using leasing. So I commented out the references to the 3 PN tables. I got 150 rows of data when I queried using the parameter and again when I hard coded the BETWEEN for the gl_date. You do have to make sure that your EUL owner has been granted SELECT right from all the tables and views used in your code and, if you intend to share this code with someone else, you will also need to have GRANT rights.
Try your code in a SQL tool such as TOAD and see what happens. Are you absolutely sure that every one of your transactions has an entry in the PN tables? This might be why you are not getting the results you expect. You could try, as I did, to comment those lines out and then see what happens.
Hope this has given you enough to solve your issue
Michael
PS. It would be nice to know your name. You haven't used it once in your thread. -
Date type parameters do not work package procedure
a cordial greeting to the whole community, in advance thank you very much for your precious time
a general way I have the following, a package in which I have a main procedure which I recible three parameters: a start date, a final, and a number of client
to use the dates I enter as parameter to query yields no records, but if I assign the date internally in the procedure, if it sheds records, the strange thing is that both the data and the parameters that are identical internally assigned even in its length and I checked, the truth and I stay out of ideas thank you very much for your time attaching the code
for now I'm just using the second query forget the first
------call to procedure-----
DECLARE
errcode VARCHAR2(200);
errbuf VARCHAR2(200);
BEGIN
xxxxx.pkg.xxxinitial_end(errcode ,errbuf
,'2013/08/19 00:00:00'
,'2013/08/23 00:00:00','456456456546');
END;
-----------------------------------------------------------------procedure---------------------------------------------------------------------
PROCEDURExxxinitial_end (ERRCODE OUT VARCHAR2
, ERRBUFF OUT VARCHAR2
, p_initial_date IN VARCHAR2
, p_end_date IN VARCHAR2
, customer IN VARCHAR2)IS
l_encoding_line VARCHAR2(240);
cur_without_customer SYS_REFCURSOR;
cur_with_customer SYS_REFCURSOR;
initial_date DATE;
end_date DATE;
initial_date2 DATE;
end_date2 DATE;
BEGIN
l_encoding_line := '<?xml version="1.0" encoding=' || '"iso-8859-1"' ||
' ?>' || chr(10) || '<XXOCS_TOTAL_VENTAS_SINEXP>';
initial_date := to_date(p_initial_date, 'YYYY/MM/DD HH24:MI:SS');-----------------input parameters NOT WORKING
end_date := to_date(p_end_date, 'YYYY/MM/DD HH24:MI:SS');-------------------input parameters
initial_date2:=to_date('2013/08/19 00:00:00', 'YYYY/MM/DD HH24:MI:SS');---------------------default values
end_date2:=to_date('2013/08/23 00:00:00', 'YYYY/MM/DD HH24:MI:SS');---------------------default values WORKING FINE
IF customer IS NULL THEN
-- OPEN cur_without_customer;
DBMS_OUTPUT.PUT_LINE('se ejecuto el primero');
-------------------------cursor -----------------------------------
OPEN cur_without_customer FOR
SELECT rct.customer_trx_id
,rctl.customer_trx_line_id
,hp.party_name ---cliente
,hca.account_number ----N° Cliente
,rctl.line_number -----item
,rctt.name---descripcion transaccion
,rct.trx_number -----numero
,rctt.type ------tipo de transaccion
,hp.party_id--control solamente
,rct.trx_date------Fecha de emisión Comprobante de Venta
,rct.attribute1 ---No. de autorización del Comprobante de Venta
,mp.attribute9||rct.trx_number N_Comprobante---No. de Comprobante de Venta
,rct.attribute4-----Unidad Estratégica de Negocio
,mp.attribute9---- N° de establecimiento
,rctl.description-----Descripción (Tipo de Combustible)
,rctl.quantity_invoiced---Cantidad Vendida en galones
,rctl.unit_selling_price---Precio de venta unitario
--,rctl.taxable_amount-------Valor Base Imponible --restriccion
--,rctl.extended_amount---valor iva 12%
-- ,NVL(importe_12(rctl.customer_trx_line_id,rct.customer_trx_id),'N/A')
FROM ra_customer_trx_all rct,
ra_customer_trx_lines_all rctl,
hz_cust_accounts hca,
hz_parties hp,
ra_cust_trx_types_all rctt,
mtl_parameters mp
-- mtl_system_items_b msi,
-- zx_lines zl
--ra_batch_sources_all rbs
WHERE
--rct.trx_date BETWEEN initial_date AND end_date --parametros de fecha
rct.trx_date BETWEEN to_date('2013/08/19 00:00:00', 'YYYY/MM/DD HH24:MI:SS')/*initial_date*/ AND to_date('2013/08/23 00:00:00', 'YYYY/MM/DD HH24:MI:SS')/*end_date*/
AND rct.sold_to_customer_id = hca.cust_account_id
AND hca.party_id = hp.party_id
AND rct.customer_trx_id=rctl.customer_trx_id
--AND rctl.inventory_item_id=msi.inventory_item_id
AND mp.organization_id=rctl.warehouse_id
AND rct.cust_trx_type_id = rctt.cust_trx_type_id;
print_output(fnd_file.output, l_encoding_line);
get_xml(cur_without_customer, 'G_REGISTER', 'CABECERA', ERRCODE);
IF ERRCODE = 1 THEN
ERRBUFF := 'El reporte no arrojo datos para los parametros ingresados';
ERRCODE := 2;
RETURN;
ELSIF ERRCODE = 2 THEN
ERRBUFF := SQLERRM;
RETURN;
END IF;
print_output(fnd_file.output, '</XXOCS_TOTAL_VENTAS_SINEXP>');
ELSE
-- OPEN cur_with_customer;
DBMS_OUTPUT.PUT_LINE('se ejecuto el segundo');
-----------------------cursor 2---------------------------
DBMS_OUTPUT.PUT_LINE('customer ' || customer);
DBMS_OUTPUT.PUT_LINE('ASI ESTAN ENTRANDO LOS PARAMETROS '||length(p_initial_date));
DBMS_OUTPUT.PUT_LINE('ASI ESTAN ENTRANDO LOS PARAMETROS '||length(p_end_date));
DBMS_OUTPUT.PUT_LINE('customer ' || customer);
DBMS_OUTPUT.PUT_LINE('ASI ESTAN ENTRANDO LOS PARAMETROS quemados '|| length(initial_date2));
DBMS_OUTPUT.PUT_LINE('ASI ESTAN ENTRANDO LOS PARAMETROS quemados '|| length(end_date2));
DBMS_OUTPUT.PUT_LINE('customer ' || customer);
DBMS_OUTPUT.PUT_LINE('ASI ESTAN ENTRANDO LOS PARAMETROS convertidso '|| length(initial_date));
DBMS_OUTPUT.PUT_LINE('ASI ESTAN ENTRANDO LOS PARAMETROS convertidos '|| length(end_date));
OPEN cur_with_customer FOR
SELECT rct.customer_trx_id
,rctl.customer_trx_line_id
,hp.party_name ---cliente
,hca.account_number ----N° Cliente
,rctl.line_number-----item
,rctt.name---descripcion transaccion
,rct.trx_number -----numero
,rctt.type ------tipo de transaccion
,hp.party_id---control solamente
,rct.trx_date------Fecha de emisión Comprobante de Venta
,rct.attribute1 ---No. de autorización del Comprobante de Venta
,mp.attribute9||rct.trx_number N_Comprobante--No. de Comprobante de Venta
,rct.attribute4------ Unidad Estratégica de Negocio
,mp.attribute9---------N° de establecimiento
,rctl.description---------Descripción (Tipo de Combustible)
,rctl.quantity_invoiced----Cantidad Vendida en galones
,rctl.unit_selling_price ---Precio de venta unitario
-- ,rctl.taxable_amount-------Valor Base Imponible --restriccion
-- ,rctl.extended_amount---valor iva 12%
-- ,NVL(importe_12(rctl.customer_trx_line_id,rct.customer_trx_id),'N/A')
FROM ra_customer_trx_all rct,
ra_customer_trx_lines_all rctl,
hz_cust_accounts hca,
hz_parties hp,
ra_cust_trx_types_all rctt,
mtl_parameters mp
-- mtl_system_items_b msi,
--zx_lines zl
WHERE hca.account_number=customer
AND hca.party_id=hp.party_id
AND hca.cust_account_id=rct.sold_to_customer_id
AND rct.customer_trx_id=rctl.customer_trx_id
-- AND rctl.inventory_item_id=msi.inventory_item_id
AND mp.organization_id=rctl.warehouse_id
AND rct.cust_trx_type_id = rctt.cust_trx_type_id
AND rownum = 1
AND rct.trx_date BETWEEN initial_date AND end_date;<------------when I assign these parameters( initial_date AND end_date )--are the insert by parameter initial_date2 AND end_date2 defualt
DBMS_OUTPUT.PUT_LINE('customer ' || customer);
DBMS_OUTPUT.PUT_LINE('fe inicial ' || initial_date);
DBMS_OUTPUT.PUT_LINE('fe final ' ||end_date);
print_output(fnd_file.output, l_encoding_line);
get_xml(cur_with_customer, 'G_REGISTER', 'CABECERA', ERRCODE);
IF ERRCODE = 1 THEN
ERRBUFF := 'El reporte no arrojo datos para los parametros ingresados';
ERRCODE := 2;
RETURN;
ELSIF ERRCODE = 2 THEN
ERRBUFF := SQLERRM;
RETURN;
END IF;
print_output(fnd_file.output, '</XXOCS_TOTAL_VENTAS_SINEXP>');
END IF;
EXCEPTION
WHEN OTHERS THEN
print_output(fnd_file.log, 'Error Ventas sin Exportaciones:' || SQLERRM);
ERRCODE := 2;
ERRBUFF := SQLERRM;
-- Initialization
END xxxinitial_end;Welcome. As a note, this question has nothing to do with PL/SQL XML programming and everything to do with SQL and PL/SQL
That said, the simple test case I setup, because I don't have all your tables, works just fine.
declare
l_errcode VARCHAR2(300);
l_errbuff VARCHAR2(300);
PROCEDURE xxxinitial_end (ERRCODE OUT VARCHAR2
, ERRBUFF OUT VARCHAR2
, p_initial_date IN VARCHAR2 -- why not a date?
, p_end_date IN VARCHAR2 -- why not a date?
, customer IN VARCHAR2)
IS
initial_date DATE;
end_date DATE;
l_value VARCHAR2(10);
BEGIN
initial_date := to_date(p_initial_date, 'YYYY/MM/DD HH24:MI:SS');
end_date := to_date(p_end_date, 'YYYY/MM/DD HH24:MI:SS');
-- Not trapping the No Data Found on purpose
SELECT 'hit'
INTO l_value
FROM dual
WHERE SYSDATE BETWEEN initial_date AND end_date;
END xxxinitial_end;
begin
-- Test statements here
xxxinitial_end(l_errcode, l_errbuff
,'2013/08/19 00:00:00'
,'2013/10/19 00:00:00'
,null);
end;
As a comment above says, if you are dealing with dates, why not use a DATE parameter in the procedure and avoid the conversion in your code.
Also, you can simplify your code a bit by using a third sys_refcursor and setting one of the opened cursors to it. This allows you to pull out the common logic following the OPEN and only have one copy of it.
PROCEDURE xxxinitial_end (ERRCODE OUT VARCHAR2
, ERRBUFF OUT VARCHAR2
, p_initial_date IN VARCHAR2 -- why not a date?
, p_end_date IN VARCHAR2 -- why not a date?
, customer IN VARCHAR2)
IS
l_encoding_line VARCHAR2(240);
cur_without_customer SYS_REFCURSOR;
cur_with_customer SYS_REFCURSOR;
cur_comm SYS_REFCURSOR;
initial_date DATE;
end_date DATE;
BEGIN
l_encoding_line := '<?xml version="1.0" encoding=' || '"iso-8859-1"' ||
' ?>' || chr(10) || '<XXOCS_TOTAL_VENTAS_SINEXP>';
initial_date := to_date(p_initial_date, 'YYYY/MM/DD HH24:MI:SS');-----------------input parameters NOT WORKING
end_date := to_date(p_end_date, 'YYYY/MM/DD HH24:MI:SS');-------------------input parameters
IF customer IS NULL THEN
-------------------------cursor -----------------------------------
OPEN cur_without_customer FOR
SELECT rct.customer_trx_id
,rctl.customer_trx_line_id
,hp.party_name ---cliente
,hca.account_number ----N° Cliente
,rctl.line_number -----item
,rctt.name---descripcion transaccion
,rct.trx_number -----numero
,rctt.type ------tipo de transaccion
,hp.party_id--control solamente
,rct.trx_date------Fecha de emisión Comprobante de Venta
,rct.attribute1 ---No. de autorización del Comprobante de Venta
,mp.attribute9||rct.trx_number N_Comprobante---No. de Comprobante de Venta
,rct.attribute4-----Unidad Estratégica de Negocio
,mp.attribute9---- N° de establecimiento
,rctl.description-----Descripción (Tipo de Combustible)
,rctl.quantity_invoiced---Cantidad Vendida en galones
,rctl.unit_selling_price---Precio de venta unitario
--,rctl.taxable_amount-------Valor Base Imponible --restriccion
--,rctl.extended_amount---valor iva 12%
-- ,NVL(importe_12(rctl.customer_trx_line_id,rct.customer_trx_id),'N/A')
FROM ra_customer_trx_all rct,
ra_customer_trx_lines_all rctl,
hz_cust_accounts hca,
hz_parties hp,
ra_cust_trx_types_all rctt,
mtl_parameters mp
-- mtl_system_items_b msi,
-- zx_lines zl
--ra_batch_sources_all rbs
WHERE
--rct.trx_date BETWEEN initial_date AND end_date --parametros de fecha
rct.trx_date BETWEEN to_date('2013/08/19 00:00:00', 'YYYY/MM/DD HH24:MI:SS')/*initial_date*/ AND to_date('2013/08/23 00:00:00', 'YYYY/MM/DD HH24:MI:SS')/*end_date*/
AND rct.sold_to_customer_id = hca.cust_account_id
AND hca.party_id = hp.party_id
AND rct.customer_trx_id=rctl.customer_trx_id
--AND rctl.inventory_item_id=msi.inventory_item_id
AND mp.organization_id=rctl.warehouse_id
AND rct.cust_trx_type_id = rctt.cust_trx_type_id;
cur_comm := cur_without_customer;
ELSE
-----------------------cursor 2---------------------------
OPEN cur_with_customer FOR
SELECT rct.customer_trx_id
,rctl.customer_trx_line_id
,hp.party_name ---cliente
,hca.account_number ----N° Cliente
,rctl.line_number-----item
,rctt.name---descripcion transaccion
,rct.trx_number -----numero
,rctt.type ------tipo de transaccion
,hp.party_id---control solamente
,rct.trx_date------Fecha de emisión Comprobante de Venta
,rct.attribute1 ---No. de autorización del Comprobante de Venta
,mp.attribute9||rct.trx_number N_Comprobante--No. de Comprobante de Venta
,rct.attribute4------ Unidad Estratégica de Negocio
,mp.attribute9---------N° de establecimiento
,rctl.description---------Descripción (Tipo de Combustible)
,rctl.quantity_invoiced----Cantidad Vendida en galones
,rctl.unit_selling_price ---Precio de venta unitario
-- ,rctl.taxable_amount-------Valor Base Imponible --restriccion
-- ,rctl.extended_amount---valor iva 12%
-- ,NVL(importe_12(rctl.customer_trx_line_id,rct.customer_trx_id),'N/A')
FROM ra_customer_trx_all rct,
ra_customer_trx_lines_all rctl,
hz_cust_accounts hca,
hz_parties hp,
ra_cust_trx_types_all rctt,
mtl_parameters mp
-- mtl_system_items_b msi,
--zx_lines zl
WHERE hca.account_number=customer
AND hca.party_id=hp.party_id
AND hca.cust_account_id=rct.sold_to_customer_id
AND rct.customer_trx_id=rctl.customer_trx_id
-- AND rctl.inventory_item_id=msi.inventory_item_id
AND mp.organization_id=rctl.warehouse_id
AND rct.cust_trx_type_id = rctt.cust_trx_type_id
AND rownum = 1
AND rct.trx_date BETWEEN initial_date AND end_date;<------------when I assign these parameters( initial_date AND end_date )--are the insert by parameter initial_date2 AND end_date2 defualt
cur_comm := cur_with_customer;
END IF;
print_output(fnd_file.output, l_encoding_line);
get_xml(cur_comm, 'G_REGISTER', 'CABECERA', ERRCODE);
CLOSE cur_comm;
IF ERRCODE = 1 THEN
ERRBUFF := 'El reporte no arrojo datos para los parametros ingresados';
ERRCODE := 2;
RETURN;
ELSIF ERRCODE = 2 THEN
ERRBUFF := SQLERRM;
RETURN;
END IF;
EXCEPTION
WHEN OTHERS THEN
print_output(fnd_file.log, 'Error Ventas sin Exportaciones:' || SQLERRM);
ERRCODE := 2;
ERRBUFF := SQLERRM;
-- Initialization
END xxxinitial_end; -
To get code combination in transaction screen -AR
hi all
i am using r12
in AR super user -transactions-in the transactions screen -when it is queried say 10000086 in the field Number
when distributions tab is clicked we get to see a field named GL account eg 701-100001-1000-0101-1220001-000000-0000-0000
when i see record history for Transactions screen it says RA_CUSTOMER_TRX_PARTIAL_V
when i see record history for gl account RA_CUST_TRX_LINE_GL_DIST_V but i don't see the code combinations
how to join RA_CUSTOMER_TRX_PARTIAL_V and RA_CUST_TRX_LINE_GL_DIST_V
i did join with customer_trx_id but it gives more number of rows
kindly guide
thanking in advanceDo you want sql script to find GL Code Combinations for a AR transaction?
If yes, following is the query.
select rcta.trx_number, gcck.concatenated_segments
from ra_customer_trx_all rcta, ra_customer_trx_lines_all rctla, RA_CUST_TRX_LINE_GL_DIST rctlgd, gl_code_combinations_kfv gcck
where rcta.trx_number = '<Give your AR Invoice>'
and rcta.customer_trx_id = rctla.customer_trx_id
and rctla.customer_trx_line_id = rctlgd.customer_trx_line_id
and rctlgd.code_combination_id = gcck.code_combination_id;
If you are looking for something else, please be clear
Regards,
Srini -
A more efficient way to assure that a string value contains only numbers?
Hi ,
I'm using Oracle 9.2.0.6.
I was curious to know if there was any way I could write a more efficient query to determine if a string value contains only numbers.
Here's my current query. This SQL is from a sub query in a Join clause.
select distinct cta.CUSTOMER_TRX_ID, to_number(cta.SALES_ORDER) SALES_ORDER
from ra_customer_trx_lines_all cta
where length(cta.SALES_ORDER) = 6
and cta.SALES_ORDER is not null
and substr(cta.SALES_ORDER,1,1) in('1','2','3','4','5','6','7','8','9','0')
and substr(cta.SALES_ORDER,2,1) in('1','2','3','4','5','6','7','8','9','0')
and substr(cta.SALES_ORDER,3,1) in('1','2','3','4','5','6','7','8','9','0')
and substr(cta.SALES_ORDER,4,1) in('1','2','3','4','5','6','7','8','9','0')
and substr(cta.SALES_ORDER,5,1) in('1','2','3','4','5','6','7','8','9','0')
and substr(cta.SALES_ORDER,6,1) in('1','2','3','4','5','6','7','8','9','0')This is a string where I'm finding A-Z-a-z characters and '/' and '-' characters in all 6 positions, plus there are values that are longer than 6 characters. That's what the length(cta.SALES_ORDER) = 6 is for. Also, of course. some cells are NULL.
So the question is, is there a more efficient way to screen out only the values in this field that are 6 character numbers or is what I have the best I can do?
Thanks,I appreciate all of your very helpfull workarounds. The cost is a little better in all cases than my original where clause.
To address the discussion that's popped up about design from this question, I can say a few things that should clear , at least, my situation up.
First of all this custom quoting , purchase order , and sales order entry system WAS written by a bunch a of 'bad' coders who didn't document their work and then left. We don't even have an ER diagram
The whole project that I'm only a small part of is literally trying to put Humpty Dumpty together again and then move it from a bad custom solution into Oracle Applications.
We're rebuilding, documenting, and doing ETL. This is one of your prototypical projects from hell.
It's a huge database project so we're taking small bites as a time. Hopefully, somewhere right before Armageddon hits, this thing will be complete.
But until then,..., well,..., you know the drill.
Thanks Again.
Maybe you are looking for
-
HT201412 Ipad2 doesn't work since IOS8
What options are there for my IPad2 since the IOS8 update. It is slow in every area. Slow to turn on, slow to slide from screen to screen, apps constantly crash. I can't even do the newest 8 update because it crashes during the process. Apple has
-
Validation user exit at asset master data
hi all, at asset master data creation level, if you want to validate company code vs asset class vs equipment type, how do you define validation user exit? Also, we have so many company codes. Do we have to individually validate rules for each and ev
-
Access to Draft and Pending is Sharepoint
On my document library everyone with edit permission can see Drafts and Pending. How can I limit this access to people who can only approve it? In versioning setting there is an option for 'Only users who can approve items' but how can I use that?
-
To whom it shall concern: I have to say that I recently purchased the Apple USB Fax Modem from an unsuspecting Apple Store, and plugged it into an iMac running Leopard. The Fax Modem worked in the absence of any appreciable problems, pronouncing full
-
I am curious what the "best practice" is for exporting data programmaticly from SQL Server to Excel. Is it best to do it straight from SQL Server, or should I do it with in my C# code? My program is going to pull the data, put in the excel file, th