Skip to Content

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

simple logic from below internal tables

Hi,

I have one i.table ITAB.

entries as:

Year Month value

2008 12 0.00

I have another i.table ITAB1

entries as:

Year Month value

2008 1 12.00

2008 2 15.00

2008 3 10.00

2008 4 11.00

2008 11 0.00

2008 12 0.00

Both these i.tables are retrieved from same table.

Now i required logic such that i should be able check each month 12-1, 11-1 etc.. till the month have some value other than 0.00.

Note: i should not use

Loop at ITAB.

If itab-value eq 0.

  • logic should pick up value from previous available month which have value from ITAB1

endif.

endloop.

can anybody provide simple logic for this!

Thanks,

Deep.

Former Member
Former Member replied

Hi,

use this code and it will work for your requirement...

sort ITAB1 by year descending 
                           month descending.
 
Loop at ITAB.
If itab-value eq 0.
    Read table itab1 into itab1 with key year <= itab-year
                                                       month < itab-month
                                                       value <> 0.                         
"   this read statement will give you the record where the value is not eq 0 for the month which is less 
"   than the month in itab and year <= itab-year.
endif.
endloop.

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