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

Converting string to SAP Time format

Former Member
0 Likes
8,816

Hi everyone,

I am taking input from a text file in BDC. Declaring time in char10 as SAP standard time format accepts only 6 chars in length type,but it's not getting stored properly. I need to convert this string into standard sap time format. The way we have FM CONVERSION_EXIT_IDATE_INPUT  for date conversion, do we have something for TIME as well?

I found  CONVERT_TIME_INPUT in google, but on using this got error saying output type is not same as required one.

Please help.

Regards,

Chetna D

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,868

How come it is 10? Including separator?

You can also just remove the separator then condense?

DATA: time TYPE char10.

time = '23:59:59'.

REPLACE ALL OCCURRENCES OF ':' IN time WITH space.

CONDENSE time.

6 REPLIES 6
Read only

Former Member
0 Likes
4,869

How come it is 10? Including separator?

You can also just remove the separator then condense?

DATA: time TYPE char10.

time = '23:59:59'.

REPLACE ALL OCCURRENCES OF ':' IN time WITH space.

CONDENSE time.

Read only

0 Likes
4,868

Hi,

Soryy,not 10. I am taking input from BDC file as 8 chars like: 10:10:10

Now in order to store it in sap custom table, wherein data type for time is erzet (input length 6, output length 8), I need to convert it in SAP standard format.

So i was wondering just like date has FM to convert string into standard sap date format, do we have one for time as well ?

Or is the way you have suggested work here ?

Regards,

Chetna D

Read only

0 Likes
4,868

Actually using the FM CONVERT_TIME_INPUT, its already giving the correct output. Not just sure why its showing error on your side. But yes, you can also use my suggestion. Then just move the value of time to your erzet type field. you can try below and check.

DATA: tm TYPE char10,

       final type erzet.

tm = '23:59:59'.

REPLACE ALL OCCURRENCES OF ':' IN tm WITH space.

CONDENSE tm.

MOVE tm TO final.

WRITE final.

Read only

0 Likes
4,868

Hi Chetna,

Do as suggested and also write another statement in additional as below:

DATA : MTIME TYPE C LENGTH 10,
      STIME
TYPE SYTIME.

MTIME
= '12:13:14'.

REPLACE ALL OCCURRENCES OF ':' IN MTIME WITH SPACE.
CONDENSE MTIME.
WRITE MTIME TO STIME TIME ZONE <required_time_zone>.


Thanks & Regards,

Vijay

Read only

manivel
Participant
0 Likes
4,868

Hi Chetna,

Just do this in simple way as below.

Declare one variable(wk_time) with type sy-uzeit.


Let's say your input time variable is wk_input(char10).


CONCATENATE wk_input+0(2) wk_input+3(2) wk_input+6(2)  into wk_time.


Try this.


Regards,

Manivel S



Read only

Former Member
0 Likes
4,868

Thank you all for responding and solving the problem

Regards,

Chetna D