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

Former Member
0 Likes
951

Hi all,

I have a requirement that, i have the date in <b>YYYYMMDD</b> format. I need to change it to <b>DDMONYY</b>.For example,

<b> 20070312</b> should come as <b>12MAR07</b>.

please help me out.

1 ACCEPTED SOLUTION
Read only

messier31
Active Contributor
0 Likes
929

hi,

get DD and YY from date and use following function module to get month name.

MONTH_NAMES_GET

then concatenate date

first three char of month name and

year

and the translate to upper case...

Enjoy SAP.

Pankaj Singh

6 REPLIES 6
Read only

messier31
Active Contributor
0 Likes
930

hi,

get DD and YY from date and use following function module to get month name.

MONTH_NAMES_GET

then concatenate date

first three char of month name and

year

and the translate to upper case...

Enjoy SAP.

Pankaj Singh

Read only

Former Member
0 Likes
929

HI,

data : lv_month(2) type c,

lv_date(7) type c.

lv_month = sy-datum+4(2).

case lv_month.

when '01'.

concatenate sy-datum6(2) 'Jan' sy-datum2(2) into lv_month.

when '02'.

concatenate sy-datum6(2) 'Feb' sy-datum2(2) into lv_month.

and so on till 12.

endcase.

Thanks

mahesh

Read only

Former Member
0 Likes
929

Check the below code :

REPORT YEDULOCK.

data : date(8) type c.

data vdate(11) type c.

data : v_day(2),

v_year(2),

v_mon(2).

data : mon(3) type c.

start-of-selection.

date = '20070312'.

v_year = date+2(2).

v_mon = date+4(2).

v_day = date+6(2).

case v_mon.

when '01'.

mon = 'Jan'.

when '02'.

mon = 'Feb'.

when '03'.

mon = 'Mar'.

when '04'.

mon = 'Apr'.

when '05'.

mon = 'May'.

when '06'.

mon = 'Jun'.

when '07'.

mon = 'Jul'.

when '08'.

mon = 'Aug'.

when '09'.

mon = 'Sep'.

when '10'.

mon = 'Oct'.

when '11'.

mon = 'Nov'.

when '12'.

mon = 'Dec'.

endcase.

concatenate v_day mon v_year into vdate.

write:/ vdate.

Thanks

Seshu

Read only

Former Member
0 Likes
929

Hi,

find the below code and modify it according to your system date format.

PARAMETER:S_DATE TYPE SY-DATUM DEFAULT SY-DATUM.

DATA:MONTH TYPE T247-MNR,

YEAR TYPE CHAR2,

KTX TYPE T247-KTX,

DAY TYPE CHAR2,

DAY_DATE TYPE STRING,

P_DATE TYPE SY-DATUM.

DATA: NEW_DATE TYPE STRING.

P_DATE = S_DATE.

***FOR DAY AND DATE FORMAT.

DAY = P_DATE+6(2).

MONTH = P_DATE+4(2).

YEAR = P_DATE+2(2).

SELECT SINGLE KTX FROM T247 INTO KTX WHERE MNR = MONTH

AND SPRAS = 'E'.

CONCATENATE MONTH KTX YEAR INTO NEW_DATE.

WRITE:/ NEW_DATE.

For the above code , my system date format is MMDDYYYY. Change it according to your system date format.

Reward me the points, if it is usefull for you .

Thanks

Ramesh.

Read only

Former Member
0 Likes
929

Hi,

I hope following code will solve your problem. Just replace sy-datum by the variable you are using in your program. v_date will have date as <b>DDMONYY</b>.


DATA : x_t247  TYPE t247,
       v_date  TYPE string,
       v_month TYPE fcktx.

SELECT SINGLE ktx
  FROM t247
  INTO v_month
  WHERE spras = sy-langu
    AND mnr   = sy-datum+4(2).

CONCATENATE sy-datum+6(2) v_month sy-datum+0(4) INTO v_date.

Reward points if the answer is helpful.

Regards,

Mukul

Read only

Former Member
0 Likes
929

There is a FM that get you all the THREE characters for the months.

<b>MONTH_NAMES_GET</b>

Try this code:

  DATA: months LIKE t247 OCCURS 0 WITH HEADER LINE.
  DATA: date(7) TYPE c.
  CALL FUNCTION 'MONTH_NAMES_GET'
    EXPORTING
      language                    = sy-langu
    TABLES
      month_names                 = months.

  READ TABLE months WITH KEY spras = 'EN' mnr = sy-datum+4(2).
  CONCATENATE sy-datum+6(2) months-ktx sy-datum+2(2) INTO date.
  WRITE: date.

<i><b>Please reward points for helpful answer.</b></i>

Thanks.