‎2006 Feb 15 2:17 PM
Hi,
I am writing some update routines for BW, and have an ABAP related question to you.
I would like to pull data from two tables into that internal table. The problem is that those tables have one field in common however this field is not a key field on neither of them.
Can i use the statement "FOR all Entries" in this case?
What i mean is that i will first select from one table and then write a second select statement for the other table and use the "FOR ALL ENTRIES" statement to match between the records?
Will this work? If not can you suggest some code that will do it?
Regards,
Xibi
‎2006 Feb 15 3:16 PM
Hi,
You can use the follow sentence:
To obtain data from first table
SELECT a b c INTO itab
FROM tab1
WHERE <cond>
and then obtain data from second table, and storage in the same internal table with APPENDING TABLE
SELECT a b c APPENDING TABLE itab
FROM tab2
WHERE <cond>
if this is not what you need, you could make a loop from the first table and then make a read table from second table comparing the no key field
loop at itab.
read table itab2 with key (common not key field) field = itab-field
if sy-subrc eq 0.
move values from itab2 to itab 1.
endif.
modify itab
endloop.
hope this help you.
Alejandro
‎2006 Feb 15 2:23 PM
Hi
Would you like to do that:
SELECT * FROM <TABLE_1> INTO TABLE ITAB WHERE ....
IF SY-SUBRC = 0.
SELECT * FROM <TABLE_2> INTO TABLE ITAB2
FOR ALL ENTRIES IN ITAB WHERE FIELD = ITAB-FIELD.
ENDIF.
If it's so, yes it works, but I don't understand your problem.
Max
Max
‎2006 Feb 15 2:24 PM
Hi ,
You can use for all entries.
Pseudo Code:
Select A B C from <TABLEA> into table ITAB1 where
TABLEA-FieldK = K
---
--- so on...
Select D E F from < TableB> into itab2 for all entries in itab1
where TableB-FieldX = Itab1-fieldX
and TableB-FieldY = Itab1-FieldY.
Hope this may help you.
Regards,
Lanka
‎2006 Feb 15 2:28 PM
I think i didn't explained myself correctly.
I wanted to select from the two tables into one internal table not into two of them.
Is this feasible in ABAP?
Regards,
Xibi
‎2006 Feb 15 2:55 PM
Hi,
You you can pull the data from 2 diff tables into one table.& FOR ALL ENTRIES CAN BE USED.
‎2006 Feb 15 3:00 PM
Hi,
using for all entries, and combine the two tables and make it one table.
regards
vijay
‎2006 Feb 15 3:10 PM
Hi Xibi,
You can join the two data base tables during select statement and then you can us "appending the corresponding fields of <ITAB>".
Lanka
‎2006 Feb 15 2:27 PM
Hi,
this can be done...
select a
b
c
from <db>
into table itab.
if sy-subrc = 0.
select b
d
from <db2>
into table itab1
for all entries in itab
where b = itab-b.
endif.regards
vijay
‎2006 Feb 15 3:16 PM
Hi,
You can use the follow sentence:
To obtain data from first table
SELECT a b c INTO itab
FROM tab1
WHERE <cond>
and then obtain data from second table, and storage in the same internal table with APPENDING TABLE
SELECT a b c APPENDING TABLE itab
FROM tab2
WHERE <cond>
if this is not what you need, you could make a loop from the first table and then make a read table from second table comparing the no key field
loop at itab.
read table itab2 with key (common not key field) field = itab-field
if sy-subrc eq 0.
move values from itab2 to itab 1.
endif.
modify itab
endloop.
hope this help you.
Alejandro
‎2006 Feb 15 3:30 PM
hi Xibi,
use
select afield1 afield2...
from table1 as a
into table itab
inner join table2 as b
on afield = bfield.
i think it works..
regards
satesh