07-24-2009 3:03 PM
Hi All,
one issue with Date field.
in my internal table i have a date field with type char(10).
But when I upload the data to database through upload program, there I have a date field with type "DATS".
how do I convert and store it in "DATS " format in database.
please help...
07-24-2009 3:09 PM
HI ,
Try this use CONVERT_DATE_TO_INTERNAl
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = "ur date from file
ACCEPT_INITIAL_DATE =
IMPORTING
DATE_INTERNAL = "( date in dats format )
EXCEPTIONS
DATE_EXTERNAL_IS_INVALID = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
07-24-2009 3:08 PM
Hi
U need to MOVE the date from CHAR field to DATs field:
DATA: DATE_C(10), DATE_D TYPE SY-DATUM.
MOVE DATE_C TO DATE_D.
It's important the date if CHAR field is in format YYYYMMDD
Max
07-24-2009 3:08 PM
Hi,
Day = date(2)
month = date+2(2)
Year = date+4(4)
then concanate year month day to date format.
Thanks.
07-24-2009 3:11 PM
hi,
i have an entry in my internal table like:
01.01.2004 31.12.2006 of type char 10.
when i storing it in ztable(DB) its of type DATS.
so any sample code helps me.
07-24-2009 3:17 PM
Hi
Just as I said u need to convert the date in internal forma YYYYMMDD, there are some function to do it, but it's easy and u can do it by yourself:
DATA: DATE_CHAR(10) TYPE C.
DATA: DATE_DATS TYPE SY-DATUM.
DATE_CHAR = '01.01.2004'.
DATE_DATS (4) = DATE_CHAR+6(4).
DATE_DATS 4(2) = DATE_CHAR+3(2).
DATE_DATS 6(2) = DATE_CHAR(2).
Max
07-24-2009 3:23 PM
Hi,
Try this way.
Thanks
Venkat.O
DATA: date_1 type char10 value '01.01.2004',
date_2 type char10 value '31.12.2006'.
DATA: date_x type DATUM,
date_y type DATUM.
concatenate date_1+6(4) date_1+4(2) date_1+0(2) into date_x.
concatenate date_2+6(4) date_2+4(2) date_2+0(2) into date_y.
Write:/ date_x, date_x.
07-24-2009 3:36 PM
hi Venkat,
I tried like this.
v_startdate(10).
in loop
I move my internal table entry to date1 like
move wa_cost-v_startdate to date1.
move wa_cost-v_enddate to date2.
CONCATENATE date_16(4) date_14(2) date_1+0(2) INTO date_x.
CONCATENATE date_26(4) date_24(2) date_2+0(2) INTO date_y.
MOVE date_x TO ztable-startdate.
MOVE date_y TO ztable-enddate.
modify ztable.
date format is not storing properly. output is coming as 20041.01.
please help.
07-24-2009 3:39 PM
07-24-2009 3:09 PM
HI ,
Try this use CONVERT_DATE_TO_INTERNAl
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = "ur date from file
ACCEPT_INITIAL_DATE =
IMPORTING
DATE_INTERNAL = "( date in dats format )
EXCEPTIONS
DATE_EXTERNAL_IS_INVALID = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.