Performance problem of asset selection statement.
Hi guys quick question.
SELECT a~bukrs
a~anln1
b~anln2
a~anlkl
a~aktiv
a~txt50
a~lvtnr
b~afabe
b~afabg
b~ndjar
b~ndper
INTO TABLE it_anla
FROM anla AS a
INNER JOIN anlb AS b
ON a~bukrs EQ b~bukrs
AND a~anln1 EQ b~anln1
WHERE a~bukrs IN s_bukrs
AND a~anln1 IN s_anln1
AND a~anln2 EQ '0000'
AND a~anlkl IN s_anlkl
AND a~aktiv EQ '00000000'
AND a~lvtnr IN s_lvtnr
AND b~afabe EQ 01.
I have a select statement which is filtered by capitalization date which is the field AKTIV. This select alone has 450 thousand hits. Having an ANLN2 = 0 and AKTIV = blank/no date means that the asset group is no longer active.
Now for another scenario I have to retrieve table ANLA again excluding all the Main Asset Number/ANLN1 found on that table.
Is there a way to select by doing it only once?
I tried to pass all the anln1 to a range table but the program dumps. I think the range table can't handle too many entries.
Retrieving all the entries from the DB then processing it takes longer.
I tried to delete the table using a loop but it takes to long as it process the table every loop.
LOOP AT it_anla WHERE anln2 EQ '0000' AND aktiv EQ '0000000'.
DELETE it_anla WHERE bukrs EQ it_anla-bukrs AND anln1 EQ it_anla-anln1.
ENDLOOP.
Thanks.
Edited by: Thomas Zloch on Sep 21, 2010 5:39 PM - please use code tags
Moderator message - Welcome to SCN
If the range table for anln1 is large and contains distinct values, you can try using it in a FOR ALL ENTRIES construct rather than IN.
Rob
Similar Messages
-
Increase performance of the following SELECT statement.
Hi All,
I have the following select statement which I would want to fine tune.
CHECK NOT LT_MARC IS INITIAL.
SELECT RSNUM
RSPOS
RSART
MATNR
WERKS
BDTER
BDMNG FROM RESB
INTO TABLE GT_RESB
FOR ALL ENTRIES IN LT_MARC
WHERE XLOEK EQ ' '
AND MATNR EQ LT_MARC-MATNR
AND WERKS EQ P_WERKS
AND BDTER IN S_PERIOD.
The following query is being run for a period of 1 year where the number of records returned will be approx 3 million. When the program is run in background the execution time is around 76 hours. When I run the same program dividing the selection period into smaller parts I am able to execute the same in about an hour.
After a previous posting I had changed the select statement to
CHECK NOT LT_MARC IS INITIAL.
SELECT RSNUM
RSPOS
RSART
MATNR
WERKS
BDTER
BDMNG FROM RESB
APPENDING TABLE GT_RESB PACKAGE SIZE LV_SIZE
FOR ALL ENTRIES IN LT_MARC
WHERE XLOEK EQ ' '
AND MATNR EQ LT_MARC-MATNR
AND WERKS EQ P_WERKS
AND BDTER IN S_PERIOD.
ENDSELECT.
But the performance improvement is very negligible.
Please suggest.
Regards,
KarthikHi Karthik,
<b>Do not use the appending statement</b>
Also you said if you reduce period then you get it quickly.
Why not try dividing your internal table LT_MARC into small internal tables having max 1000 entries.
You can read from index 1 - 1000 for first table. Use that in the select query and append the results
Then you can refresh that table and read table LT_MARC from 1001-2000 into the same table and then again execute the same query.
I know this sounds strange but you can bargain for better performance by increasing data base hits in this case.
Try this and let me know.
Regards
Nishant
> I have the following select statement which I would
> want to fine tune.
>
> CHECK NOT LT_MARC IS INITIAL.
> SELECT RSNUM
> RSPOS
> RSART
> MATNR
> WERKS
> BDTER
> BDMNG FROM RESB
> INTO TABLE GT_RESB
> FOR ALL ENTRIES IN LT_MARC
> WHERE XLOEK EQ ' '
> AND MATNR EQ LT_MARC-MATNR
> AND WERKS EQ P_WERKS
> AND BDTER IN S_PERIOD.
>
> e following query is being run for a period of 1 year
> where the number of records returned will be approx 3
> million. When the program is run in background the
> execution time is around 76 hours. When I run the
> same program dividing the selection period into
> smaller parts I am able to execute the same in about
> an hour.
>
> After a previous posting I had changed the select
> statement to
>
> CHECK NOT LT_MARC IS INITIAL.
> SELECT RSNUM
> RSPOS
> RSART
> MATNR
> WERKS
> BDTER
> BDMNG FROM RESB
> APPENDING TABLE GT_RESB
> PACKAGE SIZE LV_SIZE
> FOR ALL ENTRIES IN LT_MARC
> WHERE XLOEK EQ ' '
> AND MATNR EQ LT_MARC-MATNR
> AND WERKS EQ P_WERKS
> AND BDTER IN S_PERIOD.
> the performance improvement is very negligible.
> Please suggest.
>
> Regards,
> Karthik
Hi Karthik, -
Problem in jdbc select statement
{{ public List dis(int getmodified,int getindex){
List outerList=null;
outerList=new ArrayList();
List display=null;
try{
System.out.println("testing.....3");
con=getconnection();
pstmt= con.prepareStatement("SELECT title from newss where nno >(10*(?)) and nno <=(10*?)");
pstmt.setInt(1,getmodified);
pstmt.setInt(2,getindex);
System.out.println("testing.....2");
//pstmt.setInt(1,pgno);
rs=pstmt.executeQuery();
while(rs.next())
display=new ArrayList();
display.add(rs.getString(1));
System.out.println("###########################" +rs.getString(1));
System.out.println("(((((((((((())))))))))" +display);
outerList.add(display);
}catch(Exception e){
System.out.println ("exception in select statement" +e.getMessage());
System.out.println("*************" +outerList);
return outerList;
my problem is it says exception in select statement and no data found
can someone resolve my problem}Check the below code snippet this what my fellow poster meant.check whether the proposed works well or not.
public List dis(int getmodified,int getindex){
List outerList = new ArrayList();
List display=null;
try{
System.out.println("testing.....3");
con = getconnection();
pstmt = con.prepareStatement("SELECT title from newss where nno > ? and nno <= ?");
pstmt.setInt(1,10*getmodified);
pstmt.setInt(2,10*getindex);
System.out.println("testing.....2");
rs = pstmt.executeQuery();
while(rs.next()){
display=new ArrayList();
String title = rs.getString(1);
display.add(title);
System.out.println("###########################" +title);
System.out.println("(((((((((((())))))))))" +display);
outerList.add(display);
}catch(Exception e){
e.printStackTrace();
}finally{
if(rs != null){
try{rs.close();}catch(Exception e){e.printStackTrace();}
if(pstmt != null){
try{pstmt.close();}catch(Exception e){e.printStackTrace();}
if(con != null){
try{con.close();}catch(Exception e){e.printStackTrace();}
con = null;
pstmt = null;
rs = null;
return outerList;
REGARDS,
RaHuL -
Problem in excuting select statement
Hi,
I have created simple report and in start-of-selection i have writen select statement with bukrs and lifnr as parameters. But i am unable to execute the query.
find the code
start-of-selection.
select bukrs
lifnr
name1
name2
name3
from zapv_names
into table it_zapv
where bukrs = p_bukrs
and lifnr = p_lifnr.
I am not under stand why it is not working. The code is correct. I have taken names as zname field and others are standered data elements.
Thanks,
RamuVI'm going to take a wild guess that since you show this to be the first statement
after the START-OF-SELECTION line, that is is coming from a report program
where the two field you are testing for are actually RANGEs on the selection screen.
select bukrs
lifnr
name1
name2
name3
from zapv_names
into table it_zapv
where bukrs = p_bukrs " This is likely a RANGE
and lifnr = p_lifnr. " This is likely a RANGE
Change them to this
select bukrs
lifnr
name1
name2
name3
from zapv_names
into table it_zapv
where bukrs IN p_bukrs " This is likely a RANGE
and lifnr IN p_lifnr. " This is likely a RANGE
Ranges would be tables and have value like 'IEQ0101' where with the = sign would never be equal.
Edited by: Paul Chapman on Jan 12, 2009 12:23 PM -
Problem in the select statement
I have to select the values of the fields BEZEI depending on tha sales order number vbeln. HOw can i write the select statement what will be the tables associated?
Hi,
tables: vbak.
types: begin of ty_vbak,
vbeln type vbeln,
kokrs type kokrs,
end of ty_vbak,
begin of ty_it_tka01,
kokrs type kokrs,
bezei type bezei,
end of ty_tka01.
data: it_vbak type table of ty_vbak,
wa_vbak type ty_vbak,
it_tka01 type table of ty_tka01,
wa_tka01 type ty_tka01.
Select-options: s_vbeln for vbak-vbeln.
Select VBELN KOKRS from VBAK into table it_VBAK where vbeln in s_vbeln.
if sy-subrc = 0.
select KOKRS BEZEI from TKA01 into it_tka01 for all entries in it_vbak where kokrs = it_vbak-kokrs.
endif.
Loop at it_vbak into wa_vbak.
read table it_tka01 into wa_tka01 with key kokrs = wa_vbak-kokrs.
if sy-subrc = 0.
* Move data to final internal table.
endif.
endloop.
Regards,
Satish -
Performance Problem with Nested Select
I have an urgent performance question, I run a nested select like this one
SELECT tabname
INTO ls_dd02l
FROM dd02l
WHERE tabname LIKE c_feld
AND buffered IS NOT NULL.
SELECT tabname fieldname keyflag position
INTO CORRESPONDING FIELDS OF ls_dd03l
FROM dd03l
WHERE tabname = ls_dd02l-tabname
AND fieldname IN ('MANDT', 'CLIENT', 'CLNT')
AND keyflag = 'X'.
IF ( sy-subrc EQ 0 ).
wa-tabname = ls_dd03l-tabname.
wa-fieldname = ls_dd03l-fieldname.
wa-keyflag = ls_dd03l-keyflag.
wa-position = ls_dd03l-position.
APPEND wa TO itab.
ENDIF.
ENDSELECT.
ENDSELECT.
It is taking about 20sec, which is much too long.
How can I improve the performance.
Points rewarded!
S.B.Hi Siegfried,
As Vinay said u can use INNER JOIN to get the data from both database tables
or u can use FOR ALL ENTRIES statement.
You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.
The above statement is from Library. Please check this link
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm
Tabular Conditions sub heading
SELECT a~tabname
b~fieldname
b~keyflag
b~position
FROM dd02l as a INNER JOIN dd03l as b
ON a~tabname = b~tabname
INTO TABLE itab
WHERE a~tabname LIKE c_feld
AND buffered IS NOT NULL
AND fieldname IN ('MANDT', 'CLIENT', 'CLNT')
AND keyflag = 'X'.
OR
SELECT tabname
INTO TABLE lt_dd02l
FROM dd02l
WHERE tabname LIKE c_feld
AND buffered IS NOT NULL.
IF NOT lt_dd02l IS INITIAL.
SELECT tabname fieldname keyflag position
INTO CORRESPONDING FIELDS OF TABLE itab
FROM dd03l
FOR ALL ENTRIES IN lt_dd02l
WHERE tabname = lt_dd02l-tabname
AND fieldname IN ('MANDT', 'CLIENT', 'CLNT')
AND keyflag = 'X'.
ENDIF.
Please check this link
/people/rob.burbank/blog/2007/03/19/joins-vs-for-all-entries--which-performs-better
You have to look at the primary keys..
MANDT
STLTY
STLNR
STLAL
STLKN
STASZ
MANDT
STLTY
STLNR
STLKN
STPOZ
You need the stlty for both tables stas and stpo
The on condition between stas and stpo is obvious, will help a
bit.
It would be much better, if you could add it to the WHERE Condition.
Do you know it?
If not, then as the BOM categories are not so many,
Try
select distinct stlty
from stas.
and add the values to you where condition as
AND s1-stlty in ( ....... )
This should improve the performance.
I don't kknow whether the BOM Categories can change in future.
instead of a fixed in, you could add a subselect from a customizing table.
I am quite confident that the solution I proposed will be much faster than the FOR ALL ENTRIES.
But with more complicated joins you really have to try it.
There is no general rule about the number of tables in a join, there are perfectly running joins with 5 tables
and there are porblems with 2 tables.
You must analyze the indexes, it it is clear which index will support the accesses then it will work fine.
The FOR ALL ENTRIES is by construction much slower!
Best regards,
raam -
Problem with my select statement
Dear buddies,
Really seeking someone to guide me in this sql issue.
Here is the scenario.
- should check for the number of prospects(to be customers) downloaded from a file for every dealer based on the
region
description about columns shown
1st column, region
2nd column, dealer code
3rd column, number of prospect received
4th column, the percentage of conversion
5th column, i must order by the 4th column and select the top 20 percentage and take its average.
sample data
region dealer_code no. of no of % of % of Comparing with
prospect prospect prospect Top 20 top 20 conversion
received converted conversion Conversion
A dealer 1 150 50 33% 56% Red
dealer 2 100 40 40% 56% Red
dealer 3 120 60 50% 56% Red
130 70 54% 56% Red
200 20 10% 56% Red
B 140 60 43% 56% Red
110 60 55% 56% Red
100 60 60% 56% Green
130 69 53% 56% Red
140 75 54% 56% Red
D 110 40 36% 56% Red
100 30 30% 56% Red
140 74 53% 56% Red
100 70 70% 56% Green
110 65 59% 56% Green
E 130 85 65% 56% Green
150 65 43% 56% Red
150 70 47% 56% Red
160 95 59% 56% Green
170 100 59% 56% Green
F 200 150 75% 56% Green
100 65 65% 56% Green
120 40 33% 56% Red
140 80 57% 56% Green
150 85 57% 56% Green
Legend (for the sample data)
when % of prospect conversion > % of top 20 conversion, then green
when % of prospect conversion = % of top 20 conversion, then yellow
when % of prospect conversion < % of top 20 conversion, then red
NOTE
i have a few more columns after this, but if i know how to fix these columns, i can manage them too.
here is my sql
select a.dealer_region,
a.dealer_code,
count(b.id) as "No of Prospect Received",
COUNT (case when b.id in (select d.id
from contact_details d
where d.contact_result ='04'
and d.dealer_code = c.dealer_code)
then b.id end) "No of Prospect Converted to Booking",
(COUNT (case when b.id in (select d.id
from contact_details d
where d.contact_result ='04'
and d.dealer_code = c.dealer_code)
then b.id end)
/ (count(b.id))*100 || '%')"%of Prospect Conversion" ,
((COUNT (case when b.id in (select d.id
from contact_details d
where d.contact_result ='04'
and d.dealer_code = c.dealer_code
and rownum <20)
then b.id end)
/20 )* 100 || '%')"% Top 20 Conversion",
/*(avg((COUNT (case when b.id in (select d.id
from contact_details d
where d.contact_result ='04'
and d.dealer_code = c.dealer_code)
then b.id end)
/ (count(b.id))*100 || '%'))
(case when((COUNT (case when b.id in (select d.id
from contact_details d
where d.contact_result ='04'
and d.dealer_code = c.dealer_code
and rownum <20)
then b.id end)
/ 20 )* 100) > ((count(case when b.id in (select d.id
from contact_details d
where d.contact_result ='04'
and d.dealer_code = c.dealer_code
and rownum <20)
then b.id end)
/ 20 )* 100)
then 'Green'
when((COUNT (case when b.id in (select d.id
from contact_details d
where d.contact_result ='04'
and d.dealer_code = c.dealer_code
and rownum <20)
then b.id end)
/ 20 )* 100) = ((count(case when b.id in (select d.id
from contact_details d
where d.contact_result ='04'
and d.dealer_code = c.dealer_code
and rownum <5)
then b.id end)
/ 20 )* 100)
then 'Yellow'
else
'Red'
end) "Comparison with Top 20 Convers",
/* i can handle this part if the sql given above is solved */
COUNT (case when b.id in (select d.id
from contact_details d
where d.contact_result ='05'
and d.dealer_code = c.dealer_code)
then b.id end) "#of Lead ConvertedC",
(COUNT (case when b.id in (select d.id
from contact_details d
where d.contact_result ='05'
and d.dealer_code = c.dealer_code)
then b.id end)
/ (count(b.id))*100 || '%')"%of Lead ConversionC",
((COUNT (case when b.id in (select d.id
from contact_details d
where d.contact_result ='05'
and d.dealer_code = c.dealer_code
and rownum <21)
then b.id end)
/ 20 )* 100 || '%')"% Top 20 ConversionC",
/* (avg((COUNT (case when b.id in (select d.id
from contact_details d
where d.contact_result ='04'
and d.dealer_code = c.dealer_code)
then b.id end)
/ (count(b.id))*100 || '%'))
(case when((COUNT (case when b.id in (select d.id
from contact_details d
where d.contact_result ='05'
and d.dealer_code = c.dealer_code
and rownum <21)
then b.id end)
/ 20 )* 100) > ((count(case when b.id in (select d.id
from contact_details d
where d.contact_result ='05'
and d.dealer_code = c.dealer_code
and rownum <21)
then b.id end)
/ 20 )* 100)
then 'Green'
when((COUNT (case when b.id in (select d.id
from contact_details d
where d.contact_result ='05'
and d.dealer_code = c.dealer_code
and rownum <21)
then b.id end)
/ 20 )* 100) = ((count(case when b.id in (select d.id
from contact_details d
where d.contact_result ='05'
and d.dealer_code = c.dealer_code
and rownum <21)
then b.id end)
/ 20 )* 100)
then 'Yellow'
else
'Red'
end) "Comparison with Top 20 ConverC"
from dealers a, prospect_list b, files c, marketing_details e, customer f
where b.file_id = c.file_uid
and c.dealer_code = a.dealer_code
and b.id = e.id
and e.id = f.id
group by a.dealer_region, a.dealer_code; hope someone can help me out.
i actually can change the count(d.dealer_code) to 20 and solve the problem but what if they are less than 20 dealers in the table?
because the table will be refreshed every morning with new data and the unnecessary one will be removed.
it works fine now when i divide it by 20.
pls advice
thanks
alagu
Edited by: user645399 on Jul 1, 2009 7:49 PM
Edited by: user645399 on Jul 1, 2009 7:56 PM
Edited by: user645399 on Jul 1, 2009 8:14 PM
Edited by: user645399 on Jul 1, 2009 10:20 PMHope this helps. First rank all the rows. Then find the average for the top3 using CASE statement
LPALANI@l11gr2>select ename, sal, dense_rank() over (order by sal desc) dr,
2 avg(sal) over() avg_sal_all
3 from scott.emp;
ENAME SAL DR AVG_SAL_ALL
KING 5,000 1 2,073
FORD 3,000 2 2,073
SCOTT 3,000 2 2,073
JONES 2,975 3 2,073
BLAKE 2,850 4 2,073
CLARK 2,450 5 2,073
ALLEN 1,600 6 2,073
TURNER 1,500 7 2,073
MILLER 1,300 8 2,073
WARD 1,250 9 2,073
MARTIN 1,250 9 2,073
ADAMS 1,100 10 2,073
JAMES 950 11 2,073
SMITH 800 12 2,073
14 rows selected.
LPALANI@l11gr2>
LPALANI@l11gr2>select ename, sal,
2 avg(case when dr <=3 then sal end) over () avg_sal_top,
3 count(case when dr <=3 then 1 end) over() cnt_of_top3_earners,
4 avg_sal_all,
5 dr
6 from (select ename, sal, dense_rank() over (order by sal desc) dr, avg(sal) over() avg_sal_all from scott.emp);
ENAME SAL AVG_SAL_TOP CNT_OF_TOP3_EARNERS AVG_SAL_ALL DR
KING 5,000 3,494 4 2,073 1
FORD 3,000 3,494 4 2,073 2
SCOTT 3,000 3,494 4 2,073 2
JONES 2,975 3,494 4 2,073 3
BLAKE 2,850 3,494 4 2,073 4
CLARK 2,450 3,494 4 2,073 5
ALLEN 1,600 3,494 4 2,073 6
TURNER 1,500 3,494 4 2,073 7
MILLER 1,300 3,494 4 2,073 8
WARD 1,250 3,494 4 2,073 9
MARTIN 1,250 3,494 4 2,073 9
ADAMS 1,100 3,494 4 2,073 10
JAMES 950 3,494 4 2,073 11
SMITH 800 3,494 4 2,073 12 -
Performance issue on a select statement
Hi all @ SAPforums and thanks for your attention,
the task is quite simple: given a Purchase Requisition number and position (banfn, bnfpo) I have to check if a contract with the same PR as source exists in the EKPO table.
In order to check for it, I simply typed the following select:
SELECT SINGLE * FROM EKPO INTO wa_checkekpo
WHERE bstyp EQ 'K'
AND banfn EQ l_eban-banfn
AND bnfpo EQ l_eban-bnfpo.
This kind of query is quite consuming (more than three seconds in my process) due to the fact that banfn and bnfpo don't belong to a key for the table.
Any idea/workaround that can lead to better performance? Please note I'm not interested in retrieving the contract number (KONNR), it's sufficient to know it exists.Hi,
> Do not use select * if you just want to check existence of the record.
so far so good.
> Use a single variable to store teh count.
But why should we count the records if we just want to know if a key exists in
the db or not? change the second half of the recommendation to:
Use a single field of the used index for the select list to check (sy-subrc or result
of that field) if the record exists or not.
Kind regards,
Hermann -
Query related to excution and performance of count in select statement
Hi,
What are the difference between
select count(1) from table
and
select count(*) from tableThanks for the reply.I searched lots of thread for the same and found that it's same (excution wise and performance wise).
But in few thread i found that someone is saying
"At the time of exceution Count(1) will conevrted internally to count(*) " --- is it correct
"is there any soecial significance of using count(42)" ?
Tx,
Anit -
Problem in executing select statement using hetrogenous services
I am trying to import data from SqlServer 2005 to oracle 10g using hetrogenous services.
Oracle is installed on solaris 10 platform. I am running my query by Windows platform using Pl/Sql Developer
when i run the following query,
select * from GSecMstr@demodata2;
i get the following error message
Error: ORA-04052: error occurred when looking up remote object [email protected]
ORA-00604: error occurred at recursive SQL level 1
ORA-07268: szguns: getpwuid error.
But strange thing is that when i logon to the solaris server machine with user oracle and execute the same command using sqlplus from solaris console, then command is executed successfullyServer side tnsnames.ora file
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = solaris.ssilhr.com.pk)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
SQLServer =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = tcp)(HOST = solaris.ssilhr.com.pk)(PORT = 1522))
(CONNECT_DATA =
(SID = SQLServer)
(HS = OK)
Server side sqlnet.ora file
SQLNET.AUTHENTICATION_SERVICES= (NONE)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
Client side tnsnames.ora file
# tnsnames.ora Network Configuration File: E:\Oracle\product\10.2.0\db_2\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
ORCL_SUN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.235)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = orcl)
Client side sqlnet.ora file
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
Another thing i want to mention is that by mistake, i changed the role of user oracle from dba to root, which i have changed back to dba now.
To create database link, i used the following SQL
create public database link DEMODATA2
connect to "username"
IDENTIFIED BY "MyPassword"
using 'SQLServer'; -
Performance Problem in Select query
Hi,
I have performance Problem in following Select Query :
SELECT VBELN POSNR LFIMG VRKME VGBEL VGPOS
FROM LIPS INTO CORRESPONDING FIELDS OF TABLE GT_LIPS
FOR ALL ENTRIES IN GT_EKPO1
WHERE VGBEL = GT_EKPO1-EBELN
AND VGPOS = GT_EKPO1-EBELP.
as per trace i have analysed that it is fetch the complete table scan from the LIPS table and table contants almost 3 lakh records.
Kindly Suggest what we can do to optimize this query.
Regards,
Harshtypes: begin of line,
vbeln type lips-vbeln
posnr type lips-posnr
lfimg type lips-lfimg
vrkme type lips-vrkme
vgbel type lips- vgbel
vgpos type lips-vgpos
end of line.
data: itab type standard table of line,
wa type line.
IF GT_EKPO1[] IS NOT INITIAL.
SELECT VBELN POSNR LFIMG VRKME VGBEL VGPOS
FROM LIPS INTO TABLE ITAB
FOR ALL ENTRIES IN GT_EKPO1
WHERE VGBEL = GT_EKPO1-EBELN
AND VGPOS = GT_EKPO1-EBELP.
ENDIF. -
Hi Experts,
I am facing the problem in the select statement where it giving the short dump
DBIF_RSQL_INVALID_RSQL CX_SY_OPEN_S.
i have searched many forms, but i found that the select option s_matnr have the limitaion 2000 entreis, but i am passing same s_matnr to other select statement with more than 2000 entries but it is not giving me any short dump.
but i am facing problem with only one select statement where if i pass select option s_matnr more than 1500 entris also giving short dump.
my select statement is
SELECT * FROM bsim
INTO CORRESPONDING FIELDS OF TABLE g_t_bsim_lean
FOR ALL ENTRIES IN t_bwkey WHERE bwkey = t_bwkey-bwkey
AND matnr IN matnr
AND bwtar IN bwtar
AND budat >= datum-low.
in the internal table g_t_bsim_lean internal table contain all the fields of the table bsim with 2 fields from other table.
Please let me know whether i need to change the select statement or any other solution for this.
Regards,
udupimy select query is like this:
DATA: BEGIN OF t_bwkey OCCURS 0, "184465
bwkey LIKE bsim-bwkey, "184465
END OF t_bwkey. "184465
LOOP AT g_t_organ WHERE keytype = c_bwkey.
MOVE g_t_organ-bwkey TO t_bwkey-bwkey.
COLLECT t_bwkey. "184465
ENDLOOP. "184465
READ TABLE t_bwkey INDEX 1. "184465
CHECK sy-subrc = 0. "184465
SELECT * FROM bsim "n443935
INTO CORRESPONDING FIELDS OF TABLE g_t_bsim_lean "n443935
FOR ALL ENTRIES IN t_bwkey WHERE bwkey = t_bwkey-bwkey
AND matnr IN matnr
AND bwtar IN bwtar
AND budat >= datum-low. -
Performance problem in data replication program written in java
Dear all,
I need your valuable ideas on improving below logic on replicating data fromDB2 to Oracle 9i.We have a huge tables in DB2 to replicate to Oracle side.For one table this taking lot of time.The whole app' is written in java.The current logic is Setting soft delete to specific set of records in oracel table and Reading all records from DB2 table to set only these records in oracle table to 'N' so that deleted records got soft deleted in oralce side.The DB2 query is having 3 table join and taking nearly 1minute.We are updating the oracle table in batch of 100000.For 610275 record update in batch mode it is taking 2.25 hours which has to be reduced to <1hour.The first update to all Y and second update using DB2 query is taking 2.85 hrs.
Do you have any clever idea to reduce this time?? kindly help us.we are in critical situation now.Even new approach in logic to replicate also welcome..hi,
just remove joins and use for all entries.
if sy-subrc = 0.
use delete adjacent duplicates from itab comparing key fields.(it will increase performance)
then write another select statement.
endif.
some tips:
Always check the driver internal tables is not empty, while using FOR ALL ENTRIES
Avoid for all entries in JOINS
Try to avoid joins and use FOR ALL ENTRIES.
Try to restrict the joins to 1 level only ie only for tables
Avoid using Select *.
Avoid having multiple Selects from the same table in the same object.
Try to minimize the number of variables to save memory.
The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
Avoid creation of index as far as possible
Avoid operators like <>, > , < & like % in where clause conditions
Avoid select/select single statements in loops.
Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.
Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
Avoid using ORDER BY in selects
Avoid Nested Selects
Avoid Nested Loops of Internal Tables
Try to use FIELD SYMBOLS.
Try to avoid into Corresponding Fields of
Avoid using Select Distinct, Use DELETE ADJACENT
Go through the following Document
Check the following Links
Re: performance tuning
Re: Performance tuning of program
http://www.sapgenie.com/abap/performance.htm
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTunin -
Select statement for generic select options
Hello,
I have a problem implementing a SELECT-Statement. I have a generic number of select options on my selection screen and I have a range table for each select option. How can a generate a database select for these generic number of range tables?
Thank you very much in advance & regards,
Alexanderthe answer I gave you will work if you have a ranges table for every possible select-options and refer to every ranges table in your where clause.... that way, you don't have to know which are populated and which are not at the time of SELECT.
You could also choose to create a dynamic where clause, based upon what you had select-options for and use with
WHERE ( whereclause ).
Edited by: BreakPoint on Mar 2, 2011 4:31 PM -
Performance problem in This program
Hi friends ,
Below is the one of the perform in my program which is taking more time .. Can you please suggest me to find a solution to take less time for execution.
Thanks in Adv .
Varma ..
DATA: l_count TYPE i.
SELECT m~customer
m~name
m~payer
t~txtmd
INTO TABLE gt_cust2
FROM /bi0/pcustomer AS m
JOIN /bi0/tcustomer AS t
ON mcustomer EQ tcustomer
WHERE m~objvers EQ 'A'
AND m~accnt_grp NE space.
SORT gt_cust2 BY customer.
SELECT m~customer
m~name
m~payer
t~txtmd
INTO TABLE gt_cust
FROM /bi0/pcustomer AS m
JOIN /bi0/tcustomer AS t
ON mcustomer EQ tcustomer
WHERE m~objvers EQ 'A'
AND m~accnt_grp IN s_ktokd
AND m~payer NE space.
IF sy-subrc = 0.
SORT gt_cust BY customer.
LOOP AT gt_cust.
CLEAR l_count.
LOOP AT gt_cust2 WHERE payer = gt_cust-payer.
ADD 1 TO l_count.
IF l_count > 1.
EXIT.
ENDIF.
ENDLOOP.
gt_soldto-customer = gt_cust-customer.
gt_soldto-payer = gt_payer-payer = gt_cust-payer.
IF l_count > 1.
Payer found
CLEAR gt_cust2.
READ TABLE gt_cust2 WITH KEY customer = gt_cust-payer
BINARY SEARCH.
IF NOT gt_cust2-name IS INITIAL.
gt_payer-name = gt_cust2-name.
ELSE.
gt_payer-name = gt_cust2-txtmd.
ENDIF.
ELSE.
Stand alone customer
gt_soldto-payer = gt_payer-payer = p_nonpyr.
gt_payer-name = p_nonpnm.
ENDIF.
COLLECT: gt_soldto,
gt_payer.
ENDLOOP.
SORT: gt_soldto,
gt_payer.
ENDIF.hi,
just remove joins and use for all entries.
if sy-subrc = 0.
use delete adjacent duplicates from itab comparing key fields.(it will increase performance)
then write another select statement.
endif.
some tips:
Always check the driver internal tables is not empty, while using FOR ALL ENTRIES
Avoid for all entries in JOINS
Try to avoid joins and use FOR ALL ENTRIES.
Try to restrict the joins to 1 level only ie only for tables
Avoid using Select *.
Avoid having multiple Selects from the same table in the same object.
Try to minimize the number of variables to save memory.
The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
Avoid creation of index as far as possible
Avoid operators like <>, > , < & like % in where clause conditions
Avoid select/select single statements in loops.
Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.
Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
Avoid using ORDER BY in selects
Avoid Nested Selects
Avoid Nested Loops of Internal Tables
Try to use FIELD SYMBOLS.
Try to avoid into Corresponding Fields of
Avoid using Select Distinct, Use DELETE ADJACENT
Go through the following Document
Check the following Links
Re: performance tuning
Re: Performance tuning of program
http://www.sapgenie.com/abap/performance.htm
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTunin
Maybe you are looking for
-
Nikon .NEF Files - can not import these files - help please
Hi Folks. I just made the plunge into the dslr world, purchasing a nikon d40x. I want to shoot raw files and work with the keepers in PS. I saw LR and watched several on-line tutorials by michael tate, and decided to DL the trial version. I'm running
-
How to run report without report server
hi my question : how i can run report without using the report server; by simple URL to the report stored in directory and accessing by HTTPserver; and the report is running by the local client runtime. thinks for replay
-
My iphone 5 has a lock on the rotation
my iphone 4s has a lock on the rotation. how can i take it off
-
Linked lists understanding help
Hi I am having problems trying to understand linked lists. For example in the following code: public class LinkDouble private double dData; // data item private LinkDouble next; // next link in list private Lin
-
Finding out timezone from TimeZone offset
Hi, I'm using JavaScript to find out the local time on client, setting it to a cookie. I then retrieve the value in a JSP page to find out the correction necessary for adjusting the time (in UTC) to local time. The problem, however, is that JavaScrip