Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Need some help with the Select query.

Former Member
0 Kudos

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

7 REPLIES 7

Former Member
0 Kudos

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.

0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi,

Try with: Select up to 1 rows ...

Regards,

Bhaskar

Former Member
0 Kudos

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.

0 Kudos

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.