cancel
Showing results for 
Search instead for 
Did you mean: 

sapui5 send table to backend

former_member548272
Participant
0 Kudos

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.

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member548272
Participant
0 Kudos

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");
	}
);
Sharathmg
Active Contributor
0 Kudos

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.

former_member548272
Participant
0 Kudos

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.

former_member340030
Contributor
0 Kudos

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

former_member548272
Participant

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.

former_member340030
Contributor
0 Kudos

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/6c47b2b39db9404582994070ec3...

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

thanks

Viplove

former_member548272
Participant
0 Kudos

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.

Joseph_BERTHE
Active Contributor
0 Kudos

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

former_member548272
Participant
0 Kudos

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.