Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get posting period from the past

sadasgreg
Discoverer
0 Kudos
230

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.
2 REPLIES 2

fprokopiuk
Active Participant
171

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.

0 Kudos
171

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.