Skip to Content
-2

How to get table list from all selected item value

May 20, 2017 at 01:10 PM

76

avatar image
This is ODATA :
MATCH LIST: CharHeaderSet and MatdetailsSet

{
  "d": {
    "results": [
      {
        "__metadata": {
          "id": "/PlantDetailsSet('Z009')",
          "uri": "/PlantDetailsSet('Z009')",
          "type": "Z_M_EPM_BOM_SRV.PlantDetails"
        },
        "WERKS": "Z009",
        "NAME": "Southern Area Oil",
        "CharHeaderSet": {
          "__deferred": {
            "uri": "V/PlantDetailsSet('Z009')/CharHeaderSet"
          }
        },
        "MatdetailsSet": {
          "__deferred": {
            "uri": "V/PlantDetailsSet('Z009')/MatdetailsSet"
          }
        }
      },
      {
        "__metadata": {
          "id": "V/PlantDetailsSet('Z011')",
          "uri": "V/PlantDetailsSet('Z011')",
          "type": "Z_M_EPM_BOM_SRV.PlantDetails"
        },
        "WERKS": "Z011",
        "NAME": "Khuff Gas plant",
        "CharHeaderSet": {
          "__deferred": {
            "uri": "V/PlantDetailsSet('Z011')/CharHeaderSet"
          }
        },
        "MatdetailsSet": {
          "__deferred": {
            "uri": "V/PlantDetailsSet('Z011')/MatdetailsSet"
          }
        }
      },
      {
        "__metadata": {
          "id": "V/PlantDetailsSet('Z015')",
          "uri": "V/PlantDetailsSet('Z015')",
          "type": "Z_M_EPM_BOM_SRV.PlantDetails"
        },
        "WERKS": "Z015",
        "NAME": "Northern Area Oil Upstream",
        "CharHeaderSet": {
          "__deferred": {
            "uri": "V/PlantDetailsSet('Z015')/CharHeaderSet"
          }
        },
        "MatdetailsSet": {
          "__deferred": {
            "uri": "V/PlantDetailsSet('Z015')/MatdetailsSet"
          }
        }
      },
      {
        "__metadata": {
          "id": "V/PlantDetailsSet('Z016')",
          "uri": "V/PlantDetailsSet('Z016')",
          "type": "Z_M_EPM_BOM_SRV.PlantDetails"
        },
        "WERKS": "Z016",
        "NAME": "Shaybah Onshore Oil",
        "CharHeaderSet": {
          "__deferred": {
            "uri": "V/PlantDetailsSet('Z016')/CharHeaderSet"
          }
        },
        "MatdetailsSet": {
          "__deferred": {
            "uri": "V/PlantDetailsSet('Z016')/MatdetailsSet"
          }
        }
      },
      {
        "__metadata": {
          "id": "V/PlantDetailsSet('Z017')",
          "uri": "V/PlantDetailsSet('Z017')",
          "type": "Z_M_EPM_BOM_SRV.PlantDetails"
        },
        "WERKS": "Z017",
        "NAME": "Khurais Onshore Oil",
        "CharHeaderSet": {
          "__deferred": {
            "uri": "V/PlantDetailsSet('Z017')/CharHeaderSet"
          }
        },
        "MatdetailsSet": {
          "__deferred": {
            "uri": "V/PlantDetailsSet('Z017')/MatdetailsSet"
          }
        }
      }
    ]
  }
}

onPlantchange : function(){

var plant = sap.ui.getCore().byId("plant").getSelectedKey();

if(plant!=0){


var sServiceUrl = "/sap/opu/odata/SAP/Z_M_EPM_BOM_SRV/";
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);
var filterList =[];
var i;

filterList.push(new sap.ui.model.Filter("Plant",sap.ui.model.FilterOperator.EQ,plant));
oModel.read("/MatCharFieldSet",{
context : null,
async : false,
filters : filterList,
urlParameters:{"$expand" : "MatCharValuesSet"},
success : function(data){
var res = data.results;
var content=[];
for ( i = 0; i < res.length; i++) {

content.push(new sap.m.Label({text:res[i].DescrChar,name :res[i].FieldName}));
var items=[];
for (var j = 0; j < res[i].MatCharValuesSet.results.length; j++)
{
items.push(new sap.ui.core.Item ({text:res[i].MatCharValuesSet.results[j].FieldValue,key : res[i].MatCharValuesSet.results[j].FieldValue}));

}
content.push(new sap.m.Select({items :items}));
}
fields = new sap.ui.layout.form.SimpleForm({

editable : true,
layout : sap.ui.layout.form.SimpleFormLayout.ResponsiveGridLayout,
labelSpanL : 4,
labelSpanM : 4,
adjustLabelSpan : true,
emptySpanL : 0,
emptySpanM : 0,
columnsL : 4,
columnsM : 4,
content : content

});

fields.placeAt("fields","only");
sap.ui.getCore().byId("fields").setVisible(true);

sap.ui.getCore().byId("plantSearch").setVisible(false);
sap.ui.getCore().byId("Get").setVisible(true);

}

screen.jpg (121.3 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Christopher Solomon
May 20, 2017 at 02:49 PM
0

Are you being serious? You have a subject line and then just a bunch of code pasted in. Good job!
The answer is 42.

Share
10 |10000 characters needed characters left characters exceeded