简体   繁体   English

SAP Gateway 获取创建 ID 作为响应

[英]SAP Gateway get create ID as response

I'm using OData services to send data to an SAP system.我正在使用 OData 服务将数据发送到 SAP 系统。 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?有没有办法让服务器给我我刚刚在数据库中创建的 ID 或字段作为响应?

Any suggestion is welcome.欢迎任何建议。

Yes, this is a very common use case.是的,这是一个非常常见的用例。

Model the id as a field of your entity.将 id 建模为实体的字段。

Leave the id empty when making the call from the Frontend.从前端拨打电话时,将 id 留空。

The server fills the id field in the response.服务器在响应中填写 id 字段。 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在您的后端方法MYENTITY_CREATE_ENTITY ,执行类似的操作

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
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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