Get Last Date of Month in ABAP/4


*&---------------------------------------------------------------------*
*&     Form get_last_date_of_month
*&---------------------------------------------------------------------*
*      get last date of month
*----------------------------------------------------------------------*
*     -->P_BEGDA is the date in month that you want to know last date
*     <--P_ENDDA last date of month that system will return to you
*----------------------------------------------------------------------*
form get_last_date_of_month using   p_begda
                           changing p_endda.
CALL FUNCTION ’LAST_DAY_OF_MONTHS’ EXPORTING
   day_in                = p_begda
 IMPORTING
  LAST_DAY_OF_MONTH      = p_endda
 EXCEPTIONS
  DAY_IN_NO_DATE         = 1
  OTHERS                 = 2         .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform.                   " get_last_date_of_month

Post new comment