In the below program I have used RP_LAST_DAY_OF_MONTHS function module to get the last of the month.
DATA: last_day TYPE sy-datum.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
day_in = sy-datum
last_day_of_month = last_day
day_in_no_date = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
WRITE: 'Last day:', last_day.
IDE Used To Test This Code : ABAP Editor.
Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.