简体   繁体   中英

SAP Gateway get create ID as response

I'm using OData services to send data to an SAP system. When I'm doing a

oModel.create({data})

Is there any way to let the server give me as response the ID or field I just created in the database?

Any suggestion is welcome.

Yes, this is a very common use case.

Model the id as a field of your entity.

Leave the id empty when making the call from the Frontend.

The server fills the id field in the response. In the response, the server may also change or fill any other field of the entity.

in your backend method MYENTITY_CREATE_ENTITY , do something like

io_data_provider->read_entry_data( IMPORTING es_data = ls_myentity ).

"create object in database which fills the field lv_id_from_database

ls_myentity-id = lv_id_from_database.
er_entity = ls_myentity.

Frontend:

oModel.create("/Myentity", 
    oDataCreate, null, false, 
         function(oData, oResponse){
                  //Function for Success
         },
         function(oData, oResponse){
                  //Function for Error
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM