Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

read statement

Former Member
0 Likes
792

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
768

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

8 REPLIES 8
Read only

Former Member
0 Likes
768

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

Read only

Former Member
0 Likes
768

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.

Read only

Former Member
0 Likes
768

Hi,

Try this.

LIFNR = '0000000100'.

Regards,

Suresh.

Read only

Former Member
0 Likes
768

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

Read only

Former Member
0 Likes
768

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

Read only

Former Member
0 Likes
768

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.

Read only

Former Member
0 Likes
769

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

Read only

Former Member
0 Likes
768

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.