‎2006 Jun 23 9:00 PM
Hi,
I have an itab.
It has fields vbeln posnr and edatu.
Now I have to go to vbep and find out the relevant edatu for the vbeln and posnr.
If edatu is with in this month(say june), I will display on the output as with in this month.
If edatu falls under next month (i.e above june 30 and less than aug 1), I will display on the output as under next month. (I mean here only for the next month, not with in next month).
Like this, I have to display the output for upto next 3 months. I can do data retrieval easily but could not figure out about these months exactly. Can you suggest a code here?
I appreciate.
Thanks.
‎2006 Jun 23 9:16 PM
Here is an example program showing how you can setup your month buckets using ranges.
report zrich_0001.
ranges: r_datum1 for sy-datum,
r_datum2 for sy-datum,
r_datum3 for sy-datum.
data: tmp_datum type sy-datum.
tmp_datum = sy-datum.
clear r_datum1.
r_datum1-sign = 'I'.
r_datum1-option = 'BT'.
r_datum1-low+0(6) = tmp_datum+0(6).
r_datum1-low+6(2) = '01'.
call function 'LAST_DAY_OF_MONTHS'
exporting
day_in = r_datum1-low
importing
last_day_of_month = r_datum1-high.
append r_datum1.
call function 'RE_ADD_MONTH_TO_DATE'
exporting
months = 1
olddate = r_datum1-low
importing
newdate = tmp_datum.
clear r_datum2.
r_datum2-sign = 'I'.
r_datum2-option = 'BT'.
r_datum2-low+0(6) = tmp_datum+0(6).
r_datum2-low+6(2) = '01'.
call function 'LAST_DAY_OF_MONTHS'
exporting
day_in = r_datum2-low
importing
last_day_of_month = r_datum2-high.
append r_datum2.
call function 'RE_ADD_MONTH_TO_DATE'
exporting
months = 1
olddate = r_datum2-low
importing
newdate = tmp_datum.
clear r_datum3.
r_datum3-sign = 'I'.
r_datum3-option = 'BT'.
r_datum3-low+0(6) = tmp_datum+0(6).
r_datum3-low+6(2) = '01'.
call function 'LAST_DAY_OF_MONTHS'
exporting
day_in = r_datum3-low
importing
last_day_of_month = r_datum3-high.
append r_datum3.
check sy-subrc = 0.
Regards,
Rich Heilman
‎2006 Jun 23 9:16 PM
Here is an example program showing how you can setup your month buckets using ranges.
report zrich_0001.
ranges: r_datum1 for sy-datum,
r_datum2 for sy-datum,
r_datum3 for sy-datum.
data: tmp_datum type sy-datum.
tmp_datum = sy-datum.
clear r_datum1.
r_datum1-sign = 'I'.
r_datum1-option = 'BT'.
r_datum1-low+0(6) = tmp_datum+0(6).
r_datum1-low+6(2) = '01'.
call function 'LAST_DAY_OF_MONTHS'
exporting
day_in = r_datum1-low
importing
last_day_of_month = r_datum1-high.
append r_datum1.
call function 'RE_ADD_MONTH_TO_DATE'
exporting
months = 1
olddate = r_datum1-low
importing
newdate = tmp_datum.
clear r_datum2.
r_datum2-sign = 'I'.
r_datum2-option = 'BT'.
r_datum2-low+0(6) = tmp_datum+0(6).
r_datum2-low+6(2) = '01'.
call function 'LAST_DAY_OF_MONTHS'
exporting
day_in = r_datum2-low
importing
last_day_of_month = r_datum2-high.
append r_datum2.
call function 'RE_ADD_MONTH_TO_DATE'
exporting
months = 1
olddate = r_datum2-low
importing
newdate = tmp_datum.
clear r_datum3.
r_datum3-sign = 'I'.
r_datum3-option = 'BT'.
r_datum3-low+0(6) = tmp_datum+0(6).
r_datum3-low+6(2) = '01'.
call function 'LAST_DAY_OF_MONTHS'
exporting
day_in = r_datum3-low
importing
last_day_of_month = r_datum3-high.
append r_datum3.
check sy-subrc = 0.
Regards,
Rich Heilman
‎2006 Jun 23 9:16 PM
Hi Nuren,
Try with the following code.
DATA V_DATE1 TYPE VBAK-EDATU.
DATA V_DATE2 TYPE VBEP-EDATU.
DATA V_MONTH1(2).
DATA V_MONTH2(2).
DATA V_DIFF_MONTHS TYPE I.
V_MONTH1 = V_DATE1+4(2).
V_MONTH2 = V_DATE2+4(2).
V_DIFF_MONTHS = V_MONTH2 - V_MONTH1.
<b>CASE V_DIFF_MONTHS.
WHEN '1'.
WRITE:/ 'NEXT MONTH'.
WHEN '2'.
WRITE:/ 'AFTER 2 MONTHS'.
WHEN '3'.
WRITE:/ 'AFTER 3 MONTHS'.
ENDCASE.</b>
Thanks,
Vinay
‎2006 Jun 23 9:17 PM