05-25-2006 12:59 PM
hi friends,
user has to upload data to TCODE here DATE field has to
accept all formats[eg.MM/DD/YYYY,DD/MM/YYYY,YYYY/MM/DD etc.,,] so plz tell how to code this r is there any variable plz suggest me any code with eg
thanks
soorya
05-25-2006 1:01 PM
hi
each user has a defualt date setting maintaineed in
USR01
so first make a query on the usr01 table and get the default date
then convert all the dates into the default user format.
in the sample code i'm taking simple date like 20060101
and getting year month & date
SELECT SINGLE DATFM
FROM USR01
INTO (V_DATFORMAT)
WHERE BNAME = SY-UNAME.
YEAR = DATESTRING+0(4).
MONTH = DATESTRING+4(2).
DATE = DATESTRING+6(2).
CASE V_DATFORMAT.
WHEN 1.
CONCATENATE DATE MONTH YEAR INTO DATESTRING SEPARATED BY '.'.
WHEN 2.
CONCATENATE MONTH DATE YEAR INTO DATESTRING SEPARATED BY '/'.
WHEN 3.
CONCATENATE MONTH DATE YEAR INTO DATESTRING SEPARATED BY '-'.
WHEN 4.
CONCATENATE YEAR MONTH DATE INTO DATESTRING SEPARATED BY '.'.
WHEN 5.
CONCATENATE DATE MONTH YEAR INTO DATESTRING SEPARATED BY '/'.
WHEN 6.
CONCATENATE DATE MONTH YEAR INTO DATESTRING SEPARATED BY '-'.
ENDCASE.
05-25-2006 1:01 PM
hi
each user has a defualt date setting maintaineed in
USR01
so first make a query on the usr01 table and get the default date
then convert all the dates into the default user format.
in the sample code i'm taking simple date like 20060101
and getting year month & date
SELECT SINGLE DATFM
FROM USR01
INTO (V_DATFORMAT)
WHERE BNAME = SY-UNAME.
YEAR = DATESTRING+0(4).
MONTH = DATESTRING+4(2).
DATE = DATESTRING+6(2).
CASE V_DATFORMAT.
WHEN 1.
CONCATENATE DATE MONTH YEAR INTO DATESTRING SEPARATED BY '.'.
WHEN 2.
CONCATENATE MONTH DATE YEAR INTO DATESTRING SEPARATED BY '/'.
WHEN 3.
CONCATENATE MONTH DATE YEAR INTO DATESTRING SEPARATED BY '-'.
WHEN 4.
CONCATENATE YEAR MONTH DATE INTO DATESTRING SEPARATED BY '.'.
WHEN 5.
CONCATENATE DATE MONTH YEAR INTO DATESTRING SEPARATED BY '/'.
WHEN 6.
CONCATENATE DATE MONTH YEAR INTO DATESTRING SEPARATED BY '-'.
ENDCASE.
05-25-2006 1:03 PM
Get your date in internal format.
Then you can use the write statement to get the user defined format for the date.
data: v_datum type sy-datum,
v_date_new(10).
write: v_datum to v_date_new.
REgards,
Ravi
05-25-2006 1:03 PM
Hi,
You can make the screen accept the date format specified in the user defaults, which you can see in SU01 transaction, else you will take wahtever the user enters and change the format and put it in the field.
regards,
Ravi
05-25-2006 1:04 PM
Hi,
in Table <b>USR01</b> check the field <b>DATFM</b> , this will tell you in which format it can take.
Regards
vijay
05-25-2006 1:07 PM
use this FM.
CONVERT_DATE_TO_INTERN_FORMAT
pass DTYPE = 'DATS'.
this function module will take care of the user's defined settings and accordingly convert into proper format
05-25-2006 1:08 PM
Hi,
Use CONVERT_DATE_TO_INTERN_FORMAT
pass DTYPE = 'DATS'.
This FM will TAKE CARE OF THE USERS SETTINGSAND ACCORDINGLY CONVERT INTO PROPER FORMAT
(IE NITERNAL FORMAT OF YYYYMMDD)
Hope it helps you.
Regards,
Anjali
05-25-2006 1:08 PM
Hi soorya,
1. Simple.
2. Instead of worrying about the
user format,
just use
WRITE date to variable.
(and use this variable in bdc data)
<b>(WRITE will AUTOMATICALLY TAKE CARE OF USER SETTINGS)</b>
3. just copy paste to get a taste of it.
4.
report abc.
*----
data : d type sy-datum.
data : mydate(10) type c.
*----
start-of-selection.
d = '20060525'.
<b> write d to mydate.</b>
*----
write 😕 mydate..
regards,
amit m.