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

select into variable and itab/working area together

Former Member
0 Likes
3,138

hi all,

may i know if can select into variable and itab or into variable and working area in the same select statement?

if cannot then what should do.

select x y into ( l_x , l_y ) a b c into corresponding field of table itab .......

or

select x y into ( l_x , l_y ) a b c into correspondinf field of working area .....

thanks

hi all,

may i know if can select into variable and itab or into variable and working area in the same select statement?

if cannot then what should do.

select x y into ( l_x , l_y ) a b c into corresponding field of table itab .......

or

select x y into ( l_x , l_y ) a b c into correspondinf field of working area .....

thanks

7 REPLIES 7
Read only

Former Member
0 Likes
1,262

I think into is valid for one area , Two 'INTO'S cannot be simultaneously accessed in a select .

In my opinion this is not possible .

regards,

vijay

Read only

Former Member
0 Likes
1,262

what about following:

select x y into (l_x, l_y ).

wa-x = l_x.

wa-y = l_y.

append wa to itab.

or

select x y into wa.

l_x = wa-x.

l_y = wa-y.

Message was edited by:

Florian Kemmer

Read only

Former Member
0 Likes
1,262

Hi,

select x y <b>into </b>( l_x , l_y ) a b c <b>into</b> corresponding field of table itab .......

or

select x y <b>into</b> ( l_x , l_y ) a b c <b>into </b>correspondinf field of working area .....

It is not possible to use into twice in select statement

The different possibilities are

Report zex33.
tables : likp.

select-options : s_vbeln for likp-vbeln.
data : begin of itab occurs 0,
       vbeln like likp-vbeln,
       vstel like likp-vstel,
       end of itab.

data : v_vbeln like likp-vbeln,
       v_vstel like likp-vstel.

data : wa_itab like itab.

****Method 1**************
select vbeln vstel into (v_vbeln , v_vstel)
   from likp
   where vbeln in s_vbeln.
itab-vbeln = v_vbeln.
itab-vstel = v_vstel.
append itab.
clear itab.
endselect.
******************************
********Method 2***********
*select vbeln vstel into wa_itab
*   from likp
*   where vbeln in s_vbeln.
*insert wa_itab into table itab.
*endselect.
**********************************
**********Method 3*************
*select vbeln vstel into table itab
*   from likp
*   where vbeln in s_vbeln.
*********************************
loop at itab.
   write : / itab-vbeln , itab-vstel.
endloop.

Read only

Former Member
0 Likes
1,262

cannot have two into clauses.

use the logic as suggested above.

kiran

Read only

0 Likes
1,262

just for the memory:

in ABAP you as well can NO`T do following

Data:

a type c,

b type c,

c type c.

a = b = c.

Read only

Former Member
0 Likes
1,262

You can do something like this:

SELECT SINGLE VBELN ERNAM ERDAT VSTEL
  INTO (I_TAB-VBELN, I_TAB-ERNAM, V_ERDAT, V_VSTEL)
  FROM LIKP
 WHERE VBELN = V_VBELN.

Read only

Former Member
0 Likes
1,262

Hi,

You can not have two INTO in one SELECT clause. In your case, along with a variable, use fields of work area & then append the work area to an internal table.

TABLES : vbap.

DATA : it_vbap TYPE TABLE OF vbap.

DATA : x_vbap TYPE vbap.

DATA : v_vbeln TYPE vbeln.

DATA : v_mandt TYPE mandt.

SELECT-OPTIONS: s_vbeln FOR vbap-vbeln.

SELECT mandt vbeln posnr matnr

FROM vbap

INTO (v_mandt, v_vbeln, x_vbap-posnr, x_vbap-matnr)

WHERE vbeln IN s_vbeln.

IF sy-subrc = 0.

APPEND x_vbap TO it_vbap.

ENDIF.

ENDSELECT.

Reward points if the answer is helpful.

Regards,

Mukul