‎2007 Apr 18 7:57 AM
Hi,
can anyone explain to me why read table statement is not working in the followinf code:
data: begin of it_lfb1 occurs 10,
lifnr like lfb1-lifnr,
bukrs like lfb1-bukrs,
end of it_lfb1.
select *
from lfb1
into corresponding fields of it_lfb1.
append it_lfb1.
read table it_lfb1 into wa_lfb1 with key lifnr = '100'.
write:/ wa_lfb1-lifnr,
wa_lfb1-bukrs.
endselect.
when i am executing the read statement without key, its fetching first record.
Regards
vivek
‎2007 Apr 18 8:25 AM
Hi Vivek,
As LIFNR as the conversion exit, so pad zeros prior to 100 to get the record.
If you doesnt specify WITH KEY then it will display the first record only. Dont use READ statements inside your SELECT statement.
data: begin of it_lfb1 occurs 10,
lifnr like lfb1-lifnr,
bukrs like lfb1-bukrs,
end of it_lfb1.
select *
from lfb1
into corresponding fields of it_lfb1.
append it_lfb1.
read table it_lfb1 into wa_lfb1 with key <b>lifnr = '0000000100'.</b>
write:/ wa_lfb1-lifnr,
wa_lfb1-bukrs.
endselect.
(or)
data: begin of it_lfb1 occurs 10,
lifnr like lfb1-lifnr,
bukrs like lfb1-bukrs,
end of it_lfb1.
select lifnr bukrs from lfb1
into table it_lfb1.
Loop at it_lfb1 where <b>lifnr = '0000000100'.</b>
write:/ it_lfb1-lifnr,
it_lfb1-bukrs.
endif.
endloop.
Thanks,
Vinay
‎2007 Apr 18 8:00 AM
Hi,
data: begin of it_lfb1 occurs 10,
lifnr like lfb1-lifnr,
bukrs like lfb1-bukrs,
end of it_lfb1.
select lifnr bukrs from lfb1
into table it_lfb1.
Loop at it_lfb1.
if it_lfb1-lifnr = '100'.
write:/ it_lfb1-lifnr,
it_lfb1-bukrs.
endif.
endloop.
regards,
Anji
Message was edited by:
Anji Reddy Vangala
‎2007 Apr 18 8:00 AM
Hi,
data: begin of it_lfb1 occurs 10,
lifnr like lfb1-lifnr,
bukrs like lfb1-bukrs,
end of it_lfb1.
select *
from lfb1
into corresponding fields of table it_lfb1.
looat it_lfb1 into wa_lfb1 where lifnr = '100'.
write:/ wa_lfb1-lifnr, wa_lfb1-bukrs.
endloop.
‎2007 Apr 18 8:01 AM
‎2007 Apr 18 8:02 AM
Hi..,
check this !! it is working !!..
data: begin of it_lfb1 occurs 10,
lifnr like lfb1-lifnr,
bukrs like lfb1-bukrs,
end of it_lfb1.
<b>
select *
from lfb1
into corresponding fields of table it_lfb1.</b>
loop at it_lfb1 where lifnr eq '0000000100'.
write:/ it_lfb1-lifnr,
it_lfb1-bukrs.
endloop.
<b>
The output contains all the records where lifnr = 100.</b>
regards,
sai ramesh
‎2007 Apr 18 8:05 AM
Hi Vivek,
try with this line
read table it_lfb1 into wa_lfb1 with key lifnr = '0000000100'
you need to pad zeros as many number according to size of the field. lifner length of the field is 10. so you need to pad 7 zeros befor '100'. It may solve your problem
Regards,
venkat
‎2007 Apr 18 8:23 AM
Hi,
Try this...
data: begin of it_lfb1 occurs 10,
lifnr like lfb1-lifnr,
bukrs like lfb1-bukrs,
end of it_lfb1.
select *
from lfb1
into corresponding fields of it_lfb1.
append it_lfb1.
data wa_lfb1 like line of it_lfb1.
read table it_lfb1 into wa_lfb1 with key lifnr = <b>'0000000100'.</b>
write:/ wa_lfb1-lifnr,
wa_lfb1-bukrs.
endselect.
‎2007 Apr 18 8:25 AM
Hi Vivek,
As LIFNR as the conversion exit, so pad zeros prior to 100 to get the record.
If you doesnt specify WITH KEY then it will display the first record only. Dont use READ statements inside your SELECT statement.
data: begin of it_lfb1 occurs 10,
lifnr like lfb1-lifnr,
bukrs like lfb1-bukrs,
end of it_lfb1.
select *
from lfb1
into corresponding fields of it_lfb1.
append it_lfb1.
read table it_lfb1 into wa_lfb1 with key <b>lifnr = '0000000100'.</b>
write:/ wa_lfb1-lifnr,
wa_lfb1-bukrs.
endselect.
(or)
data: begin of it_lfb1 occurs 10,
lifnr like lfb1-lifnr,
bukrs like lfb1-bukrs,
end of it_lfb1.
select lifnr bukrs from lfb1
into table it_lfb1.
Loop at it_lfb1 where <b>lifnr = '0000000100'.</b>
write:/ it_lfb1-lifnr,
it_lfb1-bukrs.
endif.
endloop.
Thanks,
Vinay
‎2007 Apr 18 1:38 PM
hi,
try this u include the read statement inside the loop..this is internal table with
select *
from lfb1
into corresponding fields of it_lfb1.
append it_lfb1 to wa_lfb1.
loop at it_lfb1 into wa_lfb1.
read table it_lfb1 into wa_lfb1 with key lifnr = '100'.
write:/ wa_lfb1-lifnr,
wa_lfb1-bukrs.
endloop.