Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Loop creation for my function

Hello expert,

I need a loop for taking values from table that will added from customer and should write every possible rows to batch input function.

This is my code :

            oDialog1.addButton(new sap.m.Button({text: "SAVE", press:function(){

          //alert("SUCESSFULLY SAVE");

            var mname = sap.ui.getCore().byId('pdmalkod').getValue();

                     var lname = sap.ui.getCore().byId('pdparti').getValue();

                     var aname = sap.ui.getCore().byId('pdmiktar').getValue();

                     var bname = sap.ui.getCore().byId('pdolcbir').getValue();

                     var cname = sap.ui.getCore().byId('pdmasyer').getValue();

                     var dname = sap.ui.getCore().byId('pdnedekod').getValue();

                     var ename = sap.ui.getCore().byId('pdharkodu').getValue();

                  aData.clients.push({"id":mname,"parti":lname,"miktar":aname,"olcbirimi":bname,"masyeri":cname,"nedkodu":dname,"harkodu":ename});

               moModel.setData(aData);

            oDialog1.close();}}));

            oDialog1.open();

          },

          });

      var omddepButton2 = new sap.m.Button('omddepButton2',{text:'Transfer',

        contentAlign : "right",

        press:function(){

          var oEntry = [];

          oEntry.push({

//              PSTNG_DATE : "", //content[2].getValue(),

//              DOC_DATE : "", //content[4].getValue(),

//              REF_DOC_NO : "",  //content[6].getValue(),

//              HEADER_TXT : "deneme", //content[8].getValue(),

              MATERIAL : "20004140", //content[2].getValue(),

              PLANT : "TKHQ", //content[4].getValue(),

              STGE_LOC : "1001",  //content[6].getValue(),

              BATCH : "NEW", //content[8].getValue(),

              MOVE_TYPE : "202", //content[10].getValue()

//              ENTRY_QNT : "1", //content[2].getValue(),

              ENTRY_UOM : "PA",

              COSTCENTER : "1000", //content[4].getValue(),

//              PERSNO : "",  //content[6].getValue(),

//              MOVE_REAS : "", //content[8].getValue(),

              ITEM_TEXT : "4444", //content[10].getValue()

              GR_RCPT : "4444" //content[10].getValue()

          });

          oEntry.push({

//              PSTNG_DATE : "", //content[2].getValue(),

//              DOC_DATE : "", //content[4].getValue(),

//              REF_DOC_NO : "",  //content[6].getValue(),

//              HEADER_TXT : "deneme", //content[8].getValue(),

            MATERIAL : "20004140", //content[2].getValue(),

            PLANT : "TKHQ", //content[4].getValue(),

            STGE_LOC : "1001",  //content[6].getValue(),

            BATCH : "NEW", //content[8].getValue(),

            MOVE_TYPE : "202", //content[10].getValue()

//            ENTRY_QNT : "2", //content[2].getValue(),

            ENTRY_UOM : "PA",

            COSTCENTER : "1000", //content[4].getValue(),

//            PERSNO : "",  //content[6].getValue(),

//            MOVE_REAS : "", //content[8].getValue(),

            ITEM_TEXT : "4444", //content[10].getValue()

            GR_RCPT : "4444" //content[10].getValue()

        });

          jQuery.sap.require("sap.ui.commons.MessageBox");

          var oModel = sap.ui.getCore().getModel(); // ensure that you did not overwrite your

                    // model locally!! with some JSON model for example

            //create an array of batch changes and save

            var batchChanges = [];

            batchChanges.push(oModel.createBatchOperation("MATERIAL_POSTSet", "POST", oEntry[0]));

            batchChanges.push(oModel.createBatchOperation("MATERIAL_POSTSet", "POST", oEntry[1]));

            oModel.addBatchChangeOperations(batchChanges);

            //submit changes and refresh the table and display message

            oModel.submitBatch(function(data){

              oModel.refresh();

              sap.ui.commons.MessageBox.show(data.__batchResponses[0].__changeResponses.length

                + " contacts created", sap.ui.commons.MessageBox.Icon.SUCCESS,

              "Batch Save", sap.ui.commons.MessageBox.Action.OK);

This is right now just write after oEntry.push values that defined up, Couldn't find anything for taking all of the values from my table and write everything to batch. Please help me for this situation.

Regards,

Ogulcan G.

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question