Skip to Content
0

sapui5 send table to backend

Jan 10 at 07:11 AM

204

avatar image

Hi experts,

I read on the net about how to solve that issue but nothing is helping.

I have a simple table created in SAPUI5 and I want to send it back to my sap gateway.

I am using sap.ui.model.odata.v2.ODataModel.

I read about the batch technique but it is for v1.

I guess I have to use the create method of the model.

How can I achieve it? What to do on sapui5 side and what method to implement on sap gateway side?

Thank you.

Regards.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Joseph BERTHE Jan 10 at 07:46 AM
0

Hello,

How your UI5 table is created, with JSon model or OData model.

I guess it is with JSon (in other case you wouldn't ask this questin ;)). In that case, you should create a OData with the same struture than your table, then with a post query the data are sent to the Back-end.

If you can give us more detail of the table's structure and your OData, it will be easier to help you.

Regards,

Joseph

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Joseph,

My RFC is like this:

*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IS_HEADER) TYPE  ZLMS_HEADER_T OPTIONAL
*"     VALUE(I_ID) TYPE  CHAR10 OPTIONAL
*"     VALUE(I_DETAIL_NO) TYPE  CHAR10 OPTIONAL
*"  EXPORTING
*"     VALUE(E_SUCCESS) TYPE  FLAG
*"  TABLES
*"      T_FLIGHTS STRUCTURE  ZLMS_FLIGHTS_T OPTIONAL

I went to segw and created the entities. It created 2 entities: one for the Import data and the second for the table.

I did the mapping for the create, query. I created queryset only for the table.

Of course, everything is activated and I can test it via gateway client.

Now, I want to call from my ui5 this rfc and send it the IS_HEADER, the I_ID, the I_DETAIL_NO and the table T_FLIGHTS.

What am I missing?

Thank you,

Regards.

0
VIPLOVE KHUSHALANI Jan 10 at 08:47 AM
0

Hi ..

You can send a batch request of POST ... V2 oData model also supports batch ...Just check out these links for implementing batch ..

And there will be no change in gateway side as long as your service is oData oriented ..

https://stackoverflow.com/questions/45821145/sapui5-batch-with-sap-ui-model-odata-v2-odatamodel

https://help.sap.com/viewer/0ce0b8c56fa74dd897fffda8407e8272/7.5.9/en-US/6c47b2b39db9404582994070ec3d57a2.html

https://stackoverflow.com/questions/45821145/sapui5-batch-with-sap-ui-model-odata-v2-odatamodel

thanks

Viplove

Share
10 |10000 characters needed characters left characters exceeded
David Raven Jan 10 at 07:54 AM
0

Hi,


Thank you for your fast reply.

I realy need a bit more precision. Do I need to implement the DEEP method on sap gateway side ? What do I need to implement there ?

I have create the mapping for the Create, Query and QuerySet operations.

Another thing, I read that I have to send 2 arrays: item and header ? Is it right? If yes, do you know why I have to send a Header array?

Lot of questions but I realy need help with this issue.

Thank you.

Regards.

Share
10 |10000 characters needed characters left characters exceeded
David Raven Jan 10 at 11:20 AM
0

Sorry, but it is still not clear for me.

I will post a sample code and maybe you can help me.

I want to send per RFC one IId, one IDetailNo, one Subject and many ItFlights.

var oEntry =[ 
"IId": "my name",
"IDetailNo": "1",
"Subject": "subject 1",
"ItFlights": {
	"Country" : "11",
	"Aircraft" : "22",
	"Unitsinstock" : "33",
	"CommentText" : "44"
	},
];	
var sServiceUrl11 = "host:port/sap/opu/odata/SAP/ZGW200_LMS1_SRV_01";	
var oModel11 = new sap.ui.model.odata.v2.ODataModel(sServiceUrl11,{
	            json     : true,
});
oModel11.setHeaders({"X-Requested-With" : "X"});
			
oModel11.create("/SaveFlightSet", oEntry, null, 
	function(oData, oResponse){
	  alert ("OK");
	},
	function(err) {
		  alert("Error");
	}
);
Show 4 Share
10 |10000 characters needed characters left characters exceeded

In the sample, you have created a single entry and then used the service variable to create data based on that single entry JSON.

Now, is your query on how to have multiple entries in one JSON and then push that json in a single go to the oData service?

Regards.

0

I want to have multiple entries in one JSON and "send" (push is maybe a better word) a single call to oData service.

I could do a loop and update....but there must be a better way.

Regards.

0

Hi ..

This is not a batch request .. if you need to send multiple post request you need to use batch to send multiple post request to server in one service call... before post you need to include a get request in your batch to fetch the xcsrf token which you need to add it in the headers for the upcoming post requests of yours ..

thanks

Viplove

0

Hi,

It is not a multiple post request, it is a request with multiple lines.

I really do not understand why it is so hard to send a table back to backend....

The sap gateway does not simplify my life at all.

0