2006 Sep 27 3:43 PM
Hi 2 all,
How to join two internal tables in abap,
give me a example
2006 Sep 27 3:45 PM
select
amblnr bbwart bmatnr bwerks blifnr Bdmbtr bmenge bebeln
b~bukrs into table t_mseg from mkpf as a inner join mseg as b
on amblnr = bmblnr where
budat in s_budat
and bukrs in s_bukrs
and matnr in s_matnr.
hope this helps
Regards
select
amblnr bbwart bmatnr bwerks blifnr Bdmbtr bmenge bebeln
b~bukrs into table t_mseg from mkpf as a inner join mseg as b
on amblnr = bmblnr where
budat in s_budat
and bukrs in s_bukrs
and matnr in s_matnr.
hope this helps
Regards
2006 Sep 27 3:44 PM
Hi,
*Select statment for fetching all the owners
SELECT ba~ba_ba_no
ba~ba_seq_no
ba~ba_nm_1
INTO TABLE it_owners
FROM oiuh_cm_ba AS ba INNER JOIN
oiucm_ba_link AS balink
ON ba~ba_ba_no = balink~ba_no AND
ba~ba_seq_no = balink~ba_seq
WHERE ba~ba_ba_no IN s_own AND
balink~ba_type = 'V'.
2006 Sep 27 3:56 PM
hi friend i am beginner in abap
i want a query to join two intenal tables and store in another table
tables:mara,marc
fields in mara:matnr,ersda
fields in marc:werks
2006 Sep 27 4:01 PM
hi Raj,
do this way ..
select a~matnr
a~ersda
b~werks
into table it_mara
from mara as a inner join
marc as b
on a~matnr = b~matnr where
matnr in s_matnr
and werks in s_werks.
Reward if it helps
Regards,,
Santosh
Message was edited by: Santosh Kumar P
2006 Sep 27 4:07 PM
SELECT amatnr aersda c~werks
into table itab
from mara as a inner join marc as c
on amatnr = cmatnr.
Also, just want to inform you that MaRA, MARC are database tables and not internal tables
2006 Sep 27 3:44 PM
Hi,
You cannot JOIN two internal tables..You have to write two separate LOOP AT..
Ex.
LOOP AT ITAB1.
LOOP AT ITAB2 WHERE VBELN = ITAB1-VBELN.
........
ENDLOOP.
ENDLOOP.
Thanks,
Naren
2006 Sep 27 3:46 PM
Example
Output a list of all flights from Frankfurt to New York between 10th and 20th September, which are not sold out:
DATA: DATE LIKE SFLIGHT-FLDATE,
CARRID LIKE SFLIGHT-CARRID,
CONNID LIKE SFLIGHT-CONNID.
SELECT FCARRID FCONNID F~FLDATE
INTO (CARRID, CONNID, DATE)
FROM SFLIGHT AS F INNER JOIN SPFLI AS P
ON FCARRID = PCARRID AND
FCONNID = PCONNID
WHERE P~CITYFROM = 'FRANKFURT'
AND P~CITYTO = 'NEW YORK'
AND F~FLDATE BETWEEN '19970910' AND '19970920'
AND FSEATSOCC < FSEATSMAX.
WRITE: / DATE, CARRID, CONNID.
ENDSELECT.
2006 Sep 27 3:45 PM
select
amblnr bbwart bmatnr bwerks blifnr Bdmbtr bmenge bebeln
b~bukrs into table t_mseg from mkpf as a inner join mseg as b
on amblnr = bmblnr where
budat in s_budat
and bukrs in s_bukrs
and matnr in s_matnr.
hope this helps
Regards
2006 Sep 27 3:45 PM
Do you need to Query on 2 internal tables or just to
merge 2 internal table into one ????
Regards,
2006 Sep 27 3:45 PM
Hi raja,
We have to use FOR ALL ENTRIES
to join internal tables.
1. INNER JOIN
DBTAB1 <----
> DBTAB2
It is used to JOIN two DATABASE tables
having some COMMON fields.
2. Whereas
For All Entries,
DBTAB1 <----
> ITAB1
is not at all related to two DATABASE tables.
It is related to INTERNAL table.
3. If we want to fetch data
from some DBTABLE1
but we want to fetch
for only some records
which are contained in some internal table,
then we use for alll entries.
*----
1. simple example of for all entries.
2. NOTE THAT
In for all entries,
it is NOT necessary to use TWO DBTABLES.
(as against JOIN)
3. use this program (just copy paste)
it will fetch data
from T001
FOR ONLY TWO COMPANIES (as mentioned in itab)
4
REPORT abc.
DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
END OF itab.
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
*----
itab-bukrs = '1000'.
APPEND itab.
itab-bukrs = '1100'.
APPEND itab.
*----
SELECT * FROM t001
INTO TABLE t001
FOR ALL ENTRIES IN itab
WHERE bukrs = itab-bukrs.
*----
LOOP AT t001.
WRITE 😕 t001-bukrs.
ENDLOOP.
regards,
amit m.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |