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 DD.MM.YYYY to DDMMMYYYY

Former Member
0 Kudos

Hi All,

I have a requirement in which one of the output field is date.

I am fetching it in format DD.MM.YYYY.But the client wants it

in 1 OCT 2008 format.Any FM or method to achieve so.

Thanks in Advance,

Saket

8 REPLIES 8

Former Member
0 Kudos

Hi,

I used below logic to convert this.

*Start Date

SELECT SINGLE ltx FROM t247 INTO month_name

WHERE spras = is_audit-langu

AND mnr = sy-datum+4(2).

IF sy-subrc EQ 0.

CONCATENATE sy-datum+6(2) ',' INTO gv_date.

CONCATENATE month_name gv_date sy-datum+0(4) INTO gv_date SEPARATED BY space.

ENDIF.

Thanks,

Sree.

Former Member
0 Kudos

Hi,

To search an FM you can always type in the search string and go ahead.

Just type * date * and search and you will get a lot of function modules which you can use to convert the date.

Regards,

Pramod

Former Member
0 Kudos

Check this,

CALL FUNCTION 'CONVERSION_EXIT_SDATE_OUTPUT'

EXPORTING

INPUT = SY-DATUM

IMPORTING

OUTPUT = V_DATE.

,CONVERSION_EXIT_IDATE_OUTPUT ,CONVERSION_EXIT_LDATE_OUTPUT

Any of this FM will Solve

Regards,

Midhun abraham

Edited by: Midhun Abraham on Oct 7, 2008 7:07 PM

Former Member
0 Kudos

Hi,

The following would do the trick.

report  ztest.

start-of-selection.

  data: begin of ls_date,
          day(2)   type c,
          sep1(1)  type c,
          month(2) type c,
          sep2(1)  type c,
          year(4)  type c,
        end of ls_date.

  data: ls_month  type t247,
        lt_months type table of t247.

  write: sy-datum to ls_date.

  call function 'MONTH_NAMES_GET'
    tables
      month_names           = lt_months
    exceptions
      month_names_not_found = 1
      others                = 2.

  read table lt_months into ls_month with key mnr = ls_date-month.

  write: / ls_date-day, ls_month-ktx, ls_date-year.

Darren

Former Member
0 Kudos

Hi Saketh,

here i am giving one table name just check that table .

Table name is T247

In that you have month in the format of JAN FEB like that.

Just pass the MNR value like 01 0r 02 like that and return value for KTX field.

Exampe:

12.03.2008.

ekko-bedat = 12.03.2008

WRITE ekko-bedat+3(2) TO gv_mnth.

WRITE ekko-bedat+0(2) TO gv_date.

WRITE ekko-bedat+6(4) TO gv_year.

SELECT SINGLE ktx FROM t247 INTO gv_month

WHERE mnr = gv_mnth.

CONCATENATE gv_date gv_month gv_year INTO gv_newdate SEPARATED BY SPACE.

WRITE: gv_newdate.

If you want to pass SPRAS field also in the SELECT query Then you will get EN type language.

Try this code.

You will get exact output what you are expecting.

Thanks,

Surendra Babu Vemula

0 Kudos

Hi,

Just use ' write to ' statement with date mask.

Best Regards,

Mohamed_Mukhtar
Active Contributor
0 Kudos

Hi,

Example Code

DATA: wa_date TYPE dats VALUE '01102008',
     wa_date1(15),
     wa_month(4).
 
CASE wa_date+2(2).
  WHEN 01.
    wa_month = 'Jan'.
  WHEN 02.
    wa_month = 'Feb'.
  WHEN 03.
    wa_month = 'Mar'.
  WHEN 04.
    wa_month = 'Apr'.
  WHEN 05.
    wa_month = 'May'.
  WHEN 06.
    wa_month = 'Jun'.
  WHEN 07.
    wa_month = 'Jul'.
  WHEN 08.
    wa_month = 'Aug'.
  WHEN 09.
    wa_month = 'Sep'.
  WHEN 10.
    wa_month = 'Oct'.
  WHEN 11.
    wa_month = 'Nov'.
  WHEN 12.
    wa_month = 'Dec'.
 
ENDCASE.
 
 
CONCATENATE wa_date+0(2) wa_month wa_date+4(4) INTO wa_date1 SEPARATED BY SPACE.
 
WRITE wa_date1.

Regards

Former Member
0 Kudos

Thanks a lot.