08-25-2007 12:54 PM
two fields from one table and three fields from another table...with out using join and with using join....can any one explain with a simple example
what i mean is :
select tab1-fld1 tab1-fld2 tab2-fld1 tab2-fldthree frome tab1 tab2 where tab1-fld1 = tab2-fld1
Message was edited by:
balaji velpuri
08-25-2007 1:06 PM
Hi,
Suppose your table are like this.
Table 1
CLM1 CLM2 CLM3 CLM4.
Table 3
CLM5 CLM6 CLM7.
DATA: itab1 type table of Table1 with header line,
itab2 type table of Table2 with header line.
TYPES: begin of itab3_type,
INCLUDE STRUCTURE table1.
INCLUDE STRUCTURE table2.
TYPES: end of itab3_type.
DATA: itab3 type table of itab3_type with header line.
Now you can loop at ITAB1 and move data of CLM1 to CLM4 to itab3.
Then loop at ITAB2 and copy CLM5 to CLM7 to itab3.
loop at itab1.
move-corresponding itab1 to itab3.
append itab3.
endloop.
clear itab3.
loop at itab2.
move-corresponding itab2 to itab3.
modify itab3 index sy-tabix.
endloop.
Regards,
Sesh
08-25-2007 1:16 PM
data: begin of itab occurs 0,
fld1 type mara-matnr,
end of itab.
data: begin of itab2 occurs 0,
fld1 type mara-matnr,
fld2 type mard-werks,
fld3 type mard-lgort,
end of itab.
******select the data.................for the itab1
refresh itab[].
select matnr from mara into table itab.
*****use for all entries as below.
refresh itab2[].
if itab[] is not initial.
select matnr werks lgort from mard into table itab2 for all entries in itab.
endif.
08-25-2007 1:18 PM
data: begin of itab occurs 0,
fld1 type mara-matnr,
end of itab.
data: begin of itab2 occurs 0,
fld1 type mara-matnr,
fld2 type mard-werks,
fld3 type mard-lgort,
end of itab.
******select the data.................for the itab1
refresh itab[].
select matnr from mara into table itab.
*****use for all entries as below.
refresh itab2[].
if itab[] is not initial.
select matnr werks lgort from mard into table itab2
for all entries in itab where matnr = itab-matnr.
endif.
08-25-2007 1:25 PM
data: begin of itab occurs 0,
fld1 type mara-matnr,
fld2 type mard-werks,
fld3 type mard-lgort,
end of itab.
select a~matnr
b~werks
b~lgort
into table itab
from mara as a
inner join mard as b
on amatnr EQ bmatnr.