Application Development 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: 

Convert SAP DATE to LDAP Date Format

BalaMalvatu
Participant
0 Kudos

Dear All,

Is there any Formula that we could use and convert SAP system Date to LDAP time Format.

Ex: SAP Date : 18.06.2015    Time 21:00:00 (UTC+3)

Required Output : 130790484000000000 ( LDAP Format).

Bala.M

1 ACCEPTED SOLUTION

matt
Active Contributor
0 Kudos

The LDAP date format is number of 100s of nanoseconds since 12:00 a.m. January 1st 1601. To convert it to an ABAP date:


1. Create a timestamp constant of that initial date (i.e. CONSTANTS c_time_base TYPE timestamp = 16010101120000.)

2. Add your ldap number to this c_time_base in another timestamp variable.(my_timestamp = c_time_base + ldap_value ).

3. Use CONVERT keyword to convert the timestamp to date and time.

8 REPLIES 8

matt
Active Contributor
0 Kudos

The LDAP date format is number of 100s of nanoseconds since 12:00 a.m. January 1st 1601. To convert it to an ABAP date:


1. Create a timestamp constant of that initial date (i.e. CONSTANTS c_time_base TYPE timestamp = 16010101120000.)

2. Add your ldap number to this c_time_base in another timestamp variable.(my_timestamp = c_time_base + ldap_value ).

3. Use CONVERT keyword to convert the timestamp to date and time.

0 Kudos

Hi Mathew,

I want to convert SAP Date to LDAP Value.

The Above isn't working and I want it the other Way.

Convert 18-june-2015 to LDAP Format.

Bala

matt
Active Contributor
0 Kudos

Do it the other way then. Convert 18-june-2015 to a timestamp using CONVERT then subtract c_base_time.

0 Kudos

I have done this way.

SAP Provided FM to get seconds CCU_TIMESTAMP_DIFFERENCE.

I used the same Logic and got this result and solved my problem

Thankyou so much.


DATA v_data_ad(18TYPE n ,

              ls_date      TYPE  sydatum  ,

              ls_date1      TYPE  sydatum  ,

              ls_time  TYPE sy-uzeit ,

              ls_time1 TYPE sy-uzeit.

ls_date    = '16010101'.

ls_date1  = '20150618'.

ls_time1    = '210000'.

ls_time    = '120000'.

v_data_ad = ( ls_date1 - ls_date ) * 86400

              + ( ls_time - ls_time1 )        ) .

  v_data_ad = v_data_ad  * 10000000 .


Final Result : v_data_Ad  = 130790286000000000.


matt
Active Contributor
0 Kudos

Now code it as CONSTANTS with meaningful names. If you don't know why you should do that, read this: http://c2.com/cgi/wiki?MagicNumber

0 Kudos

Yes, We can do that way using constants.

matt
Active Contributor
0 Kudos

Not just "can". "Should".

Not using constants would be bad programming.

0 Kudos

Yes we should..

Thank you.