
// Value of current order
var orderValue = parseFloat(session.findById("wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4021/txtVBAK-NETWR").text.replace(",", ""));
// Credit account details
session.findById("wnd[0]/mbar/menu[4]/menu[0]/menu[6]").select();
var creditLimit = parseFloat(session.findById("wnd[0]/usr/txtKNKK-KLIMK").text.replace(",", ""));
var creditExposure = parseFloat(session.findById("wnd[0]/usr/txtRF02L-OBLIG").text.replace(",", ""));
session.findById("wnd[0]/tbar[0]/btn[3]").press();
var contents = [
{ "Type": "Credit Limit", "Source": "Existing", "Value": creditLimit },
{ "Type": "Credit Exposure", "Source": "Existing", "Value": creditExposure},
{ "Type": "Credit Exposure", "Source": "This order", "Value": orderValue}
];
var chartHTML = '<html> <head>';
chartHTML += '
<script src="/ui5/1/resources/sap-ui-core.js"\
type="text/javascript"\
data-sap-ui-libs="sap.ui.core,sap.ui.commons,sap.viz" \
data-sap-ui-theme="sap_goldreflection"></script>';
chartHTML += '<script>';
chartHTML += 'var oModel = new sap.ui.model.json.JSONModel({businessData:' + JSON.stringify(contents) + '});';
// Need a sorter to get the chart columns in the right order
chartHTML += ' var oSorter = new sap.ui.model.Sorter("Source", true);'
// A Dataset defines how the model data is mapped to the chart
chartHTML += 'var oDataset = new sap.viz.ui5.data.FlattenedDataset({\
dimensions : [ \
{\
axis : 1, \
name : "Type", \
value : "{Type}"\
}, \
{\
axis: 2, \
name: "Source", \
value: "{Source}"\
}\
],\
measures : [ \
{\
name : "Value", \
value : "{Value}" \
}\
],\
data : {\
path : "/businessData", \
sorter: oSorter \
}\
});';
// Set the colour for the "this order" column based on exposure + order value
if(creditExposure + orderValue < creditLimit ) {
thisOrderColour = "#9a9a08";
} else {
thisOrderColour = "#b4153a";
}
// create a StackedColumn chart
chartHTML += 'var oBarChart = new sap.viz.ui5.StackedColumn({\
width : "100%",\
height : "100px",\
plotArea : {colorPalette: ["' + thisOrderColour + '", "#5698d2"]} , \
title : { visible : false },\
legend: { visible: true },\
toolTip: { visible: false }, \
dataset : oDataset\
});';
// attach the model to the chart and display it
chartHTML += ' oBarChart.setModel(oModel);\
oBarChart.placeAt("content"); ';
chartHTML += '</script>';
chartHTML += '</head>';
chartHTML += '<body class="sapUiBody" supportedthemes="sap_corbu" role="application">';
chartHTML += '<div id="content"></div>'
chartHTML += '</body></html>';
session.findById("wnd[0]/usr/htmlViewerPersonas_1447866610072").content = chartHTML;
var customer = session.findById("wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4021/subPART-SUB:SAPMV45A:4701/ctxtKUAGV-KUNNR").text;
var PONumber = session.findById("wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4021/txtVBKD-BSTKD").text;
var chartHTML;
if(!customer || !PONumber) {
chartHTML = '';
} else {
// The rest of the script from above...
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
7 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |