cancel
Showing results for 
Search instead for 
Did you mean: 

SUP BAPI - Create Operation Return Value

Former Member
0 Kudos

Hi there,

currently I'm facing some issues with SUP 2.1.0 in a native iPad Application.

Long story short:

- one A has many B's

- create object A locally

- A has no primary key

- create object B locally

- since A has no primary key, B can't have this as a foreign key

- submit pending changes

- A gets a primary key

- B doesn't get his foreign key value, because the "create" of B is called at a time where A didn't have a primary key value

This is the Szenario:

I have two MBOs based on two search BAPIs. The MBOs have create operations based on create BAPIs

BAPI_SEARCH_BUSINESSPARTNER

In

- City

Out

- *BP Number

- Name 1

- Name 2

- etc.

BAPI_CREATE_BUSINESSPARTNER

In

- Name 1

- Name 2

- etc.

and

BAPI_SEARCH_OPPORTUNITIES

In

- BP Number

Out

- *Op Number

- Description

- Start Date

- etc.

BAPI_CREATE_OPPORTUNITIY

In

- BP Number

- Description

- Start Date

- etc.

For the Input Parameter of the BAPI_SEARCH_BUSINESSPARTNER I created a Personalization Key. So the Application gets Data based on the given City. Between MBO_BP and MBO_OPP is a relationship (one-to-many). The BP Number of MBO_BP is mapped to the Load Parameter (BP Number) of MBO_OPP.

Reading data is working good. I can access the relevant business partners and their opportunities.

I also want to create data. Therefore, I have create Operations in MBO_BP and MBO_OPP which are bound to create BAPIs. This is also working.

Here is the problem:

If I'm offline with the iPad and create a business partner, a local entitiy is created. This entitiy doesn't have a BP_Number because BP_Number is generated in the SAP backend system. Now I want to add an opportunity to this business partner. In the iPad Application I instantiate a new Opportunity, set the reference to the business partner and call create.

[newOpp setBusinessPartner:[self bp]]

[newOpp create]

this creates the local entity. Locally, the data is fine: A business partner is created which has the new opportunity.

When the application goes online again, the new local data will be submitted to the server. The problem: since the local bp_number of the new business partner is empty (because it's generated by SAP), a empty value will be passed for the create operation of the opportunity.

So the BAPI_CREATE_OPPORTUNITY will be called without the BP Number.

I added a Diagram of my Project (I hope it's not extremely confusing). Maybe you can see an error in my modeling.

Thanks,

Christian Hoff

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Update:

According to this paper ( http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/3028168a-4727-2f10-5099-b8452a91e... ). The creation process works like this:

  • Every MBO should have a primary key (like businesspartner number)
  • Every MBO has an internal primary key called surrogateKey which is used by SUP

when a object is created in the local database with like

*businesspartner = [BusinessPartner getInstance]

[businesspartner create];

it has a generated surrogateKey. The business-side primary key is still empty.

Now the local entity shall be submitted to the server calling for example

[DB submitPending]

the Object with its surrogateKey is now passed to the Unwired Server. The Unwired Server than executes the create operation on the backend. This create operation generates the real primary key (businesspartner number). This primary key will be saved in the consolidated database.

So the consolidated database has the relation of <surrogateKey, primary key>

This way, the client can associate its local entity with the one on the unwired server via the surrogateKey. On replay of this entity it shall now get the business-side primary key.

In the paper is mentioned (page 4), that if the create operation of the backend didn't return a real primary key, the unwired server will create a new entitiy with a new surrogateKey and deletes the old one.

This means the previously created entity in the local database will be deleted and replaced with a new one. This should not happen, but it does in my application. The create operation is a BAPI which gets several inputs and returns the businesspartner number of the created business partner. If I create a new business partner and call submitPending, the old object will be removed and replaced by a new one. This will break some references to other entities which were previously set.

Does anyone know a solution for this? I mean, this is a totally common scenario. I want to be able to create local objects in a 1:N relationship, which will be created in the backend when I'm back online. The documentation gives an example of a Multi-Level-Insert. But there, the primary keys are generated on the client side, which is rather uncommon.

Greetings,

Christian