As I am in the learning process, I am stuck at one point for which I need your help. I am mentioning that in details below.
I have developed the following application in which one master page comes which shows the list of PRs to be approved by a user.
When clicking a particular PR, it shows the detail page.
In the detail page, several fields are displayed like general details, approval status list, comments (if any) and the list of attachments (attachments not yet integrated).
The line-item list is also displayed as follows –
Now, if I click on a particular line item, it opens a line item view as follows –
It is showing the selected line-item details. It will show the service sub-line item list also which is within that particular line-item as follows –
`
Line Number 00080 has sub-line item which is shown below.
Now, I have kept provision of modifying quantity, rate, cost center and G/L account (the value you are seeing above is placeholder value. I have created the gateway channels (along with RFC) for updating the same.
The process for updating the same through gateway also is known to me as I have seen some test applications (using X-CSRF-Token etc.). I have tested my gateway configuration and RFC also through test data in Postman Rest Client.
The problem I am facing is for reading the value of entered quantity, rate, G/L account, cost center in the line item controller once I presses the ‘Save Data’ button (details will be available in the lineitem view and lineitem controller in the WebContent folder). Along with that I need to read 2 fields – Banfn (PR number) and Bnfpo (PR Lineitem number) (these are needed for sending the data to gateway and updating R3 system) – these are already available in the line-item view model as data is displaying in the lineitem view.
I have to take those 6 values in 6 variables for passing to gateway service.
Can you please tell me how can I do that? It will be of great help to me if you please help me to read those 6 values in line item view controller once 'Save Data' button is pressed. I tried to attach the webcontent folder but could not attach. I am attaching the same document with screen-shots here separately.
It will be of great help if anybody can suggest what can be done to read those in controller. After reading code for sending to Gateway is known to me. I could not attach the webcontent folder as I can not upload .rar file, however I am giving the code for lineitem.view.xml and lineitem.controller.xml below -
Code of Lineitem.View.XML -
<core:View
controllerName="sap.ui.demo.myFiori.view.LineItem"
xmlns="sap.m"
xmlns:core="sap.ui.core" >
<Page
id="page"
title=" {i18n>LineItemTitle}"
showNavButton="true"
navButtonPress="handleNavBack" >
<content>
<ObjectHeader
title="{Txz01}"
number="{Tpreis1}"
numberUnit="INR" >
<attributes>
<ObjectAttribute text="{Bnfpo}" />
<ObjectAttribute text="{Menge}" />
<ObjectAttribute text="{Preis1}" />
<ObjectAttribute text="{Kostl}" />
<ObjectAttribute text="{Sakto}" />
</attributes>
</ObjectHeader>
<List
headerText="Modify Quantity, Rate, Cost Center and G/L Account if needed">
<InputListItem label="Quantity">
<Input
id="Vmenge"
placeholder="Enter Value"
value="{Menge}"/>
</InputListItem>
<InputListItem label="Rate">
<Input
id="Vpreis"
placeholder="Enter Value"
value="{Preis1}"/>
</InputListItem>
<InputListItem label="G/L Account">
<Input
placeholder="Enter Value"
value="{Sakto}"/>
</InputListItem>
<InputListItem label="Cost Center">
<Input
placeholder="Enter Value"
value="{Kostl}"/>
</InputListItem>
</List>
<Table id="Table10"
headerText="{i18n>SubLineItemTableHeader}"
items="{LINETOSUBLINES}">
<columns>
<Column>
<header><Label text="Service" /></header>
</Column>
<Column>
<header><Label text="Quantity" /></header>
</Column>
<Column>
<header><Label text="Rate" /></header>
</Column>
<Column>
<header><Label text="Price" /></header>
</Column>
</columns>
<ColumnListItem>
<ObjectIdentifier
title="{ShortText}"
text="{Service}"
class="sapTableContentMargin" />
<ObjectNumber
number="{Quantity}"/>
<ObjectNumber
number="{GrPrice}"
unit="INR"/>
<ObjectNumber
number="{NetValue}"
unit="INR"/>
</ColumnListItem>
</Table>
</content>
<footer>
<Bar>
<contentRight>
<Button
text="{i18n>dataSave}"
type="Transparent"
icon="sap-icon://save"
press="handleUpdate" />
</contentRight>
</Bar>
</footer>
</Page>
</core:View>
Code of LineItem.Controller.JS
ap.ui.controller("sap.ui.demo.myFiori.view.LineItem", {
// onAfterRendering: function() {
// var var_menge = sap.ui.getCore().byId("Vmenge").getValue();
// var var_preis = sap.ui.getCore().byId("Vpreis").getValue();
// },
handleUpdate : function (evt) {
// show confirmation dialog
var bundle = this.getView().getModel("i18n").getResourceBundle();
sap.m.MessageBox.confirm(
bundle.getText("UpdateDialogMsg"),
function (oAction) {
if (sap.m.MessageBox.Action.OK === oAction) {
var var_menge = sap.ui.getCore().byId("Vmenge").getValue();
var var_preis = sap.ui.getCore().byId("Vpreis").getValue()
?? Was trying to read those variables but those were giving errors as below. Rest code for sending value to Gateway will be written once the above code is corrected -
I am getting the error while reading the input values from the XML view.
_______________________________________________________________________________________________________
//LineItem.Controller.JS code is continuing below.
// notify user
var successMsg = bundle.getText("UpdateDialogSuccessMsg");
sap.m.MessageToast.show(successMsg);
// TODO call proper service method and update model (not part of this session)
}
},
bundle.getText("UpdateDialogTitle")
);
},
handleNavBack : function (evt) {
this.nav.back("Detail");
}
});