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 and time

Former Member
0 Likes
791

i have declared the date and time fields as date(12) and time(15) in an internal table . The data is coming from a file with some comma separater then i am splitting the data based on comma and storing them in date and time fields internal table first and then update my custome table with the internal table . I have declared the fields in the custom table as dats and tims. The data in the internal table is fine but i cant update it properly to the custom table.I appreciate your immediate response.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
766

Hi,

use the FM CONVERT_DATE_TO_INTERNAL

Check this example

DATA: v_date TYPE sydatum.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

date_external = '6/1/2006'

IMPORTING

date_internal = v_date

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.

ENDIF.

WRITE: / v_date.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

date_external = '10/1/2006'

IMPORTING

date_internal = v_date

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.

ENDIF.

WRITE: / v_date.

Thanks,

Naren

i have declared the date and time fields as date(12) and time(15) in an internal table . The data is coming from a file with some comma separater then i am splitting the data based on comma and storing them in date and time fields internal table first and then update my custome table with the internal table . I have declared the fields in the custom table as dats and tims. The data in the internal table is fine but i cant update it properly to the custom table.I appreciate your immediate response.

5 REPLIES 5
Read only

Former Member
0 Likes
766

Hi,

What is the date format stored in the file??

Thanks,

Naren

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
766

You need to convert the date and time in your file to the format YYYYMMDD and HHMMSS to store it in your custom table. This is how the date and time is stored in SAP, and you must convert your date and time to it.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
766

file data will be like 6/1/2006 or 10/1/2006 . I mean day and month length can be 1 or 2.

Read only

0 Likes
766

Rich,

how can i convert it to that format

.

Read only

Former Member
0 Likes
767

Hi,

use the FM CONVERT_DATE_TO_INTERNAL

Check this example

DATA: v_date TYPE sydatum.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

date_external = '6/1/2006'

IMPORTING

date_internal = v_date

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.

ENDIF.

WRITE: / v_date.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

date_external = '10/1/2006'

IMPORTING

date_internal = v_date

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.

ENDIF.

WRITE: / v_date.

Thanks,

Naren