cancel
Showing results for 
Search instead for 
Did you mean: 

Data model design, Do I need a complex entity?

Former Member
0 Kudos

Hello Gurus,

Our project is trying to build a UI5 application for  transaction processing(ex-Service order) and have decided to use OData protocol for interacting with SAP ECC. I'm trying to create a datamodel for my gateway project and wondering which of the two below options I should choose.

Option 1

Create a separate entity for

Header,

Item,

Text,

Attachment,

Partners Involved.


Batch up update/create requests when information relevant for more than one of the above entities need to be updated with single click for save button on the UI.

Option 2

Complex entity that would hold all the above information.

I'm leaning towards option#2 for the following reason: In the scenario, when there is a need to update header info and item data for an existing order and if I have the corresponding put requests in single batch - I may run into a situation where the second put request may fail if the first request is still processing the transaction and still holds a lock.

Please confirm my understanding and shed some light on the pros and cons of the above options.

Regards,

Seetharam

Accepted Solutions (1)

Accepted Solutions (1)

kammaje_cis
Active Contributor
0 Kudos

Seetharam,

Complex Type cannot hold multiple rows. It is only a flat structure. So Header and Item have to be separate Entities.

I believe there is only one 'Text' for a Service Order. In such a case it can be a Complex Type within the 'Header' Entity. If there are multiple texts for each Sales Order then it can be an Entity on its own.

I guess you will have multiple Attachments to a Sales Order, so it can be a 'Media Entity' on its own.

Partner is definitely an Entity on its own.

So You have

Header Entity (Having Text as Complex structure)

Item Entity

Attachment Entity

Partner Entity

Now you need to tie them using Associations, Navigation and right Cardinality.

When you create a Sales Order, you will be doing a 'Deep Insert' of Header and all the Child Entities.

Regards

Krishna

Former Member
0 Kudos

Thanks Krishna. What about update operation? In the scenario, when there is a need to update header info and item data for an existing order and if I have the corresponding put requests in single batch - I may run into a situation where the second put request may fail if the first request is still processing the transaction and still holds a lock.


Any advice on the best way to handle this?


Regards,

Seetharam

kammaje_cis
Active Contributor
0 Kudos

Hi Seetharam,

May be you can explain a little more on this.

I may run into a situation where the second put request may fail if the first request is still processing the transaction and still holds a lock.

There are two ways to handle this. If both the put requests are part of single change-log inside a batch, then if one fails, other change will be rolled back as well.

If they are part of different change-logs then they are independent of failure in the each-other update.

Former Member
0 Kudos

Hi Kishore,

I will try to explain in detail.

User opens the UI5 applicaiton:

1) Opens the transaction.

2) Updates Header information - For ex: Description and date

3) Adds an item

4) Updates an existing item.

5) Clicks Save.

If I have separate entities for Header and Item - I need to create a batch request that has a)Put request for header, b) Post request for an item, c) Put request for an item.

I need to have them all in one changeset - correct?

My real question is - Put request #(a) creates a lock on the transaction - updates header -releases the lock, Post request (b) creates the lock - adds an item - releases the lock. and Put request(c) creates the lock - Updates the item - releases the lock.

I'm trying to know if there is a better way of handling this. Would there be a way to submit all updates in one request and call update API only once(ex-CRM_ORDER_MAINTAIN or BAPI for sales order change) so that I'm not trying to open the transaction in edit mode three times.

Regards,

Seetharam

kammaje_cis
Active Contributor
0 Kudos

Hi Seetharam,

I got your problem now.

You can use methods CHANGESET_BEGIN and CHANGESET_END.

In CHANGESET_BEGIN you can collect changes in an Internal Table and in CHANGESET_END you can call the BAPI CRM_ORDER_MAINTAIN

In the below link check for method documentation.

/IWBEP/IF_MGW_APPL_SRV_RUNTIME - SAP NetWeaver Gateway Foundation (SAP_GWFND) - SAP Library

Regards

Krishna

Former Member
0 Kudos

Thanks Krishna,

I will try to implement in the system per your advice and revert to you if I have anymore questions on this topic.

I will close this thread if I don't have any more questions in 2-3 days.

Regards,

Seetharam

Murali_Shanmu
Active Contributor
0 Kudos

Hi Seetharam,

As per Krishna's recommendation, initiate all the requests within a --changeset from the UI5.

In the Gateway - you can put your logic within CHANGESET_BEGIN - where you can call 'CRM_ORDER_INITIALIZE'. Within the UPDATE_ENTITY methods, you could construct the internal tables  and finally retrieve the Internal tables in CHANGESET_END before calling the 'CRM_ORDER_MAINTAIN/SAVE'.

Regards,

Murali

Former Member
0 Kudos

Thanks Krishna & Murali,

I was able to implement your suggestion to collect the data in internal tables and call CRM_ORDER_MAINTAIN fm in Changeset_end method.

I marked krishna's answer as correct answer.


Regards,

Seetharam

Answers (1)

Answers (1)

gopalkrishna_baliga
Participant
0 Kudos

Hi Krishna,

  Can you elaborate on how to collect the data in CHANGESET_BEGIN?

  Can you send some code example?

Thanks

Gopal