‎2007 Feb 20 7:38 PM
Hi can any body give me a sample code on joining 2 internal tables having the common field.
thanks in advance
kp
‎2007 Feb 20 7:49 PM
Hi,
Check this example..
I am joining the internal table where VBELN is the common field..
DATA: ITAB_VBAK LIKE VBAK OCCURS 0 WITH HEADER LINE.
DATA: ITAB_VBAP LIKE VBAP OCCURS 0 WITH HEADER LINE.
DATA: V_TABIX TYPE SYTABIX.
SORT ITAB_VBAP BY VBELN.
LOOP AT ITAB_VBAK.
READ TABLE ITAB_VBAP TRANSPORTING NO FIELDS
WITH KEY VBELN = ITAB_VBAK-VBELN
BINARY SEARCH.
IF SY-SUBRC = 0.
Store the row number.
V_TABIX = SY-TABIX.
LOOP AT ITAB_VBAP FROM V_TABIX.
Exit condition for the loop.
IF ITAB_VBAK-VBELN <> ITAB_VBAP-VBELN.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
Thanks,
Naren
‎2007 Feb 20 7:49 PM
Hi KP,
There wr no joins on internal tables. You have to use loop-read-endloop.
loop at itab.
read table itab2 with key field1 = itab-field1.
if sy-subrc = 0.
move itab-field1 = itab_final-field1.
move itab2-field2 = itab_final-field2.
.
.
append itab_final.
clear itab_final.
endif.
endloop.
Regards,
Ravi
‎2007 Feb 20 7:54 PM
It is only possible through LOOPs and READ WITH KEY.
If you are expecting to use SQL JOINS on internal tables, then this is not possible as ABAP follows OPEN SQL.
Thanks,
Santosh
‎2007 Feb 21 6:57 AM
Hi,
SELECT AEQUNR BDATAB BILOAN CSWERK
INTO TABLE ITEQ
FROM ( EQUI AS A INNER JOIN EQUZ AS B
ON AEQUNR = BEQUNR ) INNER JOIN ILOA AS C
ON BILOAN = CILOAN
WHERE A~EQART = 'ESTPL'
AND B~IWERK = 'M011'
AND B~INGRP = 'SLM'
AND BDATAB GE SDATE-LOW AND BDATAB LE SDATE-HIGH
AND C~SWERK IN S_WERK.
Hope this helps.
Reward if helpful.
Regards,
Sipra
‎2007 Feb 21 6:59 AM
a simple select statement:
SELECT amvgr3 bbezei
FROM tvm3 AS a INNER JOIN tvm3t AS b
ON amvgr3 = bmvgr3
INTO TABLE lt_tab
WHERE b~spras = 'EN'.
regards,
naren
‎2007 Feb 21 7:09 AM
Hi,
s_werks for mvke-dwerk obligatory. " Plant
select marcmatnr marcwerks marcdisgr mbewsalk3
into table t_marc
from marc join mbew on ( mbewbwkey = marcwerks and
mbewmatnr = marcmatnr )
where werks in s_werks.
For mor info
http://goldenink.com/abap/select_statements.html
regards
Shiva