Find last day of month of a given date in ABAP.

yes, ABAP!!!

So here is my code:
REPORT ZTMP_TEST_INNBOUND.
 
** Find last day of month of the provided date.
 
DATA:
DATE TYPE D,
YEAR(4) TYPE N,
MONTH(2) TYPE N,
DAY(2) TYPE N.
 
PARAMETERS:
DATE1 TYPE D.
 
** First get next month of DATE1:
YEAR = DATE1+0(4).
WRITE: 'Current year: ', YEAR.
 
MONTH = DATE1+4(2).
WRITE: /, 'Current month: ', MONTH.
 
DAY = DATE1+6(2).
WRITE: /, 'Current date: ', DAY.
 
IF MONTH < 12.
MONTH = MONTH + 1.
ELSE.
MONTH = 1.
ENDIF.
 
** Find the correct year:
IF MONTH EQ 1.
YEAR = DATE1+0(4) + 1.
ENDIF.
 
** Set Date to 1:
DAY = 01.
 
** Print first day of next month:
DATE+0(4) = YEAR.
DATE+4(2) = MONTH.
DATE+6(2) = DAY.
 
WRITE: /, 'First day of next month of DATE1: ', DATE DDMMYY.
 
DATE = DATE - 1.
WRITE: /, 'Last day of month of date entered is: ', DATE DDMMYY.

And let 's test our code: