‎2009 Oct 27 1:52 PM
Dear Experts,
in my itab.
material year period amt qty
abc 2008 01 4545 878
abc 2008 03 5255 900
abc 2008 07 4545 1212
abc 2009 02 4551 1555
like that i stored in PSA in BI Side.
But user give the input period 03-2009 i show the result for only 02-2009 records.
But user give the input period 10-2008 i show the result for only 07-2008 records.
But user give the input period 05-2008 i show the result for only 03-2008 records.
Thanks and regards,
raj
‎2009 Oct 27 5:47 PM
previously your itab is like this
*material year period amt qty*
abc 2008 01 4545 878
abc 2008 03 5255 900
abc 2008 07 4545 1212
abc 2009 02 4551 1555
use this code
sort itab by year descending period descending. now it becomes like
*material year period amt qty*
abc 2009 02 4551 1555
abc 2008 07 4545 1212
abc 2008 03 5255 900
abc 2008 01 4545 878
now use this code to read the value
loop at itab into is where year = p_year period LT p_per.
write : / is-material , is-year, is-period, is-amt, is-qty.
exit. " to loop only once
endloop.Edited by: Soumyaprakash Mishra on Oct 27, 2009 11:17 PM
‎2009 Oct 27 2:15 PM
It is because the calendar period and fiscal year periods are different.
For calendar year JANUARY - 01 whereas from
financial point of view .
APRIL - 01
Edited by: vijetasap on Oct 27, 2009 3:16 PM
‎2009 Oct 27 2:17 PM
Hello
Try this logic:
do.
read table itab with key year = p_year
period = p_period.
if sy-subrc = 0.
write: itab-material, itab-year, itab-period, itab-amt, itab-qty.
exit.
else.
p_period = p_period - 1.
if p_period = 0.
p_period = 12.
p_year = p_year - 1.
endif.
endif.
enddo.
p_period and p_year - user input.
‎2009 Oct 27 5:34 PM
Hi raj a,
so what do you want? If you want an exit, what for? Do you want the previous month data?
I could try to explain but I have no idea what.
Regards,
Clemens
‎2009 Oct 27 5:47 PM
previously your itab is like this
*material year period amt qty*
abc 2008 01 4545 878
abc 2008 03 5255 900
abc 2008 07 4545 1212
abc 2009 02 4551 1555
use this code
sort itab by year descending period descending. now it becomes like
*material year period amt qty*
abc 2009 02 4551 1555
abc 2008 07 4545 1212
abc 2008 03 5255 900
abc 2008 01 4545 878
now use this code to read the value
loop at itab into is where year = p_year period LT p_per.
write : / is-material , is-year, is-period, is-amt, is-qty.
exit. " to loop only once
endloop.Edited by: Soumyaprakash Mishra on Oct 27, 2009 11:17 PM