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

Function Module to get month name

Former Member
0 Likes
29,138

Hi all,

I need to capture the month name in a variable.Example if the month is 02 then i need the result as February or if it is 12 then i need the result as December..

Is there any Function Module for the same..

Please suggest..

Thanks,

Arun

1 ACCEPTED SOLUTION
Read only

amit_khare
Active Contributor
0 Likes
10,208

Use this code -

TABLES : t247.

DATA : v_mon(2) TYPE n,

v_date(10) VALUE '04.09.2007',

v_ltx LIKE t247-ltx,

v_ktx LIKE t247-ktx.

SELECT SINGLE ktx

ltx

INTO (v_ktx , v_ltx)

FROM t247

WHERE spras = sy-langu AND

mnr EQ v_date+3(2).

WRITE : v_ktx , v_ltx.

Otherwise use FM MONTH_NAME_GET.

I will prefer the above quote.

6 REPLIES 6
Read only

Sougata
Active Contributor
0 Likes
10,208

Not that I'm aware of but its easy to write one. Build a case statement around a FM/Routine Importing/Using the month number and Exporting/Changing the variable containing the month name. There are only 12 months so it should be short and simple.

Cheers,

Sougata.

Read only

amit_khare
Active Contributor
0 Likes
10,209

Use this code -

TABLES : t247.

DATA : v_mon(2) TYPE n,

v_date(10) VALUE '04.09.2007',

v_ltx LIKE t247-ltx,

v_ktx LIKE t247-ktx.

SELECT SINGLE ktx

ltx

INTO (v_ktx , v_ltx)

FROM t247

WHERE spras = sy-langu AND

mnr EQ v_date+3(2).

WRITE : v_ktx , v_ltx.

Otherwise use FM MONTH_NAME_GET.

I will prefer the above quote.

Read only

vallamuthu_madheswaran2
Active Contributor
10,208

hi,

using the following function module MONTH_NAMES_GET.

or

data: l_month(10) type c.

select ltx form t247

into l_month

where spras = 'EN'

and mnr = 12 "==> month.

Thanks & regards,

Vallamuthu.M

Read only

former_member386202
Active Contributor
0 Likes
10,208

Hi,

Use FM MONTH_NAME_GET

Regards,

Prashant

Read only

Former Member
0 Likes
10,208

3 ways;

data:itab_month type standard table of T247

data: month_name type table of t247 with header line.

data: mm(2) type n.

*

mm = sy-datum+4(2).

*

CALL FUNCTION 'MONTH_NAMES_GET'

TABLES

MONTH_NAMES = month_name.

*

read table month_name index mm.

*

write: / month_name-ltx.

OR

REPORT ychatest2.

TABLES : t247.

DATA : v_mon(2) TYPE n,

v_date(10) VALUE '04.09.2007',

v_ltx LIKE t247-ltx,

v_ktx LIKE t247-ktx.

SELECT SINGLE ktx

ltx

INTO (v_ktx , v_ltx)

FROM t247

WHERE spras = sy-langu AND

mnr EQ v_date+3(2).

WRITE : v_ktx , v_ltx.

OR

Hi,

use sub srtingoperation, as below.

MONTH_NAMES_GET cannot be used to spell the month, it is used to retrieve the available month options in a perticular system and their possible representation.

if you want to spell the month use the FM ' SPELL_AMOUNT'.

Use sub string operation for this.

data: c1(2) type c,

d1 type d value '04.09.2007,

WORDS LIKE SPELL.

c1 = d1+3(2).

call function 'SPELL AMOUNT'

EXP

AMOUNT = C1

LANGUAGE = SY-LANGU

IMPORTING

IN_WORDS = WORDS

WRITE: WORDS-WORD

Read only

Former Member
0 Likes
10,208

Hi Arun,

You can use FM " Month_name_get"..

It would be better to write Case statements and create some piece of code.

Reward If Useful.

Regards,

Chitra Parameswaran