本文介绍了SAPUI5使用帖子创建多个值(批次)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在SAP后端中发布数据,请使用:

To post data in the SAP Back-end I use:

oModel.create("/Dummyset", oEntry); //so far it works fine

现在,我的oEntry中有多行,它不起作用.我找到了以下解决方案

Now I have multiple lines in my oEntry and it doesn't work. I found the following solution

aBatchOperation.push(contactBatchOperation);
oModel.addBatchChangeOperations(aBatchOperation);
oModel.submitBatch(fSuccess,fError,true);

但是不幸的是,它不适用于我的OData 2.0版.我总是收到

But unfortunately it's not working with my OData version 2.0 . I always get an error as

然后,我试图找出可以与OData v2一起使用的功能.我可以找到这个.

Then I tried to find out which function I can use with OData v2. I could find this.

batchChanges.push(oModel._createBatchRequest("/AttributesSet", "POST", wert.Atrributes[i].name));
oModel._submitBatchRequest(oModel.setProperty("/AttributesSet", batchChanges), true);

但是它仍然不起作用.我该如何解决?

But it still does not work. How do I fix it ?

推荐答案

我想您要将多个创建请求捆绑为一批,对吧?

I suppose you want to bundle several create requests into one batch, right?

对于ODataModel create 方法,您可以定义其他groupId.见下文.

For ODataModel create method, you can define additional groupId. See below.

基本上,您可以使用可以定义自己的相同 groupId 提交多个 create .

Basically you can submit multiple create with the same groupId which you can define yourself.

首先,您必须设置某些 deferredGroups

First you have to set a certain deferredGroups for ODataModel

var aDeferredGroup = oModel.getDeferredGroups().push("batchCreate");
oModel.setDeferredGroups(aDeferredGroup);

然后您将其称为多次创建.

Then you call multiple create.

var mParameters = {groupId:"batchCreate"};
oModel.create("/Dummyset", oEntry1, mParameters);
oModel.create("/Dummyset", oEntry2, mParameters);
oModel.create("/Dummyset", oEntry3, mParameters);

最后,您可以调用提交更改,一次批处理多个请求.

At last, you can call submitChanges with one single batch for multiple requests.

oModel.submitChanges(mParameters);

这篇关于SAPUI5使用帖子创建多个值(批次)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 03:59