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

Former Member
0 Likes
966

Hello experts,

Is it possible write something as

SELECT x.*, y.field1, y.field2

FROM table1 x, table2 y

in ABAP statement ?

I don't want write ALL fields of table table1 and i want only some fields of table table2.

Thanks for advice in advance

Martin

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
944

Hi,

I think it is not possible in select statement the way you wrote,,

first get the data from first table

select * from DBtable into itab where <f1> = <s_f1>.

Now use for all entries

if itab[] is not initial

select <f1> <f2> ..

from DBTABLE2 into itab2

for all entries in itab

where <f1> = itab-f1 ..

endif.

this gives you better performance..

rewards if useful,

regards,

nazeer

7 REPLIES 7
Read only

dev_parbutteea
Active Contributor
0 Likes
944

Hi,

try like this

SELECT coep~MATNR

COEP~WTGBTR

COEP~MEGBTR

COEP~MEINH

COEP~OBJNR

MARA~MTART

FROM COEP INNER JOIN MARA

ON COEPMATNR = MARAMATNR

INTO TABLE IT_RESB

FOR ALL ENTRIES IN IT_CAUFV

WHERE

coep~OBJNR = IT_CAUFV-OBJNR

AND MARA~MTART IN ('YFLM','YCHE','YRAW').

Read only

0 Likes
944

You can use a view or a join

Read only

Former Member
0 Likes
944

u can write a inner join and for all entries .. so for example u can refer to abapdocu.. example will be clear and simple

Read only

Former Member
0 Likes
944

Hi

Use Joins options or else use FOR ALL ENTRIES options if at all there is any link between these 2 tables.

Mostly preferred is FOR ALL ENTRIES option. Avoid using Joins.

Regards

Haritha.

Read only

Former Member
0 Likes
944

I want to get ALL fields of the table table1 + 2 fields of the table table2, but i don't want write ALL fields in SQL statement (x.field1, x.field2....x.fieldN, y.field1, y.field2)

Read only

Former Member
0 Likes
945

Hi,

I think it is not possible in select statement the way you wrote,,

first get the data from first table

select * from DBtable into itab where <f1> = <s_f1>.

Now use for all entries

if itab[] is not initial

select <f1> <f2> ..

from DBTABLE2 into itab2

for all entries in itab

where <f1> = itab-f1 ..

endif.

this gives you better performance..

rewards if useful,

regards,

nazeer

Read only

Former Member
0 Likes
944

Hi,

You could try the dynamical SQL.

For ex.

select (itab) from ekko as a inner join ekpo as b

on aebeln = bebeln

...

and you could define the itab like below:

data:

begin of itab occurs 0,

field(30),

end of itab.

and add the itab.

field = a~ebeln.

append field.

......

U can add all of the fields of ekko in the itab.

And for an enhace, you could get all field of ekko in table dd03l, and take the dd03l fieldname to a internal table, loop this table, concatenate 'a~' dd03l-fieldname into field, append field to itab.

Note that there maybe some .include field in the dd03l, so you should delete this kind of field.

Hope this helps

Bob