The problem: “How in ABAP get last day of month SAP ?” and first month in ABAP is not uncommon. For example, display orders for the current month, regardless of what date it is today. Or calculate the turnover for this month and so on.
ABAP get first day of month SAP.
The problem with the first day of the month is solved without using any FM or methods as follows:
1 2 3 4 5 |
" for example lv_begda = '20230809'. lv_begda = |{ lv_begda(6) }01|. " as a result lv_begda = '20230801'. |
We simply change the first number of the date and as a result we get the first day of the given month.
ABAP get last day of month SAP.
To get the last day of month in ABAP program, you can use the FM RP_LAST_DAY_OF_MONTHS. Below is an example of a simple call:
1 2 3 4 5 6 7 8 9 10 11 |
" for example lv_begda = '20230809'. CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS' EXPORTING day_in = lv_begda IMPORTING last_day_of_month = lv_endda EXCEPTIONS OTHERS = 2. " as a result lv_endda = '20230831'. |
Basic call options:
- day_in – source date. (day_in = 04/18/2022)
- last_day_of_month – last day of the month (last_day_of_month = 04/30/2022)
Additional information: Some FMs may not be in your system, so FMs with the same functions will also work!
In what task did you use this FM? Do you know an alternative to this Functional module? Write in the comments!