Skip to Content

sapui5 send table to backend

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Jan 10 at 07:46 AM

    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

    Add comment
    10|10000 characters needed 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.

  • Jan 10 at 08:47 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 10 at 07:54 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 10 at 11:20 AM

    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");
    	}
    );
    
    Add comment
    10|10000 characters needed characters exceeded

    • 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.