‎2007 Apr 17 11:52 AM
Hi All,
I have a query regarding internal table. i want to create an internal table having fields: lfa1-lifnr , lfa1-land1 and lfb1-bukrs using the condition lfa1-lifnr = lfb1-lifnr. and want to display the output. can anyone please explain me the procedure and role of work-area in the above example.
‎2007 Apr 17 12:00 PM
Hi,
types: begin of ty_itab,
lifnr type lfa1-lifnr,
land1 type lfa1-land1,
bukrs type lfb1-bukrs,
end of ty_itab.
data: itab type standard table of ty_itab,
wa_itab like line of itab. "Work area
start-of-selection.
"fetch data
select alifnr aland` b~bukrs into table itab
from lfa1 as a inner join lfb1 as b on alifnr = blifnr.
"Display data
loop at itab into wa_itab.
write: / wa_itab-lifnr, wa_itab-land1, wa_itab-bukrs.
endloop.
That's all...
Check this codes...
Hope this will solve ur problem...
‎2007 Apr 17 11:56 AM
use <b>select</b> statement with <b>inner joint</b>
see ABAP help for select statement with inner join
‎2007 Apr 17 11:56 AM
‎2007 Apr 17 11:57 AM
Hi..
Define itab with 3 fields u wanted..
<b>select</b> lfa1~lifnr
lfa1~land1
lfb1~bukrs
into table itab
from ( lfa1 inner join lfb1 )
on <b>lfa1lifnr = lfb1lifnr</b>.
<b>no need of work area</b> in the selecct query..
‎2007 Apr 17 11:57 AM
data : begin of itab occurs 0,
lifnr like lfa1-lifr,
land1 like lfa1-land1,
bukrs like lfb1-bukrs,
end of itab.
select A~lifnr
A~land1
B~bukrs
into table itab
from lfa1 as A inner join
lfb1 as b on
A~lifnr eq B~lifnr.No need to use workarea here
‎2007 Apr 17 11:57 AM
hi
join lfa1 and lfb1 to fetch the required data
select alifnr aland1 b~bukrs
into table itab
from lfa1 as a inner join lfb1 as b
on alifnr = blifnr
where <conditions>.
regards,
madhu
‎2007 Apr 17 11:58 AM
use os WA(work area) depends if u want to use it.
if u declare the internal tble with hearder line tgen u dont need WA
‎2007 Apr 17 12:00 PM
Hi,
types: begin of ty_itab,
lifnr type lfa1-lifnr,
land1 type lfa1-land1,
bukrs type lfb1-bukrs,
end of ty_itab.
data: itab type standard table of ty_itab,
wa_itab like line of itab. "Work area
start-of-selection.
"fetch data
select alifnr aland` b~bukrs into table itab
from lfa1 as a inner join lfb1 as b on alifnr = blifnr.
"Display data
loop at itab into wa_itab.
write: / wa_itab-lifnr, wa_itab-land1, wa_itab-bukrs.
endloop.
That's all...
Check this codes...
Hope this will solve ur problem...
‎2007 Apr 17 12:03 PM
Hi
Create like this.
Data: Begin of it_lfa1 occurs 0,
lifnr like lfa1-lifnr,
land1 like lfa1-land1,
End of it_lfa1.
Data: Begin of it_lfb1 occurs 0,
lifnr like lfb1-lifnr,
bukrs like lfb1-bukrs,
End of it_lfb1.
Data: Begin of it_final occurs 0,
lifnr like lfa1-lifnr,
land1 like lfa1-land1,
bukrs like lfb1-bukrs,
End of it_final.
select lifnr
land1
from lfa1
into table it_lfa1.
sort it_lfa1 by lifnr.
if not it_lfa1[] is initial.
select lifnr
bukrs
from lfb1
into table it_lfb1
for all entries in it_lfa1
where lifnr = it_lfa1-lifnr.
endif.
loop at it_lfa1.
read table it_lfb1 with key lifnr = it_lfa1-lifnr.
it_final-lifnr = it_lfa1-lifnr.
it_final-land1 = it_lfa1-land1.
it_final-bukrs = it_lfb1-bukrs.
append it_final.
endloop.
loop at it_final.
write:/ it_final-lifnr,it_final-land1,it_final-bukrs.
endloop.
I think this will solve ur problem. Here there is no need of a workarea.
Regards
Haritha.