Saturday, November 5, 2011

Sample Program to get first day and last day of a month



REPORT  ZDATE01.
DATA: v_date   TYPE sy-datum,
      v_last   TYPE sy-datum,
      v_first  TYPE sy-datum.

v_date = sy-datum.
CONCATENATE v_date+0(4) v_date+4(2) '01' into v_first.
write:/ 'First day of the month : ', v_first.

IF v_date+6(2) > 15.
  v_date = v_date + 20.
ELSE.
  v_date = v_date + 30.
ENDIF.

CONCATENATE v_date+0(4) v_date+4(2) '01' into v_last.
v_last = v_last - 1.
write:/ 'Last day of the month : ', v_last.

No comments:

Post a Comment