Skip to Content

Convert xsd:dateTime to DDIC timestamp?

Hi all,

I have an SOAP --> PI --> RFC synchronous scenario. One node of the request of the SOAP sender is in xsd:dateTime format with milliseconds and time zone. So the payload xml looks like this (simplified)

<Shipment>          <ShipID>0815</ShipID>          <Delivery>                    <DeliveryID>1234</DeliveryID>                    <HandlingUnit>                              <HandlingUnitID>001</HandlingUnitID>                              <Timestamp>2013-04-11T09:11:03.3357248-05:00</Timestamp>                    </HandlingUnit>                    <HandlingUnit>                              <HandlingUnitID>002</HandlingUnitID>                              <Timestamp>2013-04-12T13:11:03.3357248-04:00</Timestamp>                    </HandlingUnit>          </Delivery></Shipment>

As I use XSLT mapping to flatten the nested input XML to the RFC input parameters I am not able to use UDF or standard functions like DateTrans.

Having said this: What is the most sound way to send xsd:dateTime data to an RFC and use that data as data dictionary timestamp (or timestampl in our case).

Side notes:

  • First I tried to just pass the xsd:dateTime as is to the RFC where the RFC expects a data element of type TIMESTAMPL. This resulted in an error on jco stating that it could not convert the xsd:dateTime to a BCD. Error text was "JCO_ERROR_CONVERSION: Number 2013-04-11T09:11:03.3357248-05:00 cannot be encoded as a BCD of length 21 with 7 decimal places"
  • Then I tried to send the xsd:dateTime to the RFC where the RFC expects a data element of type XSDDATETIME_ISO (Char33). This of course worked on PI but how would I go on the ABAP side from there? I ended up, concatenating the xsd:dateTime into a asXML string like so...
    DATA: l_myxml                   TYPE string,         l_timestamp_input   TYPE XSDDATETIME_ISO.CONCATENATE '<asx:abap version = "1.0" xmlns:asx = ''"http://www.sap.com/abapxml">''<asx:values>''<MYTIMESTAMP>'                 <ls_hk>-timestamp'</MYTIMESTAMP>''</asx:values>''</asx:abap>'INTO l_myxml.

    ...and then using CALL TRANSFORMATION to get the timestamp back like so...
    DATA:l_timestampTYPE xsddatetime_long_z.CALL TRANSFORMATION id       SOURCE XML l_myxml       RESULT mytimestamp = l_timestamp.

There must be any helper class or some sort of standard mechanism to do this, right? I mean, in the end SAP does this somehow when having an xsd:dateTime in your message type and then generating a proxy from that.

Any insights on this would really be appreciated.

Cheers

Jens

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 15, 2013 at 03:35 PM

    Hi Jens,

    have you checked the standard conversion table from XSD elements to DDIC elements in ABAP? There is such a table with certain rules specified (look in ABAP help for "Mapping of elementary ABAP types" or just for "XSD"), and I am confident that you'll find some information regarding date types there. When RFC or Proxy calls are sent to an ABAP system this conversion happens in the Simple Transformations (some light XSLT generated automatically).

    Regards,

    Jörg

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Jens Schwendemann

      Hi Jens,

      the point is that you don't need to map explicitly. You keep it as xsd:date in PI mapping and pass it this way to ABAP. The proxy framework then automatically generates the corresponding data types and a transformation that converts the xsd:date to the corresponding data types. So if your xsd type is generated in ABAP as TIMESTAMPL the transformation will automatically do the appropriate conversion.

      What I am describing is the ABAP proxy scenario, probably in RFC calls this function is not available (since you import the RFC to PI, not the PI model to ABAP). Anyway, you may want to check out the proxy/webservice option for this functionality, since it could save you this kind of trouble.

      Regards,

      Jörg

  • Apr 15, 2013 at 08:41 PM

    Hi Jens,

    I suggest you play with the content of the MYTIMESTAMP field, remove hyphens, colons etc and make it similar to YYYYMMDDhhmmssmmmuuun which is the UTC Time Stamp in Long Form in ECC for Data element TIMESTAMPL. You may end up trimming the field length to 21 characters but you need to check if it meets the requirement and no data loss happens.

    Hope it helps.

    Ambrish

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Ambrish,

      sorry if I haven't been detailed enough. The "MYTIMESTAMP" field within SAP is part of an already possible solution i came up with. Having the xsd:DateTime mapped to a XSDDATETIME_ISO (Char33) data element and the using CALL TRANSORMATION within RFC is working fine. I was just curious if this is the best solution.

      Having said that and answering your question: No, I would not want to make any time zone conversions within mapping (so before calling the RFC).

      My hopes when I initially set up this scenario where that just using xsd:DateTime on the sender side and TIMESTAMP / TIMESTAMPL on the receiver side would suffice, but that seemed not to be the case, hence the question.

      So is there a more simple / more "standard way" of a solution to this than that what I came up with?

      Cheers

      Jens