Skip to Content
Author's profile photo Former Member

DateTime Format issue between .Net and ABAP (ByDesign Soap Calls)

I thought I would post this since I have run into this several times,…

Many times when accessing a Webservice from .net you use the Proxy classes that are auto generated… This can cause an issue with DateTime fields and you will get the

Processing Error. Details in WS Error Log (transaction SRT_UTIL, note 1558107) by selection with UTC timestamp 20121018164542

After the Whole Process of getting the Log via an incident ( I WISH I HAD ACCESS TO IT… I heard 4.0 does but can not find it anywhere)

you will find  this entry

The value 2012-08-16T00:00:00 is not a valid date with time. It does not correspond to the XML format for ABAP.

ABAP uses   ISO 8601  See http://en.wikipedia.org/wiki/ISO_8601

This is Bothersome since you are using the Proxy Classes in .net…. and the serialization of a date time does not include the “Z” or offset time zone and ABAP requires this. Even though the LOCALNORMALISED_DateTime1 Time has a Timezone Component

To remedy this I took the following approach… (I am sure there is a better way and If you have one please Let me know)

in the Proxy Classes I found the LOCALNORMALISED_DateTime1 definition

(AHHH VB.net… I know but that is how I roll 😉 )

 '''<remarks/>
    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.225"),  _
     System.SerializableAttribute(),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Xml.Serialization.XmlTypeAttribute(TypeName:="LOCALNORMALISED_DateTime", [Namespace]:="http://sap.com/xi/BASIS/Global")>  _
    Partial Public Class LOCALNORMALISED_DateTime1
        Private timeZoneCodeField As String
        Private valueField As Date
        '''<remarks/>
        <System.Xml.Serialization.XmlAttributeAttribute(DataType:="token")>  _
        Public Property timeZoneCode() As String
            Get
                Return Me.timeZoneCodeField
            End Get
            Set
                Me.timeZoneCodeField = value
            End Set
        End Property
        '''<remarks/>
        <System.Xml.Serialization.XmlTextAttribute()>  _
        Public Property Value() As Date
            Get
                Return Me.valueField
            End Get
            Set
                Me.valueField = Value
            End Set
        End Property
    End Class

So I changed this to

   '''<remarks/>
    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.225"),  _
     System.SerializableAttribute(),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Xml.Serialization.XmlTypeAttribute(TypeName:="LOCALNORMALISED_DateTime", [Namespace]:="http://sap.com/xi/BASIS/Global")>  _
    Partial Public Class LOCALNORMALISED_DateTime1
        Private timeZoneCodeField As String
        Private valueField As String   ''<----------------------------------
        '''<remarks/>
        <System.Xml.Serialization.XmlAttributeAttribute(DataType:="token")>  _
        Public Property timeZoneCode() As String
            Get
                Return Me.timeZoneCodeField
            End Get
            Set
                Me.timeZoneCodeField = value
            End Set
        End Property
        '''<remarks/>
        <System.Xml.Serialization.XmlTextAttribute()>  _
        Public Property Value() As Date
            Get
                Return Me.valueField
            End Get
            Set
                Me.valueField = Value.ToString("s") & "Z"      ''<----------------------------------
            End Set
        End Property
    End Class

The Z is there because

If the time is in UTC, add a ‘Z’ directly after the time without a space. ‘Z’ is the zone designator for the zero UTC offset. “09:30 UTC” is therefore represented as “09:30Z” or “0930Z”. “14:45:15 UTC” would be “14:45:15Z” or “144515Z”.

And that did the Trick…

Note that with this all my times need to be in UTC…… I could change the Fromat to do an offset time form the “Z”  component of  the time by the following

Dim hours As Integer = TimeZoneInfo.Local.BaseUtcOffset.Hours
Dim offset As String = String.Format("{0}{1}", (If((hours > 0), "+", "")), hours.ToString("00"))
Dim isoformat As String = DateTime.Now.ToString("s") & offset

FINAL BIG NOTE Updating the WSDL or Webreference will Override these changes… So Be aware of that….

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Michelle Crapo
      Michelle Crapo

      Very cool.   When we have .NET VB call an RFC, on the SAP side everything is character including the dates.   Since it has all been programmed that way - I'm doubting we will change it, but this gives us another option.

      Author's profile photo Nic Teunckens
      Nic Teunckens

      For anyone who stumbles on this Blogpost (because you've obviously encountered the same problems), I believe to have seen an easier Solution via the SAP IDE (the now 'old' Trx. "SE80") ...

      So here's the Gist :

      • Find your generated WebService (Find this as "Enterprise Services") ...
      • Open up the Service - DoubleClick
      • See the Tab "External View"
      • Go to the Specific Field / Parameter that generates this Error ...
      • Check the Elemnts Type of your Field and make a Change from "XSDDATETIME_Z" to "XSDDATETIME_ISO"
      • Save / Activate your Changes ... And Test ...

      That did it for us ...

      PS : Now I see this is also mentioned in another SAP Blog : link

      Â