2023 Aug 24 2:18 PM
Hello experts,
I've got a quick question, how can i get the posting period 6 months back from the period that i use as an input on selection screen? Is there any function module that covers my request?
For example:
*INPUT
lv_period = 3.
*OUTPUT
lv_period_6m_back = 9.
2023 Aug 24 3:52 PM
Hi Greg,
You can use MONTH_PLUS_DETERMINE FM. To substract months just use negative value in MONTHS parameter. You need to provide full date but you can just add dummy year and day and read month afterwards from returned date.
2023 Aug 25 10:10 AM
You can also use below code in method or subroutine.
IF month_change = 0.
new_month = old_month.
RETURN.
ENDIF.
new_month = old_month + ( month_change MOD 12 ).
IF new_month < 1.
new_month = 12 + new_month.
ELSEIF new_month > 12
new_month = new_month - 12.
ENDIF.