on 06-29-2015 12:24 PM
Please explain the issue properly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Below is the screen shot of my app
When I enter all fields and press "AddItem" button It will display Line Item List below is screen shot
Once again I enter all fields and press AddItem button it will display overriden data.
But i need different data in different lineItems.
Below is my code:
view.xml
<Page title="Goods Issue" navButtonPress="navHome" showNavButton="true" | ||
showHeader="true" enableScrolling="true"> | ||
<headerContent> |
<Button icon="sap-icon://log" press="logoutPressed"></Button> |
</headerContent> | ||
<content> |
<VBox fitContainer="false" justifyContent="Center" alignItems="Center"> |
<HBox fitContainer="false" justifyContent="Center" alignItems="Center"> | |||||
<Text text="Moment Type" width="120px" /> | |||||
<Input id="MType" width="250px" value="201" enabled="true" /> | |||||
<Label text=" *" class="required" /> | |||||
</HBox> |
<HBox fitContainer="false" justifyContent="Center" alignItems="Center"> | |||||
<Text text="Plant" width="120px" /> | |||||
<Input id="Plant" width="250px" /> | |||||
<Label text=" *" class="required" /> |
</HBox> |
<HBox fitContainer="false" justifyContent="Center" alignItems="Center"> | |||||
<Text text="Storage Location" width="120px" /> | |||||
<Input id="SLocation" width="250px" /> | |||||
<Label text=" *" class="required" /> |
</HBox> | |||||
<HBox fitContainer="false" justifyContent="Center" alignItems="Center"> | |||||
<Text text="Cost Center" width="120px" /> | |||||
<Input id="CostCenter" width="250px" /> | |||||
<Label text=" *" class="required" /> |
</HBox> |
</VBox> | |||
<HBox></HBox> |
<HBox fitContainer="false" alignItems="Center"> | ||||
<Text text="Line Items List" width="120px" /> | ||||
<Button text="Add Item" press="ADDItem" class="addItem"></Button> | ||||
</HBox> |
</content> |
<List id="LineItemID" visible="false" items="{/}"> | |||||||
<items> | |||||||
<ObjectListItem title="Material Number" type="Active" | |||||||
number="{material}"> | |||||||
<firstStatus> | |||||||
<ObjectStatus text="{Status}" | |||||||
state="{ |
path: 'Status',
formatter: 'sap.m.sample.ObjectListItem.Formatter.status'
}" />
</firstStatus> | ||||||
<attributes> | ||||||
<ObjectAttribute title="Storage Location" text="{sLoc}" /> | ||||||
<ObjectAttribute title="Quantity" text="{rQty}" /> |
</attributes> | |||||
</ObjectListItem> |
</items> | |||
</List> |
<footer> | ||||
<Toolbar> | ||||
<ToolbarSpacer /> | ||||
<Button text="Submit" press="submitLineItem" type="Accept"></Button> | ||||
</Toolbar> | ||||
</footer> |
</Page> |
Controller.js
ADDItem:function(){ | ||
count++; | ||
console.log("count:"+count); | ||
this.getView().byId("addItemDialog").open(); |
}, | |||
saveLineItem:function(){ | |||
var mType=$("#GI--MType-inner").val(); | |||
var plant=$("#GI--Plant-inner").val(); | |||
var sLoc=$("#GI--SLocation-inner").val(); | |||
var costCenter=$("#GI--CostCenter-inner").val(); | |||
var material=$("#__input13-inner").val(); | |||
var rQty=$("#__input16-inner").val(); | |||
var dataArray=[]; | |||
for(var i=0;i<=count;i++){ | |||
// | dataArray.push({mType:mType,plant:plant,sLoc:sLoc,costCenter:costCenter,material:material,rQty:rQty}); | ||
dataArray[i] = {mType:mType,plant:plant,sLoc:sLoc,costCenter:costCenter,material:material,rQty:rQty}; | |||
console.log(dataArray[i]); | |||
} | |||
console.log(dataArray);
this.getView().byId("LineItemID").setVisible(true); | ||
jModel.setData(dataArray); | ||
this.getView().byId("LineItemID").setModel(jModel); | ||
//this.page.rerender(); | ||
// | this.getView().byId("addItemDialog").close(); | |
this.closeDialog(); | ||
}, | ||
closeDialog:function(){ | ||
this.getView().byId("addItemDialog").close(); | ||
}, | ||
submitLineItem:function(){ |
var date = new Date(); | ||
var year = date.getFullYear(), | ||
month = (date.getMonth() + 1), | ||
day = date.getDate(); | ||
console.log(year); | ||
if (month < 10) month = "0" + month; | ||
if (day < 10) day = "0" + day; |
var properlyFormatted = year+"-"+ month+"-" + day+"T00:00:00"; |
OData | ||||||
.request( | ||||||
{ | ||||||
// | requestUri : "http://host:8000/sap/opu/odata/sap/ZMM_GR_APP_SRV_01/", | |||||
requestUri : rooturl, | ||||||
method : "GET", | ||||||
headers : { | ||||||
"X-Requested-With" : "XMLHttpRequest", | ||||||
"Content-Type" : "application/xml charset=utf-8", | ||||||
"DataServiceVersion" : "2.0", | ||||||
"X-CSRF-Token" : "Fetch" | ||||||
} | ||||||
}, | ||||||
function(data, response) { | ||||||
header_xcsrf_token = response.headers['x-csrf-token']; | ||||||
console.log(data); | ||||||
console.log(header_xcsrf_token); |
OData | |||||||||
.request( | |||||||||
{ | |||||||||
// | requestUri : "http://host:8000/sap/opu/odata/sap/ZMM_GR_APP_SRV_01/GRSet", | ||||||||
requestUri : rooturl+"GRSet", | |||||||||
method : "POST", | |||||||||
headers : { | |||||||||
"X-Requested-With" : "XMLHttpRequest", | |||||||||
"Content-Type" : "application/atom+xml", | |||||||||
"DataServiceVersion" : "2.0", | |||||||||
"Accept" : "application/atom+xml,application/atomsvc+xml,application/xml", | |||||||||
"X-CSRF-Token" : header_xcsrf_token | |||||||||
}, | |||||||||
data : { |
dataArray
} | |||||||||
}, | |||||||||
function(data, | |||||||||
response) { |
//alert("success"); | ||||||||
console | ||||||||
.log(data); | ||||||||
console | ||||||||
.log(response); | ||||||||
alert("document number:::"+ data.MatDoc); |
}, | |||||||
function(err) { |
console | ||||||||
.log(err); | ||||||||
alert("Failure"+err); | ||||||||
}); | ||||||||
}, function(err) { | ||||||||
var request = err.request; | ||||||||
var response = err.response; | ||||||||
alert("Error in Get -- Request " | ||||||||
+ request + " Response " | ||||||||
+ response); | ||||||||
}); |
}, |
Adding to what Robin and Maksim have.
1. It is almost impossible for us to go through your code to figure the issue out.
2. Narrow down the issue(s) but creating smaller samples. Actually, this is what every developer should be doing. Then the issue(s) shall be more obvious to you and us. then we can discuss the solution(s)
3. Please spend some time formatting your code if you want to share them. This is a public forum and whatever that you have post here are seen by many people. It is good that you leave a good impression. and most importantly, make it easier for us to read the code.
Thanks
Dennis (moderator)
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.