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

Convert time into time with user's time format (table usr11)

0 Likes
4,503

Dear SDN-Community,

I am looking for a possibility to convert time into time using user's time format customizing of database table usr11.

There is a field TIMEFM in which this setting is stored. The following variants are possible:

0 24 Hour Format (Example: 12:05:10)

1 12 Hour Format (Example: 12:05:10 PM)

2 12 Hour Format (Example: 12:05:10 pm)

3 Hours from 0 to 11 (Example: 00:05:10 PM)

4 Hours from 0 to 11 (Example: 00:05:10 pm)

Do anybody know a function module for this conversion purpose?

Thanks in advanced and best regards,

Thomas

Dear SDN-Community,

I am looking for a possibility to convert time into time using user's time format customizing of database table usr11.

There is a field TIMEFM in which this setting is stored. The following variants are possible:

0 24 Hour Format (Example: 12:05:10)

1 12 Hour Format (Example: 12:05:10 PM)

2 12 Hour Format (Example: 12:05:10 pm)

3 Hours from 0 to 11 (Example: 00:05:10 PM)

4 Hours from 0 to 11 (Example: 00:05:10 pm)

Do anybody know a function module for this conversion purpose?

Thanks in advanced and best regards,

Thomas

11 REPLIES 11
Read only

Former Member
0 Likes
2,067

Hi Thomas Ploski ,

Take a charachter field of length 10 and use below sytax. You can achieve time in user format.

example.

w_time = 072222.

Write w_time to w_char.

w_time = 072222.

w_char = 07:22:22.

Venkat.

Read only

0 Likes
2,067

Hi Venkat,

Thanks for your reply, but I need s solution in which the time format using usr11 table is considered.

Best regards,

Thomas

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,067

Hello Thomas,

I think that if you define the variable like SY-UZEIT then when you display it, the output will be in user format by default.

BR,

Suhas

Read only

0 Likes
2,067

Hi Suhas,

I have tested my coding with defining data type sy-uzeit. But there is no conversion

Best regards,

Thomas

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,067

Hello Thomas,

I dont find this field TIMEFM in the table USR11. Can you please elaborate?

BR,

Suhas

Read only

0 Likes
2,067

I'm sorry, i was my fault - the corresponding table is USR01.

Best regards,

Thomas

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,067

But there is no field for the time format in table USR01

Read only

0 Likes
2,067

There is a field named TIMEFM for the time format in this mentioned database table.

Read only

Former Member
0 Likes
2,067

Hi Thomas Ploski,

Not exact but based on the value of USR01-TIMEFM table entries you can differeciate logic and for value 1 & 2 ( means 12 hours) you can use below FM to convert time from 24 hours to 12 hours format...

HRVE_CONVERT_TIME

Import parameters               Value

TYPE_TIME                       A
INPUT_TIME                      18:34:00
INPUT_AM_PM                     AM


Export parameters               Value

OUTPUT_TIME                     06:34:00
OUTPUT_AM_PM                    PM

Hope it will solve your problem..

Thanks & Regards

ilesh 24x7

ilesh Nandaniya

Read only

Clemenss
Active Contributor
0 Likes
2,067

Hi Thomas,

see SAP help for SET:

Example

When outputting documents, display the decimal point and date in the format specified for the country of the recipient:

DATA: RECEIVER_COUNTRY LIKE T005X-LAND,
      DATE             LIKE SY-DATUM,
      AMOUNT           TYPE P DECIMALS 2.
...
SET COUNTRY RECEIVER_COUNTRY.
IF SY-SUBRC = 4.
   WRITE: / RECEIVER COUNTRY, ' is unknown'.
ENDIF.
WRITE: / DATE, AMOUNT.

Then, you can say

SET COUNTRY SPACE.

to display the decimal point and date according to the specification for the user again.

Regards,

Clemens

Read only

Former Member
0 Likes
2,067

Hi Thomas, take a look at 'convert time stamp lv_timestamp time zone lv_tz into date lv_date'. Where lv_timestamp type timestamp, lv_tz type ttzz-zone and lv_date type d.

Kevin