08-21-2008 8:23 AM
Need some help with the Select query.
I had created a Z table with the following fields :
ZADS :
MANDT
VKORG
ABGRU.
I had written a select query as below :
select single vkorg abgru from ZADS into it_rej.
IT_REJ is a Work area:
DATA : BEGIN OF IT_REJ,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
This is causing performance issue. They are asking me to include the where condition for this select query.
What should be my select query here?
Please suggest....
Any suggestion will be apprecaiated!
Regards,
Developer
08-21-2008 8:26 AM
in that ztable what is the primary key ? Because Select single will get only one recird. To get only one record you need to specify the Unique key.
08-21-2008 8:29 AM
Hi,
When you are using select single ,It will retrieve Single record . so you need to specify
Select * from <table_name> where <primary_key> = 100.
If u give like this it will work.
Frist for your Ztable u need to specify primary key.
08-21-2008 8:31 AM
Hi Friend,
Everytime make sure that while writing a SELECT statement you have a WHERE condition. Otherwise it will select all the records of that table. This will hamper the performance.
While using SELECT SINGLE you need to specify the primary key field in the WHERE condition.
Regards,
Chandra Sekhar
08-21-2008 8:32 AM
hi there...
the performance issue is because of the select single... statement. Using "single" is not considered to be a gud practice. So its better u aplly the following statement.
Select vkorg abgru from ZADS into it_rej.
<Here u will put the code which will implement the values u fetched in the internal table.>
endselect.
hope it helps...
get back if u need further assistance.
08-21-2008 8:35 AM
08-21-2008 10:53 AM
Hello Everybody!
Thank you for all your response!
I had changes this work area into Internal table and changed the select query. PLease let me know if this causes any performance issues?
I had created a Z table with the following fields :
ZADS :
MANDT
VKORG
ABGRU.
I had written a select query as below :
I had removed the select single and insted of using the Structure it_rej, I had changed it into Internal table
select vkorg abgru from ZADS into it_rej.
Earlier :
IT_REJ is a Work area:
DATA : BEGIN OF IT_REJ,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
Now :
DATA : BEGIN OF IT_REJ occurs 0,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
I guess this will fix the issue correct?
PLease suggest!
Regards,
Developer.
08-21-2008 12:45 PM
hi there...
yep this will do ... you also need to put in the endselect statement. moreover, please note that select query now employed will work in a loop fetching the values one at a time.... so u need to employ the working strategy inside this select -- endselect.
do close the question if the query is solved.