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

Current month

Former Member
0 Likes
933

Hi,

Is there any function module available to get the current month or is there any other way to get the current month in a program?

Thanks..

Uma.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
901

Like this.



report zrich_0001 .

data: current_month(2) TYPE N.

current_month = sy-datum+4(2).

write:/ current_month.

Regards,

RIch Heilman

6 REPLIES 6
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
902

Like this.



report zrich_0001 .

data: current_month(2) TYPE N.

current_month = sy-datum+4(2).

write:/ current_month.

Regards,

RIch Heilman

Read only

0 Likes
901

and if you accidentaly want to work with other dates you can use

CALL FUNCTION 'GET_CURRENT_YEAR'

EXPORTING

bukrs = so_bukrs-low

date = it_catsdb-workdate

IMPORTING

currm = h_currmonth

curry = h_curryear

Read only

Former Member
0 Likes
901

If you want to get month name :

Use Rich program:

report zrich_0001 .

data: current_month(2) TYPE N.

current_month = sy-datum+4(2).

write:/ current_month.

pass current_month to fm ,you will get month name

MONTH_NAMES_GET

Read only

ferry_lianto
Active Contributor
0 Likes
901

Hi,

Please try this FM CACS_DATE_GET_YEAR_MONTH.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
901

Hi Uma,

try this:

DATA: month_table type table of T247 with header line.

data: idx like sy-tabix.

*

CALL FUNCTION 'MONTH_NAMES_GET'

TABLES

MONTH_NAMES = month_table.

*

idx = sy-datum+4(2).

read table month_table index idx.

*

write: / 'actual month =', month_table-LTX.

Regards, Dieter

another way is this:

tables: T247.

*

select single * from t247 where spras = sy-langu

and MNR = sy-datum+4(2).

*

write: / 'actual month =', t247-LTX.

regards, Dieter

Message was edited by:

Dieter Gröhn

Read only

Former Member
0 Likes
901

Hi,

Try with this code:

data: var(4) type d.

var = sy-datum+4(2).

write: sy-datum.

write: / var1.

Regards,

Bhaskar