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
660

Hi Experts ,

IM Having doubt in Select & Endselect Query .abt this Code .

SELECT matnr kwmeng werks lgort

UP TO l_index ROWS """"l_index contains 2 rows

FROM vbap

INTO tp_vbap

WHERE vbeln = com_kbv1-vbeln.

ENDSELECT.

When i try 2 execute this Query , it has to read 2 times as L_index = 2.

But it is Reading for only one time.

Here we have 2 use only Select & Endselect Not Internal table.

after reading this 2 entries , it wil go for further Processing .

Please provide me a proper solutions for this ?

Thanq Very Much !!

Regs,

Murthy.

7 REPLIES 7
Read only

Former Member
0 Likes
632

why the heck do you have to use select endselect?

cant you just make an array fetchj in an internal table and then loop over this one?

Besides i cant imagine that a select endselect statement cooperates with the up to 2 rows statement.

Message was edited by:

Florian Kemmer

Read only

Former Member
0 Likes
632

hi

what is tp_vbap.? declared as...

Read only

varma_narayana
Active Contributor
0 Likes
632

Hi Narayana..

Just change the Code using Array fetch like this.. it will work..

Note: ENDSELECT not needed here

SELECT matnr kwmeng werks lgort

UP TO l_index ROWS

FROM vbap

<b>INTO TABLE tp_vbap</b>

WHERE vbeln = com_kbv1-vbeln.

<i>reward if Helpful.</i>

Read only

Former Member
0 Likes
632

Hi NArayana,

u might be declared ur internal<b> table with header line</b>...

so remove that header line or use <b>INTO table tp_vbap</b>.

Read only

Former Member
0 Likes
632

select matnr kwmeng werks lgort

from vbap

into tp_vbap

where vbeln = com_kbv1-vbeln.

if sy-tabix = 2.

exit.

endif.

append tp_vbap.

endselect.

Regards

Vasu

Read only

Former Member
0 Likes
632

Hi narayana,

You can get 2rows or 3 rows according to ur requirement .

But u have to keep APPEND there in between select and endselect statement.

Plz make a look in foolowing code............

REPORT ZTESS.

tables: kna1.

select-options: s_kunnr for kna1-kunnr.

types: begin of Ty_kna1,

kunnr type kna1-kunnr,

name1 type kna1-kunnr,

ort01 type kna1-ort01,

end of ty_kna1,

tt_kna1 type standard table of ty_kna1.

Data: wa type ty_kna1,

IT_kna1 type tt_kna1.

select kunnr name1 ort01 up to 10 rows from kna1 into wa

where kunnr in s_kunnr.

append wa to it_kna1.

endselect.

loop at it_kna1 into wa.

write:/ wa-kunnr,wa-name1,wa-ort01.

endloop.

Reward points if it useful to u.....

Read only

Former Member
0 Likes
632

Hi,

Better to use the following code instead of select-endselect....

SELECT matnr kwmeng werks lgort

UP TO l_index ROWS

FROM vbap

INTO TABLE tp_vbap

WHERE vbeln = com_kbv1-vbeln

and perform wise also is not good, if u check in debugg mode it will go short dump...

<b>if it is use answer reward me a points....</b>

praveen