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

date conversion logic using function modules

0 Likes
559

Hi there,

I have been researching in the forum how data conversion is done in ABAP and I found out about the function modules

CONVERSION_EXIT_LDATE_OUTPUT

and

MONTH_NAMES_GET

It seems that the first function module can convert the date format 06/08/2011 to MONTH DD,YYYY and the second function can easily translate the month names once language SPRAS has been specified.

Problem is I am not sure how I can convert my VBRK-FKDAT with format MM/DD/YYYY into the format DD MONTH YYYY format with the MONTH still dependent on the specified language.

I tried to look at how to MONTH_NAMES_GET FM works and made this code:


DATA: d_return like sy-subrc,
      itab_T247 like T247 occurs 0 with header line,
      gs_spras type spras.

gs_spras = 'RU'.

CALL FUNCTION 'MONTH_NAMES_GET'
 EXPORTING
   LANGUAGE                    = gs_spras
 IMPORTING
   RETURN_CODE                 = d_return
  TABLES
    MONTH_NAMES                 = itab_T247
 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.

Loop at itab_t247.

Write:/ itab_t247-LTX.

endloop.

The code just lists the months in Russian (which is the language I need). I am just new to ABAP so I am an avid reader of the forum. I hope someone can help.

Thanks,

dgrachee

2 REPLIES 2
Read only

Former Member
0 Likes
505

Hi,

you have the date DD , MONTH name and YYYY from the 2 function modules.

Now just concatenate the desired text into a variable.

SO if you get ddmmYYYY use offset to read 1st two characters as day and last 4 as year. And tehn concatenate with month.

Read only

former_member212713
Contributor
0 Likes
505

Hi Dgrachee ;

You can change it as follows.

Best Regards.


....
gs_spras = sy-langu. "'RU'.
CALL FUNCTION 'MONTH_NAMES_GET'
....