Application Development and Automation 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: 
Read only

need function module

Former Member
0 Likes
1,297

hi

is there any function module that gives previous month and year? for eg. if the input is 01.2007 (monyr), 12.2006 should be exported..thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,240

<b>RS_VARI_V_L_LAST_MONTH</b> Returns last day of last month.

<b>RS_VARI_V_1_LAST_MONTH</b> Returns first day of the last month.

11 REPLIES 11
Read only

Former Member
0 Likes
1,241

<b>RS_VARI_V_L_LAST_MONTH</b> Returns last day of last month.

<b>RS_VARI_V_1_LAST_MONTH</b> Returns first day of the last month.

Read only

Former Member
0 Likes
1,240

Hi sathish,

u just have to give the date from which u have to go back and the number of months..in th follwing fm

CCM_GO_BACK_MONTHS

from the exported value u can take the year or month or both

hope this helps,

all the best,

sampath

  • award points if helpful

Read only

Former Member
0 Likes
1,240

Hi Sathish,

U can use <b>BKK_ADD_MONTH_TO_DATE</b>.

Pass the old date and months to be added as '-1'. Suppose if u pass old date as 01.01.2007 and months as '-1', then ur output will be 01.12.2006. Take only the month and year.

-Satya Priya

Read only

learnsap
Active Participant
0 Likes
1,240

Hi Satish,

Try these function modules.

RS_VARI_V_1_LAST_MONTH

RS_VARI_V_LAST_MONTH

RS_VARI_V_L_LAST_MONTH

Regards,

Ramesh

*If reply is helpful award the points

Read only

Former Member
0 Likes
1,240

Hi,

Use this FM.

CALCULATE_DATE.

CALL FUNCTION 'CALCULATE_DATE'

EXPORTING

DAYS = '0'

MONTHS = '-1'

START_DATE = SY-DATUM

IMPORTING

RESULT_DATE = lv_date.

write lv_date+0(4).

write lv_date+4(2).

Rgds,

Prakash

Read only

Former Member
0 Likes
1,240

hi sathish,

the function module <u><b>RS_VARI_V_LAST_MONTH</b></u> will give u the previous month

Read only

Former Member
0 Likes
1,240

hi,

this does it without a FM.

Try out.

DATA: fdate TYPE sy-datum.

parameter: ldate TYPE sy-datum.

WRITE:/ 'Current Date - ', ldate.

ldate+6(2) = '01'.

ldate = ldate - 1.

fdate = ldate.

fdate+6(2) = '01'.

WRITE:/ 'First Date - ' , fdate.

WRITE:/ 'Last Date - ' , ldate.

Reward points if helpful,

Bijal

Read only

anversha_s
Active Contributor
0 Likes
1,240

hi,

just try this.

data: wa_date like sy-datum.
data: month(2),      
year(4).
call function 'RP_CALC_DATE_IN_INTERVAL'
exportingdate = sy-datum
days = 0
months = 1
signum = '-'
years = 0
importing
calc_date = wa_date.

month = wa_date+4(2).
year = wa_date+0(4).

Regards

Anver

Read only

anversha_s
Active Contributor
0 Likes
1,240

hi,

just try this.

data: wa_date like sy-datum.
data: month(2),      
year(4).
call function 'RP_CALC_DATE_IN_INTERVAL'
exportingdate = sy-datum
days = 0
months = 1
signum = '-'
years = 0
importing
calc_date = wa_date.

month = wa_date+4(2).
year = wa_date+0(4).

Regards

Anver

Read only

Former Member
0 Likes
1,240

Hi Sathish,

check out these fm:

CCM_GO_BACK_MONTHS

RS_VARI_V_LAST_MONTH

CALCULATE_DATE

this will give you the previous month.

Read only

Former Member
0 Likes
1,240

friends,

thanks for your answers...i was expecting a fm that would only return previous monyr (200612 if i give 200701)..but anyway, i can use any of your fms and get the result..BKK_ADD_MONTH_TO_DATE seems to be simple as there are only 2 import parameters