2012 Aug 25 7:28 AM
Hi Experts...
I have a requirement to get the current date in user specified format.
I am using function module which will return the user specific date format (DATFM) and that I am storing into a variable.
Now I need to convert current date into that particular format.
suppose gd_format will store the user spcific date format.
I used the following code to convert the system date into that format.
WRITE: sy-datum USEING EDIT MASK gd_format TO gd_date.
But it will store the format itself into gd_date insted of the date.
Eg: If gd_format is DD.MM.YYYY and sy-datum is 20120824
After using the Write statement
The value in gd_date is DD.MM.YYYY.
I want date in gd_date as per the user specified format. That can be different for different users.
Kindly help me..
Thanks
Pradeep
Hi Experts...
I have a requirement to get the current date in user specified format.
I am using function module which will return the user specific date format (DATFM) and that I am storing into a variable.
Now I need to convert current date into that particular format.
suppose gd_format will store the user spcific date format.
I used the following code to convert the system date into that format.
WRITE: sy-datum USEING EDIT MASK gd_format TO gd_date.
But it will store the format itself into gd_date insted of the date.
Eg: If gd_format is DD.MM.YYYY and sy-datum is 20120824
After using the Write statement
The value in gd_date is DD.MM.YYYY.
I want date in gd_date as per the user specified format. That can be different for different users.
Kindly help me..
Thanks
Pradeep
2012 Aug 25 8:05 AM
hi pradeep,
please try this,
date1 = sy-datum.
time = sy-timlo.
WRITE date1 USING EDIT MASK '____/__/__' TO lv1.
WRITE time USING EDIT MASK '__:__:__' TO lv2.
write 😕 lv1 DD/MM/YYYY.
use underscor instead of DD MM YYYY
thanks,
marimuthu.k
2012 Aug 25 8:33 AM
Dear,
please tell me how you can identify which user want which format?
2012 Aug 25 9:20 AM
Have a look at this Link.Maybe this might provide you with the solution that you want.Please give Points if link was found useful.
2012 Aug 25 10:04 AM
hi pradeep,
please try the following,
DATA : date1 TYPE char8,
time TYPE char6,
var10 TYPE char10,
var8 TYPE char8,
lv_length TYPE i,
li TYPE i,
lv_off TYPE i,
z TYPE char2.
PARAMETER lv TYPE char10.
date1 = sy-datum.
time = sy-timlo.
FIELD-SYMBOLS <f> TYPE char10.
ASSIGN lv TO <f>.
<f> = lv.
FIND ALL OCCURRENCES OF 'DD' IN <f> MATCH LENGTH lv_length MATCH OFFSET lv_off.
var10+lv_off(lv_length) = date1+6(2).
li = lv_off + lv_length.
IF li <> 10.
lv_off = li.
var10+lv_off(1) = '/'.
ENDIF.
FIND ALL OCCURRENCES OF 'MM' IN <f> MATCH LENGTH lv_length MATCH OFFSET lv_off.
var10+lv_off(lv_length) = date1+4(2).
li = lv_off + lv_length.
IF li <> 10.
lv_off = li.
var10+lv_off(1) = '/'.
ENDIF.
FIND ALL OCCURRENCES OF 'YYYY' IN <f> MATCH LENGTH lv_length MATCH OFFSET lv_off.
var10+lv_off(lv_length) = date1+0(4).
li = lv_off + lv_length.
IF li <> 10.
lv_off = li.
var10+lv_off(1) = '/'.
ENDIF.
WRITE: date1,var10.
if u give input DD/mm/yyyy like this u ll get o/p as 25/08/2012.
in ur case instead of lv pass gd_date u will get desired o/p.
reward points if it is useful.
thanks,
marimuthu.k
2012 Aug 25 11:03 AM
Hi,
Can you try this and give me the result :
WRITE sy-datum TO gd_date USING EDIT MASK gd_format.
Khalid.
2012 Aug 25 11:12 AM
Dear first give me answer
where you define that which user want which formt?
means user and format combination is fixed or not?
if fix then where it is?
if not then how you get the format for user?
2012 Aug 28 6:45 AM
2012 Aug 28 2:45 PM
Hi,
You just need to call the FM CONVERT_DATE_TO_EXTERNAL, which take the user format into account...
Manu.
2012 Aug 29 6:55 AM
Use FM FORMAT_DATE_4_OUTPUT
For ex,
CALL FUNCTION 'FORMAT_DATE_4_OUTPUT'
EXPORTING
datin = sy-datum
format = 'DD.MM.YYYY'
IMPORTING
datex = result.
you can pass format in export parameter 'format'.
Regards.
Kaushik Savaliya
2012 Aug 29 7:48 AM
Hi Pradeep,
Use FM SLS_MISC_CONVERT_TO_DATE to convert date sy-datum format to user default format.
Hi Bharat,
User format is defaulted in (Menu option:System-->User Profile-->Own data) or can also be found in USR01 table. Check DATFM field passing BNAME. Use domain value range of DATFM to indentify what format is set for the user.
Regards,
Sravan Guduru
2022 Nov 08 5:45 PM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |