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: 

Convert Numeric Period Month to First Three Letters of Month

keega
Participant
0 Kudos
681

Hi all,

I've been looking at various ways to achieve my task of converting a numeric month to a 3-letter alpha

The Period "04" should be "Apr 2022".

I'm seeing some people suggest using CASE...ENDCASE, others using a SELECT on t247, and others using FMs.

What is the best way to do this?

Thank you in advance.

1 ACCEPTED SOLUTION

venkateswaran_k
Active Contributor
587

Hi

You can use the FM MONTH_NAMES_GET

This will return the internal table with month names . You can read this internal table and concatenate with year

4 REPLIES 4

venkateswaran_k
Active Contributor
588

Hi

You can use the FM MONTH_NAMES_GET

This will return the internal table with month names . You can read this internal table and concatenate with year

0 Kudos
587

Ok then, I'll give it a shot. Thank you 🙂

587

Here's what I did:

* FM /CPD/GET_MONTH_NAME for 3 char month
DATA: v_mlong LIKE t247-ltx, " long text
v_mshort LIKE t247-ktx. " short text
CALL FUNCTION '/CPD/GET_MONTH_NAME'
EXPORTING
* DATE = '00000000'
language = sy-langu
month_number = wa_itab3-prodallocationperiodstartdate+4(2)
IMPORTING
* LANGU_BACK =
longtext = v_mlong
shorttext = v_mshort
EXCEPTIONS
calendar_id = 1
date_error = 2
not_found = 3
wrong_input = 4
OTHERS.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

This is what was returned:

It's perfect!

Thank you very much Venkat.

Sandra_Rossi
Active Contributor
587

It would be better to use the FM if it's released, but I think it's not, so it's up to you.