Skip to Content
0

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

Feb 15 at 09:00 AM

75

avatar image

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Ralf Handl
Feb 15 at 03:25 PM
2

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

0
Ankit Maskara
Feb 15 at 03:41 PM
1

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"
}
]
}]
}
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Ankit,

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

Thanks

Michael

0