‎2013 Feb 18 7:24 AM
Hi all,
I know there are many such posts but i was unable to find an answer that suited my requirement.
I want to convert the internal date format into the format specified below. Is there any FM's for this or do i have to code it?
For Ex:
Internal Format : 20130218
Format Needed : 18th February 2013
I found the FM CONVERSION_EXIT_LDATE_OUTPUT but it does not add the th to the date.
Any Help will be greatly appreciated.
Thanks
‎2013 Feb 18 7:44 AM
Hi Kaeyur Rudra,
I don't think any function module would give you the desired result as expected by you.
But you can modify the function module based on your requirement.
‎2013 Feb 18 7:33 AM
Hello,
I have a suggestion for you, but is not actually such a good method.
You can try;
DATA: LV_DATUM(15).
CALL FUNCTION 'CONVERSION_EXIT_LDATE_OUTPUT'
EXPORTING
INPUT = P_DATUM
IMPORTING
OUTPUT = LV_DATUM.
REPLACE ALL OCCURRENCES OF '.' IN LV_DATUM WITH 'th'.
‎2013 Feb 18 7:37 AM
‎2013 Feb 18 7:35 AM
Hi,
I think for your requirement there is no function module available you have to write the code as below
please check the below link
http://scn.sap.com/thread/1112656
Definately it will help u.
Thanks
Mani
‎2013 Feb 18 7:38 AM
‎2013 Feb 18 7:44 AM
Hi Kaeyur Rudra,
I don't think any function module would give you the desired result as expected by you.
But you can modify the function module based on your requirement.
‎2013 Feb 18 8:43 AM
‎2013 Feb 18 8:39 AM
Hi,
Write a simple select query on table T247.
Thanks,
Tooshar Bendale
‎2013 Feb 18 8:43 AM
Thanks Tooshar,
But doing that will give me the month in long form, not the whole date.
Thanks
‎2013 Feb 18 8:53 AM
Hi use the function module
HR_IN_GET_DATE_COMPONENTS
It will give the day, month and year.
Hope this helps.
Thanks,
Tooshar Bendale
‎2013 Feb 18 9:03 AM
The FM has a issue.
Month Day and Year are of type c( 1 char long). Hence when u pass sy-datum to it gives an exception since it cant take the whole of the month number..
‎2013 Feb 18 9:10 AM
Hi,
You had entered a wrong date. Check the screen shot attached.
Thanks,
Tooshar Bendale
‎2013 Feb 18 9:42 AM
‎2013 Feb 18 9:05 AM
hi,
with th will not come in any function module you have to write select query in t247 table and concatenate date 'th' month and year ..
hope it helps,
Vinoth
‎2013 Feb 18 9:43 AM
Thanks everyone..
Guess i will have to add the th manually..
‎2013 Feb 18 10:33 AM
hi , As suggested by Nagabhushan earlier, u can copy the FM and add the code after output statement.
data day1 type c.
day1 = output+1(1).
if day1 = 1.
replace all occurrences of '.' in output with 'st'.
elseif day1 = 2.
replace all occurrences of '.' in output with 'nd'.
elseif day1 = 3. replace all occurrences of '.' in output with 'rd'.
else. replace all occurrences of '.' in output with 'th'.
endif.
Thanks
Vijay
‎2013 Feb 18 10:42 AM
Hi Rudra,
Its very simple. Just get the year date and month separated.
w_year = w_input+0(4) = 2013
w_date = w_input0+6(2) = 18
w_month = w_input0+4(2) = 02
Internal Format : 20130218
Assign the month name as per the month number we get in the w_month variable.
and the concatenate accordingly to get the final answer.
‎2013 Feb 18 10:46 AM
‎2013 Feb 18 10:47 AM
‎2013 Feb 19 1:32 AM
May be this REGEX solution helps which I got from some other post.
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
‎2013 Feb 18 10:54 AM
Hi Rudra,
yes,according to Dnyaneshwar follow the code and add this.
case w_month.
when '01'.
lv_name = 'January.
when '02'
lv_name = 'Febraury.
......
endcase.
concatenate w_date lv_name w_year into w_format.
Regards,
Gurunath Kumar D