cancel
Showing results for 
Search instead for 
Did you mean: 

How to return a large number of messages in an OData service?

0 Kudos

We are using an OData service to call BAPI_SALESORDER_SIMULATE. For very large orders (1000+ lines) many messages can be returned in the parameter table MESSAGETABLE. We would like to return these messages to the consumer/caller of the service but how can we do that for so many messages?

Since there is no UPDATE_DEEP_ENTITY (PUT) we are using CREATE_DEEP_ENTITY (POST).

We have looked into the following options:

A) We return the messages in the http-header parameter sap-messages. This doesn't work as apparently there is a limit to what this parameter can contain.

B) Someone suggested using a Complex Type - but apparently there is a 1:1 relationship between this and the entity which in this case is SalesOrder. Which means we cannot return more than one message.

C) Then we wanted to create a seperate entity for messages and return this in the response body. But it looks like it is not possible to return any entities that wasn't in the request to begin with.

Am I wrong about the conclusions of A, B and C - maybe I have missed or misunderstood something?

If I am correct that the problem cannot be solved using neither A, B nor C, how can this problem then be solved?

Our solution/workaround for now is that when more than 100 messages are returned from the BAPI we simply return a single message to the requestor saying "too many messages. cannot be displayed" (or something like that).

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

RalfHandl
Product and Topic Expert
Product and Topic Expert

Hi Michael,

Your conclusions are correct, the only workaround currently is

C2) You model a separate entity type for messages, a to-n navigation property from your root type to the message type, and then you deep-insert with a dummy message. That way you can return messages because the message structure is part of the request and thus the response.

We are working on a revamped message transport mechanism for services using OData V4, but please apply the usual disclaimers here: I never said, suggested, or implied that anyone at SAP ever even considered releasing this at any time in any form of product 🙂

Hope this helps

Ralf

0 Kudos

Hi Ralph,

Thank you for your answer and help. I'm glad to be confirmed that I am not all wrong. I will discuss your suggestion for a workaround with my colleagues.

Regarding OData V4, I heard nothing and I know nothing 😉

Thanks

Michael

Answers (1)

Answers (1)

former_member185414
Active Contributor

The approach C should be modified a bit as under.

1. Model as below. Here have a three level navigation. Dummy Entity to Sales Order to Message Table. The underlined properties denote key fields in below JSON model.

{
"DummyKey": "XXXXXX",
"SalesOrders": [{
"DummyKey": "XXXXXX",
"SalesOrderID": "1",
"Attribute1": "<value 1>",
"Messages": [{
"DummyKey": "XXXXXX",
"SalesOrderID": "1",
"MessageId": "1",
"MessageType": "E",
"MessageText": "This is an error message for Sales Order 1"
},
{
"DummyKey": "XXXXXX",
"SalesOrderID": "1",
"MessageId": "2",
"MessageType": "E",
"MessageText": "This is an another error message for Sales Order 1"
}
]
}]
}
0 Kudos

Hi Ankit,

Thank you for the detailed example. Now it shouldn't be possible for me to do anything wrong 🙂

Thanks

Michael

BODHISATTWA__20
Participant
0 Kudos

ankit.maskara3

Hi I am applying your logic .
But how do we deal with Status Error COde?

If we need to return the error Messages as separate entity , The status code has to be 200.

former_member185414
Active Contributor
0 Kudos

Hi Bodhisattwa,

If you want to follow above approach then it assumes that the HTTP call will be successful and the Deep Create will return a 200 code. Then only the payload can be returned whose structure was mentioned in my previous answer.

Else, you can return a single message in HTTP header and set the status code suitably to some error like 500.

Thanks and Regards.