Need Supply and Demand Query
Hi All,
I need Supply and Demand Query in a single SQL. I have a requirement to put the Supply and Demand in a single reporting structure for a particular org/item/product line. I have the supply and Demand Queries seperately, but iam not able to join them to look like the below
Item Prod_line Org Demand_Type Demand_qty Supply_type supply_qty
when I try to do it by joining msc_supplies and msc_demands table, i am getting duplicates and junk data. can some one help me out in this?
Thanks,
Brightraj
Edited by: user12086827 on Oct 20, 2009 6:04 AM
Similar Messages
-
Help with supply and demand query using monthly buckets
I'm working on a query bound for Discoverer which pulls the aggregated supply and demand for an item and buckets it into months. So for any given item, I need to show the item, onhand, cost, aggregated supply (planned orders, requisitions, pos), and aggregated demand (planned order demand, jobs) - all bucketed by months.
The code below works okay to find all of the data for July, but I also need to show August and September. I'm thinking I could use a union but am reluctant because the query already runs kind of slow and I'm not sure if I'm on the right track.
Database Server
RDBMS : 10.2.0.3.0
Oracle Applications : 11.5.9
-Tracy
select
item.inventory_item_id, item.organization_code, item.item, item.description
, item.make_buy,item.planner_code
, planned.compile_designator, planned.order_type_text, sum(planned.quantity_rate)planned_total
, planned.mrp_sugg_due_month
, sum(job.required_quantity-job.quantity_issued)job_open, job.required_month
, onhand.total_qoh
, purchase.item_revision prev, purchase.promised_month, purchase.ship_to_organization_id
, sum((purchase.quantity-purchase.quantity_cancelled)-purchase.quantity_received)po_open
, req.item_revision rrev, req.destination_organization_id, req.org_id, req.need_by_month
, sum((req.quantity-req.quantity_cancelled)-req.quantity_delivered)req_open
, cost.item_cost,cost.cost
from
--item--
(select mtl.inventory_item_id, mtl.segment1 item,mtl.description,decode(mtl.planning_make_buy_code,1,'Make',2,'Buy') make_buy
,mtl.organization_id, mtp.organization_code, mtl.planner_code
,to_char(add_months(sysdate,+1),'YYYY_MM')month1, to_char(add_months(sysdate,+2),'YYYY_MM')month2
,to_char(add_months(sysdate,+3),'YYYY_MM')month3
from inv.mtl_system_items_b mtl, inv.mtl_parameters mtp
where mtl.organization_id = mtp.organization_id
)item,
--planned orders - 3 months --
(select compile_designator,organization_id,inventory_item_id,order_type_text,nvl(quantity_rate,0)quantity_rate,new_due_date
,to_char(trunc(new_due_date,'MM'),'YYYY_MM')mrp_sugg_due_month
from apps.mrp_orders_sc_v
where order_type_text in ('Planned order','Planned order demand')
and to_char(trunc(new_due_date,'MM'),'YYYY_MM') <= to_char(add_months(:Month,+2),'YYYY_MM')
and to_char(trunc(new_due_date,'MM'),'YYYY_MM') >= to_char(:Month,'YYYY_MM')
)planned,
--jobs - 3 months--
(select organization_id,wip_entity_name job, inventory_item_id,concatenated_segments,nvl(required_quantity,0)required_quantity
,nvl(quantity_issued,0)quantity_issued, date_required,to_char(trunc(date_required,'MM'),'YYYY_MM') required_month
,wip_entity_id,creation_date, wip_job_status
from apps.wip_requirement_ops_inq_v
where primary_item_id <>inventory_item_id
and wip_job_status not in ('Closed','Cancelled','Complete')
and to_char(trunc(date_required,'MM'),'YYYY_MM') <= to_char(add_months(:Month,+2),'YYYY_MM')
and to_char(trunc(date_required,'MM'),'YYYY_MM') >= to_char(:Month,'YYYY_MM')
)job,
--qty onhand--
(select inventory_item_id,organization_id,sum(nvl(transaction_quantity,0))total_qoh
from inv.mtl_onhand_quantities_detail
group by inventory_item_id, organization_id
)onhand,
-- po - 3 months--
(select pol.item_id, pol.item_revision, nvl(pll.quantity,0)quantity, nvl(pll.quantity_received,0)quantity_received
, nvl(pll.quantity_rejected,0),nvl(pll.quantity_cancelled,0)quantity_cancelled,poh.segment1 po_num
,pll.promised_date, to_char(trunc(pll.promised_date,'MM'),'YYYY_MM')promised_month
,pll.shipment_num,pll.ship_to_organization_id
from po.po_lines_all pol, po.po_headers_all poh, po.po_line_locations_all pll
where poh.po_header_id = pol.po_header_id
and pol.po_header_id = pll.po_header_id
and pol.po_line_id = pll.po_line_id
and pol.cancel_flag != 'Y'
and pol.item_id is not null
and to_char(trunc(pll.promised_date,'MM'),'YYYY_MM')<= to_char(add_months(:Month,+2),'YYYY_MM')
and to_char(trunc(pll.promised_date,'MM'),'YYYY_MM')>= to_char(:Month,'YYYY_MM')
)purchase,
--reqs - 3 months--
(select prh.segment1 req_number,nvl(prl.quantity,0)quantity,nvl(prl.quantity_delivered,0)quantity_delivered
,nvl(prl.quantity_cancelled,0)quantity_cancelled
,prl.destination_organization_id,prl.org_id,prl.item_id,prl.item_revision,prl.need_by_date
,to_char(trunc(prl.need_by_date,'MM'),'YYYY_MM')need_by_month
from po.po_requisition_headers_all prh, po.po_requisition_lines_all prl
where prh.requisition_header_id = prl.requisition_header_id(+)
and nvl(prl.cancel_flag,'N') !='Y'
and prh.authorization_status != 'CANCELLED'
and to_char(trunc(prl.need_by_date,'MM'),'YYYY_MM') <= to_char(add_months(:Month,+2),'YYYY_MM')
and to_char(trunc(prl.need_by_date,'MM'),'YYYY_MM') >= to_char(:Month,'YYYY_MM')
)req,
--cost--
(select msib.inventory_item_id,msib.organization_id,cqm.material_cost,cic.item_cost
,(case when cqm.material_cost=0 then cic.item_cost else cqm.material_cost end) cost, cqm.cost_group_id
from inv.mtl_system_items_b msib
,(select cql.cost_group_id,cql.inventory_item_id,cql.organization_id,cql.layer_quantity,cql.material_cost,mp.organization_code
from bom.cst_quantity_layers cql, inv.mtl_parameters mp
where mp.default_cost_group_id = cql.cost_group_id) cqm
,bom.cst_item_costs cic
where msib.inventory_item_id = cqm.inventory_item_id(+)
and msib.organization_id = cqm.organization_id(+)
and msib.inventory_item_id = cic.inventory_item_id(+)
and msib.organization_id = cic.organization_id(+)
)cost
where item.inventory_item_id = job.inventory_item_id(+)
and item.organization_id = job.organization_id(+)
and item.month1 = job.required_month(+) -- 2009_07 --
and item.inventory_item_id = onhand.inventory_item_id(+)
and item.organization_id = onhand.organization_id(+)
and item.inventory_item_id = purchase.item_id(+)
and item.month1 = purchase.promised_month(+) -- 2009_07 --
and item.inventory_item_id = req.item_id(+)
and item.month1 = req.need_by_month(+) -- 2009_07 --
and item.inventory_item_id = cost.inventory_item_id(+)
and item.organization_id = cost.organization_id(+)
and item.inventory_item_id = planned.inventory_item_id(+)
and item.organization_id = planned.organization_id(+)
and item.month1 = planned.mrp_sugg_due_month(+) -- 2009_07 --
and item.make_buy = 'Buy'
and item.item in ('161309040','744L755','150-GFM') --test items --
group by item.inventory_item_id,item.organization_code,item.item,item.description,item.make_buy,item.planner_code
,job.required_month ,onhand.total_qoh , purchase.item_revision, purchase.promised_month
,purchase.ship_to_organization_id ,cost.item_cost,cost.cost
,req.item_revision, req.destination_organization_id,req.org_id,req.need_by_month
,planned.compile_designator,planned.order_type_text,planned.mrp_sugg_due_month
order by item.organization_code,item.itemHi,
Six things:
(1) Where are the one-to-many relationships between your tables? If a single row in mtl can match two (or more) rows in mrp, and can also match two (or more) rows in wip, then it looks like, when you join both of them them, you'll have a chasm trap, that is, you'll get all the matching rows from mrp paired with all matching rows from wip. Are you sure your existing query is producing the right results?
Are there one-to-many relationships with the other tables in your original query?
(2) Are your DATEs always at midnight? If not, avoid using BETWEEN and LAST_DAY for DATE comparisons: otherwise you'll miss everything between 00:00:01 and 23:59:59 on the last day.
That is, instead of
and mrp.new_due_date(+) BETWEEN :Month AND LAST_DAY(ADD_MONTHS(:Month,2))ypou should say
and mrp.new_due_date (+) >= :Month
and mrp.new_due_date (+) < ADD_MONTHS (:Month, 3)(3) The basic way to pivot the months of mrp_due_date is:
SELECT ...
, NVL ( SUM ( CASE
WHEN mrp.new_due_date >= :month
AND mrp.new_due_date < ADD_MONTHS (:month, 1)
THEN mrp.quantity_rate
END
, 0
) AS mrp_qty_0
, NVL ( SUM ( CASE
WHEN mrp.new_due_date >= ADD_MONTHS (:month, 1)
AND mrp.new_due_date < ADD_MONTHS (:month, 2)
THEN mrp.quantity_rate
END
, 0
) AS mrp_qty_1When you do this, do not GROUP BY TRUNC (mrp.new_due_date, 'MM').
The code above does two months: I'm sure you get the idea for how to do more.
To get dynamic column headings (such as Jun_2009 or "2009-06" instead of the generic mrp_qty_o) requires dynamic SQL. The best way to do dynamic SQL depends on the tool that is producing the query (e.g. SQL*Plus). What are you using? Are you willing to change, if it helps?
(4) Displaying separate columns from one row as a single column on multiple rows is called unpivoting. How badly do you want to do that? Your query would be simpler and faster if the output had only one row per group (rather than one row for mrp_qty and another row for wip_wty). That one row could have six columns (e.q. June_mrp, June_wip, July_mrp, July_wip, August_mrp and August_wip) instead of three. Depending on your front-end tool, you might even be able to wrap the single row of output so that it always appeared as two rows, each with three columns.
(5) Sorry I told you to do
and mrp.order_type_text(+) in (...)I never use the + outer-join notation any more, so I forgot about the ORA-01719 error. There's no problem having an outer-join condition like that using ANSI notation. (One more reason to switch.)
(6) As you noticed, this site doesn't like to print the <> inequality operator, even inside tags.
Use the equivalent != operator instead, when posting on this site. -
Need sql query on supply and demand pegging in ASCP
Can any one have sample supply and demand pegging query to have some idea....so that i can map with my requirement.
Edited by: user12086827 on Oct 20, 2009 6:04 AM
-
Hello, I have a query about supply and demand chart. I want to create a column chart for supply and demand by month. I can plot only one row how to plor second row so that it show two bars in each month? and there is data in both buckets.
Please share your ideas.
Thanks.If you need a chart like this:
And you have a data grid in excel like this:
Here is the binding you need for the column chart component: -
Supply and Demand Propagation not working in SCM5.0
Just curious if anyone is using S&OP (Supply and Demand Propagation) in APO?
I am using SCM v5.0 and Planning Area 9ASNP01 can not be initialized.
OSS 832393 states: The SNP propagation planning (planning area SNP 9ASNP01, transaction /SAPAPO/SNPSOP) can only be used with times series live Cache. In productive systems, this functionality should be used only after consultation of SAP.
I am trying to use the standard default SAP Planning area 9ASNP01 and am curious what needs to be done to use it?
I am submitting on OSS message for this, but am curious to see if anyone is using S&OP currently in APO?
Ken Snyder
[email protected]Ken,
I have just posted a similar question to your regarding S&OP, have you in the meantime managed to obtain some information regarding anyone using propagation (S&OP), and any advantages/disdvantages?
Regards
Paul -
Supply and Demand Collaborative Planning
Is it possible to upload data via Demand collaborative planning? I understand how to download the data to a spreadsheet. The download funtionality is controlled by the user parameter. Is there a user parameter for uploading data via this tool?
Regards,
JamesHi James ,
Not sure on the upload of the data from upload option of excel but yes you can exchange data from external system.
refer help document on link [Requesting data (pull activity)|http://help.sap.com/saphelp_scm50/helpdata/en/c8/0aad39010abd21e10000000a114084/frameset.htm]
Regds,Digambar -
I need to pass a query in form of string to DBMS_XMLQUERY.GETXML package...the parameters to the query are date and varchar ..please help me build the string .Below is the query and the out put. ( the string is building fine except the parameters are with out quotes)
here is the procedure
create or replace
procedure temp(
P_MTR_ID VARCHAR2,
P_FROM_DATE IN DATE ,
P_THROUGH_DATE IN DATE ) AS
L_XML CLOB;
l_query VARCHAR2(2000);
BEGIN
l_query:= 'SELECT
a.s_datetime DATETIME,
a.downdate Ending_date,
a.downtime Ending_time,
TO_CHAR(ROUND(a.downusage,3),''9999999.000'') kWh_Usage,
TO_CHAR(ROUND(a.downcost,2),''$9,999,999.00'') kWh_cost,
TO_CHAR(ROUND(B.DOWNUSAGE,3),''9999999.000'') KVARH
FROM
(SELECT s_datetime + .000011574 s_datetime,
TO_CHAR(S_DATETIME ,''mm/dd/yyyy'') DOWNDATE,
DECODE(TO_CHAR(s_datetime+.000011574 ,''hh24:'
||'mi''), ''00:'
||'00'',''24:'
||'00'', TO_CHAR(s_datetime+.000011574,''hh24:'
||'mi'')) downtime,
s_usage downusage,
s_cost downcost
FROM summary_qtrhour
WHERE s_mtrid = '
||P_MTR_ID||
' AND s_mtrch = ''1''
AND s_datetime BETWEEN TO_DATE('
||P_FROM_DATE||
',''DD-MON-YY'') AND (TO_DATE('
||P_THROUGH_DATE||
',''DD-MON-YY'') + 1)
) a,
(SELECT s_datetime + .000011574 s_datetime,
s_usage downusage
FROM summary_qtrhour
WHERE s_mtrid = '
||P_MTR_ID||
' AND s_mtrch = ''2''
AND s_datetime BETWEEN TO_DATE('
||P_FROM_DATE||
',''DD-MON-YY'') AND (TO_DATE('
||P_THROUGH_DATE||
','' DD-MON-YY'') + 1)
) B
where a.S_DATETIME = B.S_DATETIME(+)';
SELECT DBMS_XMLQUERY.GETXML('L_QUERY') INTO L_XML FROM DUAL;
INSERT INTO NK VALUES (L_XML);
DBMS_OUTPUT.PUT_LINE('L_QUERY IS :'||L_QUERY);
END;
OUTPUT parameters are in bold (the issue is they are coming without single quotes otherwise th equery is fine
L_QUERY IS :SELECT
a.s_datetime DATETIME,
a.downdate Ending_date,
a.downtime Ending_time,
TO_CHAR(ROUND(a.downusage,3),'9999999.000') kWh_Usage,
TO_CHAR(ROUND(a.downcost,2),'$9,999,999.00') kWh_cost,
TO_CHAR(ROUND(B.DOWNUSAGE,3),'9999999.000') KVARH
FROM
(SELECT s_datetime + .000011574 s_datetime,
TO_CHAR(S_DATETIME ,'mm/dd/yyyy') DOWNDATE,
DECODE(TO_CHAR(s_datetime+.000011574 ,'hh24:mi'), '00:00','24:00', TO_CHAR(s_datetime+.000011574,'hh24:mi')) downtime,
s_usage downusage,
s_cost downcost
FROM summary_qtrhour
WHERE s_mtrid = N3165 AND s_mtrch = '1'
AND s_datetime BETWEEN TO_DATE(01-JAN-13,'DD-MON-YY') AND (TO_DATE(31-JAN-13,'DD-MON-YY') + 1)
) a,
(SELECT s_datetime + .000011574 s_datetime,
s_usage downusage
FROM summary_qtrhour
WHERE s_mtrid = N3165 AND s_mtrch = '2'
AND s_datetime BETWEEN TO_DATE(01-JAN-13,'DD-MON-YY') AND (TO_DATE(31-JAN-13,' DD-MON-YY') + 1)
) B
where a.S_DATETIME = B.S_DATETIME(+)The correct way to handle this is to use bind variables.
And use DBMS_XMLGEN instead of DBMS_XMLQUERY :
create or replace procedure temp (
p_mtr_id in varchar2
, p_from_date in date
, p_through_date in date
is
l_xml CLOB;
l_query VARCHAR2(2000);
l_ctx dbms_xmlgen.ctxHandle;
begin
l_query:= 'SELECT
a.s_datetime DATETIME,
a.downdate Ending_date,
a.downtime Ending_time,
TO_CHAR(ROUND(a.downusage,3),''9999999.000'') kWh_Usage,
TO_CHAR(ROUND(a.downcost,2),''$9,999,999.00'') kWh_cost,
TO_CHAR(ROUND(B.DOWNUSAGE,3),''9999999.000'') KVARH
FROM
(SELECT s_datetime + .000011574 s_datetime,
TO_CHAR(S_DATETIME ,''mm/dd/yyyy'') DOWNDATE,
DECODE(TO_CHAR(s_datetime+.000011574 ,''hh24:'
||'mi''), ''00:'
||'00'',''24:'
||'00'', TO_CHAR(s_datetime+.000011574,''hh24:'
||'mi'')) downtime,
s_usage downusage,
s_cost downcost
FROM summary_qtrhour
WHERE s_mtrid = :P_MTR_ID
AND s_mtrch = ''1''
AND s_datetime BETWEEN TO_DATE(:P_FROM_DATE,''DD-MON-YY'')
AND (TO_DATE(:P_THROUGH_DATE,''DD-MON-YY'') + 1)
) a,
(SELECT s_datetime + .000011574 s_datetime,
s_usage downusage
FROM summary_qtrhour
WHERE s_mtrid = :P_MTR_ID
AND s_mtrch = ''2''
AND s_datetime BETWEEN TO_DATE(:P_FROM_DATE,''DD-MON-YY'')
AND (TO_DATE(:P_THROUGH_DATE,'' DD-MON-YY'') + 1)
) B
where a.S_DATETIME = B.S_DATETIME(+)';
l_ctx := dbms_xmlgen.newContext(l_query);
dbms_xmlgen.setBindValue(l_ctx, 'P_MTR_ID', p_mtr_id);
dbms_xmlgen.setBindValue(l_ctx, 'P_FROM_DATE', to_char(p_from_date, 'DD-MON-YY'));
dbms_xmlgen.setBindValue(l_ctx, 'P_THROUGH_DATE', to_char(p_through_date, 'DD-MON-YY'));
l_xml := dbms_xmlgen.getXML(l_ctx);
dbms_xmlgen.closeContext(l_ctx);
insert into nk values (l_xml);
end; -
I have had Adobe XI for about two years and My harddrive just crashed. My backups were part of the failure so I can't get it back. I purchased it from a third part supplier and it was a download. I need to find out how to get it restored. I can send screen shots of all of the drive location where the drive is still good and I can see my Adobe Acrobat pro information, but the download itself is missing. NEXT STEP?
If you are talking about Reader (you did post in the Reader forum), then just download http://get.adobe.com/reader/enterprise. However Reader is free not purchasable. You can download a trial then install using your serial number, which if you didn’t register or write down somewhere you will be out of luck to track down.
Download a free trial or buy Adobe products | Adobe downloads -
Hello, I have a Macbook Pro 2011, and put an SSD on it. Yesterday i upgrade to Yosemite and sadly mi trim is not supported .... I really need (and demand) a solution to this, because like i see in the manual of the mac, Iam allowed to install a disk.
Try a Safe Boot to clear the dyld_shared_cache (dynamic loader cache)
SafeBoot http://support.apple.com/kb/HT1564
Safe Boot, which automatically rebuilds this cache (among other things). -
What is the best way to query planned orders or work orders for make items and identify the buy component that is short for supply and vice versa?
What is the best way to query planned orders or work orders for make items and identify the buy component that is short for supply and vice versa?
-
Steps to create workbook and need to insert 10 query's in the workbook
Hi,
Please let me know Steps to create workbook and need to insert 10 query's in the workbook.
Thanks,
rajesh bHi,
Creating Workbook ---> Open your query --> save it as a new workbook -->provide description for workbook -->If you want more queries into the same workbook then insert related queries into different different sheets by insert query from Tools menu .
Regards
Pcrao. -
Modelling organization as supplier and using in ASCP
Hi
Bit lengthy problem but Interesting : Please read on .,
Following is the org structure:
OU1 - Plant D (destination plant)
OU2- Pant S (source plant)
The plants need to be in 2 diff OUs so that invoices can be made.(within single OU its not possible)
We need to have IR/ISO setup so that the implementation is seamless and easy to use.
Plan owning org is Plant D (dest) and though we will be including we should not consider BOM explosion and res const etc in the plant S(source) and there will be a separate plan run there.
I tried modelling the same with assigning supplier name and site to the plant S(source) say Supp A and Site A.
However following are the issues:
1. The supp A and Site A details need to be given in supplier defn in OU2(source plant's OU)
Though in supply demand form in ASCP I see in sources tab :org id (Plant S) , supplier name :Supp A and site name: Site A,after req import and implementing it as PO, the ship to Dest becomes the OU2 and not OU1 as expected.
2. How to prevent planning for the BOM/Comp / Resources at the Plant S(source) level in the plan owned by Plant D (dest) ?
Are there any pointers to use both simplicity of IR/ISO and not planning for source plant as well ?
Best Regards
ParthaHi Sara
Have your earlier problem of Creating Customer resolved?
As I said in my earlier post related to Creating Customer, this is not the right Forum the right Forum for Customer Vendor master data is :- [Customer / vendor master data Forum|ERP SCM Customer & Vendor Master;
How to differentiate Supplier and Customer in one system
Customer is created using T-code XD01 / VD01, whereas Vendor by using XK01. Both will have different No. range if you set properly.
Do I need to create two different company codes and etc
NO
Regards
Amitesh
Edited by: AA on Aug 10, 2009 1:31 PM -
MRS couldn't be considered as supply or demand in ASCP
Here is the situation:
I created some MRs by using CMRO , and the MRs could be seen in UMP,but after I runned ASCP,the MRs wasn't considered as supply or demand in ASCP.
I want to confirm two things:
1. Would ASCP take MRS as supplies or demands or not?
2.If this is possible and how could these MRs be displayed /considered in ASCP.
Is there anyone who gets some helpful information for me》Nothing to do with being smart or not. Just an oversight based on a routine getting disrupted by some new excitement. So you got to learn something new (which is wonderful about disruptions to routines), and you thankfully shared it with the rest of us.
While it's easy to say it makes sense it would have to be plugged in to operate closed, I think it's more of an afterthought of it making sense than it having to be that way. I'm sure some would complain about it not allowing you to drain the battery in that way. I like that it wants to be plugged in as it probably needs the extra boost of power anyways.
Again, thanks for sharing. -
Help needed to tune the Query:Statistics added
Can someone DBA please help me to tune this query:
SELECT DISTINCT K.ATTRIBUTE_VALUE AGENCY_ID,B.PROFILE_NM ,NVL(G.OFFICE_DESC,'--') OFFICE_DESC,f.OFFICE_ID,B.PROFILE_ID,'%' ROLE,'%' LAYOUT,
CASE
WHEN 'flagB' = '%' THEN
NVL(J.ISS_GRP_DESC,'BILLING')
WHEN 'flagO' = '%' THEN
NVL(J.ISS_GRP_DESC,'ORDERING')
WHEN 'flag' = '%' THEN
NVL(J.ISS_GRP_DESC,'BILLING/ORDERING')
ELSE
NVL(J.ISS_GRP_DESC,' ')
END ISS_GRP_DESC,
DECODE(NVL(H.USERID,' ') ,' ','--','<a sbcuid_in=' || H.USERID || ' target=NEW >'||H.FIRSTNAME || ' ' || H.LASTNAME || '( ' || H.USERID || ' )</a>' ) USER_NAME
FROM
PROFILE_PORTAL B ,
TBL_BDA_AGENCY_RESP_REP C ,
TBL_BDA_AGENCY_OFFICE F,
TBL_BDA_OFFICE G,
USERS_PORTAL H,
TBL_BDA_USR_ISS_GRP I ,
TBL_BDA_ISS_GROUP J,
ATTRIBUTE_VALUES_PORTAL K,
PROFILE_TYPE_PORTAL L
WHERE
B.PROFILE_ID = F.AGENCY_ID (+)
AND B.PROFILE_ID = C.AGENCY_ID (+)
AND G.OFFICE_ID (+)= F.OFFICE_ID
AND H.USERID (+)= C.RESP_USR_ID
AND C.ISS_GRP_ID = I.ISS_GRP_ID (+)
AND I.ISS_GRP_ID = J.ISS_GRP_ID(+)
AND 'PROFILE.'||B.PROFILE_ID = K.ENTITY_ID(+)
AND K.ATTRIBUTE_VALUE IS NOT NULL
AND L.PROFILE_TYPE_ID = B.PROFILE_TYPE_ID
AND L.APPLICATION_CD='BDA'
AND NOT EXISTS (SELECT agency_id
FROM TBL_BDA_AGENCY_RESP_REP t
WHERE t.ISS_GRP_ID IN ('%')
AND t.AGENCY_ID = C.AGENCY_ID)
AND K.ATTRIBUTE_VALUE LIKE '%'
AND UPPER(B.PROFILE_NM) LIKE UPPER('%')
AND (to_char(NVL(B.PROFILE_ID,0)) LIKE '%' OR NVL(B.PROFILE_ID,0) IN ('a'))
AND NVL(G.OFFICE_ID,0) IN ('%')
AND (to_char(NVL(C.RESP_USR_ID,'0')) LIKE '%' OR NVL(C.RESP_USR_ID,'0') IN ('k'))
ORDER BY PROFILE_NM
The number of rows in these tables are as follows:
PROFILE_PORTAL -- 2392
TBL_BDA_AGENCY_RESP_REP 3508
TBL_BDA_AGENCY_OFFICE 2151
TBL_BDA_OFFICE 3
USERS_PORTAL 270500
TBL_BDA_USR_ISS_GRP 234
TBL_BDA_ISS_GROUP 2
ATTRIBUTE_VALUES_PORTAL 2790
PROFILE_TYPE_PORTAL 3
The Explain pal nhas given this o/p to me:
SQL> select * from table(dbms_xplan.display) dual;
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost |
| 0 | SELECT STATEMENT | | 807 | 102K| | 2533 |
| 1 | SORT UNIQUE | | 807 | 102K| 232K| 82 |
|* 2 | FILTER | | | | | |
|* 3 | HASH JOIN OUTER | | 807 | 102K| | 52 |
|* 4 | HASH JOIN OUTER | | 807 | 95226 | | 40 |
|* 5 | TABLE ACCESS BY INDEX ROWID | ATTRIBUTE_VALUES | 1 | 23 | | 2 |
| 6 | NESTED LOOPS | | 7 | 805 | | 37 |
| 7 | NESTED LOOPS OUTER | | 6 | 552 | | 25 |
|* 8 | FILTER | | | | | |
| 9 | NESTED LOOPS OUTER | | | | | |
|* 10 | FILTER | | | | | |
| 11 | NESTED LOOPS OUTER | | | | | |
| 12 | NESTED LOOPS OUTER | | 3 | 141 | | 10 |
|* 13 | HASH JOIN | | 3 | 120 | | 7 |
|* 14 | TABLE ACCESS FULL | PROFILE | 6 | 198 | | 4 |
|* 15 | TABLE ACCESS FULL | PROFILE_TYPE | 1 | 7 | | 2 |
|* 16 | INDEX RANGE SCAN | SYS_C0019777 | 1 | 7 | | 1 |
| 17 | TABLE ACCESS BY INDEX ROWID| TBL_BDA_OFFICE | 1 | 10 | | 1 |
|* 18 | INDEX UNIQUE SCAN | SYS_C0019800 | 1 | | | |
| 19 | TABLE ACCESS BY INDEX ROWID | TBL_BDA_AGENCY_RESP_REP | 2 | 26 | | 2 |
|* 20 | INDEX RANGE SCAN | IDX_AGECYRESP_AGNCYID | 2 | | | 1 |
| 21 | TABLE ACCESS BY INDEX ROWID | USER_ | 1 | 22 | | 1 |
|* 22 | INDEX UNIQUE SCAN | USER_PK | 1 | | | |
|* 23 | INDEX RANGE SCAN | IDX_ATTVAL_ENTATTID | 1 | | | 1 |
| 24 | TABLE ACCESS FULL | TBL_BDA_USR_ISS_GRP | 234 | 702 | | 2 |
| 25 | TABLE ACCESS FULL | TBL_BDA_ISS_GROUP | 2 | 24 | | 2 |
|* 26 | TABLE ACCESS BY INDEX ROWID | TBL_BDA_AGENCY_RESP_REP | 1 | 7 | | 3 |
|* 27 | INDEX RANGE SCAN | IDX_AGECYRESP_AGNCYID | 2 | | | 1 |
Predicate Information (identified by operation id):
2 - filter( NOT EXISTS (SELECT /*+ */ 0 FROM "TBL_BDA_AGENCY_RESP_REP" "T" WHERE "T"."AGENCY_ID"=:B1
AND "T"."ISS_GRP_ID"=TO_NUMBER('%')))
3 - access("I"."ISS_GRP_ID"="J"."ISS_GRP_ID"(+))
4 - access("SYS_ALIAS_1"."ISS_GRP_ID"="I"."ISS_GRP_ID"(+))
5 - filter("K"."ATTRIBUTE_VALUE" IS NOT NULL AND "K"."ATTRIBUTE_VALUE" LIKE '%')
8 - filter(NVL("SYS_ALIAS_1"."RESP_USR_ID",'0') LIKE '%' OR NVL("SYS_ALIAS_1"."RESP_USR_ID",'0')='k')
10 - filter(NVL("G"."OFFICE_ID",0)=TO_NUMBER('%'))
13 - access("L"."PROFILE_TYPE_ID"="B"."PROFILE_TYPE_ID")
14 - filter(UPPER("B"."PROFILE_NM") LIKE '%' AND (TO_CHAR(NVL("B"."PROFILE_ID",0)) LIKE '%' OR
NVL("B"."PROFILE_ID",0)=TO_NUMBER('a')))
15 - filter("L"."APPLICATION_CD"='BDA')
16 - access("B"."PROFILE_ID"="F"."AGENCY_ID"(+))
18 - access("G"."OFFICE_ID"(+)="F"."OFFICE_ID")
20 - access("B"."PROFILE_ID"="SYS_ALIAS_1"."AGENCY_ID"(+))
22 - access("H"."USERID"(+)="SYS_ALIAS_1"."RESP_USR_ID")
23 - access("K"."ENTITY_ID"='PROFILE.'||TO_CHAR("B"."PROFILE_ID"))
26 - filter("T"."ISS_GRP_ID"=TO_NUMBER('%'))
27 - access("T"."AGENCY_ID"=:B1)
Note: cpu costing is off
57 rows selected.
Elapsed: 00:00:01.08
Please help me.
Aashish S.Hello Eric,
Here is the code:
SELECT DISTINCT
K.ATTRIBUTE_VALUE AGENCY_ID,
B.PROFILE_NM ,
NVL(G.OFFICE_DESC,'--') OFFICE_DESC,
f.OFFICE_ID,
B.PROFILE_ID,
'%' ROLE,
'%' LAYOUT,
case
WHEN 'flagB' = '%' THEN
NVL(J.ISS_GRP_DESC,'BILLING')
WHEN 'flagO' = '%' THEN
NVL(J.ISS_GRP_DESC,'ORDERING')
WHEN 'flag' = '%' THEN
NVL(J.ISS_GRP_DESC,'BILLING/ORDERING')
else
NVL(J.ISS_GRP_DESC,' ')
END ISS_GRP_DESC,
DECODE(NVL(H.USERID,' ') ,' ','--','<a sbcuid_in=' || H.USERID || ' target=NEW >'||H.FIRSTNAME || ' ' || H.LASTNAME ||
'( ' || H.USERID || ' )</a>' ) USER_NAME
from
PROFILE_PORTAL B ,
TBL_BDA_AGENCY_RESP_REP C ,
TBL_BDA_AGENCY_OFFICE F,
TBL_BDA_OFFICE G,
USERS_PORTAL H,
TBL_BDA_USR_ISS_GRP I ,
TBL_BDA_ISS_GROUP J,
ATTRIBUTE_VALUES_PORTAL K,
PROFILE_TYPE_PORTAL L
WHERE
B.PROFILE_ID = F.AGENCY_ID (+)
AND B.PROFILE_ID = C.AGENCY_ID (+)
AND G.OFFICE_ID (+)= F.OFFICE_ID
AND H.USERID (+)= C.RESP_USR_ID
AND C.ISS_GRP_ID = I.ISS_GRP_ID (+)
AND I.ISS_GRP_ID = J.ISS_GRP_ID(+)
AND 'PROFILE.'||B.PROFILE_ID = K.ENTITY_ID(+)
AND K.ATTRIBUTE_VALUE IS NOT NULL
AND L.PROFILE_TYPE_ID = B.PROFILE_TYPE_ID
AND L.APPLICATION_CD='BDA'
AND NOT EXISTS
(SELECT agency_id
FROM TBL_BDA_AGENCY_RESP_REP t
WHERE t.ISS_GRP_ID IN (1)
AND t.AGENCY_ID = C.AGENCY_ID)
AND K.ATTRIBUTE_VALUE LIKE '%'
AND UPPER(B.PROFILE_NM) LIKE UPPER('%')
AND (to_char(NVL(B.PROFILE_ID,0))
LIKE '%'
OR NVL(B.PROFILE_ID,0) IN (1))
AND NVL(G.OFFICE_ID,0) IN (1)
AND (to_char(NVL(C.RESP_USR_ID,'0'))
LIKE '%'
OR NVL(C.RESP_USR_ID,'0') IN ('%'))
ORDER BY PROFILE_NM
This is the Query and the query takes some mins. to run in prod environment.
From the Query plan ,I am not able to get any idea for optimization.
Now,Can you tell me which steps I need to follow to run it faster and which all modifications should be made?
Thanks.
Aashish S. -
Two problmes between Crystal Reports 2008 and Bex Query
Hi Gurus.
I have two problems with Crystal Reports 2008 when It obtains data from a Bex Query (SAP MDX query connection).
1) I have defined some Parameters Fields using the follow options:
Type: String
List of Values: Dynamic
Value Options Level1:
Show on (Viewer) Panel :Editable
Prompt text: <text>
Sort Order: Ascending by value
Prompt With description Only : False
Optional Prompt: True
Allow multiple values: True
Allow discrete values: True
Allow range values: False
When I execute the report with the client of Crystal Reports 2008 (the developer tool), in the initial screen shows a list box where I can select the values from the left box and add it to the left box (as a usually filter). When the number of options (LOV) is more than the maximum of the system, I have a input box bellow the list box, where I can insert any value (manually) and a button to insert it into the left box. When I publish the Report in the infoview, this filter is modified and the input box where I can introduce manually values is not showed and I can insert only the values showed in the list box, it causes that I can`t select a lot of values that is in the master data of SAP BW, because they arenu2019t listed in the list box.
There is any option to ability this option in the infoview.
2) My Bex query, have a date filter with variable in the restricted key figures, when I execute a Crystal Reports, the infoview (and the Crystal Reports 2008 designer) ask me 2 times the same date, first only the date and second the date and the rest of parameters (introduced in the report of Crystal Reports).
Why I need insert the date 2 times? How can I modify the Crystal Report for ask me only one time all the parameters?.
Thanks.Hi Abhilash.
Thank you for your information.
1) Yes, the parameters are created in the Crystal Reports designer. I have created the parameters in the Crystal Report because I use the same Bex Query to create some Crystal Report, in other case, I will need create some Bex Query.
2)The Bex query has the date filters and I have created some filters in Crystal Reports designer, the date filter from the Bex query is created automatically in the Crystal Report Designer but I don't use it, I haven't created it anytime. I use my filters only in the record selection. The date filters from the Bex query is showed as Static, and I can`t delete it, if I modify the parameter to dynamic or static with values, at first step ask me again static without values and the second step of the report execution ask me the parameter as I have defined in Crystal Reports Designer, my parameters fields are dynamic. A lot of reports have subreport, but I have created one of them without subreport (to trial) and the Crystal Reports ask me the date filters at first execution, and when I insert the date filters, in the second step, ask me the date filters again and my parameters fields again.
Thank you again.
Maybe you are looking for
-
Is there a way to edit/manage Launchpad?
is there a way to show the apps and a list, mark them into groups, and then move them into folders? I like the idea of Launchpad, but this isn't my iPad where I have a few apps that I use all the time. I have approximately 300 apps ... many of them f
-
Will leaving your iPhone 6+ plugged in all the time damage the battery or shorten its life? Can you overcharge the iPhone 6+ battery? Thanks in advance, Bill
-
How to create group or subnet proxy exclusions in Mozilla Firefox 29? Used to be in shape of X.Y.Z.0/8 or X.Y.0.0/16 or X.0.0.0/24 but that is a no go since version 4...
-
Struts problem on IBM Websphere
Hi, We have a struts application that works fine when running in the IBM Webphere Studio Application Developer. But when it is deployed to IBM Websphere in our test environment, it spits out the following error on start up. RVE0100E: Did not realize
-
Hello folks! I am creating an Excel chart using Excel Interop (please find below code and output for the code given below). I need to vary the colors of same-series chart bar graphs (The graphs only now in orange). This line of code doesn't do the tr