‎2007 May 28 11:52 AM
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
‎2007 May 28 12:13 PM
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
‎2007 May 28 11:54 AM
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').
‎2007 May 28 11:56 AM
‎2007 May 28 11:59 AM
u can write a inner join and for all entries .. so for example u can refer to abapdocu.. example will be clear and simple
‎2007 May 28 12:03 PM
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.
‎2007 May 28 12:05 PM
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)
‎2007 May 28 12:13 PM
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
‎2007 May 28 12:13 PM
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