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

month name

Former Member
0 Likes
1,254

hi experts

i have the itab-budat contains date in the format of '04.09.2007'.

i want to display the month in name, how to use MONTH_NAMES_GET'

give me example program.

thanks in advance.

Regards

Rajaram

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,209
Hi Raja,

chk this

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.

hi experts

i have the itab-budat contains date in the format of '04.09.2007'.

i want to display the month in name, how to use MONTH_NAMES_GET'

give me example program.

thanks in advance.

Regards

Rajaram

9 REPLIES 9
Read only

varma_narayana
Active Contributor
0 Likes
1,209

Hi Rajaram...

to Display the Date along with Month name.

Call the FM CONVERSION_EXIT_SDATE_OUTPUT.

This will give the Date in 10.AUG.2007 Format.

whereas MONTH_NAMES_GET is used to return all the month names as per language etc.

<b>reward if Helpful.</b>

Read only

0 Likes
1,209

i want to display the month only.

for example if the date 04.09.2007 = September

01.08.2007 = August

how to display this.

Read only

Former Member
0 Likes
1,210
Hi Raja,

chk this

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.
Read only

Former Member
0 Likes
1,209

Dont pass anything to the FM

data : i_month type standard table of T247.

CALL FUNCITON 'MONTH_NAMES_GET'

importing

LANGUAGE = 'EN'

TABLES

MONTH_NAMES = i_month.

Now depending on your month value

read table i_month into wa_month with key SPRAS = 'EN'

MNR = itab-budat+3(2).

Read only

Former Member
0 Likes
1,209

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
1,209

Hi Raja,

Use any one of the following methods

  • method 1.

data: v_month like t247-ltx.

select single ltx into v_month from t247

where spras = sy-langu and

mnr = sy-datum+4(2).

write:/ 'Month = ', v_month.

  • method 2.

data: v_month like t247-ltx,

month_names like t247 occurs 0 with header line.

CALL FUNCTION 'MONTH_NAMES_GET'

EXPORTING

LANGUAGE = SY-LANGU

  • IMPORTING

  • RETURN_CODE = RETURN_CODE

TABLES

MONTH_NAMES = MONTH_NAMES

EXCEPTIONS

MONTH_NAMES_NOT_FOUND = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

read table month_names with key spras = sy-langu

mnr = sy-datum+4(2).

if sy-subrc = 0.

v_month = month_names-ltx.

endif.

write:/ 'Month = ', v_month.

Read only

Former Member
0 Likes
1,209

hi,

Try these sample code........

DATA: date1 like sy-datum,

date2,

it_month like t247 occurs 0 with header line.

date13(4) = itab-budat3(4).

date2 = date1+3(4).

it_month-mn = date2.

call function 'month_names_get'

exporting

LANGUAGE = 'EN'

TABLE

month_names = it_month[].

Rewards points if useful

Read only

Former Member
0 Likes
1,209

Hi raja,

1. 04.09.2007 = <b>04-SEP-2007</b>

2. Just use this FM

CONVERSION_EXIT_SDATE_OUTPUT

regards,

amit m.

Read only

Former Member
0 Likes
1,209

Hi,

try this:

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.

regards, Dieter