Issue in select query
HI All experts,<br><br>
i have a program in which i have a select query <pre>
SELECT b~vertrag
a~anlage
a~operand
a~saison
a~ab
a~ablfdnr
a~bis
a~wert1
FROM ettifn AS a INNER JOIN ever AS b
ON aanlage = banlage
INTO TABLE li_captran PACKAGE SIZE p_pack
WHERE a~anlage IN s_anlage
AND a~ab <= l_date
AND a~bis >= l_date
AND a~operand IN ('ID-CAPLOAD','ID-OBLT')
AND b~einzdat <= l_date
AND b~auszdat >= l_date.</pre><br><br>
this query is taking a lot of time in running and we are facing lot of performance related issues
<br><br>
kindly guide me how i can break this into som simpler query
<br><br>
ettifn has 10 million records
ever has around 5 million records .
<br><br>
also please tell me how much data i can store into an internal table
can i store 5 million records in an internal table ??????
is it good in terms of performance of a program if not please tell me what is the better way of doing dat .
<br><br>
also tell me how secondry indexes help in improving performance of select query
is it good to maintain number of secondry indexes in a standard table or it decreases performance of a standard table .
<br><br>
<pre>
TYPES: BEGIN OF ty_eanlh,
anlage LIKE eanlh-anlage,
bis LIKE eanlh-bis,
tariftyp LIKE eanlh-tariftyp,
END OF ty_eanlh.
DATA: l_date TYPE datum.
DATA: li_eanlh TYPE HASHED TABLE OF ty_eanlh WITH UNIQUE KEY anlage
bis
WITH HEADER LINE.
DATA: li_captran TYPE HASHED TABLE OF ty_captran WITH UNIQUE KEY vertrag
anlage
operand
saison
ab
ablfdnr
WITH HEADER LINE.
DATA: l_tariftyp LIKE eanlh-tariftyp.
l_date = p_date + 6.
l_date = p_date + 5. "As per Terry's Request 1/23/2009
CHECK NOT p_cap IS INITIAL.
Get Operand Values
SELECT b~vertrag
a~anlage
a~operand
a~saison
a~ab
a~ablfdnr
a~bis
a~wert1
FROM ettifn AS a INNER JOIN ever AS b
ON aanlage = banlage
INTO TABLE li_captran PACKAGE SIZE p_pack
WHERE a~anlage IN s_anlage
AND a~ab <= l_date
AND a~bis >= l_date
AND a~operand IN ('ID-CAPLOAD','ID-OBLT')
AND b~einzdat <= l_date
AND b~auszdat >= l_date.
IF sy-subrc EQ 0 AND NOT li_captran[] IS INITIAL.
Get Rate Category
SELECT anlage
bis
tariftyp
FROM eanlh INTO CORRESPONDING FIELDS OF TABLE li_eanlh
FOR ALL ENTRIES IN li_captran
WHERE anlage = li_captran-anlage
AND ab <= l_date
AND bis >= l_date.
Get POD ID
SELECT a~anlage
a~int_ui
a~dateto
a~timeto
b~ext_ui
INTO TABLE i_pod
FROM euiinstln AS a INNER JOIN euitrans AS b
ON aint_ui = bint_ui
FOR ALL ENTRIES IN li_captran
WHERE a~anlage = li_captran-anlage.
IF sy-subrc EQ 0 AND NOT i_pod[] IS INITIAL.
SORT i_pod BY anlage.
SELECT vertrag
int_ui
serviceid
FROM eservice
INTO TABLE i_servicect
FOR ALL ENTRIES IN i_pod
WHERE int_ui = i_pod-int_ui
AND service_start <= l_date
AND service_end >= l_date
AND service = 'ESUP'.
ENDIF.
LOOP AT li_captran.
i_ct-anlage = li_captran-anlage.
READ TABLE li_eanlh WITH KEY anlage = li_captran-anlage.
IF sy-subrc EQ 0.
i_ct-tariftyp = li_eanlh-tariftyp.
READ TABLE i_rate WITH KEY tariftyp = i_ct-tariftyp.
IF sy-subrc NE 0.
CONTINUE.
ENDIF.
ELSE.
i_ct-tariftyp = '0000'.
ENDIF.
READ TABLE i_pod WITH KEY anlage = li_captran-anlage.
IF sy-subrc EQ 0.
READ TABLE i_servicect WITH KEY int_ui = i_pod-int_ui.
IF sy-subrc EQ 0.
i_ct-serviceid = i_servicect-serviceid.
ENDIF.
ENDIF.
IF li_captran-operand = 'ID-CAPLOAD'.
i_ct-cap = li_captran-wert1.
ELSEIF li_captran-operand = 'ID-OBLT'.
i_ct-tran = li_captran-wert1.
ENDIF.
COLLECT i_ct.
CLEAR: li_captran, i_ct.
ENDLOOP.
ENDIF.
ENDSELECT.</pre><br><br>
this code is taking a lot of time to execute and decreasing the system performance .<br><br>
please guide me how can i increase the performance of this code .<br><br>
Thanks in advance<br><br><br><br>
Edited by: Matt on Oct 11, 2009 9:45 PM
Hi matt ,
no i am not thru bcoz of formatting i just trying to remove it and i just marked it answered so that it will not come in my unanswered because unanswered questions are limited.
also could you please help me in this question .
now how can i change this question to unanswerd .
plz guide me
Thanks in advance
Similar Messages
-
Issue in select query with where clause
Hi guys,
I'm facing an issue while using select query with the where clause. When I'm selecting all the data from the table it returns the correct result. But when I'm using the where clause to get the specific rows from the table it returns no rows. But the data I'm trying to fetch using the where condition exists in the table.
Here is my query which causing the issue,
select * from mytable where myfield = 'myvalue'
But if I use the following query it returns the result correctly.
select * from mytable
Also the myfield value 'myvalue' exists in the table.
I have tried by running this query in both SQL Developer and SQL Plus. I have tried this query in mssql as well. It works perfectly and returns correct result sets for both the queries I have mentioned above. I'm unable to predict the issue as I'm new to ORACLE. Please help.
Thanks,
Ram.Hi Ram,
I experienced an issue similar to this with a varchar2 field. Some of our records had a hidden newline character at the end of them, which was making queries like the one below fail:
select * from employees
where email = '[email protected]'The best way I found to detect this was to use
select 'XX'||email||'XX' from employeesTo make sure that there were no newlines. But that is just a guess. If you could provide some example table data and the outputs of your selects, it would be helpful.
Jeff -
Issue with Select Query in the Delivery userexit USEREXIT_SAVE_DOCUMENT
Hi All,
I am facing a strang issue with delivery userexit
1) I have a delivery user exit MV50AFZ1 - USEREXIT_SAVE_DOCUMENT.
2) In this user exit. I have written a select query as shown below
*Get the already delivered data
SELECT vbeln
vgbel
vgpos
erdat
erzet
lfimg
FROM lips
INTO TABLE t_lips
FOR ALL ENTRIES IN t_xlips_reference
WHERE vgbel EQ t_xlips_reference-vgbel
AND vgpos EQ t_xlips_reference-vgpos.
IF sy-subrc EQ 0.
ENDIF.
3) The use of the above select query is to find out if there is any delivery that has already been created for the reference slaes order for which the current delivery is being created.
4) The issue here is that for the FIRST DELIVERY, this select query should fail becuase there is no delivery created earlier and LIPS table would not have data. But, I am seeing some data getting populated in the internal table. The data that I am seeing in the internal table is the data of XLIPS which is nothing but the one that is about to get saved in the database after finishing this userexit.
5) STRANGE Point is that this is working fine in case if I create delivery using the transaction VL01N. But, if I create delivery using VL10A program I am facing this issue.
<< Removed >>
Thanks,
Babu Kilari
Edited by: Rob Burbank on Jun 16, 2010 4:22 PMThen why don't you add
AND vbeln NE likp-vbeln -
Performance issue with select query
Hi friends ,
This is my select query which is taking so much time to retrive the records.CAn Any one help me in solving this performance issue.
*- Get the Goods receipts mainly selected per period (=> MKPF secondary
SELECT msegebeln msegebelp mseg~werks
ekkobukrs ekkolifnr ekkozterm ekkoekorg ekko~ekgrp
ekkoinco1 ekkoexnum
lfa1name1 lfa1land1 lfa1ktokk lfa1stceg
mkpfmblnr mkpfmjahr msegzeile mkpfbldat mkpf~budat
mseg~bwart
*Start of changes for CIP 6203752 by PGOX02
mseg~smbln
*End of changes for CIP 6203752 by PGOX02
ekpomatnr ekpotxz01 ekpomenge ekpomeins
ekbemenge ekbedmbtr ekbewrbtr ekbewaers
ekpolgort ekpomatkl ekpowebaz ekpokonnr ekpo~ktpnr
ekpoplifz ekpobstae
INTO TABLE it_temp
FROM mkpf JOIN mseg ON msegmblnr EQ mkpfmblnr
AND msegmjahr EQ mkpfmjahr
JOIN ekbe ON ekbeebeln EQ msegebeln
AND ekbeebelp EQ msegebelp
AND ekbe~zekkn EQ '00'
AND ekbe~vgabe EQ '1'
AND ekbegjahr EQ msegmjahr
AND ekbebelnr EQ msegmblnr
AND ekbebuzei EQ msegzeile
JOIN ekpo ON ekpoebeln EQ ekbeebeln
AND ekpoebelp EQ ekbeebelp
JOIN ekko ON ekkoebeln EQ ekpoebeln
JOIN lfa1 ON lfa1lifnr EQ ekkolifnr
WHERE mkpf~budat IN so_budat
AND mkpf~bldat IN so_bldat
AND mkpf~vgart EQ 'WE'
AND mseg~bwart IN so_bwart
AND mseg~matnr IN so_matnr
AND mseg~werks IN so_werks
AND mseg~lifnr IN so_lifnr
AND mseg~ebeln IN so_ebeln
AND ekko~ekgrp IN so_ekgrp
AND ekko~bukrs IN so_bukrs
AND ekpo~matkl IN so_matkl
AND ekko~bstyp IN so_bstyp
AND ekpo~loekz EQ space
AND ekpo~plifz IN so_plifz.
Thanks & Regards,
Manoj Kumar .Thatha
Moderator message - Please see Please Read before Posting in the Performance and Tuning Forum before posting and please use code tags when posting code - post locked
Edited by: Rob Burbank on Feb 4, 2010 9:03 AMHi friends ,
This is my select query which is taking so much time to retrive the records.CAn Any one help me in solving this performance issue.
*- Get the Goods receipts mainly selected per period (=> MKPF secondary
SELECT msegebeln msegebelp mseg~werks
ekkobukrs ekkolifnr ekkozterm ekkoekorg ekko~ekgrp
ekkoinco1 ekkoexnum
lfa1name1 lfa1land1 lfa1ktokk lfa1stceg
mkpfmblnr mkpfmjahr msegzeile mkpfbldat mkpf~budat
mseg~bwart
*Start of changes for CIP 6203752 by PGOX02
mseg~smbln
*End of changes for CIP 6203752 by PGOX02
ekpomatnr ekpotxz01 ekpomenge ekpomeins
ekbemenge ekbedmbtr ekbewrbtr ekbewaers
ekpolgort ekpomatkl ekpowebaz ekpokonnr ekpo~ktpnr
ekpoplifz ekpobstae
INTO TABLE it_temp
FROM mkpf JOIN mseg ON msegmblnr EQ mkpfmblnr
AND msegmjahr EQ mkpfmjahr
JOIN ekbe ON ekbeebeln EQ msegebeln
AND ekbeebelp EQ msegebelp
AND ekbe~zekkn EQ '00'
AND ekbe~vgabe EQ '1'
AND ekbegjahr EQ msegmjahr
AND ekbebelnr EQ msegmblnr
AND ekbebuzei EQ msegzeile
JOIN ekpo ON ekpoebeln EQ ekbeebeln
AND ekpoebelp EQ ekbeebelp
JOIN ekko ON ekkoebeln EQ ekpoebeln
JOIN lfa1 ON lfa1lifnr EQ ekkolifnr
WHERE mkpf~budat IN so_budat
AND mkpf~bldat IN so_bldat
AND mkpf~vgart EQ 'WE'
AND mseg~bwart IN so_bwart
AND mseg~matnr IN so_matnr
AND mseg~werks IN so_werks
AND mseg~lifnr IN so_lifnr
AND mseg~ebeln IN so_ebeln
AND ekko~ekgrp IN so_ekgrp
AND ekko~bukrs IN so_bukrs
AND ekpo~matkl IN so_matkl
AND ekko~bstyp IN so_bstyp
AND ekpo~loekz EQ space
AND ekpo~plifz IN so_plifz.
Thanks & Regards,
Manoj Kumar .Thatha
Moderator message - Please see Please Read before Posting in the Performance and Tuning Forum before posting and please use code tags when posting code - post locked
Edited by: Rob Burbank on Feb 4, 2010 9:03 AM -
Performance issue with select query and for all entries.
hi,
i have a report to be performance tuned.
the database table has around 20 million entries and 25 fields.
so, the report fetches the distinct values of two fields using one select query.
so, the first select query fetches around 150 entries from the table for 2 fields.
then it applies some logic and eliminates some entries and makes entries around 80-90...
and then it again applies the select query on the same table using for all entries applied on the internal table with 80-90 entries...
in short,
it accesses the same database table twice.
so, i tried to get the database table in internal table and apply the logic on internal table and delete the unwanted entries.. but it gave me memory dump, and it wont take that huge amount of data into abap memory...
is around 80-90 entries too much for using "for all entries"?
the logic that is applied to eliminate the entries from internal table is too long, and hence cannot be converted into where clause to convert it into single select..
i really cant find the way out...
please help.chinmay kulkarni wrote:Chinmay,
Even though you tried to ask the question with detailed explanation, unfortunately it is still not clear.
It is perfectly fine to access the same database twice. If that is working for you, I don't think there is any need to change the logic. As Rob mentioned, 80 or 8000 records is not a problem in "for all entries" clause.
>
> so, i tried to get the database table in internal table and apply the logic on internal table and delete the unwanted entries.. but it gave me memory dump, and it wont take that huge amount of data into abap memory...
>
It is not clear what you tried to do here. Did you try to bring all 20 million records into an internal table? That will certainly cause the program to short dump with memory shortage.
> the logic that is applied to eliminate the entries from internal table is too long, and hence cannot be converted into where clause to convert it into single select..
>
That is fine. Actually, it is better (performance wise) to do much of the work in ABAP than writing a complex WHERE clause that might bog down the database. -
Issue with select query for secondary index
Hi all,
I have created a secondary index A on mara table with fields Mandt and Packaging Material Type VHART.
Now i am trying to write a report
Tables : mara.
data : begin of itab occurs 0.
include structure mara.
data : end of itab.
*select * from mara into table itab*
CLIENT SPECIFIED where
MANDT = SY-MANDT and
VHART = 'WER'.
I'm getting an error
Unable to interpret "CLIENT". Possible causes of error: Incorrect spelling or comma error.
if i change to my select query to
*select * from mara into table itab*
where
MANDT = SY-MANDT and
VHART = 'WER'.
I'm getting an error
Without the addition "CLIENT SPECIFIED", you cannot specify the client field "MANDT" in the WHERE condition.
Let me know if iam wrong and we are at 4.6c
ThanksLike I already said, even if you have added the mandt field in the secondary index, there is no need the use it in the select statement.
Let me elaborate on my reply before. If you have created a UNIQUE index, which I don't think you have, then you should include CLIENT in the index. A unique index for a client-dependent table must contain the client field.
Additional info:
The accessing speed does not depend on whether or not an index is defined as a unique index. A unique index is simply a means of defining that certain field combinations of data records in a table are unique.
Even if you have defined a secondary index, this does not automatically mean, that this index is used. This also depends on the database optimizer. The optimizer will determine which index is best and use it. So before transporting this index, you should make sure that the index is used. How to check this, have a look at the link:
[check if index is used|http://help.sap.com/saphelp_nw70/helpdata/EN/cf/21eb3a446011d189700000e8322d00/content.htm]
Edited by: Micky Oestreich on May 13, 2008 10:09 PM -
Issue with select query join....
Hello,
I am facing a problem with a select query. I get a message that itab_data is not long enough.
DATA: itab_data like ptrv_head occurs 0 with header line.
SELECT * from PTRV_HEAD
as a inner join PA0002 as b
on a~pernr = b~pernr
inner join PA0001 as c
on a~pernr = c~pernr
INTO TABLE itab_data
where a~PERNR in S_PERNR
and a~REINR in S_TRIP
and a~ZLAND in S_LAND
and a~DATV1 in S_BEGIN
and a~DATB1 in S_END
and b~NACHN in S_FIRST
and b~VORNA in S_LAST
and c~BUKRS in S_BUKRS
and c~KOSTL in S_KOSTL
and c~PERSG in S_EMPGP
and c~PERSK in S_SUBGP
and c~begda in ldbbegda
and c~endda in ldbendda.
Regards,
Jainam.
Edited by: Jainam Shah on Mar 27, 2009 4:13 PM
Edited by: Jainam Shah on Mar 27, 2009 4:13 PMHi,
Try this..
DATA: t_dfies TYPE STANDARD TABLE OF dfies.
DATA: t_fields TYPE STANDARD TABLE OF char40.
DATA: s_dfies TYPE dfies,
s_fields TYPE char40.
* Get the fields
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = 'PTRV_HEAD'
TABLES
dfies_tab = t_dfies[]
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Build the fields to be selected.
LOOP AT t_dfies INTO s_dfies.
CONCATENATE 'A~' s_dfies-fieldname INTO s_fields.
APPEND s_fields TO t_fields.
CLEAR: s_fields.
ENDLOOP.
* Select.
SELECT (t_fields) from PTRV_HEAD
Thanks
Naren -
Performance issue in Select Query on ERCH
Dear Friends,
I have to execute a query on ERCH in production system having around 20 lakh data which keeps on increasing. "Select BELNR VERTRAG ADATSOLL from ERCH where BCREASON = u201803u2019 " . The expected volume of data that the query will return is approx 1400 records.
Since the where clause includes a field which is not a key field please suggest the performance of the query so that it doesn't time-out.
Regards,
Amit SrivastavaHello Amit Srivastava ,
You can add the Contract account number(VKONT) and Business Partner number(GPARTNER) in your query and can create a custom Index for the contract account number (We have this index created in our system).
This will improve the performance effectively.
Hope this answers your question.
Thanks,
Greetson -
Issue with select query to fetch data using Join from two tabels
Hello All-
I want to fetch the ShowName as "SUN NIGHTLY NEWS" and EpisodeName as "091706"
based on the condition a.TitleNo=b.TitleNo and a.seriesNo=b.TitleNo.
If i use the only first condition-a.TitleNo=b.TitleNo than output is displayed as-
SchedItemNo | Showname| EpisodeName
2702154 | 091706 | 091706
If i use the second Condition-a.seriesNo=b.TitleNo than Output is displayed as-
SchedItemNo| Showname | EpisodeName
2702154 | SUN NIGHTLY NEWS | SUN NIGHTLY NEWS
Than i tried following Query to use the Union based on two conditions:-
Select distinct a.SchedItemNo,b.TitleName,b.TitleName as EpisodeName
from ScheduleItem a,Titles b where a.TitleNo=b.TitleNo and
a.ScheditemNo in ('2702154')
Union All
Select distinct a.SchedItemNo,b.TitleName,b.TitleName as EpisodeName
from ScheduleItem a,Titles b where b.TitleNo=a.SeriesNo and
a.ScheditemNo in ('2702154')
than it display the following result-
SchedItemNo| Showname | EpisodeName
2702154 | 091706 | 091706
2702154 | SUN NIGHTLY NEWS | SUN NIGHTLY NEWS
Here also values are not what i want :(
I want the result to be displayed as using SQL:-
SchedItemNo | Showname | EpisodeName
2702154 | SUN NIGHTLY NEWS | 091706
Please help me out!
Thanks in Advance for putting your efforts.Looking forward for your replies.SQL> create table scheduleitem
2 as
3 select 2702154 scheditemno, 1 titleno, 11 seriesno from dual
4 /
Tabel is aangemaakt.
SQL> create table titles
2 as
3 select 1 titleno, '071706' titlename from dual union all
4 select 11, 'SUN NIGHTLY NEWS' from dual
5 /
Tabel is aangemaakt.
SQL> Select distinct a.SchedItemNo,b.TitleName,b.TitleName as EpisodeName
2 from ScheduleItem a,Titles b where a.TitleNo=b.TitleNo and
3 a.ScheditemNo in ('2702154')
4 /
SCHEDITEMNO TITLENAME EPISODENAME
2702154 071706 071706
1 rij is geselecteerd.
SQL> Select distinct a.SchedItemNo,b.TitleName,b.TitleName as EpisodeName
2 from ScheduleItem a,Titles b where b.TitleNo=a.SeriesNo and
3 a.ScheditemNo in ('2702154')
4 /
SCHEDITEMNO TITLENAME EPISODENAME
2702154 SUN NIGHTLY NEWS SUN NIGHTLY NEWS
1 rij is geselecteerd.
SQL> Select distinct a.SchedItemNo,b.TitleName,b.TitleName as EpisodeName
2 from ScheduleItem a,Titles b where a.TitleNo=b.TitleNo and
3 a.ScheditemNo in ('2702154')
4 Union All
5 Select distinct a.SchedItemNo,b.TitleName,b.TitleName as EpisodeName
6 from ScheduleItem a,Titles b where b.TitleNo=a.SeriesNo and
7 a.ScheditemNo in ('2702154')
8 /
SCHEDITEMNO TITLENAME EPISODENAME
2702154 071706 071706
2702154 SUN NIGHTLY NEWS SUN NIGHTLY NEWS
2 rijen zijn geselecteerd.
SQL> select a.SchedItemNo "SchedItemNo"
2 , show.TitleName "Showname"
3 , episode.TitleName "EpisodeName"
4 from ScheduleItem a
5 , Titles episode
6 , Titles show
7 where a.TitleNo = episode.TitleNo
8 and a.SeriesNo = show.TitleNo
9 /
SchedItemNo Showname EpisodeName
2702154 SUN NIGHTLY NEWS 071706
1 rij is geselecteerd.Regards,
Rob. -
Performance issue in select query
Moderator message: do not post the same question in two forums. Duplicate (together with answers) deleted.
SELECT a~grant_nbr
a~zzdonorfy
a~company_code
b~language
b~short_desc
INTO TABLE i_gmgr_text
FROM gmgr AS a
INNER JOIN gmgrtexts AS b ON a~grant_nbr = b~grant_nbr
WHERE a~grant_nbr IN s_grant
AND a~zzdonorfy IN s_dono
AND b~language EQ sy-langu
AND b~short_desc IN s_cont.
How to use for all all entries in the above inner join for better performance?
then....
IF sy-subrc EQ 0.
SORT i_gmgr_text BY grant_nbr.
ENDIF.
IF i_gmgr_text[] IS NOT INITIAL.
* Actual Line Item Table
SELECT rgrant_nbr
gl_sirid
rbukrs
rsponsored_class
refdocnr
refdocln
FROM gmia
INTO TABLE i_gmia
FOR ALL ENTRIES IN i_gmgr_text
WHERE rgrant_nbr = i_gmgr_text-grant_nbr
AND rbukrs = i_gmgr_text-company_code
AND rsponsored_class IN s_spon.
IF sy-subrc EQ 0.
SORT i_gmia BY refdocnr refdocln.
ENDIF.
Edited by: Matt on Dec 17, 2008 1:40 PM> How to use for all all entries in the above inner join for better performance?
my best christmas recommendation for performance, simply ignore such recommendations.
And check the performance of your join!
Is the performance really low, if it is then there is probably no index support. Without indexes FOR ALL ENTRIES will be much slower.
Siegfried -
Performance issue on select query
hi,
Can any explain how the system behaves for the below 2 scenarios and which is much better?
In table EABLG i have around 1 billion records (FYI)
1)
SELECT
ablbelnr
anlage
ablesgr
FROM eablg
INTO TABLE it_eablg
FOR ALL ENTRIES IN it_eanl
WHERE ( anlage = it_eanl-anlage
AND ablesgr = '01'
AND adatsoll GT '20080706' ) " last 3 months
OR ( anlage = it_eanl-anlage
AND ablesgr = '06'
AND adatsoll GT '20080706' ) " last 3 months
2)
SELECT
ablbelnr
anlage
ablesgr
FROM eablg
INTO TABLE it_eablg
FOR ALL ENTRIES IN it_eanl
WHERE anlage = it_eanl-anlage
AND ( ablesgr = '01'
OR ablesgr = '06')
AND adatsoll GT '20080706' . " last 3 months
thanks in advance.
with regards
sumanthThe statement has to be in a special format, so it might make sense run a trace in DEV, check the "Explain" there and download/upload the statement to QA (also via ST05). I have not tried this myself yet, so I would be interested if it works
Here is two resources for you, SAP online help and a good blog by Siegfried Boes:
http://help.sap.com/saphelp_erp60_sp/helpdata/EN/d1/801f7c454211d189710000e8322d00/frameset.htm
The SQL Trace (ST05) Quick and Easy
It's a very powerful analysis tool, so it's worth the time to work yourself into it.
But again, you actually want good test data in DEV for this matter.
Thomas -
Hello experts,
I want a join on table ekpo & mbew(for valuation class).
But its not working.
if valclass is initial.
select aebeln aebelp atxz01 amatnr abukrs awerks a~menge
a~mtart
b~bklas
from ekpo as a inner join mbew as b on bmatnr eq amatnr
into corresponding fields of table ekpo_mbew
where ( a~matnr eq mat_num ) and
( a~bukrs eq compcode ) and
( a~werks eq plant ) and
( a~mtart eq mat_type ) and
b~bklas in ('3001','3045' ,'3006','3055','3065') and
( amatnr eq bmatnr ).
else.
select aebeln aebelp atxz01 amatnr abukrs awerks a~menge
a~mtart
b~bklas
from ekpo as a inner join mbew as b on bmatnr eq amatnr
into corresponding fields of table ekpo_mbew
where ( a~matnr eq mat_num ) and
( a~bukrs eq compcode ) and
( a~werks eq plant ) and
( a~mtart eq mat_type ) and
( b~bklas in valclass ) and
( amatnr eq bmatnr ).
endif.
Plz tell where I m wrng.
Ravi.Hi,
Try the below code,
SELECT aebeln aebelp atxz01 amatnr abukrs awerks a~menge
a~mtart
b~bklas
FROM ekpo AS a INNER JOIN mbew AS b ON bmatnr EQ amatnr INTO CORRESPONDING FIELDS OF TABLE ekpo_mbew
WHERE a~matnr EQ mat_num AND
a~bukrs EQ compcode AND
a~werks EQ plant AND
a~mtart EQ mat_type AND
b~bklas IN ('3001','3045' ,'3006','3055','3065').
ELSE.
SELECT aebeln aebelp atxz01 amatnr abukrs awerks a~menge
a~mtart
b~bklas
FROM ekpo AS a INNER JOIN mbew AS b
ON bmatnr EQ amatnr
INTO CORRESPONDING FIELDS OF TABLE ekpo_mbew
WHERE a~matnr EQ mat_num AND
a~bukrs EQ compcode AND
a~werks EQ plant AND
a~mtart eq mat_type AND
b~bklas IN valclass .
Note :- ( amatnr eq bmatnr ) this is not necessary as the INNER JOIN is on that condition itself.
Regards
Bala Krishna -
Parallel process in select query
Hi Experts
its production
stats are good
indexes are good
issue :
a select query is taking time 20min , the indexes exists on the where clause columns, I tried the query using parallel hint it gave the results iin 20 sec.
the DOP of the table set to 10, but when I run the query it picks old plan
constraints : I cannot modify the query, it needs to be tuned without modifying it
if DOP is >1 then select is expected to use parallellism in explain plan..is my understanding correct?
if I am wrong please advice how can i force the query to use the parallellism
Please advice and guide asap
THanks in advance
Ajay Kumaruser513478 wrote:
Hi Experts
its production
stats are good
indexes are good
issue :
a select query is taking time 20min , the indexes exists on the where clause columns, I tried the query using parallel hint it gave the results iin 20 sec.
the DOP of the table set to 10, but when I run the query it picks old plan
constraints : I cannot modify the query, it needs to be tuned without modifying itWhat version of Oracle?
Tuning SQL without modifying the SQL can be very hard but you may have options.
Could you use a materialized view with automatic query rewrite?
Can you use a SQL profile to affect performance?
Have you looked very+ carefully at the indexes to see if other indexes might be more efficient?
20 minutes to 20 seconds sounds too good to be true. Are you sure you aren't reading cached data and that the 2nd, faster run really is running in parallel? -
Performance issue after Upgrade from 4.7 to ECC 6.0 with a select query
Hi All,
There is a Performance issue after Upgrade from 4.7 to ECC 6.0 with a select query in a report painter.
This query is working fine when executed in 4.7 system where as it is running for more time in ECC6.0.
Select query is on the table COSP.
SELECT (FIELD_LIST)
INTO CORRESPONDING FIELDS OF TABLE I_COSP PACKAGE SIZE 1000
FROM COSP CLIENT SPECIFIED
WHERE GJAHR IN SELR_GJAHR
AND KSTAR IN SELR_KSTAR
AND LEDNR EQ '00'
AND OBJNR IN SELR_OBJNR
AND PERBL IN SELR_PERBL
AND VERSN IN SELR_VERSN
AND WRTTP IN SELR_WRTTP
AND MANDT IN MANDTTAB
GROUP BY (GROUP_LIST).
LOOP AT I_COSP .
COSP = I_COSP .
PERFORM PCOSP USING I_COSP-_COUNTER.
CLEAR: $RWTAB, COSP .
CLEAR CCR1S .
ENDLOOP.
ENDSELECT.
I have checked with the table indexes, they were same as in 4.7 system.
What can be the reson for the difference in execution time. How can this be reduced without adjusting the select query.
Thanks in advance for the responses.
Regards,
Dedeepya.Hi,
ohhhhh....... lots of problems in select query......this is not the way you should write it.
Some generic comments:
1. never use SELECT
endselect.
SELECT
into table
for all entries in table
where.
use perform statment after this selection.
2. Do not use into corresponding fields. use exact structure type.
3. use proper sequence of fields in the where condition so that it helps table go according to indexes.
e.g in your case
sequence should be
LEDNR
OBJNR
GJAHR
WRTTP
VERSN
KSTAR
HRKFT
VRGNG
VBUND
PARGB
BEKNZ
TWAER
PERBL
sequence should be same as defined in table.
Always keep select query as simple as possible and perform all other calculations etc. afterwords.
I hope it helps.
Regards,
Pranaya -
SELECT query performance issue
Hello experts!!!
I am facing the performance issue in the below SELECT query. Its taking long time to execute this query.
Please suggest how can i improve the performance of this query.
SELECT MBLNR MATNR LIFNR MENGE WERKS BUKRS LGORT BWART INTO CORRESPONDING FIELDS OF TABLE IT_MSEG
FROM MSEG
WHERE MATNR IN S_MATNR
AND LIFNR IN S_LIFNR
AND WERKS IN S_WERKS
AND BUKRS IN S_BUKRS
AND XAUTO = ''
AND BWART IN ('541' , '542' , '543' , '544', '105' , '106').
Thanks in advance.
Regards
AnkurHi Ankur,
the MSEG index for material is
Index MSEG~M
MANDT
MATNR
WERKS
LGORT
BWART
SOBKZ
It could be used very efficient if you supply values for MATNR, WERKS and LGORT.
There is no index on LIFNR. IKf you want the data for specific vendor(s), you should select from EKKO first, ir has index Index EKKO~1
MANDT
LIFNR
EKORG
EKGRP
BEDAT
You can JOIN EKKO and EKBE to get the BSEG key fields GJAHR BELNR BUZEI directly.
I don't know your details but I think you can get all you need from EKKO and EKBE. You may also consider EKPO as is has a material index Index EKPO~1
MANDT
MATNR
WERKS
BSTYP
LOEKZ
ELIKZ
MATKL
Do you really need the (much bigger) MSEG?
Regards,
Clemens
Maybe you are looking for
-
please respond to question above
-
This is a Question: I have one random Apple ID that comes up only when I'm trying to access Apps or iTunes. I have another Apple ID with a password that works just fine for everything else. I do not have a password for this random id. How can I g
-
How to determine the version of Adobe Reader X I have
How to determine the version of Adobe Reader X, I have
-
Characterstic is not showing up in Bex.
Hello, I have created a multicube with 4 basic cubes. All basic cubes have fiscal variant as time characterstic. As well, multicube also has fiscal variant in time dimension. However, in the Query designer (Bex), this characterstic is NOT showing up.
-
The following files could not be found??
All, Over Christmas I backed up my entire system to an external HD and then performed an erase and install of Tiger just to clean everything out. The transition has gone well until tonight . . . I went to open an older iDVD project I was working on a