cancel
Showing results for 
Search instead for 
Did you mean: 

Format to be followed for 'Time' field during Create Operation in GW

AshwinDutt
Active Contributor
0 Kudos

Hello Experts,

I am sending Date and Time during Create Operation.

For 'Date' the data type used is 'DATS' and the date format sent from rest cilent is '2013-10-23T00:00:00'

With the above date format i am able to do POST operation.

But the issue is with the TIME field.

For 'Time' the data type used is 'TIMS'. I am not able to find the correct format in which 'Time' has to be sent to GW from Rest Client.

I tried sending in the below format but i get 'Error while parsing an XML stream'

2013-10-23T23:59:59

Kindly suggest the correct format as i am unable to find anywhere and guide me if anything is wrong.

Regards,

Ashwin

Accepted Solutions (1)

Accepted Solutions (1)

ChandraMahajan
Active Contributor
0 Kudos

Hi,

Refer this link on working with odata dates andf times at http://mysapgw.wordpress.com/2013/04/28/working-with-odata-dates-and-times/

This might be useful to solve your issue.

Regards,

Chandra

Former Member
0 Kudos

Hi Ashwin,

How do you know that 'Error while parsing an XML stream' refers to the date exactly? It could be any part of the body raising this error.

Post the full body into the thread please.

Regards

Ron.

AshwinDutt
Active Contributor
0 Kudos

Hello Chandra,

Thanks. I will check.

Regards,

Ashwin

AshwinDutt
Active Contributor
0 Kudos

Hello Ron,

With the below body i am able to do 'Create Operation'.

--batch

Content-Type: multipart/mixed; boundary=changeset

--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary

POST post_order1 HTTP/1.1

Content-Type: application/atom+xml

Content-Length: 975

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"

                              xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"

                              xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">

                              <atom:content type="application/xml">

                              <m:properties>

                              <d:REQUEST_NO>CHG00003</d:REQUEST_NO>

  <d:SEND_DATE>2013-10-23T00:00:00</d:SEND_DATE>

                              <d:REQUESTER>Ash_m_1</d:REQUESTER>

                              <d:COMP_CODE>0100</d:COMP_CODE>

                              <d:PLANT>1021</d:PLANT>

                              <d:REMARK>Test m 1</d:REMARK>

                              <d:REQUEST_ITMNO>0001</d:REQUEST_ITMNO>

                              <d:FROM_MATNO>Z10D777CNW0025P</d:FROM_MATNO>

                              <d:FROM_BATCH>6MA01006</d:FROM_BATCH>

                              <d:TO_MATNO>Z10D777CNW0025P</d:TO_MATNO>

                              <d:TO_BATCH>6MA01006</d:TO_BATCH>

                              <d:QUANTITY>5.000</d:QUANTITY>

                              <d:WEIGHT_UNIT>TON</d:WEIGHT_UNIT>

                              <d:EST_FDATE>2013-10-23T00:00:00</d:EST_FDATE>

                    </m:properties>

          </atom:content>

</atom:entry>

--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary

POST post_order1 HTTP/1.1

Content-Type: application/atom+xml

Content-Length: 975

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"

                              xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"

                              xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">

                              <atom:content type="application/xml">

                              <m:properties>

                              <d:REQUEST_NO>CHG00003</d:REQUEST_NO>

  <d:SEND_DATE>2013-10-23T00:00:00</d:SEND_DATE>

                              <d:REQUESTER>Ash_m_2</d:REQUESTER>

                              <d:COMP_CODE>0100</d:COMP_CODE>

                              <d:PLANT>1021</d:PLANT>

                              <d:REMARK>Test m 2</d:REMARK>

                              <d:REQUEST_ITMNO>0002</d:REQUEST_ITMNO>

                              <d:FROM_MATNO>Z10D777CNW0025P</d:FROM_MATNO>

                              <d:FROM_BATCH>6MA01006</d:FROM_BATCH>

                              <d:TO_MATNO>Z10D777CNW0025P</d:TO_MATNO>

                              <d:TO_BATCH>6MA01006</d:TO_BATCH>

                              <d:QUANTITY>5.000</d:QUANTITY>

                              <d:WEIGHT_UNIT>TON</d:WEIGHT_UNIT>

                              <d:EST_FDATE>2013-10-23T00:00:00</d:EST_FDATE>

                    </m:properties>

          </atom:content>

</atom:entry>

--changeset--

--batch--

When i add the time field in the body (Which is highlighted below ) i get the error 'Error while parsing an XML stream'

--batch

Content-Type: multipart/mixed; boundary=changeset

--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary

POST post_order1 HTTP/1.1

Content-Type: application/atom+xml

Content-Length: 975

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"

                              xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"

                              xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">

                              <atom:content type="application/xml">

                              <m:properties>

                              <d:REQUEST_NO>CHG00003</d:REQUEST_NO>

  <d:SEND_DATE>2013-10-23T00:00:00</d:SEND_DATE>

                              <d:SEND_TIME>2013-10-23T23:59:59</d:SEND_TIME>

                              <d:REQUESTER>Ash_m_1</d:REQUESTER>

                              <d:COMP_CODE>0100</d:COMP_CODE>

                              <d:PLANT>1021</d:PLANT>

                              <d:REMARK>Test m 1</d:REMARK>

                              <d:REQUEST_ITMNO>0001</d:REQUEST_ITMNO>

                              <d:FROM_MATNO>Z10D777CNW0025P</d:FROM_MATNO>

                              <d:FROM_BATCH>6MA01006</d:FROM_BATCH>

                              <d:TO_MATNO>Z10D777CNW0025P</d:TO_MATNO>

                              <d:TO_BATCH>6MA01006</d:TO_BATCH>

                              <d:QUANTITY>5.000</d:QUANTITY>

                              <d:WEIGHT_UNIT>TON</d:WEIGHT_UNIT>

                              <d:EST_FDATE>2013-10-23T00:00:00</d:EST_FDATE>

                    </m:properties>

          </atom:content>

</atom:entry>

--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary

POST post_order1 HTTP/1.1

Content-Type: application/atom+xml

Content-Length: 975

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"

                              xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"

                              xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">

                              <atom:content type="application/xml">

                              <m:properties>

                              <d:REQUEST_NO>CHG00003</d:REQUEST_NO>

  <d:SEND_DATE>2013-10-23T00:00:00</d:SEND_DATE>

<d:SEND_TIME>2013-10-23T23:59:59</d:SEND_TIME>

                              <d:REQUESTER>Ash_m_2</d:REQUESTER>

                              <d:COMP_CODE>0100</d:COMP_CODE>

                              <d:PLANT>1021</d:PLANT>

                              <d:REMARK>Test m 2</d:REMARK>

                              <d:REQUEST_ITMNO>0002</d:REQUEST_ITMNO>

                              <d:FROM_MATNO>Z10D777CNW0025P</d:FROM_MATNO>

                              <d:FROM_BATCH>6MA01006</d:FROM_BATCH>

                              <d:TO_MATNO>Z10D777CNW0025P</d:TO_MATNO>

                              <d:TO_BATCH>6MA01006</d:TO_BATCH>

                              <d:QUANTITY>5.000</d:QUANTITY>

                              <d:WEIGHT_UNIT>TON</d:WEIGHT_UNIT>

                              <d:EST_FDATE>2013-10-23T00:00:00</d:EST_FDATE>

                    </m:properties>

          </atom:content>

</atom:entry>

--changeset--

--batch--

So i strongly suspect the error is because of TIME field.

Seems like the format is wrong and i am unable to find the correct format so need help in finding correct format to be sent to GW.

Regards,

Ashwin

former_member184867
Active Contributor
0 Kudos

Hi Ashwin,

check in your metadata if SEND_TIME is of type Edm.Time.

If it is so check the correct format of Edm.Time in http://www.odata.org/documentation/odata-v2-documentation/overview/. The format that you are passing is Edm.Datetime.

I would suggest you to fire a READ entity call and check the response. The format you get against property SEND_TIME  should be send in POST.

Regards,

Atanu

AshwinDutt
Active Contributor
0 Kudos

Hello Atanu,

In my model i have defined Time property as shown below.

The below shows the Structure and the Data type of the Time field which is bound to my model.

This is how i have defined Time Property in my model. 

I am sending as  <d:SEND_TIME>23:00:00</d:SEND_TIME> in my body like you suggested but service is still failing.

I tried sending as <d:SEND_TIME>230000</d:SEND_TIME> n my body. But no use. Service is failing.

I am unable to find the correct format which GW is expecting for the Time field.

Need Help here.

Regards,

Ashwin

Former Member
0 Kudos

Are you constructing your MPC manually? The 'types' block you have doesn't have the generated conventions present.  Service Builder should help take away most of this pain.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Ashwin,

OK, I think we should forget the body where you have send_time because you don't have a problem with send_date. When you post with/without send_time, you are going to keep your entity model in sync, i.e. you cannot post to send_time without adding it into the properties.

But enough of that because I have the answer to your original question - how to process the time.

If you just wanted the time and no date, you can use edm.time as the type. If you want date and time, you can get both from the one value, not just the date. The way you do this is to remove any internal ABAP typing, OData will then define this as a P type field in the MPC which can be used in an ABAP timestamp conversion to date and time. If your entity is based on a DDIC structure, change the property internal type to a TIMESTAMP element. You can then process date and time with one property  instead of two in the entity.

I'v made some notes here on datetime processing that explain it some more.

http://scn.sap.com/thread/3441583

Regards

Ron.