Application Development and Automation 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: 
Read only

Reg : select & endselect

Former Member
0 Likes
551

Hi experts ,

Having Doubt in select & endselect Statement

SELECT matnr

kwmeng

werks

lgort

UP TO l_index ROWS

FROM vbap

INTO tp_vbap

WHERE vbeln = com_kbv1-vbeln.

ENDSELECT.

In the above select Query l_index contains 2 Line items.

When i try to execute this Select Query?

It is reading only the First Line item Only..

Its not going to second Line item.

Regs,

Murthy

5 REPLIES 5
Read only

Former Member
0 Likes
529

Hi,

dont use the select and endselect as it a loop on the data base

SELECT matnr

kwmeng

werks

lgort

UP TO l_index ROWS

FROM vbap

INTO <b>table</b> tp_vbap

WHERE vbeln = com_kbv1-vbeln.

and your answer.

SELECT matnr

kwmeng

werks

lgort

UP TO l_index ROWS

FROM vbap

INTO tp_vbap

WHERE vbeln = com_kbv1-vbeln.

<b>l_index = l_index + 1.

if l_index > 2.

exit.

endif.</b>

ENDSELECT.

thanks & regards,

Venkatesh

Read only

Former Member
0 Likes
529

hi narayana

your select statement should be like this

SELECT matnr

kwmeng

werks

lgort

UP TO l_index ROWS

FROM vbap

INTO table tp_vbap

WHERE vbeln = com_kbv1-vbeln.

ENDSELECT.

tp_vbap should be a table then only it can accomodate all the entries . and into table clause has to be putten on the select statement

Reward if helpfull

Thanks

rohit

Read only

0 Likes
529

sory correction in my previous reply plz remove the endselect statement

Read only

Former Member
0 Likes
529

I hope tp_vbap is an internal table,

SELECT matnr

kwmeng

werks

lgort

UP TO l_index ROWS

FROM vbap

INTO tp_vbap

WHERE vbeln = com_kbv1-vbeln.

<b></b> APPEND tp_vbap.<b></b>

<b></b> CLEAR tp_vbap.<b></b>

ENDSELECT.

regards,

Prabhu

reward if it is helpful

Read only

varma_narayana
Active Contributor
0 Likes
529

Hi..

here what is the Value of l_index (If it is 1 then it will read only one row)

So check the value of l_index...

Then try like this to see the No of rows using SY-DBCNT.

SELECT matnr

kwmeng

werks

lgort

UP TO l_index ROWS

FROM vbap

INTO tp_vbap

WHERE vbeln = com_kbv1-vbeln.

write:/ SY-DBCNT, TP_VBAP-MATNR.

ENDSELECT.

REWARD IF HELPFUL.