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 format in words

Former Member
0 Likes
1,032

Hello Frnds,

I want to convert date into word format e.g. 20.09.2009 to 20th .SEP.2009 ( 'th' on the top of 19 ).

for this i am using FM 'CONVERSION_EXIT_SDATE_OUTPUT' but the output is only 20.SEP.2009. please suggest me what should i do for this 'th'....(.i want this on top of the date instead of concatenating.)

Edited by: SidhikaranCharan on Sep 19, 2009 5:23 PM

Hello Frnds,

I want to convert date into word format e.g. 20.09.2009 to 20th .SEP.2009 ( 'th' on the top of 19 ).

for this i am using FM 'CONVERSION_EXIT_SDATE_OUTPUT' but the output is only 20.SEP.2009. please suggest me what should i do for this 'th'....(.i want this on top of the date instead of concatenating.)

Edited by: SidhikaranCharan on Sep 19, 2009 5:23 PM

6 REPLIES 6
Read only

faisalatsap
Active Contributor
0 Likes
962

Hi, Charan

Where you want to display this? mean to say using simple WRITE or in Smartforms ? if you are talking about WRITE than i think it is not possible, but in Smartforms you can.

Please always be more clear with your Question

Faisal

Read only

Former Member
0 Likes
962

Hi FAISAL,

yes, I want to do this in SMARTFORMS..........will you suggest me the way?

Read only

0 Likes
962

Hi, Charan

Than for Smartforms you will have to create a SmartStyle and than use this SmartStyle for SuperScript or SubScript

Faisal

Read only

Former Member
0 Likes
962

Hi Faisal,

thanks for your valuable reply(i checked this and created in smartstyle)........but now problem is that my date is in a variable...e.g..... &W_ZMM005_VAT-vatdt(C)&.......so where should i put this style (character format 'S') into this variable......

Thanks

Read only

0 Likes
962

Sorry, Charan

I don't have system with me right now so, can you give me the answer of the following questions than we can do it..

1. You date is coming in this format 20.SEP.2009 right now in a variable Length 11.

2. For date 1st SEP 2009 it will be like this 01.SEP.2009 or 1.SEP.2009 ?

3. Try to do this way &W_ZMM005_VAT-vatdt+0(2)& it should show you only 20 ?

waiting for your reply

Faisal

Read only

Clemenss
Active Contributor
0 Likes
962

Hi,

as this cries for a REGEX solution, I gave it a try.

FORM regex .
  DATA:
    lt_string TYPE TABLE OF string.
  FIELD-SYMBOLS:
    <string>  TYPE string.
  APPEND:
    '20. SEP 2009' TO lt_string,
    '31. SEP 2009' TO lt_string,
    '22. SEP 2009' TO lt_string,
    '20. SEP 2009' TO lt_string,
    '23. SEP 2009' TO lt_string,
    '02. SEP 2009' TO lt_string,
    '1. SEP 2009' TO lt_string,
    '26. SEP 2009' TO lt_string,
    '5. SEP 2009' TO lt_string.
  LOOP AT lt_string ASSIGNING <string>.
    WRITE: / <string>, 'converts to'.
    DO 1 TIMES.
      REPLACE REGEX '^(\d{0,1}1)\.'   IN <string> WITH `$1st ` .
      CHECK sy-subrc <> 0.
      REPLACE REGEX '^(\d{0,1}2)\.'   IN <string> WITH `$1nd ` .
      CHECK sy-subrc <> 0.
      REPLACE REGEX '^(\d{0,1}3)\.'   IN <string> WITH `$1rd ` .
      CHECK sy-subrc <> 0.
      REPLACE REGEX '^(\d{0,1}[0,4-9])\.'   IN <string> WITH `$1th ` .
    ENDDO.
    WRITE:  <string>.

  ENDLOOP.
ENDFORM.                    " REGEX

creates output

20. SEP 2009 converts to 20th  SEP 2009
31. SEP 2009 converts to 31st  SEP 2009
22. SEP 2009 converts to 22nd  SEP 2009
20. SEP 2009 converts to 20th  SEP 2009
23. SEP 2009 converts to 23rd  SEP 2009
02. SEP 2009 converts to 02nd  SEP 2009
1. SEP 2009 converts to 1st  SEP 2009
26. SEP 2009 converts to 26th  SEP 2009
5. SEP 2009 converts to 5th  SEP 2009

Regex explained:

^(\d{0,1}1)\.

^ - begin of string

d{0,1}1

- zero or one digit followed by "1"

() - brackets create a back reference to what is inside the brackets

replace with `$1st `

- use `colon to preserve trailing blanks

$1 - use back reference # 1 (matched substring), contents of first () bracket pair

st - use st as in 1st

Same logic applies to the rest. I'm newbie to REGEX, possibly there is one regex that could be used for all 4 cases (?).

Hope you are on ECC600, hope you like it. Adapt to your needs and use it.

Kind regards,

Clemens