Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Read statement giving problem

Dear Experts,

I am making monthly consumption report, In which i am getting monthly data column wise for different month , here firstly i am fetching header mblnr date according to date from mkpf then i am fetching data from mseg.....

I have same mblnr in both tables..... Now i am using read statement like this.......

sort lt_mkpf by mblnr.

SORT lt_mseg BY mblnr.

LOOP AT lt_mkpf INTO lw_mkpf.

READ TABLE lt_mseg INTO lw_mseg WITH KEY mblnr = lw_mkpf-mblnr

  • mjahr = lw_mkpf-mjahr


When I am debugging i am getting data in lw_mkpf but sy-subrc = 4 is coming and getting wrong data in final table by using these above statements..........

where as if i am using loop like this:

SORT lt_mkpf BY mblnr.

SORT lt_mseg BY mblnr.

LOOP AT lt_mkpf INTO lw_mkpf.

v_mkpf = lw_mkpf-mblnr.

LOOP AT lt_mseg INTO lw_mseg WHERE mblnr EQ v_mkpf.

with this i am getting right data........ But it takes lot of time to execute..........

Can you please guide me am i using read statement by wrong method. which one is the correct method which one shoul be used.........

Not what you were looking for? View more on this topic or Ask a question