Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i am getting multiple definition error in internet explorer please help me in finding it. #154

Open
Srikar1995 opened this issue Feb 2, 2018 · 0 comments

Comments

@Srikar1995
Copy link

`sap.ui.define(["vistex/ui/core/BaseController",
"vistex/ui/core/global",
"vistex/ui/core/commonUtils",
"sap/ui/comp/variants/VariantItem"],
function (Controller,global,commonUtils,VariantItem) {
"use strict";
return Controller.extend(vui5.app +".bdoutilities.Controllers.BaseController", {
getRouter : function(){
return sap.ui.core.UIComponent.getRouterFor(this);
},
onNavBack : function() {
// var history;//previousHash;
// history = History.getInstance();
//previousHash = history.getPreviousHash();
window.history.go(-1);
//parent.window.frameElement.contentWindow.history.back();
},
getModel : function(sName){
return this.getView().getModel(sName);
},
showAllButtons: function(show){
var mainModel = this.getModel(vui5.modelName);
var changeMode = mainModel.getProperty("/CHANGE_MODE");
mainModel.setProperty("/DELETEMODE",!show);
mainModel.setProperty("/SHOWBUTTONS",changeMode && show);
},
onValueHelpRequest: function (oEvent) {
// jQuery.sap.require("globalUtilsPath/Fragments/InputHelp");
var oController = this;
var mainModel = oController.getModel(vui5.modelName);
var src = oEvent.getSource();
var _inputHelpID = src.getId();
var modelName = src.data("model");
var path = src.data("path");
var supportRangesOnly = false;
// Support F4 with filtered Values when User Pressing Show All Items
var fromSuggestions = oEvent.getParameters("fromSuggestions").fromSuggestions;
if(src.data("SUPPORTRANGESONLY"))
supportRangesOnly = true;
if(modelName && path) {
var model = src.getModel(modelName);
var fieldInfo = model.getProperty(path);
var dataArea = src.data("dataArea");
mainModel.setProperty("/INPUTHELP/FLDNAME",fieldInfo['FLDNAME']);
mainModel.setProperty("/INPUTHELP/MULTISELECT",fieldInfo['MULTISELECT']);
mainModel.setProperty("/INPUTHELP/FIELDID",_inputHelpID);
mainModel.setProperty("/INPUTHELP/TABNAME",fieldInfo['TABNAME']);
mainModel.setProperty("/INPUTHELP/LABEL",fieldInfo['LABEL']);
mainModel.setProperty("/INPUTHELP/SHLPNAME",fieldInfo['SHLPNAME']);
mainModel.setProperty("/INPUTHELP/TXTFL", fieldInfo['TXTFL']);
mainModel.setProperty("/INPUTHELP/DEPFL", fieldInfo['DEPFL']);
mainModel.setProperty("/INPUTHELP/DATAR",dataArea);
mainModel.setProperty("/INPUTHELP/SUPPORTRANGESONLY", supportRangesOnly);
mainModel.setProperty("/INPUTHELP/DATATYPE", fieldInfo['DATATYPE']);
mainModel.setProperty("/INPUTHELP/INTTYPE", fieldInfo['INTTYPE']);
mainModel.setProperty("/INPUTHELP/OUTPUTLEN", fieldInfo['OUTPUTLEN']);
/ESP4 QA issue #6352 Passing Rollname for Inputhelp/
mainModel.setProperty("/INPUTHELP/ROLLNAME", fieldInfo['ROLLNAME']);
/******/
// Support F4 with filtered Values when User Pressing Show All Items
mainModel.setProperty("/INPUTHELP/TYPEAHEAD_ACTIVE",fromSuggestions);

    var _oInputHelpDialog = sap.ui.jsfragment(global.vui5.ui.fragments.InputHelp,oController);
    _oInputHelpDialog.setModel(oController.getModel(vui5.modelName),vui5.modelName);
    oController.getView().addDependent(_oInputHelpDialog);

    jQuery.sap.syncStyleClass(oController.getOwnerComponent().getContentDensityClass(),
        oController.getView(), _oInputHelpDialog);
  }
},
onRangeHelpRequest: function (oEvent) {
  jQuery.sap.require("bdoUtilsPath/Fragments/RangeHelp");
  var oController = this;
  var mainModel = oController.getModel(vui5.modelName);
  var src = oEvent.getSource();
  var _inputHelpID = src.getId();
  var modelName = src.data("model");
  var path = src.data("path");

  if(modelName && path) {
    var model = src.getModel(modelName);
    var fieldInfo = model.getProperty(path);
    var dataArea = src.data("dataArea");
    mainModel.setProperty("/INPUTHELP/FLDNAME",fieldInfo['FLDNAME']);

// mainModel.setProperty("/INPUTHELP/MULTISELECT",fieldInfo['MULTISELECT']);
mainModel.setProperty("/INPUTHELP/FIELDID",_inputHelpID);
// mainModel.setProperty("/INPUTHELP/TABNAME",fieldInfo['TABNAME']);
mainModel.setProperty("/INPUTHELP/LABEL",fieldInfo['LABEL']);
// mainModel.setProperty("/INPUTHELP/SHLPNAME",fieldInfo['SHLPNAME']);
mainModel.setProperty("/INPUTHELP/TXTFL", fieldInfo['TXTFL']);
// mainModel.setProperty("/INPUTHELP/DEPFL", fieldInfo['DEPFL']);
// mainModel.setProperty("/INPUTHELP/DATAR",dataArea);
// mainModel.setProperty("/INPUTHELP/SUPPORTRANGESONLY", supportRangesOnly);
mainModel.setProperty("/INPUTHELP/DATATYPE", fieldInfo['DATATYPE']);
mainModel.setProperty("/INPUTHELP/INTTYPE", fieldInfo['INTTYPE']);
mainModel.setProperty("/INPUTHELP/OUTPUTLEN", fieldInfo['OUTPUTLEN']);
/ESP4 QA issue #6352 Passing Rollname for Inputhelp/
var _oRangeHelpDialog = sap.ui.jsfragment("bdoUtilsPath" + ".fragments.RangeHelp",oController);
_oRangeHelpDialog.setModel(oController.getModel(vui5.modelName),vui5.modelName);
}else{
mainModel.setProperty("/INPUTHELP","");
}

},
onF4Select: function(oEvent){

// var oController = this;
// var mainModel = oController.getModel(vui5.modelName);
// var modelName = mainModel.getProperty("/MODELNAME");
var type = oEvent.getParameter("type");
if(type != undefined && type == "tokensChanged"){
var oSource = oEvent.getSource();
var fieldPath = oSource.data('path');
var model = oSource.getModel(oSource.data('model'));
var fieldInfo = model.getProperty(fieldPath);

    var token = oSource.getBinding("tokens");
    var object = model.getProperty(token.getPath());

    var tokens = oEvent.getSource().getTokens();

    var newTokens = [];
    var newTexts = [];
    /*Define-Condition Issue Changes - START*/
    underscoreJS.each(tokens,function(obj){
      var range = obj.data("range");
      if(range){
        var sign = vui5.cons.seloptSign.include;
        if(range.exclude)
          sign = vui5.cons.seloptSign.exclude;
        newTokens.push({
          "SHLPNAME": fieldInfo['SHLPNAME'],
          "FIELDNAME": fieldInfo['FLDNAME'],
          "SHLPFIELD": fieldInfo['FLDNAME'],
          "SELNAME" : fieldInfo['FLDNAME'],
          /*Rel 60E_SP5*/
          "TABNAME": fieldInfo['TABNAME'],
          /*Rel 60E_SP5*/
          "OPTION": range.operation,
          "LOW": range.value1,
          "HIGH": range.value2,
          "SIGN": sign,
          "TEXT" : obj.getText()
        });
      }else{
        newTokens.push({
          "SHLPNAME": fieldInfo['SHLPNAME'],
          "FIELDNAME": fieldInfo['FLDNAME'],
          "SHLPFIELD": fieldInfo['FLDNAME'],
          "SELNAME" : fieldInfo['FLDNAME'],
          /*Rel 60E_SP5*/
          "TABNAME": fieldInfo['TABNAME'],
          /*Rel 60E_SP5*/
          "OPTION": '',
          "LOW": obj.getText(),
          "HIGH": '',
          "SIGN": "",
          "TEXT" : obj.getText()
        });
      }
      newTexts.push(obj.getText());
    });

    var oldTexts = [];
    for(var i=0; i<object.length ; i++){
      oldTexts.push(object[i]['TEXT']);
    }
    /*Define-Condition Issue Changes - START*/

    var diff = underscoreJS.difference(oldTexts,newTexts);
    if(diff.length == 0 )
      diff = underscoreJS.difference(newTexts,oldTexts);
    if(diff.length != 0){
      object = newTokens;
      model.setProperty(token.getPath(),object);
      oSource.fireChange();//fireChange();
    }
  }
},
attachmentDataPrepare : function(attachments){
  var docs = [];
  var mainModel = this.getModel(vui5.modelName);
  var modelName = mainModel.getProperty("/MODELNAME");
  var deletedDocs = this.getModel(modelName).getProperty("/ATTACHMENTS/DELETED");
  underscoreJS.each(attachments,function(obj){
    var doc = underscoreJS.findWhere(deletedDocs,{
      BITM_TYPE   : obj['BITM_TYPE']
    });
    if(doc == undefined){
      obj['BITM_ICON'] = obj['BITM_ICON'].toLowerCase();
      docs.push(obj);
    }
  });
  return docs;
},
/* For fetching Description*/
getDescription : function(oEvent) {
  var source = oEvent.getSource();
  var valueMoved = source.data("VALUE_MOVED");
  source.data("VALUE_MOVED",false);
  var promise;
  if(!valueMoved){
    promise = this.descriptionGet(source,source.getValue(),'X','');//oEvent.getParameter("newValue"));
  }
  return promise;
},
_sessionEnd: function () {
    var oUrl;

    if (vui5.server.url.full.indexOf("?") == -1) {
        oUrl = vui5.server.url.full + '?sap-sessioncmd=close';
    }
    else {
        oUrl = vui5.server.url.full + '&sap-sessioncmd=close';
    }
    $.ajax({
        dataType: 'json',
        data: [],
        xhrFields: {
            withCredentials: true
        },
        crossDomain: true,
        type: 'POST',
        url: oUrl,
        async: false,
        error: function (jqXHR, textStatus, errorThrown) { }
    }).done(function (data, status, xhr) {
    });
},
_registerUnloadEvent: function () {
	var oController = this;
	
	function onWindowUnload()
	{
		  if (!vui5.fromOtherApp) {

			  oController._sessionEnd();

		    }
		    else {
		        var data = [];
		        data.push({
		            "DATA": [],
		            "PARAMS": [],
		            "DTAREA": "APPLICATION",
		            "EVENT": "UNLOAD"
		        });

		        data.push({
		            "DATA": [],
		            "PARAMS": [],
		            "DTAREA": "APCTX",
		            "EVENT": "UNLOAD"
		        });
		        if (_.isArray(data)) {
		            _.each(data, function (obj) {
		                if (_.has(obj, 'DATA')) {
		                    obj['DATA'] = JSON.stringify(obj['DATA']).replace(/\"/g, "@!@");
		                    obj['DATA'] = obj['DATA'].replace(/\\r/g, "");
		                }
		            });
		        }
		        postData = JSON.stringify(data).replace(/@!@/g, '\\\"');
		        $.ajax({
		            data: postData,
		            xhrFields: {
		                withCredentials: true
		            },
		            crossDomain: true,
		            method: "POST",
		            url: vui5.server.url.full,
		            async: false,
		        }).done(function (result) {

		        });

		    }
		};

		function onWindowBeforeUnload()
		{
		  if (!vui5.session.sessionend_skip) {
		    if(vui5.fromOtherApp == false)
		    {
		      oController._sessionEnd();
		      window.removeEventListener("unload", onWindowUnload);

		    }

		    }
		    else {
		        vui5.session.sessionend_skip = false;
		    }

		}
		window.addEventListener("unload", onWindowUnload);

		window.addEventListener("beforeunload", onWindowBeforeUnload);
},
descriptionGet : function(source,newValue,getDescription,checkValue){
  var oController = this;
  var model = source.getModel(source.data("model"));
  if(model) {
    /* Multiple Change Event Issue Changes */
    var deffered = $.Deferred();
    var fieldInfo = model.getProperty(source.data("path"));
    if(parseInt(fieldInfo['OUTPUTLEN']) != 0 && parseInt(fieldInfo['OUTPUTLEN']) < newValue.length){
      source.setValueState(sap.ui.core.ValueState.Error);
      var text;
      if(source.getParent().getAggregation("label")){
        // in case of form
        text = source.getParent().getAggregation("label").getText();
      }else{
        if(source.data("sap-ui-colid")){
          // non responsive table
          text = sap.ui.getCore().byId(source.data("sap-ui-colid")).getAggregation("label").getText();
        }else{
          // m.Table
          /*QA Issue 7022 Changes - START*/
          var ariaLabelledBy = source.getAriaLabelledBy();
          for(var i=0; i < ariaLabelledBy.length ; i++){
            var textElement = sap.ui.getCore().byId(ariaLabelledBy[i]);
            if(textElement){
              text = textElement.getText();
              break;
            }
          }

// text = sap.ui.getCore().byId(source.getAriaLabelledBy()[0]).getText();
/QA Issue 7022 Changes - END/
}
}
var bundle = source.getModel("i18n").getResourceBundle();
var errorText = bundle.getText("EnterValid",[text]);
source.setValueStateText(errorText);
oController.handleCheckFieldsMessages(
errorText,
sap.ui.core.MessageType.Error,
source.getId() + "/value" );
deffered.resolve(false);
}else{
source.setValueState(sap.ui.core.ValueState.None);
source.setValueStateText('');
oController.handleCheckFieldsMessages(
"",
"",
source.getId() + "/value" );
var dataArea = source.data("dataArea");
/Fill Description from Buffer/
var mainModel = this.getModel(vui5.modelName);
var descriptionBuffer = mainModel.getProperty("/DESCRIPTION_BUFFER");
var bufferEntry = underscoreJS.find(descriptionBuffer,{
'FLDNAME' : fieldInfo['FLDNAME'],
'TABNAME' : fieldInfo['TABNAME'],
'FLDVAL' : newValue
});
var oBinding = source.getBinding("value");
var path;
if(oBinding.getContext()) {
path = oBinding.getContext().getPath() + "/" + oBinding.getPath();
}else{
path = oBinding.getPath();
}
if(bufferEntry){
this.fillDescription(model,path,fieldInfo,bufferEntry['DESCRIPTION'],newValue);
/* Multiple Change Event Issue Changes /
deffered.resolve(true);
}else{
var arr = path.split("/");
var fieldname = arr[arr.length-1];
var rsparams = [];
if( underscoreJS.isArray(fieldInfo['DEPFL']) && fieldInfo['DEPFL'].length > 0 ){
for(var i=0;i < fieldInfo['DEPFL'].length ; i++) {
var depflPath = path.replace(fieldname,fieldInfo['DEPFL'][i]);
var depflData = model.getProperty(depflPath);
rsparams.push({
"SHLPNAME" : "",
"SHLPFIELD" : fieldInfo['DEPFL'][i],
"SIGN" : vui5.cons.seloptSign.include,
"OPTION" : "EQ",
"LOW" : depflData,
"HIGH" : ""
});
}
}
var data = [];
var params = [];
params.push({ NAME : "FIELDVALUE" , VALUE : newValue });
params.push({ NAME : "FIELDNAME" , VALUE : fieldInfo['FLDNAME'] });
params.push({ NAME : "TABLENAME" , VALUE : fieldInfo['TABNAME'] });
params.push({ NAME : "CONVEXIT" , VALUE : fieldInfo['CONVEXIT'] });
params.push({ NAME : "NRART" , VALUE : fieldInfo['NRART'] });
params.push({ NAME : "DATAAREA" , VALUE : dataArea });
params.push({ NAME : "CHECK_VALUE" , VALUE : checkValue });
params.push({ NAME : "GET_DESCR" , VALUE : getDescription });
data.push({
"DATA": rsparams,
"PARAMS": params,
"DTAREA": "FIELD_CHECK",
"EVENT": "READ"
});
$.when(this.callServer({ // callDescriptionServer
data: data,
reqType: vui5.cons.reqType.post,
NoLoader : true
})).then(function(result) {
if(result){
var path;
var response = underscoreJS.find(result,{DTAREA: "FIELD_CHECK", EVENT: "READ"});
if(response) {
if(checkValue == 'X'){
if(response['RESULT']['VALUE_NOT_FOUND'] == 'X'){
source.setValueState(sap.ui.core.ValueState.Error);
var text;
if(source.getParent().getAggregation("label")){
// in case of form
text = source.getParent().getAggregation("label").getText();
}else{
if(source.data("sap-ui-colid")){
// non responsive table
text = sap.ui.getCore().byId(source.data("sap-ui-colid")).getAggregation("label").getText();
}else{
// m.Table
/QA Issue 7022 Changes - START/
var ariaLabelledBy = source.getAriaLabelledBy();
for(var i=0; i < ariaLabelledBy.length ; i++){
var textElement = sap.ui.getCore().byId(ariaLabelledBy[i]);
if(textElement){
text = textElement.getText();
break;
}
}
// text = sap.ui.getCore().byId(source.getAriaLabelledBy()[0]).getText();
/QA Issue 7022 Changes - END/
}
}
var bundle = source.getModel("i18n").getResourceBundle();
var errorText = bundle.getText("EnterValid",[text]);
source.setValueStateText(errorText);
oController.handleCheckFieldsMessages(
errorText,
sap.ui.core.MessageType.Error,
source.getId() + "/value" );
deffered.resolve(false);
}else{
source.setValueState(sap.ui.core.ValueState.None);
source.setValueStateText('');
oController.handleCheckFieldsMessages(
"",
"",
source.getId() + "/value" );
if(getDescription == 'X'){
if(oBinding.getContext()) {
path = oBinding.getContext().getPath() + "/" + oBinding.getPath();
}else{
path = oBinding.getPath();
}
oController.fillDescription(model,path,fieldInfo,response['RESULT']['DESCR'],newValue);
/
Multiple Change Event Issue Changes */
}
deffered.resolve(true);
}
}else if(getDescription == 'X'){

                if(oBinding.getContext()) {
                  path = oBinding.getContext().getPath() + "/" + oBinding.getPath();
                }else{
                  path = oBinding.getPath();
                }
                oController.fillDescription(model,path,fieldInfo,response['RESULT']['DESCR'],newValue);
                /* Multiple Change Event Issue Changes */
                deffered.resolve(true);
              }else{
                deffered.resolve(true);
              }
            }
          }
        });
      }
    }
    /* Multiple Change Event Issue Changes */
    return deffered.promise();
  }
},

fillDescription : function(model,path,fieldInfo,descr,newValue){
  if(fieldInfo['SDSCR'] == vui5.cons.fieldValue.value_cont_descr){
    var description = descr;
    if(newValue && newValue != ''){
      description = description + " (" + newValue + ")";
    }
    model.setProperty(path,description);
    path = path.replace(fieldInfo['TXTFL'],fieldInfo['FLDNAME']);
    model.setProperty(path,newValue);
  }else if(fieldInfo['SDSCR'] == vui5.cons.fieldValue.description){
    model.setProperty(path,descr);
    path = path.replace(fieldInfo['TXTFL'],fieldInfo['FLDNAME']);
    model.setProperty(path,newValue);
  }else if(fieldInfo['SDSCR'] == vui5.cons.fieldValue.value_descr) {
    path = path.replace(fieldInfo['FLDNAME'], fieldInfo['TXTFL']);
    model.setProperty(path,descr);
  }
},

handleTypeAhead : function(oEvent) {
  var source = oEvent.getSource();
  var model = source.getModel(source.data("model"));
  var fieldInfo = model.getProperty(source.data("path"));
  var dataArea = source.data("dataArea");
  var oBinding = source.getBinding("value");
  var path;
  if(oBinding.getContext()) {
    path = oBinding.getContext().getPath() + "/" + oBinding.getPath();
  }else{
    path = oBinding.getPath();
  }
  var arr = path.split("/");
  var fieldname = arr[arr.length-1];
  var rsparams = [];
  if( underscoreJS.isArray(fieldInfo['DEPFL']) && fieldInfo['DEPFL'].length > 0 ){
    for(var i=0;i < fieldInfo['DEPFL'].length ; i++) {
      var depflPath = path.replace(fieldname,fieldInfo['DEPFL'][i]);
      var depflData = model.getProperty(depflPath);
      rsparams.push({
        "SHLPNAME" : "",
        "SHLPFIELD" : fieldInfo['DEPFL'][i],
        "SIGN" : vui5.cons.seloptSign.include,
        "OPTION" : "EQ",
        "LOW" : depflData,
        "HIGH" : ""
      });
    }
  }
  var mainModel = this.getModel(vui5.modelName);
  mainModel.setProperty("/TYPEAHEAD",{});
  var data = [];
  var params = [];
  params.push({ NAME : "FIELDVALUE" , VALUE : oEvent.getParameter("suggestValue") });
  params.push({ NAME : "FIELDNAME" , VALUE : fieldInfo['FLDNAME'] });
  params.push({ NAME : "TABLENAME" , VALUE : fieldInfo['TABNAME'] });
  params.push({ NAME : "SHLPNAME" , VALUE : fieldInfo['SHLPNAME'] });
  /*ESP4 QA issue #6352 Passing Rollname for Inputhelp*/
  params.push({ NAME : "ROLLNAME" , VALUE: fieldInfo['ROLLNAME']});
  /******/
  params.push({ NAME : "DATAAREA" , VALUE : dataArea });
  if(fieldInfo['SDSCR'] == vui5.cons.fieldValue.description || fieldInfo['SDSCR'] == vui5.cons.fieldValue.value_cont_descr )
    params.push({ NAME : "SEARCHTYPE" , VALUE : "DSC" });
  else if(fieldInfo['SDSCR'] == vui5.cons.fieldValue.value || fieldInfo['SDSCR'] == vui5.cons.fieldValue.value_descr)
    params.push({ NAME : "SEARCHTYPE" , VALUE : "VAL" });
  data.push({
    "DATA": rsparams,
    "PARAMS": params,
    "DTAREA": "TYPEAHEAD",
    "EVENT": "READ"
  });
  $.when(this.callServer({
    data: data,
    reqType: vui5.cons.reqType.post,
    NoLoader : true
  })).then(function(result) {
    if(result){
      var typeAhead = {};
      typeAhead[fieldInfo['FLDNAME']] = {};
      var response = underscoreJS.find(result,{DTAREA: "TYPEAHEAD", EVENT: "READ"});
      if(response && response['RESULT']){
        typeAhead[fieldInfo['FLDNAME']]['FIELDS'] = response['RESULT']['RESULT_FCAT'];

// mainModel.setProperty("/TYPEAHEAD/FIELDS",response['RESULT']['RESULT_FCAT']);
if(response['RESULT']['RESULT_FCAT']) {
var length = response['RESULT']['RESULT_FCAT'].length;
var width = (length + 1) * 10 ;
if(width > 90)
width = 90;
width = width + "%";
source.setMaxSuggestionWidth(width);
}
typeAhead[fieldInfo['FLDNAME']]['DATA'] = response['RESULT']['RESULT_DATA'];
typeAhead[fieldInfo['FLDNAME']]['RETURNFIELD'] = response['RESULT']['RETFIELD'];
typeAhead[fieldInfo['FLDNAME']]['DESCRFIELD'] = response['RESULT']['DESCRFIELD'];
mainModel.setProperty("/TYPEAHEAD",typeAhead);
}
}
});
},
handleSuggestionItemSelected : function(oEvent) {
var source = oEvent.getSource();
var model = source.getModel(source.data("model"));
var fieldInfo = model.getProperty(source.data("path"));
var item = oEvent.getParameter("selectedRow");
var rowData = item.getBindingContext(vui5.modelName).getObject();
var mainModel = this.getModel(vui5.modelName);
var returnField = mainModel.getProperty("/TYPEAHEAD/"+ fieldInfo['FLDNAME'] + "/RETURNFIELD");
var descrField = mainModel.getProperty("/TYPEAHEAD/"+ fieldInfo['FLDNAME'] + "/DESCRFIELD");
source.setValue(rowData[returnField]);
/Description Buffer Changes/
if(descrField && descrField != '') {
var descriptionBuffer = mainModel.getProperty("/DESCRIPTION_BUFFER");
var bufferEntry = underscoreJS.find(descriptionBuffer,{'FLDNAME' : fieldInfo['FLDNAME'],
'TABNAME' : fieldInfo['TABNAME'],
'FLDVAL' : rowData[returnField] });
if(bufferEntry){
bufferEntry['DESCRIPTION'] = rowData[descrField];
}else{
descriptionBuffer.push({
'FLDNAME' : fieldInfo['FLDNAME'],
'TABNAME' : fieldInfo['TABNAME'],
'FLDVAL' : rowData[returnField] ,
'DESCRIPTION' : rowData[descrField]});
}
}
source.fireChange();
},
onCheckBoxSelect : function(oEvent) {
var source = oEvent.getSource();
var path;
if(source.getBindingContext(source.data("model"))) {
path = source.getBindingContext(source.data("model")).getPath();
path = path + "/" + source.getBinding("selected").getBindings()[0].getPath();
}else{
path = source.getBinding("selected").getBindings()[0].getPath();
}
var model = source.getModel(source.data("model"));
if(oEvent.getParameter("selected"))
model.setProperty(path,'X');
else
model.setProperty(path,'');
},
handleAmountConversion : function(oEvent) {
var oController = this;
var source = oEvent.getSource();
oController.performAmountConversion(source);
},
performDecimalConversion : function(source){
var oController = this;
var newValue = source.getValue();
var oBinding = source.getBinding("value");
var model = oBinding.getModel();
/* Multiple Change Event Issue Changes /
/QA Issue 7022 Changes - START/
var deffered = $.Deferred();
var path;
if(oBinding.getContext()) {
path = oBinding.getContext().getPath() + "/" + oBinding.getPath();
}else{
path = oBinding.getPath();
}
var fieldname = source.data("FLDNAME");
var tablename = source.data("TABNAME");
var decimalField = [{ 'FLDNAME' : fieldname, 'TABNAME' : tablename , 'VALUE' : newValue }];
var data = [];
// var params = [];
data.push({
"DATA": decimalField,
"PARAMS": [],
"DTAREA": "CONVERSION",
"EVENT": ""
});
$.when(this.callServer({
data: data,
reqType: vui5.cons.reqType.post,
NoLoader : true
})).then(function(result) {
var error = false;
if(result){
var response = underscoreJS.find(result,{DTAREA: "CONVERSION"});
if(response && response['RESULT']['DATA']) {
underscoreJS.each(response['RESULT']['DATA'] , function(obj) {
model.setProperty(path,obj['VALUE']);
if(obj['ERROR'] != '') {
source.setValueState(sap.ui.core.ValueState.Error);
source.setValueStateText(obj['MESSAGE']);
oController.handleCheckFieldsMessages(
obj['MESSAGE'],
sap.ui.core.MessageType.Error,
source.getId() + "/value" );
error = true;
}else{
source.setValueState(sap.ui.core.ValueState.None);
source.setValueStateText("");
oController.handleCheckFieldsMessages(
"",
"",
source.getId() + "/value" );
}
});
}
}
/
Multiple Change Event Issue Changes /
if(error)
deffered.resolve(false);
else
deffered.resolve(true);
});
/
Multiple Change Event Issue Changes */
return deffered.promise();
/QA Issue 7022 Changes - END/
},
performAmountConversion : function(source){
var oController = this;
var newValue = source.getValue();
// check value
/QA Issue 7022 Changes - START/
var deffered = $.Deferred();

  if (oController.checkAmountValue(newValue)){
    // set state
    source.setValueState(sap.ui.core.ValueState.None);
    source.setValueStateText("");
    oController.handleCheckFieldsMessages(
        "",
        "",
        source.getId() + "/value" );
    var oBinding = source.getBinding("value");
    var model = oBinding.getModel();
    var currencyPath = source.data("currencyPath");
    var currency = model.getProperty(currencyPath);
    if(!currency)
      currency = '';

    //check currency

// if(currency) {
/* Multiple Change Event Issue Changes */
// var deffered = $.Deferred();

    var path;
    if(oBinding.getContext()) {
      path = oBinding.getContext().getPath() + "/" + oBinding.getPath();
    }else{
      path = oBinding.getPath();
    }
    var fieldname = source.data("FLDNAME");
    var tablename = source.data("TABNAME");
    var amount = [{ 'FLDNAME' : fieldname, 'TABNAME' : tablename , 'VALUE' : newValue }];
    var data = [];
    var params = [];
    params.push({ NAME : "CURRENCY" , VALUE : currency });
    data.push({
      "DATA": amount,
      "PARAMS": params,
      "DTAREA": "CONVERSION",
      "EVENT": ""
    });
    $.when(this.callServer({
      data: data,
      reqType: vui5.cons.reqType.post,
      NoLoader : true
    })).then(function(result) {
      var error = false;
      if(result){
        var response = underscoreJS.find(result,{DTAREA: "CONVERSION"});
        if(response && response['RESULT']['DATA']) {
          underscoreJS.each(response['RESULT']['DATA'] , function(obj) {
            model.setProperty(path,obj['VALUE']);
            if(obj['ERROR'] != '') {
              source.setValueState(sap.ui.core.ValueState.Error);
              source.setValueStateText(obj['MESSAGE']);
              oController.handleCheckFieldsMessages(
                  obj['MESSAGE'],
                  sap.ui.core.MessageType.Error,
                  source.getId() + "/value" );
              error = true;
            }else{
              source.setValueState(sap.ui.core.ValueState.None);
              source.setValueStateText("");
              oController.handleCheckFieldsMessages(
                  "",
                  "",
                  source.getId() + "/value" );
            }
          });
        }
      }
      /* Multiple Change Event Issue Changes */
      if(error)
        deffered.resolve(false);
      else
        deffered.resolve(true);
    });
    /* Multiple Change Event Issue Changes */

// }
}else{
source.setValueState(sap.ui.core.ValueState.Error);
var text;
if(source.getParent().getAggregation("label")){
text = source.getParent().getAggregation("label").getText();
}else if(source.getParent().getTitle()){
text = source.getParent().getTitle();
text = text.substr(5,text.length);
}else{
if(source.data("sap-ui-colid")){
// non responsive table
text = sap.ui.getCore().byId(source.data("sap-ui-colid")).getAggregation("label").getText();
}else{
// m.Table
/QA Issue 7022 Changes - START/
var ariaLabelledBy = source.getAriaLabelledBy();
for(var i=0; i < ariaLabelledBy.length ; i++){
var textElement = sap.ui.getCore().byId(ariaLabelledBy[i]);
if(textElement){
text = textElement.getText();
break;
}
}
// text = sap.ui.getCore().byId(source.getAriaLabelledBy()[0]).getText();
/QA Issue 7022 Changes - END/
}
}
var bundle = source.getModel("i18n").getResourceBundle();
var errorText = bundle.getText("EnterValid",[text]);
source.setValueStateText(errorText);
oController.handleCheckFieldsMessages(
errorText,
sap.ui.core.MessageType.Error,
source.getId() + "/value" );

    deffered.resolve(false);
  }
  return deffered.promise();
  /*QA Issue 7022 Changes - END*/
},
handleCheckFieldsMessages : function(text,type,target){
  if(!this.oMessageProcessor){
    this.oMessageProcessor = new sap.ui.core.message.ControlMessageProcessor();
  }
  var oMessageManager = sap.ui.getCore().getMessageManager();
  oMessageManager.registerMessageProcessor(this.oMessageProcessor);
  var messageModel = oMessageManager.getMessageModel();
  var data = messageModel.getData();
  messageModel.setSizeLimit(vui5.cons.maxDataLimit);
  var messageData = underscoreJS.find(data,{target : target});
  if(messageData){
    oMessageManager.removeMessages(messageData);
  }
  if(text != '') {
    oMessageManager.addMessages(
        new sap.ui.core.message.Message({
          message: text,
          type: type,
          target : target,
          processor: this.oMessageProcessor
        })
    );
  }
},
checkAmountValue : function(value) {
  var regex;
  var mainModel = this.getModel(vui5.modelName);
  var decimalNotation = mainModel.getProperty("/LOGIN/DECIMALNOTATION");

  value = value.trim();
  if(value){
    /*QA Issue 7022 Changes*/
    switch(decimalNotation) {
    case 'X' :
      regex = /^[0-9\-.]\d*(((,\d{1,}){0,})?(\.\d{0,})?)([0-9\-]{0,1})$/;
      break;
    case 'Y' :
      regex = /^[0-9\-,]\d*(((\s\d{1,}){0,})?(,\d{0,})?)([0-9\-]{0,1})$/;
      break;
    default :
      regex = /^[0-9\-,]\d*(((\.\d{1,}){0,})?(,\d{0,})?)([0-9\-]{0,1})$/;
    break;
    }
    /*QA Issue 7022 Changes*/
    return regex.test(value);
  }else{
    return false;
  }
},
handleCurrencyConversion : function(oEvent,fields,path,currencyPath) {
  var oController = this;
  var source = oEvent.getSource();
  oController.performCurrencyConversion(source,fields,path,currencyPath);
},
performCurrencyConversion : function(source,fields,path,currencyPath) {
  var oController = this;
  var model;
  if(source.getBinding("value")){
    model = source.getBinding("value").getModel();
  }else if(source.getBinding("selectedKey")){
    model = source.getBinding("selectedKey").getModel();
  }
  /*QA Issue 7022 Changes - START*/
  var deffered = $.Deferred();

  var currency = model.getProperty(currencyPath);
  var amount = [];

  var errorExist = false;

  underscoreJS.each(fields,function(obj) {
    var data = model.getProperty(path + obj['TXTFL']);
    if (oController.checkAmountValue(data)){
      amount.push({
        'TABNAME' : obj['TABNAME'] ,
        'FLDNAME' : obj['FLDNAME'] ,
        'VALUE'  : data,
        'TXTFL' : obj['TXTFL']});
    }else{
      errorExist = true;
      obj['CONTROL'].setValueState(sap.ui.core.ValueState.Error);
      var text;
      if(obj['CONTROL'].getParent().getAggregation("label")){
        text = obj['CONTROL'].getParent().getAggregation("label").getText();
      }else if(obj['CONTROL'].getParent().getTitle()){
        text = obj['CONTROL'].getParent().getTitle();
        text = text.substr(5,text.length);
      }else{
        if(obj['CONTROL'].data("sap-ui-colid")){
          // non responsive table
          text = sap.ui.getCore().byId(obj['CONTROL'].data("sap-ui-colid")).getAggregation("label").getText();
        }else{
          // m.Table
          /*QA Issue 7022 Changes - START*/
          var ariaLabelledBy = obj['CONTROL'].getAriaLabelledBy();
          for(var i=0; i < ariaLabelledBy.length ; i++){
            var textElement = sap.ui.getCore().byId(ariaLabelledBy[i]);
            if(textElement){
              text = textElement.getText();
              break;
            }
          }

// text = sap.ui.getCore().byId(obj['CONTROL'].getAriaLabelledBy()[0]).getText();
/QA Issue 7022 Changes - END/
}
}
// var text = obj['CONTROL'].getParent().getAggregation("label").getText();
var bundle = obj['CONTROL'].getModel("i18n").getResourceBundle();
var errorText = bundle.getText("EnterValid",[text]);
obj['CONTROL'].setValueStateText(errorText);
oController.handleCheckFieldsMessages(
errorText,
sap.ui.core.MessageType.Error,
obj['CONTROL'].getId() + "/value" );
}
});
if(currency && amount.length > 0) {
/* Multiple Change Event Issue Changes /
// var deffered = $.Deferred();
var data = [];
var params = [];
params.push({ NAME : "CURRENCY" , VALUE : currency });
data.push({
"DATA": amount,
"PARAMS": params,
"DTAREA": "CONVERSION",
"EVENT": ""
});
$.when(this.callServer({
data: data,
reqType: vui5.cons.reqType.post,
NoLoader : true
})).then(function(result) {
var error = false;
if(result){
var response = underscoreJS.find(result,{DTAREA: "CONVERSION"});
if(response && response['RESULT']['DATA']) {
underscoreJS.each(response['RESULT']['DATA'] , function(obj) {
model.setProperty(path + obj['TXTFL'],obj['VALUE']);
var oControl ;
if(obj['ERROR'] != '') {
oControl = underscoreJS.find(fields,{
'FLDNAME' : obj['FLDNAME'],
'TABNAME' : obj['TABNAME']});
if(oControl){
oControl['CONTROL'].setValueState(sap.ui.core.ValueState.Error);
oControl['CONTROL'].setValueStateText(obj['MESSAGE']);
oController.handleCheckFieldsMessages(
obj['MESSAGE'],
sap.ui.core.MessageType.Error,
oControl['CONTROL'].getId() + "/value" );
}
error = true;
}else{
oControl = underscoreJS.find(fields,{
'FLDNAME' : obj['FLDNAME'],
'TABNAME' : obj['TABNAME']});
if(oControl){
oControl['CONTROL'].setValueState(sap.ui.core.ValueState.None);
oControl['CONTROL'].setValueStateText("");
oController.handleCheckFieldsMessages(
"",
"",
oControl['CONTROL'].getId() + "/value" );
}
}
});
}
}
/
Multiple Change Event Issue Changes /
if(error || errorExist)
deffered.resolve(false);
else
deffered.resolve(true);
});
/
Multiple Change Event Issue Changes */

  }else{
    if(errorExist)
      deffered.resolve(false);
    else
      deffered.resolve(true);
  }
  return deffered.promise();
},
handleQuantityConversion : function(oEvent) {
  var oController = this;
  var source = oEvent.getSource();
  oController.performQuantityConversion(source);
},
performQuantityConversion : function(source) {
  var oController = this;
  var newValue = source.getValue();
  // check value

  var deffered = $.Deferred();

  if (oController.checkQuantityValue(newValue)){
    // set state
    source.setValueState(sap.ui.core.ValueState.None);
    source.setValueStateText("");
    oController.handleCheckFieldsMessages(
        "",
        "",
        source.getId() + "/value" );
    var oBinding = source.getBinding("value");
    var model = oBinding.getModel();
    var unitPath = source.data("unitPath");
    var unit = model.getProperty(unitPath);

    if(unit)
      unit = '';

    //check unit

// if(unit) {
/* Multiple Change Event Issue Changes /
// var deffered = $.Deferred();
var path;
if(oBinding.getContext()) {
path = oBinding.getContext().getPath() + "/" + oBinding.getPath();
}else{
path = oBinding.getPath();
}
var fieldname = source.data("FLDNAME");
var tablename = source.data("TABNAME");
var quantity = [{ 'FLDNAME' : fieldname, 'TABNAME' : tablename , 'VALUE' : newValue }];
var data = [];
var params = [];
params.push({ NAME : "UNIT" , VALUE : unit });
data.push({
"DATA": quantity,
"PARAMS": params,
"DTAREA": "CONVERSION",
"EVENT": ""
});
$.when(this.callServer({
data: data,
reqType: vui5.cons.reqType.post,
NoLoader : true
})).then(function(result) {
var error = false;
if(result){
var response = underscoreJS.find(result,{DTAREA: "CONVERSION"});
if(response && response['RESULT']['DATA']) {
underscoreJS.each(response['RESULT']['DATA'] , function(obj) {
model.setProperty(path,obj['VALUE']);
if(obj['ERROR'] != '') {
source.setValueState(sap.ui.core.ValueState.Error);
source.setValueStateText(obj['MESSAGE']);
oController.handleCheckFieldsMessages(
obj['MESSAGE'],
sap.ui.core.MessageType.Error,
source.getId() + "/value" );
error = true;
}else{
source.setValueState(sap.ui.core.ValueState.None);
source.setValueStateText("");
oController.handleCheckFieldsMessages(
"",
"",
source.getId() + "/value" );
}
});
}
}
/
Multiple Change Event Issue Changes /
if(error)
deffered.resolve(false);
else
deffered.resolve(true);
});
/
Multiple Change Event Issue Changes */

// }
}else{
source.setValueState(sap.ui.core.ValueState.Error);
var text;
if(source.getParent().getAggregation("label")){
text = source.getParent().getAggregation("label").getText();
}else if(source.getParent().getTitle()){
text = source.getParent().getTitle();
text = text.substr(5,text.length);
}else{
if(source.data("sap-ui-colid")){
// non responsive table
text = sap.ui.getCore().byId(source.data("sap-ui-colid")).getAggregation("label").getText();
}else{
// m.Table
/QA Issue 7022 Changes - START/
var ariaLabelledBy = source.getAriaLabelledBy();
for(var i=0; i < ariaLabelledBy.length ; i++){
var textElement = sap.ui.getCore().byId(ariaLabelledBy[i]);
if(textElement){
text = textElement.getText();
break;
}
}
// text = sap.ui.getCore().byId(source.getAriaLabelledBy()[0]).getText();
/QA Issue 7022 Changes - END/
}
}
// var text = source.getParent().getAggregation("label").getText();
var bundle = source.getModel("i18n").getResourceBundle();
var errorText = bundle.getText("EnterValid",[text]);
source.setValueStateText(errorText);
oController.handleCheckFieldsMessages(
errorText,
sap.ui.core.MessageType.Error,
source.getId() + "/value" );
deffered.resolve(false);
}
return deffered.promise();
},
checkQuantityValue : function(value) {
var regex;
var oController = this;
var mainModel = this.getModel(vui5.modelName);
var decimalNotation = mainModel.getProperty("/LOGIN/DECIMALNOTATION");

  value = value.trim();
  if(value){
    /*QA Issue 7022 Changes*/
    regex = oController.getDecimalNotationRegex(decimalNotation);

    /*QA Issue 7022 Changes*/
    return regex.test(value);
  }else{
    return false;
  }
},
handleUnitConversion : function(oEvent,fields,path,unitPath) {
  var oController = this;
  var source = oEvent.getSource();
  oController.performUnitConversion(source,fields,path,unitPath);
},
performUnitConversion : function(source,fields,path,unitPath) {
  var oController = this;
  var model;
  if(source.getBinding("value")){
    model = source.getBinding("value").getModel();
  }else if(source.getBinding("selectedKey")){
    model = source.getBinding("selectedKey").getModel();
  }
  var unit = model.getProperty(unitPath);
  var quantity = [];

  var deffered = $.Deferred();

  var errorExist = false;

  underscoreJS.each(fields,function(obj) {
    var quantityValue = model.getProperty(path + obj['TXTFL']);
    if (oController.checkQuantityValue(quantityValue)){
      quantity.push({
        'TABNAME' : obj['TABNAME'] ,
        'FLDNAME' : obj['FLDNAME'] ,
        'VALUE'  : quantityValue,
        'TXTFL' : obj['TXTFL']});
    }else{
      errorExist = true;
      obj['CONTROL'].setValueState(sap.ui.core.ValueState.Error);
      var text;
      if(obj['CONTROL'].getParent().getAggregation("label")){
        text = obj['CONTROL'].getParent().getAggregation("label").getText();
      }else if(obj['CONTROL'].getParent().getTitle()){
        text = obj['CONTROL'].getParent().getTitle();
        text = text.substr(5,text.length);
      }else{
        if(obj['CONTROL'].data("sap-ui-colid")){
          // non responsive table
          text = sap.ui.getCore().byId(obj['CONTROL'].data("sap-ui-colid")).getAggregation("label").getText();
        }else{
          // m.Table
          /*QA Issue 7022 Changes - START*/
          var ariaLabelledBy = obj['CONTROL'].getAriaLabelledBy();
          for(var i=0; i < ariaLabelledBy.length ; i++){
            var textElement = sap.ui.getCore().byId(ariaLabelledBy[i]);
            if(textElement){
              text = textElement.getText();
              break;
            }
          }

// text = sap.ui.getCore().byId(obj['CONTROL'].getAriaLabelledBy()[0]).getText();
/QA Issue 7022 Changes - END/
}
}
// var text = obj['CONTROL'].getParent().getAggregation("label").getText();
var bundle = obj['CONTROL'].getModel("i18n").getResourceBundle();
var errorText = bundle.getText("EnterValid",[text]);
obj['CONTROL'].setValueStateText(errorText);
oController.handleCheckFieldsMessages(
errorText,
sap.ui.core.MessageType.Error,
obj['CONTROL'].getId() + "/value" );
}
});
if(unit && quantity.length > 0) {
/* Multiple Change Event Issue Changes /
// var deffered = $.Deferred();
var data = [];
var params = [];
params.push({ NAME : "UNIT" , VALUE : unit });
data.push({
"DATA": quantity,
"PARAMS": params,
"DTAREA": "CONVERSION",
"EVENT": ""
});
$.when(this.callServer({
data: data,
reqType: vui5.cons.reqType.post,
NoLoader : true
})).then(function(result) {
var error = false;
if(result){
var response = underscoreJS.find(result,{DTAREA: "CONVERSION"});
if(response && response['RESULT']['DATA']) {
underscoreJS.each(response['RESULT']['DATA'] , function(obj) {
model.setProperty(path + obj['TXTFL'],obj['VALUE']);
var oControl ;
if(obj['ERROR'] != '') {
oControl = underscoreJS.find(fields,{
'FLDNAME' : obj['FLDNAME'],
'TABNAME' : obj['TABNAME']});
if(oControl){
oControl['CONTROL'].setValueState(sap.ui.core.ValueState.Error);
oControl['CONTROL'].setValueStateText(obj['MESSAGE']);
oController.handleCheckFieldsMessages(
obj['MESSAGE'],
sap.ui.core.MessageType.Error,
oControl['CONTROL'].getId() + "/value" );
}
error = true;
}else{
oControl = underscoreJS.find(fields,{
'FLDNAME' : obj['FLDNAME'],
'TABNAME' : obj['TABNAME']});
if(oControl){
oControl['CONTROL'].setValueState(sap.ui.core.ValueState.None);
oControl['CONTROL'].setValueStateText("");
oController.handleCheckFieldsMessages(
"",
"",
oControl['CONTROL'].getId() + "/value" );
}
}
});
}
}
/
Multiple Change Event Issue Changes /
if(error || errorExist)
deffered.resolve(false);
else
deffered.resolve(true);
});
/
Multiple Change Event Issue Changes */

  }else{
    if(errorExist)
      deffered.resolve(false);
    else
      deffered.resolve(true);
  }
  return deffered.promise();
},
showPanelContent: function (key) {
  var oController = this;
  var panelObj;
  var mainModel = oController.getModel(global.vui5.modelName);
  var section = oController.getSectionBy('SECTN', key);
  var model = oController.getModel(oController.modelName);
  var path = oController._getPath(true);
  var sections = model.getProperty(path);
  var sectionID = section['SECTN'];
  var index = underscoreJS.indexOf(sections, section);

  if (oController.getPanel) {
    panelObj = oController.getPanel();
  }
  oController.sectionData = section;
  /* Prepare section config */
  if (oController.sectionConfig[sectionID] === undefined) {
    oController.sectionConfig[sectionID] = {
        keyField: section['KEYS'] || global.vui5.rowID,
        fields: {},
        metaDataLoaded: false
    };
  }
  oController.sectionConfig[sectionID]['attributes'] = oController._flattenAttributes(section['ATTRB']);
  underscoreJS.each(section['FIELDS'], function (fld) {
    oController.sectionConfig[sectionID]['fields'][fld['FLDNAME']] = {
        attributes: oController._flattenAttributes(fld['ATTRB'])
    }
  });

  oController._processCommonSections({
    section: section
  });

  model.setProperty("/SECCFG", oController.sectionConfig);

  switch (section['DAPPT']) {
  case vui5.cons.propertyType.snappingHeader:
    oController._processSnappingHeader({
      section: section,
      index: index
    });
    break;
  case vui5.cons.propertyType.treeTable:
    oController._processTreeTable({
      section: section,
      index: index
    });
    break;
  case global.vui5.cons.propertyType.form:
    oController._processForm({
      section: section,
      index: index
    });
    break;
  case global.vui5.cons.propertyType.table:
    oController._processTable({
      section: section,
      index: index
    });
    break;
  case global.vui5.cons.propertyType.selections:
    oController._processSelections({
      section: section,
      index: index
    });
    break;
  case global.vui5.cons.propertyType.variant:
    oController.sectionRef[sectionID] = new sap.m.Button({
      visible: false
    });
    break;
  case global.vui5.cons.propertyType.postings:
    oController._processPostings({
      section: section,
      index: index
    })
    break;
  case global.vui5.cons.propertyType.tradecalendar:
    oController._processCalendar({
      section: section,
      index: index
    })
    break;
  case global.vui5.cons.propertyType.processFlow:
    oController._processProcessFlow({
      section: section,
      index: index
    })
    break;
  case global.vui5.cons.propertyType.status:
    oController._processStatus({
      section: section,
      index: index
    })
    break;
  case global.vui5.cons.propertyType.partners:
    oController._processPartners({
      section: section,
      index: index
    })
    break;
  case global.vui5.cons.propertyType.texts:
    oController._processTexts({
      section: section,
      index: index
    })
    break;
  case global.vui5.cons.propertyType.reportingView:
  case global.vui5.cons.propertyType.summary:
    oController._processSummary({
      section: section,
      index: index
    })
    break;
  case global.vui5.cons.propertyType.evaluationForm:
    oController._processEvaluationForm({
      section: section,
      index: index
    })
    break;
  case global.vui5.cons.propertyType.notes:
    oController._processNotes({
      section: section,
      index: index
    });
    break;

  case global.vui5.cons.propertyType.attachments:
    oController._processAttachments({
      section: section,
      index: index
    });
    break;
  case global.vui5.cons.propertyType.objectheader:
    oController._processObjectHeader({
      section: section,
      index: index
    })
    break;
  case global.vui5.cons.propertyType.tilesGroup:
    oController._processTilesGroup({
      section: section,
      index: index
    });
    break;
  case global.vui5.cons.propertyType.attributes:
    oController._processAttributes({
      section: section,
      index: index
    })
    break;
  case global.vui5.cons.propertyType.sets:
    oController._processSets({
      section: section,
      index: index
    });
    break;
  case global.vui5.cons.propertyType.tree:
    oController._processTree({
      section: section,
      index: index
    });
    break;
  case global.vui5.cons.propertyType.address:
    oController._processAddress({
      section: section,
      index: index
    })
    break;
  case global.vui5.cons.propertyType.treeTable:
    oController._processTreeTable({
      section: section,
      index: index
    })
    break;
  case global.vui5.cons.propertyType.list:
    oController._processList({
      section: section,
      index: index
    })
    break;
  case global.vui5.cons.propertyType.HTML:
    oController._processHtml({
      section: section,
      index: index
    })
    break;
  case global.vui5.cons.propertyType.planningGrid:
    oController._processPlanningGrid({
      section: section,
      index: index
    });
    break;
  case global.vui5.cons.propertyType.pricingGrid:
    oController._processPricingGrid({
      section: section,
      index: index
    });
    break;

  case global.vui5.cons.propertyType.statementEditor:
    oController._processStatementEditor({
      section: section,
      index: index
    });
    break;
  case "MF":
    oController._processMatchForm({
      section: section,
      index: index
    })
    break;
  }
  if (section['DAPPT'] === global.vui5.cons.propertyType.table || section['DAPPT'] === global.vui5.cons.propertyType.partners ||
      section['DAPPT'] === global.vui5.cons.propertyType.treeTable) {
    oController.getControlTitleVisibility(oController.sectionRef[section['SECTN']], section);
  }
  else if (section['DAPPT'] === global.vui5.cons.propertyType.list) {
    oController.sectionRef[section['SECTN']].getAggregation("_getListControl").setHeaderText("");
  }
  else if (section['DAPPT'] === global.vui5.cons.propertyType.attachments) {
    //oController.sectionRef[section['SECTN']].getAggregation("_uploadCollection").setNumberOfAttachmentsText(null);
  }

},
_processSelections: function (cfg) {
  var oController = this, section, index, sectionID, dataArea, sectionPath, dataPath, sectionModelPath,
  sectionConfig, variantSectionConfig, variantSection, callback;
  var model = oController.getModel(oController.modelName);

  section = cfg.section;
  index = cfg.index;
  sectionID = section['SECTN'];
  dataArea = section['DATAR'];
  sectionPath = oController._getPath(true);
  dataPath = oController._getPath();
  sectionModelPath = sectionPath + index;
  sectionConfig = oController.sectionConfig[sectionID];
  variantSection = oController.getSectionBy("DAPPT", global.vui5.cons.propertyType.variant) || {
  };
  variantSectionConfig = oController.sectionConfig[variantSection['SECTN']] || {
  };
  /* Process Attributes */
  if (sectionConfig.attributes[global.vui5.cons.attributes.onSearch]) {
    sectionConfig.onSearchAction = underscoreJS.findWhere(cfg.section['FUNC'], {
      FNCNM: sectionConfig.attributes[global.vui5.cons.attributes.onSearch]
    });
  }

  if (!underscoreJS.isEmpty(variantSectionConfig)) {
    if (variantSectionConfig.attributes[global.vui5.cons.attributes.onVariantMaintain]) {
      variantSectionConfig.onVariantMaintain = underscoreJS.findWhere(variantSection['FUNC'], {
        FNCNM: variantSectionConfig.attributes[global.vui5.cons.attributes.onVariantMaintain]
      });
    }


    if (variantSectionConfig && variantSectionConfig.attributes[global.vui5.cons.attributes.onVariantSelect]) {
      variantSectionConfig.onVariantSelect = underscoreJS.findWhere(variantSection['FUNC'], {
        FNCNM: variantSectionConfig.attributes[global.vui5.cons.attributes.onVariantSelect]
      });
    }
  }

  /* Prepare Element */
  jQuery.sap.require("bdoUtilsPath/Controls/BdoSelections");
  var selRef = oController.sectionRef[sectionID] = new bdo.utility.selections({
    controller: oController,
    dataAreaID: section['DATAR'],
    sectionPath: sectionModelPath,
    dataPath: "/SRCH_DATA/",
    fieldsPath: sectionModelPath + "/FIELDS/",
    modelName: oController.modelName,
    dropdownModel: global.vui5.modelName,
    variantDataPath: dataPath + variantSection['DATAR'] + "/",
    showVariants: variantSectionConfig.onVariantMaintain !== undefined,
    goVisibleProperty: sectionConfig.onSearchAction !== undefined,
    showFilterConfiguration: oController.getBindingExpression("showFilterConfiguration", section, index),
    selectedVariant: "/SECCFG/" + variantSection['SECTN'] + "/attributes/" + global.vui5.cons.attributes.selectedVariant,
    visible: oController.getBindingExpression('visible', section, index),
    search: [oController.onSearchAction,oController],
    variantSave: function (oEvent) {
      callback = oEvent.getParameter("callback");
      oController.processVariantAction(sectionID, variantSectionConfig.onVariantMaintain).then(function () {
        if (callback && callback instanceof Function) {
          callback();
        }
      });
    },
    fieldEvent: oController.preProcessFieldEvent.bind(oController, sectionID),
    onValueHelpRequest: oController.onValueHelpRequest.bind(oController, sectionID),
    variantSelect: function (evt) {
      callback = evt.getParameter("callback");
      oController.processVariantAction(sectionID, variantSectionConfig.onVariantSelect, evt.getParameter('record')).then(function () {
        if (callback && callback instanceof Function) {
          callback();
        }
      });
    }
  });
  oController.sectionRef[sectionID].setModel(model, oController.modelName);
  oController.sectionRef[sectionID].selectionInfocusSet(global.vui5.cons.applnObject, global.vui5.cons.application);

  selRef.processOnInputChange = function (oEvent) {
    return oController.processOnInputChange(sectionID, oEvent);
  };

},
processVariantAction: function(sectionID, actionObject, rowData, urlParams){

// var filterBarModel = this.getModel("VUI_FILTERBAR");
var oController = this,promise, objDefer = $.Deferred();;
var oFilter = oController.sectionRef[sectionID].oFilter;
var model = oController.getModel(oController.modelName);
var variantDataPath = oFilter.getVariantDataPath();
var variantData = model.getProperty(variantDataPath);
switch(actionObject['FNCNM']){
case "VARMNT":
var lt_rsparams = oController.prepareVariantsData(oFilter);
var inserted = underscoreJS.find(variantData,{'UPDKZ': 'I'});
var data = [];
var params = [];
if(inserted){
var insertingData = true;
var headerData = JSON.parse(JSON.stringify(inserted));
if(headerData){
delete headerData.FLDPPTY;
headerData['SRCHP'] = vui5.uiProfile;
headerData['UPDKZ'] = '';
}

      var saveData = {};
      saveData.HEADER = headerData;
      saveData.SELECTIONS = lt_rsparams;
      saveData.FIELD_PROPERTY = variantData[0].FLDPPTY;

      if(headerData['OVRSL']){
        params.push({"NAME": "OVERWRITE","VALUE": headerData['OVRSL']});
        params.push({"NAME": "OVERWRITE_SEL","VALUE": headerData['OVRSL']});
      }
      /*Global Variant Changes-START*/
      if(headerData['SHRVR']){
        params.push({"NAME": "GLOBAL", "VALUE": headerData['SHRVR']});
      }
      params.push({ "NAME": "OBJTP", "VALUE": oFilter.getObjectType() });
      params.push({ "NAME": "APPLN", "VALUE": oFilter.getApplication() });
      params.push({ "NAME": "SRCHP", "VALUE": vui5.uiProfile });

      data.push({
        "DATA": saveData,
        "PARAMS": params,
        "DTAREA": "VARIANT",
        "EVENT": "SAVE"
      });
    }else{
      var deletedItem = underscoreJS.where(variantData,{'UPDKZ': 'D'});
      if(deletedItem){
        data.push({
          "DATA": deletedItem,
          "PARAMS": [],
          "DTAREA": "VARIANT",
          "EVENT": "DELETE"
        });
      }
      variantData = _.reject(variantData,function(obj){
        return (obj['UPDKZ'] && obj['UPDKZ'] == 'D');
      });
      var defaultVariantData = underscoreJS.find(variantData,{'DEFLT': 'X'});
      var defaultVariant,markStandardAsDefault;
      if(defaultVariantData){
        defaultVariant = defaultVariantData['VARID'];
      }else{
        defaultVariant = "*standard*";
        markStandardAsDefault = 'X';
      }
      params = [];
      params.push({"NAME" : "OVERWRITE" , "VALUE" : "X"});
      params.push({"NAME" : "DEFAULT", "VALUE" : defaultVariant});

      /*Global Variant Changes-START*/
      params.push({ "NAME": "OBJTP", "VALUE": oFilter.getObjectType() });
      params.push({ "NAME": "APPLN", "VALUE": oFilter.getApplication() });
      params.push({ "NAME": "SRCHP", "VALUE": vui5.uiProfile });
      if(markStandardAsDefault){
        params.push({"NAME" : "MARK_STANDARD_DEFAULT" , "VALUE" : markStandardAsDefault});
      }
      /*Global Variant Changes-END*/

      var overwriteItem = underscoreJS.where(variantData,{'UPDKZ': 'U'});
      if(overwriteItem){
        underscoreJS.each(overwriteItem,function(obj){
          obj['UPDKZ'] = '';
        });
      }else{
        overwriteItem = [];
      }
      data.push({
        "DATA": overwriteItem,
        "PARAMS": params,
        "DTAREA": "VARIANT",
        "EVENT": "SAVE"
      });
    }

    params = [];
    params.push({ "NAME": "OBJTP", "VALUE": oFilter.getObjectType() });
    params.push({ "NAME": "APPLN", "VALUE": oFilter.getApplication() });
    params.push({ "NAME": "SRCHP", "VALUE": vui5.uiProfile });
    data.push({
      "DATA": [],
      "PARAMS": params,
      "DTAREA": "VARIANT",
      "EVENT": "READ"
    });

    $.when(oController.callServer({
      data: data,
      reqType: vui5.cons.reqType.post
    })).then(function(result){
      if(result){
        oController._readVariantData(result,oFilter);
        if(insertingData){
          model.setProperty(oFilter.getSelectedVariant(),headerData['VARID']);
          oFilter._oVariantManagement.setInitialSelectionKey(headerData['VARID']);
        }
      }
      objDefer.resolve();
    });

    break;
  case "VARSEL":
    if(rowData.VARID){
      model.setProperty(oFilter.getSelectedVariant(),rowData.VARID);
      var variant = oFilter._oVariantManagement._oVariantSet.getVariant(rowData.VARID);
      if(variant){
        var search_data = commonUtils.selectionsFill(rowData['RSPARAMS'], model.getProperty("/SRCH_FIELDS"));
        model.setProperty("/SRCH_DATA", search_data);
        oFilter._oVariantManagement._applyVariant(variant);
      }
    }else{
      var search_data = JSON.parse(JSON.stringify(model.getProperty("/STANDARD_SRCH_DATA")));
      model.setProperty("/SRCH_DATA", search_data);
    }
    objDefer.resolve();
    break;
  };
  return objDefer.promise();
},
prepareVariantsData: function(oFilter){
  var oController = this;
  var model = oController.getModel(oController.modelName);
  var selections =  model.getProperty(oFilter.getSearchDataPath());

  var lt_selections = [];

  for(var i in selections){
          for(var j=0 ; j < selections[i].length ; j++){

              var object = {};
              object = underscoreJS.clone(selections[i][j]);

              if(object['LOW']){

                  if (object['FIELDNAME'] && object['FIELDNAME'] != '') {
                      object['SHLPFIELD'] = object['SELNAME'] = object['FIELDNAME'];
                  }else if(object['SHLPFIELD'] && object['SHLPFIELD'] != '') {
                      object['SELNAME'] = object['FIELDNAME'] = object['SHLPFIELD'];
                  }else if(object['SELNAME'] && object['SELNAME'] != '') {
                      object['SHLPFIELD'] = object['FIELDNAME'] = object['SELNAME'];
                  }
                  if(object.OPTION == ''){
                    if(object.LOW == '*'){
                      object.OPTION = 'CP';
                    }
                    else{
                      object.OPTION = 'EQ';
                    }
                      object.SIGN = 'I';
                  }
                  if(object.OPTION == "Contains") {
                      object.OPTION = 'CP';
                  }else if(object.OPTION == "StartsWith"){
                      object.OPTION = 'SW';
                  }else if(object.OPTION == "EndsWith"){
                      object.OPTION = 'EW';
                  }

                  if(!object['SHLPNAME'])
                      object['SHLPNAME'] = '';

                  if(underscoreJS.isArray(object['LOW'])){
                      for( var lowIndex = 0; lowIndex < object['LOW'].length ; lowIndex++){
                          var newObject = underscoreJS.clone(object);
                          newObject['LOW'] = object['LOW'][lowIndex];
                          lt_selections.push(newObject);
                      }
                  }else{
                      lt_selections.push(object);
                  }
              }
          }
      }
      return lt_selections;
},
_setVariantData: function(result,sectionID){
	var oController = this;
	var oFilter = oController.sectionRef[sectionID].oFilter;
	oFilter.fireInitialise();

	oController._readVariantData(result,oFilter);

	var response = _.findWhere(result, { DTAREA : "VARIANT" , EVENT: "READ"});
	if(response['RESULT']['DATA']) {
		var setStandardAsDefault = response['RESULT']['SET_STANDARD_AS_DEFAULT'];
		if(setStandardAsDefault == '') {
			var defaultVariant =_.find(response['RESULT']['DATA'],{'DEFLT' : 'X'});
			if(defaultVariant) {
				oFilter.sCurrentVariantKey = defaultVariant['VARID'];
				oFilter._oVariantManagement.setDefaultVariantKey(defaultVariant['VARID']);
				oFilter._oVariantManagement._setSelectionByKey(defaultVariant['VARID']);
				oFilter._oVariantManagement.fireSelect({key : defaultVariant['VARID'] });
			}
		}
	}
},
  _readVariantData: function(result,oFilter){
    var oController = this;
    var model = oController.getModel(oController.modelName);
      if(result){
          var response = underscoreJS.findWhere(result, { DTAREA : "VARIANT" , EVENT: "READ"});
          if(response['RESULT']['DATA']){

            if(vui5.fillDefaultSelections && vui5.donum){
              var search_fields = model.getProperty("/SRCH_FIELDS");
              var field = underscoreJS.find(search_fields,{"FLDNAME":"DONUM"});
              if(field){
                underscoreJS.each(response['RESULT']['DATA'],function(obj){
                  obj["RSPARAMS"] = underscoreJS.reject(obj["RSPARAMS"],{SELNAME:field["FLDNAME"],TABNAME:field["TABNAME"]});
                  obj["RSPARAMS"].push({
                    HIGH:"",
                    KIND:"",
                    LOW: vui5.donum,
                    OPTION:"EQ",
                    SELNAME:field["FLDNAME"],
                    SIGN:"I",
                    TABNAME:field["TABNAME"]
                  });
                });
              }
            }

            model.setProperty(oFilter.getVariantDataPath(), response['RESULT']['DATA']);

              oFilter._oVariantManagement.removeAllVariantItems();

              underscoreJS.each(response['RESULT']['DATA'],function(object){
                  var executeOnSelect = false;
                  if(object['EXESL'] == 'X')
                      executeOnSelect = true;

                  /*Global Variant Changes-START*/
                  var global = true;
                  if(object['UNAME'] != '')
                      global = false;
                  /*Global Variant Changes-END*/


                  var variantItem = new VariantItem({
                      text : object['DESCR'],
                      key : object['VARID'],
                      executeOnSelection : executeOnSelect,
                      /*Global Variant Changes-START*/
                      global : global
                      /*Global Variant Changes-END*/
                  });
                  oFilter._oVariantManagement.addVariantItem(variantItem);

                  var fieldProperty = object['FLDPPTY'];
                  var filterbar = [];
                  for(var i=0; i < fieldProperty.length ; i++){
                      var visible;
                      if(fieldProperty[i].VISIBLE == 'X')
                          visible = true;
                      else
                          visible = false;

                      filterbar.push({
                          group:fieldProperty[i].GROUP,
                          name:fieldProperty[i].FLDNAME,
                          partOfCurrentVariant:true,
                          visibleInFilterBar:visible
                      });
                  }
                  var oVariant = oFilter._createVariantObject(
                          object['VARID'],
                          object['DESCR'],
                          object['RSPARAMS'],
                          filterbar,
                          executeOnSelect
                  );
                  oFilter.mMap[object['VARID']] = oVariant;
              });

              var setStandardAsDefault = response['RESULT']['SET_STANDARD_AS_DEFAULT'];

              if(setStandardAsDefault == '') {
                  var defaultVariant =underscoreJS.find(response['RESULT']['DATA'],{'DEFLT' : 'X'});
                  if(defaultVariant) {
                    oFilter.sCurrentVariantKey = defaultVariant['VARID'];
                    oFilter._oVariantManagement.setDefaultVariantKey(defaultVariant['VARID']);
                  }
              }
          }
      }
  },
_processMatchForm: function(cfg) {
  var oController = this, section, index, sectionID, dataArea;
  var model = oController.getCurrentModel(), callBack;
  var mainModel = oController.getModel(global.vui5.modelName);
  var enableSearchAndReplace, enableSetValues, oMode, oListItemType, tableRef, maxItems, hasDrillDown, sectionModelPath, sectionModelFullPath, sectionConfig;
  section = cfg.section;
  index = cfg.index;
  sectionID = section['SECTN'];
  dataArea = section['DATAR'];
  var sectionPath = oController._getPath(true);
  var dataPath = oController._getPath();
  sectionModelPath = sectionPath + index;
  sectionModelFullPath = oController.modelName + ">" + sectionModelPath;
  sectionConfig = oController.sectionConfig[sectionID];

  var dmode = mainModel.getProperty("/DOCUMENT_MODE");
  oController.form_section = section;
  oController.sectionFieldPath = "/SECTN/" + index + "/FIELDS/" ;
  oController.sectionDataPath = "/FORMDATA/";
  oController.dataArea = section['DATAR'];

  if(dmode != global.vui5.cons.mode.display && section['DISOL'] == ''){
    oController.sectionEditable = true;
  }else{
    oController.sectionEditable = false;
  }

  jQuery.sap.require("bdoUtilsPath/Fragments/HorizontalForm");
  oController.matchForm = sap.ui.jsfragment(vui5.utilitiesDomain + ".fragments.HorizontalForm",oController);
  jQuery.sap.syncStyleClass(oController.getOwnerComponent().getContentDensityClass(),
      oController.getView(), oController.matchForm);

  oController.sectionRef[section['SECTN']] = new sap.ui.layout.VerticalLayout({
    width : "100%"
  });
  oController.sectionRef[section['SECTN']].addContent(oController.matchForm);

  /********************************** Preparing table for form **********************************************/
  var sections = model.getProperty(sectionPath);
  var tableSection = _.find(sections,{"DAPPT": global.vui5.cons.propertyType.table});
  var tableIndex = _.indexOf(sections, tableSection);
  var tableSectionID = tableSection['SECTN'];
  var tableSectionModelPath = sectionPath + tableIndex;
  var tableSectionModelFullPath = oController.modelName + ">" + tableSectionModelPath;
  var tableSectionConfig = oController.sectionConfig[tableSectionID];

  enableSearchAndReplace = !!tableSectionConfig.attributes[global.vui5.cons.attributes.enableSearchAndReplace];
  enableSetValues = !!tableSectionConfig.attributes[global.vui5.cons.attributes.enableSetValues];
  hasDrillDown = !!tableSectionConfig.onDrillDownAction;
  oListItemType = hasDrillDown ? sap.m.ListType.Navigation : sap.m.ListType.Active;
  var tableDatar = "MATCH_RESULT";
  jQuery.sap.require("bdoUtilsPath/Controls/BdoResponsiveTable");
  oController.matchTable = new bdo.utility.BdoResponsiveTable({
    sectionID: tableSection['SECTN'],
    controller: oController,
    modelName: oController.modelName,
    fieldPath: tableSectionModelPath + "/FIELDS/",
    dataPath: dataPath + tableDatar + "/",
    dataAreaPath: tableSectionModelPath + "/DATAR/",
    layoutDataPath: dataPath + tableDatar + "/",
    variantDataPath: dataPath + tableDatar + global.vui5.cons.nodeName.variant + "/",
    selectedVariant: "/SECCFG/" + tableSection['SECTN'] + "/attributes/" + global.vui5.cons.attributes.selectedVariant,
    totalNumberOfRows: "/MATCH_COUNT",
    showTitle: true,
    growingScrollToLoad: true,
    rememberSelections: false,
    listItemType: oListItemType,
    enableSearchAndReplace: enableSearchAndReplace,
    enableSetValues: enableSetValues,
    uiProfile: oController.getProfileInfo()['UIPRF'],
    fullScreen: oController.getBindingExpression("fullScreen", tableSection, tableIndex),
    backendSortFilter: oController.getBindingExpression("backendSortFilter", tableSection, tableIndex),
    handle: oController.getBindingExpression("handle", tableSection, tableIndex),
    visible: oController.getBindingExpression('visible', tableSection, tableIndex),
    title: section['DESCR'] + " (" + "{" + oController.modelName + ">/MATCH_COUNT" + "}" + ")",
    editable: oController.getBindingExpression("editable", tableSection, tableIndex),
    enableLocalSearch: oController.getBindingExpression("enableLocalSearch", tableSection, tableIndex),
    enablePersonalization: oController.getBindingExpression("enablePersonalization", tableSection, tableIndex),
    enablePersonalization: true,
    pagingType: oController.getBindingExpression("pageType", tableSection, tableIndex),
    pagingThreshold: oController.getBindingExpression("pageSize", tableSection, tableIndex),
    onValueHelpRequest: oController.onValueHelpRequest.bind(oController, tableSectionID),
    onItemSelect : [ oController.onItemNavigation, oController ],
    onFullScreen: function (oEvent) {
      oController.processFullScreen(tableSectionID, oEvent.getParameter("fullScreen"));
    },
    variantSelect: function (oEvent) {
      callBack = oEvent.getParameter("callBack");
      oController.processAction.call(oController, tableSectionID, tableSectionConfig.onVariantSelect, oEvent.getParameter("record")).then(function () {
        if (callBack && callBack instanceof Function) {
          callBack();
        }
      });
    },
    variantSave: function (oEvent) {
      callBack = oEvent.getParameter("callBack");
      oController.processAction.call(oController, tableSectionID, tableSectionConfig.onVariantMaintain, null, oEvent.getParameter("urlParams")).then(function () {
        if (callBack && callBack instanceof Function) {
          callBack();
        }
      });
    },
    layoutManage: function (oEvent) {
      callBack = oEvent.getParameter("callBack");
      oController.tableLayoutManage.call(oController, tableSectionID, tableSectionConfig.onLayoutManage).then(function () {
        if (callBack && callBack instanceof Function) {
          callBack();
        }
      });
    },
    onExport: function (oEvent) {
        var object = oEvent.getParameter('object');
        object['DARID'] = section['DARID'];
        callBack = oEvent.getParameter("callBack");
        oController.exportAllData.call(oController, sectionID, object).then(function () {
            if (callBack && callBack instanceof Function) {
                callBack();
            }
        });
    },
    pageChange: function (oEvent) {
      oController.processAction.call(oController, tableSectionID, tableSectionConfig.onPageChange, null, oEvent.getParameter("urlParams"));
    },
    onSetValues: function (oEvent) {
      callBack = oEvent.getParameter("callBack");
      oController.processAction.call(oController, tableSectionID, tableSectionConfig.onSetValues).then(function () {
        if (callBack && callBack instanceof Function) {
          callBack();
        }
      });
    },
    onSetValuesApply: function () {
      oController.processAction.call(oController, tableSectionID, tableSectionConfig.onSetValuesApply).then(function () {
        oController._setValuesAction = undefined;
      });

    }

  });

  if(tableSection['FLGRP'].length > 0)
  {
    oController.matchTable.addStyleClass('worklistTableRowHeight');
  }

  oController.matchTable.bindProperty("mode", {
    path: oController.modelName + ">/SECCFG/" + tableSection['SECTN'] + "/attributes/" + global.vui5.cons.attributes.rowSelection,
    formatter: function (rowSelection) {
      if(rowSelection == 'SINGLE_SELECT'){
        var mode = sap.m.ListMode.SingleSelectLeft;
      }else{
        var mode = rowSelection === 'X' ? sap.m.ListMode.MultiSelect : sap.m.ListMode.None;
      }
      if (mode === sap.m.ListMode.MultiSelect) {
        this.attachSelectionChange(function (evt) {
          // var record = evt.getParameter('listItem').getBindingContext(oController.modelName).getObject();
          oController.processAction.call(oController, tableSectionID, tableSectionConfig.onRowSelect, this.getSelectedRows())
        });
      }
      return mode;
    },
    mode: sap.ui.model.BindingMode.OneWay
  });
  oController.matchTable.addStyleClass("vuiTableBottomPadding");

  oController.setSectionTitle(tableSectionModelFullPath + "/DESCR", oController.modelName + ">/SECCFG/" + tableSection['SECTN'] + "/attributes/" + global.vui5.cons.attributes.maxItems, oController.sectionRef[tableSection['SECTN']],

tableSection['DAPPT']);

  oController.matchTable.processOnInputChange = function (oEvent) {
    return oController.processOnInputChange(tableSectionID, oEvent);
  };

  oController.matchTable.attachOnFieldClick(function (evt) {
    oController.preProcessFieldClickEvent(tableSectionID, evt);
  });

  oController.matchTable.preProcessFieldEvent = function (oEvent) {
    return oController.preProcessFieldEvent(tableSectionID, oEvent);
  };

  oController.matchTable.setModel(mainModel, global.vui5.modelName);
  oController.matchTable.setModel(oController.getModel("i18n"), "i18n");
  oController.matchTable.setModel(model, oController.modelName);

  oController.matchTable.prepareTable();
  oController.matchTable.setTriggeredDisplayed(false);

  oController._prepareToolBarContent(tableSectionID, model.getProperty(tableSectionModelPath + "/FUNC"));

  /********************************************************************************/

  oController.sectionRef[section['SECTN']].addContent(oController.matchTable);
},
_processTable: function (cfg) {
  var oController = this, section, index, sectionID, dataArea;
  var model = oController.getCurrentModel(), callBack;
  var mainModel = oController.getModel(global.vui5.modelName);
  var enableSearchAndReplace, enableSetValues, oMode, oListItemType, tableRef, maxItems, hasDrillDown, sectionModelPath, sectionModelFullPath, sectionConfig;
  section = cfg.section;
  index = cfg.index;
  sectionID = section['SECTN'];
  dataArea = section['DATAR'];
  var sectionPath = oController._getPath(true);
  var dataPath = oController._getPath();
  sectionModelPath = sectionPath + index;
  sectionModelFullPath = oController.modelName + ">" + sectionModelPath;
  sectionConfig = oController.sectionConfig[sectionID];

  if(!section["PGSIZ"] && sectionConfig.attributes[global.vui5.cons.attributes.pageSize]){
    section["PGSIZ"] = sectionConfig.attributes[global.vui5.cons.attributes.pageSize];
  }

  /* Process Attributes */
  enableSearchAndReplace = !!sectionConfig.attributes[global.vui5.cons.attributes.enableSearchAndReplace];
  enableSetValues = !!sectionConfig.attributes[global.vui5.cons.attributes.enableSetValues];
  hasDrillDown = !!sectionConfig.onDrillDownAction;
  oListItemType = hasDrillDown ? sap.m.ListType.Navigation : sap.m.ListType.Active;
  /* Prepare Element */

// if(!oController.sectionRef[section['SECTN']]){
if (section['TBTYP'] == global.vui5.cons.tableType.responsive) {
jQuery.sap.require("bdoUtilsPath/Controls/BdoResponsiveTable");
oController.sectionRef[section['SECTN']] = new bdo.utility.BdoResponsiveTable({
sectionID: section['SECTN'],
controller: oController,
modelName: oController.modelName,
fieldPath: sectionModelPath + "/FIELDS/",
dataPath: dataPath + section['DATAR'] + "/",
dataAreaPath: sectionModelPath + "/DATAR/",
// layoutDataPath: dataPath + section['DATAR'] + global.vui5.cons.nodeName.layout + "/",
layoutDataPath: dataPath + section['DATAR'] + "/",
variantDataPath: dataPath + section['DATAR'] + global.vui5.cons.nodeName.variant + "/",
selectedVariant: "/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.selectedVariant,
totalNumberOfRows: "/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.maxItems,
showTitle: true,
growingScrollToLoad: true,
rememberSelections: false,
listItemType: oListItemType,
enableSearchAndReplace: enableSearchAndReplace,
enableSetValues: enableSetValues,
uiProfile: oController.getProfileInfo()['UIPRF'],
fullScreen: oController.getBindingExpression("fullScreen", section, index),
backendSortFilter: oController.getBindingExpression("backendSortFilter", section, index),
handle: oController.getBindingExpression("handle", section, index),
visible: oController.getBindingExpression('visible', section, index),
title: oController.getBindingExpression("title",section, index),
editable: oController.getBindingExpression("editable", section, index),
enableLocalSearch: oController.getBindingExpression("enableLocalSearch", section, index),
enablePersonalization: oController.getBindingExpression("enablePersonalization", section, index),
enablePersonalization: true,
pagingType: oController.getBindingExpression("pageType", section, index),
pagingThreshold: oController.getBindingExpression("pageSize", section, index),
onValueHelpRequest: oController.onValueHelpRequest.bind(oController, sectionID),
onItemSelect : [oController.onItemNavigation, oController],
onRowButtonPressed : [oController.onRowButtonPressed, oController],
onFullScreen: function (oEvent) {
oController.processFullScreen(sectionID, oEvent.getParameter("fullScreen"));
},
variantSelect: function (oEvent) {
callBack = oEvent.getParameter("callBack");
oController.processAction.call(oController, sectionID, sectionConfig.onVariantSelect, oEvent.getParameter("record")).then(function () {
if (callBack && callBack instanceof Function) {
callBack();
}
});
},
variantSave: function (oEvent) {
callBack = oEvent.getParameter("callBack");
oController.processAction.call(oController, sectionID, sectionConfig.onVariantMaintain, null, oEvent.getParameter("urlParams")).then(function () {
if (callBack && callBack instanceof Function) {
callBack();
}
});
},
layoutManage: function (oEvent) {
callBack = oEvent.getParameter("callBack");
oController.tableLayoutManage.call(oController, sectionID, sectionConfig.onLayoutManage).then(function () {
if (callBack && callBack instanceof Function) {
callBack();
}
});
},
pageChange: function (oEvent) {
oController.processAction.call(oController, sectionID, sectionConfig.onPageChange, null, oEvent.getParameter("urlParams"));
},
onExport: function (oEvent) {
var object = oEvent.getParameter('object');
object['DARID'] = section['DARID'];
callBack = oEvent.getParameter("callBack");
oController.exportAllData.call(oController, sectionID, object).then(function () {
if (callBack && callBack instanceof Function) {
callBack();
}
});
},
onSetValues: function (oEvent) {
callBack = oEvent.getParameter("callBack");
oController.processAction.call(oController, sectionID, sectionConfig.onSetValues).then(function () {
if (callBack && callBack instanceof Function) {
callBack();
}
});
},
onSetValuesApply: function () {
oController.processAction.call(oController, sectionID, sectionConfig.onSetValuesApply).then(function () {
oController._setValuesAction = undefined;
});

      }

    });


    if(section['FLGRP'].length > 0)
    {
      oController.sectionRef[section['SECTN']].addStyleClass('worklistTableRowHeight');
    }

    oController.sectionRef[section['SECTN']].bindProperty("mode", {
      path: oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.rowSelection,
      formatter: function (rowSelection) {
        if(rowSelection == 'SINGLE_SELECT'){
          var mode = sap.m.ListMode.SingleSelectLeft;
        }else{
          var mode = rowSelection === 'X' ? sap.m.ListMode.MultiSelect : sap.m.ListMode.None;
        }
        if (mode === sap.m.ListMode.MultiSelect) {
          this.attachSelectionChange(function (evt) {
            // var record = evt.getParameter('listItem').getBindingContext(oController.modelName).getObject();
            oController.processAction.call(oController, sectionID, sectionConfig.onRowSelect, this.getSelectedRows())
          });
        }
        return mode;
      },
      mode: sap.ui.model.BindingMode.OneWay
    });
    oController.sectionRef[section['SECTN']].addStyleClass("vuiTableBottomPadding");
  } else {
    jQuery.sap.require("bdoUtilsPath/Controls/BdoNonResponsiveTable");
    oController.sectionRef[section['SECTN']] = new bdo.utility.BdoNonResponsiveTable({
      sectionID: section['SECTN'],
      controller: oController,
      modelName: oController.modelName,
      fieldPath: sectionModelPath + "/FIELDS/",
      dataPath: dataPath + section['DATAR'] + "/",
      dataAreaPath: sectionModelPath + "/DATAR/",

// layoutDataPath: dataPath + section['DATAR'] + global.vui5.cons.nodeName.layout + "/",
layoutDataPath: sectionModelPath,
variantDataPath: dataPath + section['DATAR'] + global.vui5.cons.nodeName.variant + "/",
selectedVariant: "/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.selectedVariant,
enableSearchAndReplace: enableSearchAndReplace,
enableSetValues: enableSetValues,
showTitle: true,
enableColumnFreeze: true,
enableCustomFilter: true,
fullScreen: oController.getBindingExpression("fullScreen", section, index),
backendSortFilter: oController.getBindingExpression("backendSortFilter", section, index),
// pagingType should be set first
pagingType: oController.getBindingExpression("pageType", section, index),
numberOfPages: oController.getBindingExpression("totalNumberOfPages", section, index),
// title: oController.getBindingExpression("title",
// section, index),
pageSize: oController.getBindingExpression("pageSize", section, index),
enablePersonalization: oController.getBindingExpression("enablePersonalization", section, index),
handle: oController.getBindingExpression('handle', section, index),
visible: oController.getBindingExpression('visible', section, index),
// editable: oController.getBindingExpression("editable", section, index),
editable:"{= ${" + vui5.modelName + ">/DOCUMENT_MODE} === 'V' }",
enableLocalSearch: oController.getBindingExpression("enableLocalSearch", section, index),
// BDOAPP changes
hideDetailButton: false,
onDetailButton : [oController.onNRItemNavigation,oController],
hideBulkEditButton : false,
onBulkEditButton : [oController.onBulkEdit,oController],
cellClick : [oController.onPopover,oController],
onFieldClick : [oController.onPopover,oController],
onFullScreen: function (oEvent) {
oController.processFullScreen(sectionID, oEvent.getParameter("fullScreen"));
},
onValueHelpRequest: oController.onValueHelpRequest.bind(oController, sectionID), variantSelect: function (oEvent) {
callBack = oEvent.getParameter("callBack");
oController.processAction.call(oController, sectionID, sectionConfig.onVariantSelect, oEvent.getParameter("record")).then(function () {
if (callBack && callBack instanceof Function) {
callBack();
}
});
},
variantSave: function (oEvent) {
callBack = oEvent.getParameter("callBack");
oController.processAction.call(oController, sectionID, sectionConfig.onVariantMaintain, null, oEvent.getParameter("urlParams")).then(function () {
if (callBack && callBack instanceof Function) {
callBack();
}
});
},
layoutManage: function (oEvent) {
callBack = oEvent.getParameter("callBack");
oController.processAction.call(oController, sectionID, sectionConfig.onLayoutManage).then(function () {
if (callBack && callBack instanceof Function) {
callBack();
}
});
},
onExport: function (oEvent) {
var object = oEvent.getParameter('object');
object['DARID'] = section['DARID'];
callBack = oEvent.getParameter("callBack");
oController.exportAllData.call(oController, sectionID, object).then(function () {
if (callBack && callBack instanceof Function) {
callBack();
}
});
},
/pageChange: function (oEvent) {
oController.processAction.call(oController, sectionID, sectionConfig.onPageChange, null, oEvent.getParameter("urlParams"));
},
/
pageChange:[oController.onNRServerSidePaging,oController],
onSetValues: function (oEvent) {
callBack = oEvent.getParameter("callBack");
oController.processAction.call(oController, sectionID, sectionConfig.onSetValues).then(function () {
if (callBack && callBack instanceof Function) {
callBack();
}
});
},
onSetValuesApply: function () {
oController.processAction.call(oController, sectionID, sectionConfig.onSetValuesApply).then(function () {
oController._setValuesAction = undefined;
});

      },

    });

    oController.sectionRef[section['SECTN']].setSelectionMode(sap.ui.table.SelectionMode.MultiToggle);

// oController.sectionRef[section['SECTN']].attachRowSelectionChange(function (evt) {
// var record = evt.getSource().getBindingContext(oController.modelName).getObject();
// oController.processAction.call(oController, sectionID, sectionConfig.onRowSelect, record)
// });
}
oController.setSectionTitle(sectionModelFullPath + "/DESCR", oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.maxItems, oController.sectionRef[section['SECTN']], section['DAPPT']);

  oController.sectionRef[section['SECTN']].processOnInputChange = function (oEvent) {
    return oController.processOnInputChange(sectionID, oEvent);
  };

  oController.sectionRef[section['SECTN']].attachOnFieldClick(function (evt) {
    oController.preProcessFieldClickEvent(sectionID, evt);
  });

  oController.sectionRef[section['SECTN']].preProcessFieldEvent = function (oEvent) {
    return oController.preProcessFieldEvent(sectionID, oEvent);
  };

  oController.sectionRef[section['SECTN']].setModel(mainModel, global.vui5.modelName);
  oController.sectionRef[section['SECTN']].setModel(oController.getModel("i18n"), "i18n");
  oController.sectionRef[section['SECTN']].setModel(model, oController.modelName);

  oController.sectionRef[section['SECTN']].prepareTable();
  if (section['TBTYP'] === global.vui5.cons.tableType.responsive) {
    oController.sectionRef[section['SECTN']].setTriggeredDisplayed(false);
  }
  else{
    oController.sectionRef[section['SECTN']].createPagingControl();

    var sectionData = model.getProperty("/DATA");
    if (sectionData[section['DATAR']] && section["PGSIZ"]) {
      oController.sectionRef[section['SECTN']].compareAndSetPageSize(sectionData[section['DATAR']].length,section["PGSIZ"]);
    }
  }

  if(oController.modelName != "worklist"){
    oController._prepareToolBarContent(sectionID, model.getProperty(sectionModelPath + "/FUNC"));
  }
},

_processStatus: function (cfg) {
  var oController = this, section, index, sectionID, dataArea, sectionConfig, sectionPath, dataPath, sectionModelPath;
  var model = oController.getModel(oController.modelName);
  section = cfg.section;
  index = cfg.index;
  sectionID = section['SECTN'];
  sectionPath = oController._getPath(true);
  dataPath = oController._getPath();
  sectionModelPath = sectionPath + index;
  var mainModel = oController.getModel(global.vui5.modelName);
  var dmode = mainModel.getProperty("/DOCUMENT_MODE");
  var editable = (dmode !== global.vui5.cons.mode.display && section['DISOL'] === '');
  sectionConfig = oController.sectionConfig[sectionID];

  if (sectionConfig.attributes[global.vui5.cons.attributes.onTriggerSelect]) {
    sectionConfig.onTriggerSelect = underscoreJS.findWhere(cfg.section['FUNC'], {
      FNCNM: sectionConfig.attributes[global.vui5.cons.attributes.onTriggerSelect]
    });
  }

  if (sectionConfig.attributes[global.vui5.cons.attributes.onFlowSelect]) {
    sectionConfig.onFlowSelect = underscoreJS.findWhere(cfg.section['FUNC'], {
      FNCNM: sectionConfig.attributes[global.vui5.cons.attributes.onFlowSelect]
    });
  }

  if (sectionConfig.attributes[global.vui5.cons.attributes.onOutcomeSelect]) {
    sectionConfig.onOutcomeSelect = underscoreJS.findWhere(cfg.section['FUNC'], {
      FNCNM: sectionConfig.attributes[global.vui5.cons.attributes.onOutcomeSelect]
    });
  }

  if (sectionConfig.attributes[global.vui5.cons.attributes.onTriggerUndo]) {
    sectionConfig.onTriggerUndo = underscoreJS.findWhere(cfg.section['FUNC'], {
      FNCNM: sectionConfig.attributes[global.vui5.cons.attributes.onTriggerUndo]
    });
  }

  if (sectionConfig.attributes[global.vui5.cons.attributes.onStepUndo]) {
    sectionConfig.onStepUndo = underscoreJS.findWhere(cfg.section['FUNC'], {
      FNCNM: sectionConfig.attributes[global.vui5.cons.attributes.onStepUndo]
    });
  }

  if (sectionConfig.attributes[global.vui5.cons.attributes.onStatusSet]) {
    sectionConfig.onStatusSet = underscoreJS.findWhere(cfg.section['FUNC'], {
      FNCNM: sectionConfig.attributes[global.vui5.cons.attributes.onStatusSet]
    });
  }

  if (sectionConfig.attributes[global.vui5.cons.attributes.onInactiveSet]) {
    sectionConfig.onInactiveSet = underscoreJS.findWhere(cfg.section['FUNC'], {
      FNCNM: sectionConfig.attributes[global.vui5.cons.attributes.onInactiveSet]
    });
  }

  oController.sectionRef[section['SECTN']] = new global.vui5.ui.controls.Status({
    controller: oController,
    modelName: oController.modelName,
    dataPath: dataPath + section['DARID'] + "/",
    stblk: sectionModelPath + "/STBLK",
    sfcat: sectionModelPath + "/FIELDS",
    triggerText: "/SECCFG/" + section['SECTN'] + "/attributes/selectedTriggerText",
    enableTriggerUndo: "/SECCFG/" + section['SECTN'] + "/attributes/enableTriggerUndo",
    flowText: "/SECCFG/" + section['SECTN'] + "/attributes/selectedFlowText",
    enableStepUndo: "/SECCFG/" + section['SECTN'] + "/attributes/enableStepUndo",
    selectedFlow: "/SECCFG/" + section['SECTN'] + "/attributes/selectedFlow",
    triggerSelect: function (oEvent) {
      var parameters = oEvent.getParameters();
      var params = parameters[1]['record'];
      var cb = parameters[0]['callBack'];
      oController.processSectionAction(sectionID, sectionConfig.attributes[global.vui5.cons.attributes.onTriggerSelect], params).then(function (resp) {
        if (cb && cb instanceof Function) {
          cb(resp);
        }
      });
    },
    flowSelect: function (oEvent) {
      var parameters = oEvent.getParameters();
      var params = parameters[1]['record'];
      var cb = parameters[0]['callBack'];
      oController.processSectionAction(sectionID, sectionConfig.attributes[global.vui5.cons.attributes.onFlowSelect], params).then(function (resp) {
        if (cb && cb instanceof Function) {
          cb(resp);
        }
      });
    },
    outcomeSelect: function (oEvent) {
      var parameters = oEvent.getParameters();
      var params = parameters[1]['record'];
      var cb = parameters[0]['callBack'];
      oController.processSectionAction(sectionID, sectionConfig.attributes[global.vui5.cons.attributes.onOutcomeSelect], params).then(function (resp) {
        if (cb && cb instanceof Function) {
          cb(resp);
        }
      });
    },
    triggerUndo: function (oEvent) {
      var cb = oEvent.getParameter('callBack');
      oController.processSectionAction(sectionID, sectionConfig.attributes[global.vui5.cons.attributes.onTriggerUndo]).then(function (resp) {
        if (cb && cb instanceof Function) {
          cb(resp);
        }
      });
    },
    stepUndo: function (oEvent) {
      var cb = oEvent.getParameter('callBack');
      oController.processSectionAction(sectionID, sectionConfig.attributes[global.vui5.cons.attributes.onStepUndo]).then(function (resp) {
        if (cb && cb instanceof Function) {
          cb(resp);
        }
      });
    },
    statusSet: function (oEvent) {
      var params = oEvent.getParameter('record');
      oController.processSectionAction(sectionID, sectionConfig.attributes[global.vui5.cons.attributes.onStatusSet], params);
    },
    inactiveSet: function (oEvent) {
      var params = oEvent.getParameter('record');
      oController.processSectionAction(sectionID, sectionConfig.attributes[global.vui5.cons.attributes.onInactiveSet], params);
    },
    editable: editable
  });
  oController.sectionRef[sectionID].statusInfocusSet();
  oController.sectionRef[sectionID].setModel(model, oController.modelName);
},
statusInfocusSet: function(dmode,objtyp,objkey,uiprf,sectn,darid){
  var oController = this;
  var infocusModel = oController.getModel(oController.modelName);
  var sections = infocusModel.getProperty('/SECTN');
  var section = _.find(sections,{'SECTN':sectn});
  var params = [{
    "NAME": "OBJTYP",
    "VALUE": objtyp
  }, {
    "NAME": "OBJKEY",
    "VALUE": objkey
  }, {
    "NAME": "UIPRF",
    "VALUE": uiprf
  }, {
    "NAME": "SECTN",
    "VALUE": sectn
  }, {
    "NAME": "DMODE",
    "VALUE": dmode
  }];

  var data = [];
  data.push({
    "DATA": [],
    "PARAMS": params,
    "DTAREA": "STATUS_FLOW",
    "EVENT": "METADATA"
  });
  data.push({
    "DATA": [],
    "PARAMS": params,
    "DTAREA": "STATUS_FLOW",
    "EVENT": "READ"
  });
  data.push({
    "DATA": [],
    "PARAMS": [],
    "DTAREA": "MESSAGES",
    "EVENT": "READ"
  });

  if(data && data.length > 0){
    $.when(this.callServer({
      data: data,
      reqType: 'POST'
    })).then(function(result) {

      if (result) {
        var messages = _.findWhere(result, {
          DTAREA: "MESSAGES",
          EVENT: "READ"
        });
        var response = _.findWhere(result, {
          DTAREA: "STATUS_FLOW",
          EVENT: "READ"
        });
        if (response && response['RESULT']) {
          if(response['RESULT']['DRPDN']){
            if(!infocusModel.getProperty("/DROPDOWNS")){
              infocusModel.setProperty("/DROPDOWNS",{});
            }
            var dropdowns = {};
            _.each(response['RESULT']['DRPDN'],function(obj){
              if(darid == obj['DARID']){
                dropdowns[obj['FIELD']] = obj['VALUE'];
              }
            });
            infocusModel.setProperty("/DROPDOWNS/" + darid, dropdowns);
          }
          if(response['RESULT']['ATTRB']){
            var attributes = section['ATTRB'];
            _.each(response['RESULT']['ATTRB'],function(obj){
              if(obj['SECTN'] == sectn){
                _.each(obj['ATTRB'],function(attrb){
                  var attrb1 = _.find(attributes,{'NAME':attrb['NAME']});
                  if(attrb1){
                    attrb1['VALUE'] = attrb['VALUE'];
                  }
                  else{
                    attributes.push(attrb);
                  }
                });
              }
            });

            oController.sectionConfig[sectn]['attributes'] = oController._flattenAttributes(attributes);

          }
          if(response['RESULT']['DATA']){
            infocusModel.setProperty("/DATA/" + darid, response['RESULT']['DATA']);
          }
        }
      }
    });
  }
},
_processAttachments: function (cfg) {
  var oController = this, section, index, sectionID, dataArea, sectionConfig, variantSectionConfig, variantSection, sectionPath, dataPath, sectionModelPath;
  var model = oController.getModel(oController.modelName);
  section = cfg.section;
  index = cfg.index;
  sectionID = section['SECTN'];
  dataArea = section['DATAR'];
  sectionPath = oController._getPath(true);
  dataPath = oController._getPath();
  sectionModelPath = sectionPath + index;
  sectionConfig = oController.sectionConfig[sectionID];

  /* Process Attributes */
  if (sectionConfig.attributes[global.vui5.cons.attributes.onUpload]) {
    sectionConfig.onUpload = underscoreJS.findWhere(cfg.section['FUNC'], {
      FNCNM: sectionConfig.attributes[global.vui5.cons.attributes.onUpload]
    });
  }
  if (sectionConfig.attributes[global.vui5.cons.attributes.onReplace]) {
    sectionConfig.onReplace = underscoreJS.findWhere(cfg.section['FUNC'], {
      FNCNM: sectionConfig.attributes[global.vui5.cons.attributes.onReplace]
    });
  }
  if (sectionConfig.attributes[global.vui5.cons.attributes.onDelete]) {
    sectionConfig.onDelete = underscoreJS.findWhere(cfg.section['FUNC'], {
      FNCNM: sectionConfig.attributes[global.vui5.cons.attributes.onDelete]
    });
  }
  if (sectionConfig.attributes[global.vui5.cons.attributes.onRename]) {
    sectionConfig.onRename = underscoreJS.findWhere(cfg.section['FUNC'], {
      FNCNM: sectionConfig.attributes[global.vui5.cons.attributes.onRename]
    });
  }
  if (sectionConfig.attributes[global.vui5.cons.attributes.onDownload]) {
    sectionConfig.onDownload = underscoreJS.findWhere(cfg.section['FUNC'], {
      FNCNM: sectionConfig.attributes[global.vui5.cons.attributes.onDownload]
    });
  }
  //

  /* Prepare Element */
  oController.sectionRef[sectionID] = new global.vui5.ui.controls.Attachments({
    controller: oController,
    modelName: oController.modelName,
    sectionPath: sectionPath + index,
    dataPath: dataPath + section['DARID'] + "/",
    mimtp: "/DROPDOWNS/" + section['DARID'] + "/MIMTP",
    editable: oController.getBindingExpression('editable', section, index),
    onUpload: oController.processSectionAction.bind(oController, sectionID, sectionConfig.attributes[global.vui5.cons.attributes.onUpload]),
    onReplace: oController.processSectionAction.bind(oController, sectionID, sectionConfig.attributes[global.vui5.cons.attributes.onReplace]),
    onDelete: function (oEvent) {
      var params = oEvent.getParameter('record');
      oController.processSectionAction(sectionID, sectionConfig.attributes[global.vui5.cons.attributes.onDelete], params);
    },
    onRename: oController.processSectionAction.bind(oController, sectionID, sectionConfig.attributes[global.vui5.cons.attributes.onRename]),
    onDownload: function (oEvent) {
      var params = oEvent.getParameter('record');
      oController.processSectionAction(sectionID, sectionConfig.attributes[global.vui5.cons.attributes.onDownload],params);
    },
    disableUploadPath: "/SECCFG/" + sectionID + "/attributes/disableUpload"

  });
  oController.sectionRef[sectionID].setModel(model, oController.modelName);
  oController.sectionRef[sectionID].setModel(oController.getModel("i18n"), "i18n");
  oController.sectionRef[sectionID].attachmentProcess();
},
attachmentInfocusSet: function(objtyp,objkey,uiprf,sectn,darid){
  var oController = this;
  var infocusModel = oController.getModel(oController.modelName);
  var sections = infocusModel.getProperty('/SECTN');
  var section = _.find(sections,{'SECTN':sectn});
  var params = [{
    "NAME": "OBJTYP",
    "VALUE": objtyp
  }, {
    "NAME": "OBJKEY",
    "VALUE": objkey
  }, {
    "NAME": "UIPRF",
    "VALUE": uiprf
  }, {
    "NAME": "SECTN",
    "VALUE": sectn
  }];

  var data = [];
  data.push({
    "DATA": [],
    "PARAMS": params,
    "DTAREA": "ATTACHMENT",
    "EVENT": "METADATA"
  });
  data.push({
    "DATA": [],
    "PARAMS": params,
    "DTAREA": "ATTACHMENT",
    "EVENT": "READ"
  });
  data.push({
    "DATA": [],
    "PARAMS": [],
    "DTAREA": "MESSAGES",
    "EVENT": "READ"
  });

  if(data && data.length > 0){
    $.when(this.callServer({
      data: data,
      reqType: 'POST'
    })).then(function(result) {

      if (result) {
        var messages = _.findWhere(result, {
          DTAREA: "MESSAGES",
          EVENT: "READ"
        });
        var response = _.findWhere(result, {
          DTAREA: "ATTACHMENT",
          EVENT: "READ"
        });
        if (response && response['RESULT']) {
          if(response['RESULT']['DRPDN']){
            if(!infocusModel.getProperty("/DROPDOWNS")){
              infocusModel.setProperty("/DROPDOWNS",{});
            }
            var dropdowns = {};
            _.each(response['RESULT']['DRPDN'],function(obj){
              if(darid == obj['DARID']){
                dropdowns[obj['FIELD']] = obj['VALUE'];
              }
            });
            infocusModel.setProperty("/DROPDOWNS/" + darid, dropdowns);
          }
          if(response['RESULT']['ATTRB']){
            var attributes = section['ATTRB'];
            _.each(response['RESULT']['ATTRB'],function(obj){
              if(obj['SECTN'] == sectn){
                _.each(obj['ATTRB'],function(attrb){
                  var attrb1 = _.find(attributes,{'NAME':attrb['NAME']});
                  if(attrb1){
                    attrb1['VALUE'] = attrb['VALUE'];
                  }
                  else{
                    attributes.push(attrb);
                  }
                });
              }
            });

            oController.sectionConfig[sectn]['attributes'] = oController._flattenAttributes(attributes);

          }
          if(response['RESULT']['DATA']){
            infocusModel.setProperty("/DATA/" + darid, response['RESULT']['DATA']);
          }
        }
      }
    });
  }
},
_processNotes: function (cfg) {
        var oController = this, section, index, sectionID, dataArea, sectionConfig, sectionPath, dataPath, sectionModelPath;
        var model = oController.getModel(oController.modelName);
        section = cfg.section;
        index = cfg.index;
        sectionID = section['SECTN'];
        var mainModel = oController.getModel(global.vui5.modelName);
        var dmode = mainModel.getProperty("/DOCUMENT_MODE");
        sectionPath = oController._getPath(true);
        dataPath = oController._getPath();
        sectionModelPath = sectionPath + index;
        // var editable = (dmode !== global.vui5.cons.mode.display &&
        // section['DISOL'] === '');
        sectionConfig = oController.sectionConfig[sectionID];
        if (sectionConfig.attributes[global.vui5.cons.attributes.onUpdateNote]) {
            sectionConfig.onUpdateNote = underscoreJS.findWhere(cfg.section['FUNC'], {
                FNCNM: sectionConfig.attributes[global.vui5.cons.attributes.onUpdateNote]
            });
        }
        oController.sectionRef[section['SECTN']] = new global.vui5.ui.controls.Notes({
            controller: oController,
            modelName: oController.modelName,
            dataPath: dataPath + section['DARID'] + "/",
            nauth: sectionModelPath + "/NAUTH",
            notyp: section['DAQLF'],
            updateNote: oController.processSectionAction.bind(oController, sectionID, sectionConfig.attributes[global.vui5.cons.attributes.onUpdateNote]),
            // editable: editable,
            editable: oController.getBindingExpression('noteEditable', section, index),
        });

        oController.sectionRef[sectionID].setModel(model, oController.modelName);
        oController.sectionRef[sectionID].setModel(oController.getModel("i18n"), "i18n");

    },
notesInfocusSet: function(dmode, objtyp, objkey, subobj, uiprf, sectn,darid) {
  var oController = this;
  var infocusModel = oController.getModel(oController.modelName);

  if(subobj){
    var params = [{
      "NAME": "OBJTYP",
      "VALUE": objtyp
    }, {
      "NAME": "OBJKEY",
      "VALUE": objkey
    }, {
      "NAME": "UIPRF",
      "VALUE": uiprf
    }, {
      "NAME": "SUBOBJ",
      "VALUE": subobj
    }, {
      "NAME": "SECTN",
      "VALUE": sectn
    }, {
      "NAME": "DMODE",
      "VALUE": dmode
    }];

    var data = [];
    data.push({
      "DATA": [],
      "PARAMS": params,
      "DTAREA": "NOTE",
      "EVENT": "METADATA"
    });
    data.push({
      "DATA": [],
      "PARAMS": params,
      "DTAREA": "NOTE",
      "EVENT": "READ"
    });
    data.push({
      "DATA": [],
      "PARAMS": [],
      "DTAREA": "MESSAGES",
      "EVENT": "READ"
    });

  }
  if(data && data.length > 0){
    $.when(this.callServer({
      data: data,
      reqType: 'POST'
    })).then(function(result) {

      if (result) {
        var messages = _.findWhere(result, {
          DTAREA: "MESSAGES",
          EVENT: "READ"
        });
        var response = _.findWhere(result, {
          DTAREA: "NOTE",
          EVENT: "READ"
        });
        if (response['RESULT']) {
          infocusModel.setProperty("/DATA/" + darid, response['RESULT']['DATA']);
        }
      }
    });
  }
},
processSectionAction : function(sectionID, actionObject,secData) {
  var oController = this,promise, objDefer = $.Deferred();
  var infocusModel = oController.getModel(oController.modelName);
  var mainModel = oController.getModel(global.vui5.modelName);
  var sections = infocusModel.getProperty('/SECTN');
  var section = _.find(sections,{'SECTN':sectionID});
  var dmode = mainModel.getProperty("/DOCUMENT_MODE");

  switch(section['DAPPT']){
  case vui5.cons.propertyType.attachments:
    var attachmentData = {};
    if(actionObject == 'ATDNL'){
      attachmentData[section['DARID']] = [];
      attachmentData[section['DARID']].push(secData);
    }
    else{
    attachmentData[section['DARID']] =  _.reject(infocusModel.getProperty('/DATA/'+ section['DARID']), function(obj){
      return (obj['UPDKZ_UI'] == undefined || obj['UPDKZ_UI'] == "");
    });
    }
    var params = [{
      "NAME": "OBJTYP",
      "VALUE": vui5.cons.applnObject
    }, {
      "NAME": "OBJKEY",
      "VALUE": oController.selectedDocument
    }, {
      "NAME": "UIPRF",
      "VALUE": infocusModel.getProperty("/UIPRF")
    }, {
      "NAME": "SECTN",
      "VALUE": oController.clickedTab
    }, {
      "NAME": "DMODE",
      "VALUE": dmode
    }];

    var data = [];
    data.push({
      "DATA": attachmentData,
      "PARAMS": params,
      "DTAREA": "ATTACHMENT",
      "EVENT": actionObject
    });
    data.push({
      "DATA": [],
      "PARAMS": [],
      "DTAREA": "MESSAGES",
      "EVENT": "READ"
    });
    $.when(this.callServer({
      data: data,
      reqType: 'POST'
    })).then(function(result) {
      var oUrl = "/sap/bc/bsp/vui/gatdnl/download.htm";
      if (actionObject == 'ATDNL') {

// window.open(oUrl, "_self");
}
oController.attachmentInfocusSet(
global.vui5.cons.applnObject,
oController.selectedDocument,
infocusModel.getProperty("/UIPRF"),
sectionID,
section['DARID']);
objDefer.resolve();
});
break;
case vui5.cons.propertyType.notes:
var notesData = {};
notesData[section['DARID']] = _.reject(infocusModel.getProperty('/DATA/'+ section['DARID']), function(obj){
return (obj['UPDKZ_UI'] == undefined || obj['UPDKZ_UI'] == "");
});
if(infocusModel.getProperty("/TECHNICAL_DATA")){
var subobj = infocusModel.getProperty("/TECHNICAL_DATA/VERSN");
}
var params = [{
"NAME": "OBJTYP",
"VALUE": vui5.cons.applnObject
}, {
"NAME": "OBJKEY",
"VALUE": oController.selectedDocument
}, {
"NAME": "UIPRF",
"VALUE": infocusModel.getProperty("/UIPRF")
}, {
"NAME": "SUBOBJ",
"VALUE": subobj
}, {
"NAME": "SECTN",
"VALUE": oController.clickedTab
}, {
"NAME": "DMODE",
"VALUE": dmode
}];

    var data = [];
    data.push({
      "DATA": notesData,
      "PARAMS": params,
      "DTAREA": "NOTE",
      "EVENT": actionObject
    });
    data.push({
      "DATA": [],
      "PARAMS": [],
      "DTAREA": "MESSAGES",
      "EVENT": "READ"
    });
    $.when(this.callServer({
      data: data,
      reqType: 'POST'
    })).then(function(result) {
      oController.notesInfocusSet(dmode,
          vui5.cons.applnObject,
          oController.selectedDocument,
          subobj,
          infocusModel.getProperty("/UIPRF"),
          sectionID,
          section['DARID']);
      objDefer.resolve();
    });
    break;
  case vui5.cons.propertyType.status:


  }
  return objDefer.promise();
},
handleRequiredFieldCheck : function(oEvent){
  var oController = this;
  var newValue = oEvent.getParameter("newValue");
  var oSource = oEvent.getSource();
  var error;
  if (newValue === "") {
    oSource.setValueState(sap.ui.core.ValueState.Error);  // if the field is empty after change, it will go red
    var text;
    if(oSource.getParent().getAggregation("label")){
      text = oSource.getParent().getAggregation("label").getText();
    }else{
      text = oSource.getParent().getTitle();
      text = text.substr(5,text.length);
    }

    var bundle = oSource.getModel("i18n").getResourceBundle();
    var errorText = bundle.getText("Enter",[text]);
    oSource.setValueStateText(errorText);
    oController.handleCheckFieldsMessages(
        errorText,
        sap.ui.core.MessageType.Error,
        oSource.getId() + "/value" );
    error = true;
  }else {
    oSource.setValueState(sap.ui.core.ValueState.None); // if the field is not empty after change, the value state (if any) is removed
    oSource.setValueStateText("");
    oController.handleCheckFieldsMessages(
        "",
        "",
        oSource.getId() + "/value" );
    error = false;
  }
  return error;
},
checkRequiredFields : function() {
  var error = false;
  var oController = this;
  var mainModel = this.getModel(vui5.modelName);
  var docMode = mainModel.getProperty("/DOCUMENT_MODE");
  var index = 0;

  jQuery('input[aria-invalid=true]').each(function(){
    var oInput = sap.ui.getCore().byId(this.parentNode.id);
    if(oInput){
      error = true;
      if(index == 0){
        oInput.focus();
      }
      index++;
    }
  });

  if(docMode != vui5.cons.mode.display) {
    jQuery('input[aria-required=true]').each(function(){
      var oInput = sap.ui.getCore().byId(this.parentNode.id);

// if(oInput.$().is(":visible") && oInput.getValue && oInput.getValue() == ''){
// oInput.setValueState(sap.ui.core.ValueState.Error); // if the field is empty after change, it will go red
// var text = oInput.getParent().getAggregation("label").getText();
// var bundle = oInput.getModel("i18n").getResourceBundle();
// var errorText = bundle.getText("Enter",[text]);
// oInput.setValueStateText(errorText);
// oController.handleCheckFieldsMessages(
// errorText,
// sap.ui.core.MessageType.Error,
// oInput.getId() + "/value" );
// error = true;
// if(index == 0){
// oInput.focus();
// }
// index++;
// }
var errorflag = false;
if(oInput.$().is(":visible") ) {
if( oInput.getSelectedKey && oInput.getSelectedItem ){
var item = oInput.getSelectedItem();
if(!item)
errorflag = true;
}else if(oInput.getValue && oInput.getValue() == ''){
errorflag = true;
}
if(errorflag) {
oInput.setValueState(sap.ui.core.ValueState.Error); // if the field is empty after change, it will go red
var text = oInput.getParent().getAggregation("label").getText();
var bundle = oInput.getModel("i18n").getResourceBundle();
var errorText = bundle.getText("Enter",[text]);
oInput.setValueStateText(errorText);
oController.handleCheckFieldsMessages(
errorText,
sap.ui.core.MessageType.Error,
oInput.getId() + "/value" );
error = true;
if(index == 0){
oInput.focus();
}
index++;
}
}
/Not Required, as it will clear error flag marked by other checks/
// else {
// oInput.setValueState(sap.ui.core.ValueState.None); // if the field is not empty after change, the value state (if any) is removed
// oInput.setValueStateText("");
// oController.handleCheckFieldsMessages(
// "",
// "",
// oInput.getId() + "/value" );
// }
});
}
return error;
},
messageDataPrepare : function(messages) {
var oController = this;
if(!this.oMessageProcessor){
this.oMessageProcessor = new sap.ui.core.message.ControlMessageProcessor();
}
var oMessageManager = sap.ui.getCore().getMessageManager();
oMessageManager.registerMessageProcessor(this.oMessageProcessor);
var messageModel = oMessageManager.getMessageModel();
messageModel.setSizeLimit(vui5.cons.maxDataLimit);
oMessageManager.removeAllMessages();
underscoreJS.each(messages,function(obj) {
var type;
switch(obj['MSGTY']){
case 'S' :
type = sap.ui.core.MessageType.Success;
break;
case 'I' :
type = sap.ui.core.MessageType.Information;
break;
case 'E' :
type = sap.ui.core.MessageType.Error;
break;
case 'W' :
type = sap.ui.core.MessageType.Warning;
break;
}
oMessageManager.addMessages(
new sap.ui.core.message.Message({
message: obj['MSGLI'],
type: type,
processor: oController.oMessageProcessor
})
);
});
},
handleMessageButtonPress: function (oEvent) {
var oController = this;
var oSource = oEvent.getSource();
if(!oController._messagePopover){
oController._messagePopover = sap.ui.jsfragment(global.vui5.ui.fragments.Messages,oController);
oSource.addDependent(oController._messagePopover);
jQuery.sap.syncStyleClass(oController.getOwnerComponent().getContentDensityClass(),
oController.getView(), oController.messagePopover);
}
oController.messagePopover.toggle(oSource);
},
loginDataSet : function(mainModel,response) {
if(response && response['RESULT']){
mainModel.setProperty("/LOGIN",response['RESULT']['DATA']);
/var dateFormat = mainModel.getProperty("/LOGIN/DATEFORMAT");
dateFormat = dateFormat.toLowerCase().replace('mm', 'MM');
mainModel.setProperty('/LOGIN/DATEFORMAT', dateFormat);
/
vui5.session.extensionPath = mainModel.getProperty('/LOGIN/EXTENSIONPATH');
global.vui5.session.ccounter = global.vui5.session.maxTime = parseInt(mainModel.getProperty('/LOGIN/TIMEOUT'));
vui5.themeRoot = mainModel.getProperty('/LOGIN/THEME_ROOT');
commonUtils.applyTheme(response['RESULT']['DATA'].THEME);
}
},
checkFloatField : function(oEvent){
var oController = this;
var oSource = oEvent.getSource();
var value = oSource.getValue();
var regx;
var mainModel = oController.getModel(vui5.modelName);
var decimalNotation = mainModel.getProperty("/LOGIN/DECIMALNOTATION");
switch(decimalNotation){
case 'X':
regx = /^[-+]?[0-9](,\d{0,})?.?[0-9]+([eE][-+]?[0-9]+)?$/;
break;
case 'Y':
regx = /^[-+]?[0-9](\s\d{0,})?,?[0-9]+([eE][-+]?[0-9]+)?$/;
break;
default:
regx = /^[-+]?[0-9](.\d{0,})?,?[0-9]+([eE][-+]?[0-9]+)?$/;
break;
}
value = value.trim();
if(value && !regx.test(value)){
oSource.setValueState(sap.ui.core.ValueState.Error);
var text;
if(oSource.getParent().getAggregation("label")){
text = oSource.getParent().getAggregation("label").getText();
}else if(oSource.getParent().getTitle()){
text = oSource.getParent().getTitle();
text = text.substr(5,text.length);
}else{
if(oSource.data("sap-ui-colid")){
// non responsive table
text = sap.ui.getCore().byId(oSource.data("sap-ui-colid")).getAggregation("label").getText();
}else{
// m.Table
/QA Issue 7022 Changes - START/
var ariaLabelledBy = oSource.getAriaLabelledBy();
for(var i=0; i < ariaLabelledBy.length ; i++){
var textElement = sap.ui.getCore().byId(ariaLabelledBy[i]);
if(textElement){
text = textElement.getText();
break;
}
}
// text = sap.ui.getCore().byId(oSource.getAriaLabelledBy()[0]).getText();
/QA Issue 7022 Changes - END/
}
}
// var text = source.getParent().getAggregation("label").getText();
var bundle = oSource.getModel("i18n").getResourceBundle();
var errorText = bundle.getText("EnterValid",[text]);
oSource.setValueStateText(errorText);
oController.handleCheckFieldsMessages(
errorText,
sap.ui.core.MessageType.Error,
oSource.getId() + "/value" );
}else{
oSource.setValueState(sap.ui.core.ValueState.None);
oSource.setValueStateText('');
oController.handleCheckFieldsMessages(
"",
"",
oSource.getId() + "/value" );
}
},
checkNumericField : function(oEvent){
var oController = this;
var source = oEvent.getSource();
var value;
if(oEvent.oSource.
$input[0]['attributes']['role'] && oEvent.oSource.
$input[0]['attributes']['role']['nodeValue'] === 'combobox'){
value = source.getSelectedKey();
}else{
value = source.getValue();
}
var regex;
regex = /^[0-9]*$/;
var error;

  value = value.trim();
  if(value && !regex.test(value)){
    source.setValueState(sap.ui.core.ValueState.Error);
    var text;
    if(source.getParent().getAggregation("label")){
      text = source.getParent().getAggregation("label").getText();
    }else if(source.getParent().getTitle()){
      text = source.getParent().getTitle();
      text = text.substr(5,text.length);
    }else{
      if(source.data("sap-ui-colid")){
        // non responsive table
        text = sap.ui.getCore().byId(source.data("sap-ui-colid")).getAggregation("label").getText();
      }else{
        // m.Table
        /*QA Issue 7022 Changes - START*/
        var ariaLabelledBy = source.getAriaLabelledBy();
        for(var i=0; i < ariaLabelledBy.length ; i++){
          var textElement = sap.ui.getCore().byId(ariaLabelledBy[i]);
          if(textElement){
            text = textElement.getText();
            break;
          }
        }

// text = sap.ui.getCore().byId(source.getAriaLabelledBy()[0]).getText();
/QA Issue 7022 Changes - END/
}
}
// var text = source.getParent().getAggregation("label").getText();
var bundle = source.getModel("i18n").getResourceBundle();
var errorText = bundle.getText("EnterValid",[text]);
source.setValueStateText(errorText);
oController.handleCheckFieldsMessages(
errorText,
sap.ui.core.MessageType.Error,
source.getId() + "/value" );
error = true;
}else{
source.setValueState(sap.ui.core.ValueState.None);
source.setValueStateText('');
oController.handleCheckFieldsMessages(
"",
"",
source.getId() + "/value" );
error = false;
}
return error;
},
checkPackedField : function(oEvent) {
var oController = this;
var source = oEvent.getSource();
var value = source.getValue();
var regex;
var mainModel = oController.getModel(vui5.modelName);
var decimalNotation = mainModel.getProperty("/LOGIN/DECIMALNOTATION");
/QA Issue 7022 Changes/
regex = oController.getDecimalNotationRegex(decimalNotation);

  /*QA Issue 7022 Changes*/
  var error;

  value = value.trim();
  if(value && !regex.test(value)){
    source.setValueState(sap.ui.core.ValueState.Error);

// var text = source.getParent().getAggregation("label").getText();
var text;
if(source.getParent().getAggregation("label")){
text = source.getParent().getAggregation("label").getText();
}else if(source.getParent().getTitle()){
text = source.getParent().getTitle();
text = text.substr(5,text.length);
}else{
if(source.data("sap-ui-colid")){
// non responsive table
text = sap.ui.getCore().byId(source.data("sap-ui-colid")).getAggregation("label").getText();
}else{
// m.Table
/QA Issue 7022 Changes - START/
var ariaLabelledBy = source.getAriaLabelledBy();
for(var i=0; i < ariaLabelledBy.length ; i++){
var textElement = sap.ui.getCore().byId(ariaLabelledBy[i]);
if(textElement){
text = textElement.getText();
break;
}
}
// text = sap.ui.getCore().byId(source.getAriaLabelledBy()[0]).getText();
/QA Issue 7022 Changes - END/
}
}
var bundle = source.getModel("i18n").getResourceBundle();
var errorText = bundle.getText("EnterValid",[text]);
source.setValueStateText(errorText);
oController.handleCheckFieldsMessages(
errorText,
sap.ui.core.MessageType.Error,
source.getId() + "/value" );
error = true;
}else{
source.setValueState(sap.ui.core.ValueState.None);
source.setValueStateText('');
oController.handleCheckFieldsMessages(
"",
"",
source.getId() + "/value" );
error = false;
}
return error;
},
checkIntegerField : function(oEvent) {
var oController = this;
var source = oEvent.getSource();
var value = source.getValue();
var regex;
regex = /^[0-9-]\d*(((,\d{1,}){0,})?)(([0-9-])?)$/ ;
var error;
value = value.trim();
if(value && !regex.test(value)){
source.setValueState(sap.ui.core.ValueState.Error);
var text;
if(source.getParent().getAggregation("label")){
text = source.getParent().getAggregation("label").getText();
}else if(source.getParent().getTitle()){
text = source.getParent().getTitle();
text = text.substr(5,text.length);
}else{
if(source.data("sap-ui-colid")){
// non responsive table
text = sap.ui.getCore().byId(source.data("sap-ui-colid")).getAggregation("label").getText();
}else{
// m.Table
/QA Issue 7022 Changes - START/
var ariaLabelledBy = source.getAriaLabelledBy();
for(var i=0; i < ariaLabelledBy.length ; i++){
var textElement = sap.ui.getCore().byId(ariaLabelledBy[i]);
if(textElement){
text = textElement.getText();
break;
}
}
// text = sap.ui.getCore().byId(source.getAriaLabelledBy()[0]).getText();
/QA Issue 7022 Changes - END/
}
}
// var text = source.getParent().getAggregation("label").getText();
var bundle = source.getModel("i18n").getResourceBundle();
var errorText = bundle.getText("EnterValid",[text]);
source.setValueStateText(errorText);
oController.handleCheckFieldsMessages(
errorText,
sap.ui.core.MessageType.Error,
source.getId() + "/value" );
error = true;
}else{
source.setValueState(sap.ui.core.ValueState.None);
source.setValueStateText('');
oController.handleCheckFieldsMessages(
"",
"",
source.getId() + "/value" );
error = false;
}
return error;
},
dateFieldCheck : function(oEvent) {
var oController = this;
var oSource = oEvent.getSource();
if(oEvent.getParameter("valid")){
oSource.setValueState(sap.ui.core.ValueState.None);
oSource.setValueStateText("");
oController.handleCheckFieldsMessages(
"",
"",
oSource.getId() + "/value" );
}else if(oEvent.getParameter("valid") == false){
oSource.setValueState(sap.ui.core.ValueState.Error);
var text;
if(oSource.getParent().getAggregation("label")){
text = oSource.getParent().getAggregation("label").getText();
}else if(oSource.getParent().getTitle()){
text = oSource.getParent().getTitle();
text = text.substr(5,text.length);
}else{
if(oSource.data("sap-ui-colid")){
// non responsive table
text = sap.ui.getCore().byId(oSource.data("sap-ui-colid")).getAggregation("label").getText();
}else{
// m.Table
/QA Issue 7022 Changes - START/
var ariaLabelledBy = oSource.getAriaLabelledBy();
for(var i=0; i < ariaLabelledBy.length ; i++){
var textElement = sap.ui.getCore().byId(ariaLabelledBy[i]);
if(textElement){
text = textElement.getText();
break;
}
}
// text = sap.ui.getCore().byId(oSource.getAriaLabelledBy()[0]).getText();
/QA Issue 7022 Changes - END/
}
}
// var text = source.getParent().getAggregation("label").getText();
var bundle = oSource.getModel("i18n").getResourceBundle();
var errorText = bundle.getText("EnterValid",[text]);
oSource.setValueStateText(errorText);
oController.handleCheckFieldsMessages(
errorText,
sap.ui.core.MessageType.Error,
oSource.getId() + "/value" );
}else{
var valid = oSource._bValid;
if(valid){
oSource.setValueState(sap.ui.core.ValueState.None);
oSource.setValueStateText("");
oController.handleCheckFieldsMessages(
"",
"",
oSource.getId() + "/value" );
}else{
oSource.setValueState(sap.ui.core.ValueState.Error);
var text;
if(oSource.getParent().getAggregation("label")){
// in case of form
text = oSource.getParent().getAggregation("label").getText();
}else{
if(oSource.data("sap-ui-colid")){
// non responsive table
text = sap.ui.getCore().byId(oSource.data("sap-ui-colid")).getAggregation("label").getText();
}else{
// m.Table
/QA Issue 7022 Changes - START/
var ariaLabelledBy = oSource.getAriaLabelledBy();
for(var i=0; i < ariaLabelledBy.length ; i++){
var textElement = sap.ui.getCore().byId(ariaLabelledBy[i]);
if(textElement){
text = textElement.getText();
break;
}
}
// text = sap.ui.getCore().byId(oSource.getAriaLabelledBy()[0]).getText();
/QA Issue 7022 Changes - END/
}
}

      var bundle = oSource.getModel("i18n").getResourceBundle();
      var errorText = bundle.getText("EnterValid",[text]);
      oSource.setValueStateText(errorText);
      oController.handleCheckFieldsMessages(
          errorText,
          sap.ui.core.MessageType.Error,
          oSource.getId() + "/value" );
    }
  }

  var cellID = oController.changedDateTimeID;
  $("#"+cellID).parents("td").removeClass (function (index, className) {
    return (className.match (/\bvui_tblrowcolor_\S+/g) || []).join(' ');
  });
  $("#"+cellID).parents("td").addClass("vui_tblrowcolor_CHANGED");

},
getDecimalNotationRegex:function(decimalNotation)
{
  var regex;
  switch(decimalNotation) {
  case 'X' :
    regex = /^[0-9\-.]\d*(((,\d{1,}){0,})?(\.\d{0,})?)([0-9\-]{0,1})$/;
    break;
  case 'Y' :
    regex =  /^[0-9\-,]\d*(((\s\d{1,}){0,})?(,\d{0,})?)([0-9\-]{0,1})$/;
    break;
  default :
    regex = /^[0-9\-,]\d*(((\.\d{1,}){0,})?(,\d{0,})?)([0-9\-]{0,1})$/;
  break;
  }

  return regex;
},

/**********************************Generic App Methods************************************************/
setProfileInfo: function (data) {
  // TODO - check if this storage at
  // main model is required.
  var modelPath;
  var mainModel = this.getMainModel();

  if (!data) return false;
  modelPath = global.vui5.cons.modelPath.infocusUIPrf;
  mainModel.setProperty(modelPath, data);
},
getProfileInfo: function() {
  var modelPath;
  var mainModel = this.getOwnerComponent().getModel(vui5.modelName);
  return mainModel.getProperty(vui5.cons.modelPath.infocusUIPrf);
},
getSections: function() {
  var oController = this;
  var model = oController.getModel(oController.modelName);
  var path = oController._getPath(true); // copy popup
  return model.getProperty(path);
},
_showMessages: function(oEvent) {
  var oController = this;
  var oSource = oEvent.getSource();

  /*
   * if(oController._messagePopover) {
   * oController._messagePopover.destroy(); }
   */
  oController._messagePopover = sap.ui.jsfragment(global.vui5.ui.fragments.Messages, oController);
  oSource.addDependent(oController._messagePopover);
  jQuery.sap.syncStyleClass(oController.getOwnerComponent().getContentDensityClass(),
      oController.getView(), oController._messagePopover);

  oController._messagePopover.toggle(oSource);
},
getQueryParams: function() {
  var oController = this, params;
  params = oController.getRouteParam('all*') || '';
  return commonUtils.paramsUnserialize(params);
},
getQueryParam: function(key) {
  var oController = this, params;
  params = oController.getQueryParams('') || {};
  return params[key];
},
getRouteParams: function() {

  var oController = this;
  var routerRef = oController.getRouter();
  var routerPvtObj = routerRef._oRouter;
  var hashManager = routerRef.oHashChanger;
  var currentHash, matchedRoutes, routeParams = {};

  if (hashManager) {
    currentHash = hashManager.getHash();
    matchedRoutes = routerPvtObj._getMatchedRoutes(currentHash);

    underscoreJS.each(matchedRoutes, function(matchedRoute) {
      underscoreJS.each(matchedRoute.params, function(g, h) {
        routeParams[matchedRoute.route._paramsIds[h]] = g;
      });
    });
  }

  return routeParams;
},
getRouteParam: function(key) {
  var oController = this;

  return oController.getRouteParams()[key];
},
_flattenAttributes: function(attributes) {
  return underscoreJS.object(underscoreJS.pluck(attributes, "NAME"), underscoreJS.pluck(attributes, "VALUE"));
},
onMenuItemSelected: function (sectionID, actionObject, rowData, urlParams) {
	var oController = this;
	if(actionObject['FNCNM'] == "NAVG"){
		var infocusModel = oController.getModel(oController.modelName);
        var uiprofile = urlParams['$SELMNITM'];
        var org = window.location.origin;
        var pName = window.location.pathname;
        var regEx = new RegExp("bdom", "ig");
        if(pName.search(regEx)){
        	pName = pName.replace(regEx,"bdosnp");
        }else{
        	pName = "/sap/bc/ui5_ui5/vui/bdosnp/index.html"
        }
        var search = '?uiprofile=' + uiprofile + '&donum=' + oController.selectedDocument + '&action=search#?mode=CHANGE';
        var lct = org + pName + search;
        window.open(lct);	
	}
    
},
_prepareButtonControl: function(object, sectionID, fromToolBar) {
	var oController = this,
	oButtonControl,
    prepareInvisibleControl,
    visible,
    oType,
    priority,
    buttonType,
    buttonConfig,
    showIcon,
    dmode,
    index,
    funcIndex;
  var mainModel = oController.getModel(vui5.modelName);
  var model = oController.getModel(oController.modelName);
  var path = oController._getPath(true);
  dmode = mainModel.getProperty("/DOCUMENT_MODE") || vui5.cons.mode.display;

  oType = sap.m.ButtonType.Transparent;
  if (object['BTNTP'] == vui5.cons.buttonType.menuButton) {
    if (!underscoreJS.isEmpty(object['MNITM'])) {
      var sMenu = [];
      priority = object['FNDTP'] === global.vui5.cons.func.showInList ? sap.m.OverflowToolbarPriority.AlwaysOverflow : sap.m.OverflowToolbarPriority.High;

// index = underscoreJS.findIndex(model.getProperty(path), { SECTN: object['SECTN'] });
// funcIndex = underscoreJS.findIndex(model.getProperty(path + index + "/FUNC"), { FNCNM: object['FNCNM'] });
// var visible = "{=${" + oController.modelName + ">" + path + index + "/FUNC/" + funcIndex + "/HIDFN} === '' &&" + " ${" + oController.modelName + ">" + path + index + "/DISOL} === '' }";

      if (underscoreJS.isEmpty(object['SECTN'])) {
          index = underscoreJS.findIndex(model.getProperty("/DOFUN"), {
              SECTN: object['SECTN'],
              FNCNM: object['FNCNM']
          });
          var visible = "{=${" + oController.modelName + ">/DOFUN/" + index + "/HIDFN} === ''}";
      } else {
          index = underscoreJS.findIndex(model.getProperty(path), {
              SECTN: object['SECTN']
          });
          funcIndex = underscoreJS.findIndex(model.getProperty(path + index + "/FUNC"), {
              FNCNM: object['FNCNM']
          });
          var visible = "{=${" + oController.modelName + ">" + path + index + "/FUNC/" + funcIndex + "/HIDFN} === ''}";
      }          
      
      underscoreJS.each(object['MNITM'], function(obj) {
        var subactions = new sap.m.MenuItem({
          text: obj['VALUE'],
          key: obj['NAME']
        });
        sMenu.push(subactions);
      });
      var oMenu = new sap.m.Menu({
        items: sMenu,
        itemSelected: function(oEvt) {
          var params = {};
          var selectedAction = oEvt.getParameter('item');
          params['$SELMNITM'] = selectedAction.getKey();
          oController.onMenuItemSelected(sectionID, object, null, params);
        }
      });
      
      oType = sap.m.ButtonType.Default;
      if (object['BTNTP'] === global.vui5.cons.buttonType.accept) {
          oType = sap.m.ButtonType.Accept;
      } else if (object['BTNTP'] === global.vui5.cons.buttonType.reject) {
          oType = sap.m.ButtonType.Reject;
      }
      oButtonControl = new sap.m.MenuButton({
        menu: oMenu,
        icon: object['FNICN'],
        visible: visible
      });
      oButtonControl = new sap.m.MenuButton({
    	  //*****Rel 60E_SP6
    	  type: oType,
    	  //*****
    	  text: object['DESCR'],
    	  menu: oMenu,
    	  icon: object['FNICN'],
    	  tooltip: object['DESCR'],
    	  visible: visible,
    	  layoutData: new sap.m.OverflowToolbarLayoutData({
    		  priority: priority
    	  })
      });
      if (object['FDTYP'] == vui5.cons.functionDisplayType.text) {
        oButtonControl.setText(object['DESCR'])
      }
      
    }
    return oButtonControl;

  }
  else if (fromToolBar) {
    index = underscoreJS.findIndex(model.getProperty(path), { SECTN: object['SECTN'] });
    funcIndex = underscoreJS.findIndex(model.getProperty(path + index + "/FUNC"), { FNCNM: object['FNCNM'] });
    visible = "{=${" + oController.modelName + ">" + path + index + "/FUNC/" + funcIndex + "/HIDFN} === '' &&" + " ${" + oController.modelName + ">" + path + index + "/DISOL} === '' }";
  }
  else {
    index = underscoreJS.findIndex(model.getProperty("/DOFUN"), { FNCNM: object['FNCNM'] });
    visible = "{= ${" + oController.modelName + ">/DOFUN/" + index + "/HIDFN} === '' }";
  }
  priority = object['FNDTP'] === vui5.cons.func.showInList ? sap.m.OverflowToolbarPriority.AlwaysOverflow : sap.m.OverflowToolbarPriority.High;
  showIcon = object['FDTYP'] === vui5.cons.functionDisplayType.icon;
  buttonType = showIcon ? sap.m.OverflowToolbarButton : sap.m.Button

      if (object['BTNTP'] === vui5.cons.buttonType.accept) {
        oType = sap.m.ButtonType.Accept;
      }
      else if (object['BTNTP'] === vui5.cons.buttonType.reject) {
        oType = sap.m.ButtonType.Reject;
      }
      else if (object['BTNTP'] === vui5.cons.buttonType.emphasize) {
        oType = sap.m.ButtonType.Emphasized;
      }

  buttonConfig = {
      type: oType,
      // text: object['DESCR'],
      tooltip: object['DESCR'],

// press: [oController.onFunctionPress,oController],
press: function(oEvent){
oEvent.getSource().data("SECTN",sectionID);
oEvent.getSource().data("FNCNM",object['FNCNM']);
oController.onFunctionPress(oEvent);
},
layoutData: new sap.m.OverflowToolbarLayoutData({
priority: priority
}),
visible: visible,
// visible: "{" + oController.modelName + ">/DATA/APTIT}"
};
if (priority == sap.m.OverflowToolbarPriority.AlwaysOverflow) {
buttonConfig['icon'] = object['FNICN'];
buttonConfig['text'] = object['DESCR'];
} else {
//showIcon ? buttonConfig['icon'] = object['FNICN'] : buttonConfig['text'] = object['DESCR'];
if (showIcon) {
buttonConfig['icon'] = object['FNICN'];
buttonConfig['text'] = object['DESCR'];
}
else {
buttonConfig['text'] = object['DESCR'];
}
}
return new buttonType(buttonConfig);
},
getMainModel: function() {
return this.getOwnerComponent().getModel(vui5.modelName);
},
_getBundleText: function(propertyName) {
var oController = this;
var bundle = oController.getOwnerComponent().getModel("i18n").getResourceBundle();
return bundle.getText(propertyName);
},
getViewContent: function(action) {

  var oController = this, contextObject, navButtonVisible = false, lineLayout = false, tabBar, preparePanelContent = true, doFunctions;
  var mainModel = oController.getOwnerComponent().getModel(vui5.modelName);
  if (!oController._formDialog) {

    var msgBtn = new sap.m.semantic.MessagesIndicator({
      icon: "sap-icon://alert",
      type: sap.m.ButtonType.Emphasized,
      press: [oController._showMessages, oController]
    }).bindProperty("visible", "mainModel>/POPUP_MESSAGES",
        Formatter.showMessages, sap.ui.model.BindingMode.OneWay);

    oController.navDownButton = new sap.m.Button({
      icon: "sap-icon://navigation-down-arrow",
      visible: false,

// "{= ${" + oController.modelName + ">" + path + index + "/HDSCT} === ''}";
tooltip: oController._getBundleText('Next'),
press: [oController.onSnappingAction, oController]
}).data("itemSwitch", "NEXT");
oController.navUpButton = new sap.m.Button({
icon: "sap-icon://navigation-up-arrow",
visible: false,
tooltip: oController._getBundleText('Previous'),
press: [oController.onSnappingAction, oController]
});
var pageObject;
pageObject = oController.pageObject = new sap.m.semantic.FullscreenPage({
// title: "page title",
title: "{" + vui5.modelName+ ">" + vui5.cons.modelPath.infocusUIPrf + "/DESCR}",
showNavButton: true,
messagesIndicator: msgBtn,
customHeaderContent: [oController.navUpButton, oController.navDownButton],
navButtonPress: [oController.handleNavButtonPress,oController]
});

  }
  else {
    var pageObject;
    var continue_action = {
        "FNCNM": vui5.cons.eventName.continue,
        "RQTYP": vui5.cons.reqTypeValue.post,
        "ACTYP": vui5.cons.actionType.back
    };
    var cancel_action = {
        "FNCNM": vui5.cons.eventName.cancel,
        "RQTYP": vui5.cons.reqTypeValue.get,
        "ACTYP": vui5.cons.actionType.cancel
    };

    var check_action = {};

    if (mainModel.getProperty("/FULLSCREEN") && oController.getCurrentModel()) {
      doFunctions = oController.getCurrentModel().getProperty("/DOFUN");
      if (doFunctions) {
        check_action = underscoreJS.findWhere(doFunctions, { 'FNCNM': vui5.cons.eventName.check });
      }
    }


    var continueUrlParams = {}, cancelUrlParams = {};

    if (action['FNCNM']) {
      continueUrlParams[vui5.cons.params.modal_action] = action['FNCNM'];
      cancelUrlParams[vui5.cons.params.modal_action] = action['FNCNM'];
    }

    var continueBtn = new sap.m.Button({
      type: sap.m.ButtonType.Emphasized,
      text: oController._getBundleText('Continue'),
      press: oController.processAction.bind(oController, "", continue_action, "", continueUrlParams),
    }).bindProperty("visible", {
      parts: [
              { path: vui5.modelName + ">/FULLSCREEN" },
              { path: oController.modelName + ">/POPUP_PROP/DISPLAY_ONLY" }
              ],
              formatter: function(fullscreen, displayOnly) {
                return displayOnly ? displayOnly != "X" : fullscreen == false;
                // return (fullscreen == false || !displayOnly ) ?
                // true : false
              },
              mode: sap.ui.model.BindingMode.OneWay
    })
    var oMessageBtn = new sap.m.Button({
      icon: "sap-icon://message-popup",
      type: "Emphasized",
      press: [oController._showMessages, oController]
    })
    .bindProperty("visible", "mainModel>/POPUP_MESSAGES",
        Formatter.showPopupMessages, sap.ui.model.BindingMode.OneWay);
    var cancelBtn = new sap.m.Button({
      // text: oController._getBundleText('Cancel'),
      visible: mainModel.getProperty("/FULLSCREEN") === false,
      press: oController.processAction.bind(oController, "", cancel_action, "", cancelUrlParams)
    }).bindProperty("text", {
      parts: [
              { path: oController.modelName + ">/POPUP_PROP/FULL_VIEW" },
              { path: oController.modelName + ">/POPUP_PROP/DISPLAY_ONLY" }
              ],
              formatter: function(fullscreen, displayOnly) {
                if (fullscreen && displayOnly) {
                  return oController._getBundleText('Back')
                }
                else if (fullscreen && !displayOnly) {
                  return oController._getBundleText("DiscardChangesBtn")
                }
                else if (!fullscreen) {
                  return oController._getBundleText('Cancel')
                }
              },
              mode: sap.ui.model.BindingMode.OneWay
    });

    var checkBtn = new sap.m.Button({
      text: oController._getBundleText("Check"),
      visible: mainModel.getProperty("/DOCUMENT_MODE") !== vui5.cons.mode.display && mainModel.getProperty("/FULLSCREEN") && !underscoreJS.isEmpty(check_action),
      press: oController.processAction.bind(oController, mainModel.getProperty("/FULLSCREEN_SECTN"), check_action)
    });

    pageObject = oController.pageObject = new sap.m.Page({
      showHeader: false,
      showSubHeader: false,
      footer: [new sap.m.Bar({
        contentLeft: [oMessageBtn],
        contentRight: [continueBtn, cancelBtn, checkBtn]
      })],
    });
    pageObject.setModel(mainModel, "mainModel");
  }
  if (!oController._formDialog) {
    pageObject.bindAggregation("customFooterContent", oController.modelName + ">/DOFUN", function(sid, oContext) {
      return oController._prepareButtonControl(oContext.getObject(), "");
    });
  }
  if (lineLayout) {

    oController.ObjectPageLayout = oController._getObjectPageContent();
    pageObject.addContent(oController.ObjectPageLayout);
  }
  else if ( "PL" == vui5.cons.layoutType.pageWithTabs) {

    var objectPageLayout = oController._getObjectPageWithTabs();
    pageObject.addContent(objectPageLayout);
  }
  return pageObject;
},

_UpdateChanges: function(section, action) {
  var oController = this, triggerUpdateChangedData;
  var mainModel = oController.getModel(vui5.modelName);
  var promise, objDefer = $.Deferred();
  var dMode = mainModel.getProperty("/DOCUMENT_MODE");

  objDefer.resolve();
  return objDefer.promise();

  if (oController.checkRequiredFields()) {
    objDefer.reject();
    return objDefer.promise();
  }

  if (action && action['FNCNM'] === vui5.cons.eventName.continue) {
    triggerUpdateChangedData = false;
  }
  else {
    triggerUpdateChangedData = underscoreJS.isObject(oController._formDialog) ||
    (action && action['ACTYP'] === vui5.cons.actionType.section_change) ||
    oController.getProfileInfo()['UITYP'] === vui5.cons.UIType.listWithProcessing;

    if (!triggerUpdateChangedData) {
      triggerUpdateChangedData = dMode && dMode !== vui5.cons.mode.display;
    }
  }


  if (triggerUpdateChangedData) {
    promise = oController.updateChangedData(section);
    if (promise) {
      if (promise.then) {
        promise.then(function() {
          if (mainModel.getProperty('/DOCUMENT_ERRORS') === 'X') {
            objDefer.reject();
          } else {
            objDefer.resolve();
          }
        });
      }
    }
  } else {
    objDefer.resolve();
  }
  return objDefer.promise();
},

_getObjectPageWithTabs: function() {
  var oController = this;
  var mainModel = oController.getOwnerComponent().getModel(vui5.modelName);
  var currentModel = oController.getCurrentModel();
  var path = oController._getPath(true);
  var objectPageLayout = oController.objectPageLayout = new sap.uxap.ObjectPageLayout({
    useIconTabBar: true,
    enableLazyLoading: true,
    upperCaseAnchorBar: false,
    navigate: [oController.onTabSelect, oController]
  }).addEventDelegate({
    onAfterRendering: function(e) {
      var tabRef = e.srcControl;

// var currentKey = oController.getQueryParam('tab');
var currentKey = oController.clickedTab;
var currentModel = oController.getCurrentModel();
var scrollFlag;
var tabSections = tabRef.getSections(), currSection, currSectionId;
if (underscoreJS.isEmpty(tabSections)) {
return;
}
var flag = underscoreJS.find(tabSections, { sId: oController._currentSectionKey });
if (flag || oController.clickedTab) {
currSectionId = oController._currentSectionKey;
oController._subSectionSelectID = null;
}
else {

        var sections = currentModel.getProperty("/SECTN");
        var tabIDWithoutHeader;
        underscoreJS.each(tabSections,function(obj,ind){
          var currPath = tabSections[ind].getBindingContext(oController.modelName).sPath;
          var currSectn = currentModel.getProperty(currPath);
          if(currSectn && currSectn["DAPPT"] !== "H" && currSectn["DAPPT"] !== "SH"){
            tabIDWithoutHeader = ind;
          }
        });
        if(!tabIDWithoutHeader){
          tabIDWithoutHeader = 0;
        }
        currSectionId = tabSections[tabIDWithoutHeader].getId();
      }
      if (!e.srcControl.overRideSelectedFn) {
        var scrollToSectionFn = e.srcControl.getAggregation('_anchorBar')._requestScrollToSection;
        e.srcControl.overRideSelectedFn = true;
        e.srcControl.getAggregation('_anchorBar')._requestScrollToSection = function(sectionId, action) {
          var controlRef = this, controlArgs = arguments, promise, sectionID = sectionId;
          var subsectionsExists = sap.ui.getCore().byId(sectionID).getParent().getAggregation('subSections');
          if (subsectionsExists) {
            var currSubSections = sap.ui.getCore().byId(sectionID).getParent().getSubSections();
            oController._currentSectionKey = sap.ui.getCore().byId(sectionID).getParent().sId;
            var flag = false;
            flag = currSubSections.length > 1;
            if (flag) {
              oController._subSectionID = sectionID;
            }
          }
          else{
            oController._currentSectionKey = sectionID;
          }
          var secId = this.getSelectedSection() ? this.getSelectedSection().data('id') : sap.ui.getCore().byId(oController._currentSectionKey).data('id')
              if (action) {
                promise = oController._UpdateChanges(secId, action);
              }
              else {
                promise = oController._UpdateChanges(secId);
              }
          if (promise) {
            if (promise.then) {
              promise.then(function() {
                scrollToSectionFn.apply(controlRef, controlArgs);
              });

              return false;
            }
          }
          return scrollToSectionFn.apply(controlRef, controlArgs);
        }
        if (currentModel.getProperty("/SELECTED_SECTION")) {
          var currentSection = underscoreJS.find(tabSections, function(sectn) {
            if (sectn.data("id") === currentModel.getProperty("/SELECTED_SECTION")) {
              return sectn;
            }
          });

          if (currentSection) {
            //currSectionId = currentSection.sId;
            currentModel.setProperty("/SELECTED_SECTION", "")
            scrollFlag = true;
            oController.objectPageLayout.getAggregation('_anchorBar')._requestScrollToSection(currentSection.getId());
          }
        }

      }
      if (!scrollFlag) {
        jQuery.sap.delayedCall(500, tabRef, tabRef.scrollToSection, [currSectionId]);
      }




    }
  });

  objectPageLayout.bindAggregation("sections", oController.modelName + ">" + path, function(sId, oContext) {

    var contextObject = oContext.getObject(), switchField, currentTab, preparePanelContent = false, currSubSection, subSectionKey,
    path = oContext.getPath(),
    index = path.substring(path.lastIndexOf("/") + 1, path.length);
    currentTab = oController.clickedTab || "";

// currentTab = oController.getQueryParam("tab") || "";
// currSubSection = oController.getQueryParam("subsectn") || "";

    if (contextObject['SCGRP'] != "" || contextObject['DAPPT'] == "H") {
      return new sap.uxap.ObjectPageSection({ visible: false });
    }
    if (contextObject['FXSCT']) {

      if (contextObject['DAPPT'] === vui5.cons.propertyType.snappingHeader) {
        if (!oController.sectionRef[contextObject['SECTN']] || oController._preparePageContent) {
          oController.showPanelContent(contextObject['SECTN']);
          var headerTitle = oController.sectionRef[contextObject['SECTN']].getAggregation('_SnappingHeader');
          var headerContent = oController.sectionRef[contextObject['SECTN']].getAggregation('_SnappingHeaderContent');
          headerContent.addStyleClass('paddingAdjust');
          objectPageLayout.setHeaderTitle(headerTitle);

          objectPageLayout.removeAllHeaderContent();
          objectPageLayout.addHeaderContent(headerContent);

        }
      }
      else if (contextObject['DAPPT'] === vui5.cons.propertyType.selections) {

        if (!oController.sectionRef[contextObject['SECTN']] || oController._preparePageContent) {
          oController.showPanelContent(contextObject['SECTN']);
          var headerContent = oController.sectionRef[contextObject['SECTN']];
          headerContent.addStyleClass('paddingAdjust');
          objectPageLayout.destroyHeaderContent();
          objectPageLayout.addHeaderContent(headerContent);
        }
      }
      else if (contextObject['DAPPT'] === vui5.cons.propertyType.variant) {
        oController.showPanelContent(contextObject['SECTN']);
      }
      var objectPageSection = new sap.uxap.ObjectPageSection({ visible: false });
    }
    else {
      if (contextObject['GRPNM']) {
        var subsection;
        var objectPageSection = new sap.uxap.ObjectPageSection({
          // id:
          // oController.createId(contextObject['SECTN']),
          title: contextObject['DESCR'],
          titleUppercase: false,
          // visible: contextObject['HDSCT'] === '' && contextObject['SCGRP'] === ''
          visible: oController.getBindingExpression("sectionVisible", contextObject, index)
        }).data("id", contextObject['SECTN']);
        oController.subSectionsArr = [];
        underscoreJS.each(oController._getGroupingSections(contextObject['GRPNM']), function(obj, i) {
          var blocksArr = [];
          oController.showPanelContent(obj['SECTN']);
          if (!underscoreJS.isEmpty(obj['FILTER'])) {
            var oBlock = oController.addFilterContent(obj);
            if (!underscoreJS.isEmpty(oBlock)) {
              underscoreJS.each(oBlock, function(ob, i) {
                blocksArr.push(ob);
              });

            }
          }

          switchField = oController._prepareSwitchField();
          if (switchField) {
            blocksArr.push(switchField);
          }
          // blocksArr.push(oController.sectionRef[obj['SECTN']]);
          if (!underscoreJS.isEmpty(blocksArr)) {
            var vLayout = new sap.ui.layout.VerticalLayout({
              width: '100%',
              content: [blocksArr, oController.sectionRef[obj['SECTN']]]
            });
            subsection = new sap.uxap.ObjectPageSubSection({
              title: obj['DESCR'],
              blocks: [vLayout]
            }).data("id", obj["SECTN"]);
          }
          else {
            subsection = new sap.uxap.ObjectPageSubSection({
              title: obj['DESCR'],
              blocks: oController.sectionRef[obj['SECTN']]
            }).data("id", obj["SECTN"]);
          }
          if (currSubSection == obj["SECTN"]) {
            subSectionKey = subsection.getId();
          }
          objectPageSection.addSubSection(subsection);
        })
      }
      else {

// var subsection;
// var blocksArr = [];
// var objectPageSection = new sap.uxap.ObjectPageSection({
// // id:
// // oController.createId(contextObject['SECTN']),
// title: contextObject['DESCR'],
// titleUppercase: false,
// visible: oController.getBindingExpression("sectionVisible", contextObject, index)
// //visible: contextObject['HDSCT'] === '' && contextObject['SCGRP'] === ''
// }).data("id", contextObject['SECTN']);
// oController.showPanelContent(contextObject['SECTN']);
// if (!underscoreJS.isEmpty(contextObject['FILTER'])) {
// var oBlock = oController.addFilterContent(contextObject);
// if (!underscoreJS.isEmpty(oBlock)) {
// underscoreJS.each(oBlock, function(ob, i) {
// blocksArr.push(ob);
// });

// }
// }
// switchField = oController._prepareSwitchField();
// if (switchField) {
// blocksArr.push(switchField);
// }
// // blocksArr.push(oController.sectionRef[contextObject['SECTN']]);
// if (!underscoreJS.isEmpty(blocksArr)) {
// var vLayout = new sap.ui.layout.VerticalLayout({
// width: '100%',
// content: [blocksArr, oController.sectionRef[contextObject['SECTN']]]
// });
// subsection = new sap.uxap.ObjectPageSubSection({
// blocks: [vLayout]
// }).data("id", contextObject['SECTN']);
// }
// else {
// subsection = new sap.uxap.ObjectPageSubSection({
// blocks: oController.sectionRef[contextObject['SECTN']]
// }).data("id", contextObject['SECTN']);
// }
// if (currSubSection == contextObject["SECTN"]) {
// subSectionKey = subsection.getId();
// }
// objectPageSection.addSubSection(subsection);

        //dummy section

        var objectPageSection = new sap.uxap.ObjectPageSection({
          title: contextObject['DESCR'],
        }).data("id", contextObject['SECTN']);
        oController.showPanelContent(contextObject['SECTN']);
        var subsection = new sap.uxap.ObjectPageSubSection({
          blocks: oController.sectionRef[contextObject['SECTN']]
        }).data("id", contextObject['SECTN']);
        objectPageSection.addSubSection(subsection);

      }
    }

    if(sId.split('-')[1] == "0" && (contextObject['DAPPT'] == "H" || contextObject['DAPPT'] == "SH")){
      var position = "1";
    }else if(sId.split('-')[1] == "0"){
      var position = "0";
    }


    if (currentTab === contextObject['SECTN']) {
      if (currSubSection) {
        oController._currentSectionKey = subSectionKey;
      }
      else {
        oController._currentSectionKey = objectPageSection.getId();
      }
      if (objectPageLayout.setSelectedSection) {
        objectPageLayout.setSelectedSection(objectPageSection.getId());
      }
    }
    // if the value is 0 and contextObject is header then it will not work.
    else if (currentTab == "" && sId.split('-')[1] == position) {
      oController._currentSectionKey = objectPageSection.getId();
      if (objectPageLayout.setSelectedSection) {
        objectPageLayout.setSelectedSection(objectPageSection);
      }
    }
    return objectPageSection;
  });


  return objectPageLayout;
},

/******************************** Line Layout ***********************************/
_getObjectPageContent: function() {
  var oController = this;
  var scrollID;
  var path = oController._getPath(true);
  var objectPageLayout = new sap.uxap.ObjectPageLayout({ upperCaseAnchorBar: false });
  objectPageLayout.addEventDelegate({
    onAfterRendering: function(e) {
      var tabRef = e.srcControl;
      if (scrollID) {
        // var scrollID = oController._subSectionToSelect;
        // delete oController._subSectionToSelect;
        jQuery.sap.delayedCall(500, tabRef, tabRef.scrollToSection, [scrollID]);
      }

    }
  })
  objectPageLayout.bindAggregation("sections", oController.modelName + ">" + path, function(sId, oContext) {

    var selectedSection = oController._sectionKey ? oController._sectionKey : "", switchField;
    var selectedSubSection = oController._subSectionKey ? oController._subSectionKey : "";
    var path = oContext.getPath(),
    index = path.substring(path.lastIndexOf("/") + 1, path.length);

    var contextObject = oContext.getObject(), subSectionToSelect;
    if (contextObject['SCGRP'] != "") {
      return new sap.uxap.ObjectPageSection({ visible: false });
    }
    if (contextObject['FXSCT']) {

      if (contextObject['DAPPT'] === vui5.cons.propertyType.snappingHeader) {

        if (!oController.sectionRef[contextObject['SECTN']] | oController._preparePageContent) {
          oController.showPanelContent(contextObject['SECTN']);
          var headerTitle = oController.sectionRef[contextObject['SECTN']].getAggregation('_SnappingHeader');
          var headerContent = oController.sectionRef[contextObject['SECTN']].getAggregation('_SnappingHeaderContent');
          headerContent.addStyleClass('paddingAdjust');
          objectPageLayout.setHeaderTitle(headerTitle);
          objectPageLayout.addHeaderContent(headerContent);

        }
        var objectPageSection = new sap.uxap.ObjectPageSection(oController.createId('dummySection'), { visible: false });
      }
    }
    else {
      if (contextObject['GRPNM'] != "") {

        var objectPageSection = new sap.uxap.ObjectPageSection({
          // id:
          // oController.createId(contextObject['SECTN']),
          title: contextObject['DESCR'],
          titleUppercase: false,
          visible: oController.getBindingExpression("sectionVisible", contextObject, index)
          //visible: contextObject['HDSCT'] === '' && contextObject['SCGRP'] === ''
        }).data("id", contextObject['SECTN']);;
        oController.subSectionsArr = [];
        underscoreJS.each(oController._getGroupingSections(contextObject['GRPNM']), function(obj, i) {
          var blocksArr = [];
          oController.showPanelContent(obj['SECTN']);
          if (!underscoreJS.isEmpty(obj['FILTER'])) {
            var oBlock = oController.addFilterContent(obj);
            if (!underscoreJS.isEmpty(oBlock)) {
              underscoreJS.each(oBlock, function(ob, i) {
                blocksArr.push(ob)
              });

            }
          }

          switchField = oController._prepareSwitchField();
          if (switchField) {
            blocksArr.push(switchField);
          }
          // blocksArr.push(oController.sectionRef[obj['SECTN']]);
          if (!underscoreJS.isEmpty(blocksArr)) {
            var vLayout = new sap.ui.layout.VerticalLayout({
              width: '100%',
              content: [blocksArr, oController.sectionRef[obj['SECTN']]]
            });

            var subsection = new sap.uxap.ObjectPageSubSection({
              title: obj['DESCR'],
              blocks: [vLayout]
            }).data('id', obj['SECTN']);
          }
          else {
            var subsection = new sap.uxap.ObjectPageSubSection({
              title: obj['DESCR'],
              blocks: oController.sectionRef[obj['SECTN']]
            }).data('id', obj['SECTN']);
          }
          if (selectedSubSection === obj['SECTN']) {
            subSectionToSelect = subsection
          }
          objectPageSection.addSubSection(subsection);
        })
      }
      else {

        var subsection;
        var blocksArr = [];
        var objectPageSection = new sap.uxap.ObjectPageSection({
          // id:
          // oController.createId(contextObject['SECTN']),
          title: contextObject['DESCR'],
          titleUppercase: false,

// visible: oController.getBindingExpression("sectionVisible", contextObject, index)
//visible: contextObject['HDSCT'] === '' && contextObject['SCGRP'] === ''
}).data("id", contextObject['SECTN']);
oController.showPanelContent(contextObject['SECTN']);
// if (!underscoreJS.isEmpty(contextObject['FILTER'])) {
// var oBlock = oController.addFilterContent(contextObject);
// if (!underscoreJS.isEmpty(oBlock)) {
// underscoreJS.each(oBlock, function(ob, i) {
// blocksArr.push(ob)
// });

// }
// }
// switchField = oController._prepareSwitchField();
// if (switchField) {
// blocksArr.push(switchField);
// }
// blocksArr.push(oController.sectionRef[contextObject['SECTN']]);
if (!underscoreJS.isEmpty(blocksArr)) {
var vLayout = new sap.ui.layout.VerticalLayout({
width: '100%',
content: [blocksArr, oController.sectionRef[contextObject['SECTN']]]
});

          subsection = new sap.uxap.ObjectPageSubSection({
            blocks: [vLayout]
          }).data('id', contextObject['SECTN']);

        }
        else {
          subsection = new sap.uxap.ObjectPageSubSection({
            blocks: oController.sectionRef[contextObject['SECTN']]
          }).data('id', contextObject['SECTN']);

        }

// if (selectedSubSection === contextObject['SECTN']) {
// subSectionToSelect = subsection;
// scrollID = subsection.getId();
// }
objectPageSection.addSubSection(subsection);

      }

    }
    if (selectedSection === contextObject['SECTN']) {
      if (objectPageLayout.setSelectedSection) {
        objectPageLayout.setSelectedSection(objectPageSection.getId());
      }
      if (selectedSubSection && subSectionToSelect) {
        objectPageSection.setAssociation("selectedSubSection", subSectionToSelect, true);
        scrollID = subSectionToSelect.getId()
      }
    }
    return objectPageSection;
  });
  return objectPageLayout;
},
getCurrentModel: function() {
  return this.getModel(this.modelName);
},
/* copy popup */
_getPath: function(metadata) {
  var oController = this;
  var currentModel = oController.getCurrentModel();
  if (currentModel) {
    if (!currentModel.getProperty("/POPUP_SECTN")) {
      currentModel.setProperty("/POPUP_SECTN", {});
    }

    if (!currentModel.getProperty("/POPUP_DATA")) {
      currentModel.setProperty("/POPUP_DATA", {});
    }
  }
  return metadata ? oController._formDialog ? "/POPUP_SECTN/" : "/SECTN/" : oController._formDialog ? "/POPUP_DATA/" : "/DATA/";
},
_processSnappingHeader: function(cfg) {
  var oController = this, section, index, sectionID, sectionConfig, snappingHeader, sectionPath, dataPath, sectionModelPath;;
  var model = oController.getModel(oController.modelName);
  section = cfg.section;
  index = cfg.index;
  sectionID = section['SECTN'];
  sectionPath = oController._getPath(true);
  dataPath = oController._getPath();
  sectionModelPath = sectionPath + index;

// sectionConfig = oController.sectionConfig[sectionID];
jQuery.sap.require("bdoUtilsPath" + "/Controls/BdoSnappingHeader");
oController.sectionRef[sectionID] = new bdo.utility.snappingHeader({
controller: oController,
modelName: oController.modelName,
dropdownModel: vui5.modelName,
dataPath: dataPath + section['DARID'] + "/",
dataAreaPath: sectionModelPath + "/" + section['DARID'],
facetGroupsPath: sectionModelPath + '/FCTGRP/',
fieldsPath: sectionModelPath + "/FIELDS/",
// titlePath: "/DATA/OBHDR_TITLE/",
titlePath: dataPath + "OBHDR_TITLE/",
sectionPath:sectionModelPath
// breadCrumbLinkPress: [oController.processBreadCrumbLink, oController]

  });
  oController.sectionRef[sectionID].preProcessFieldClickEvent = function(oEvent) {
    return oController.preProcessFieldClickEvent(sectionID, oEvent);
  };
  oController.sectionRef[sectionID].setModel(model, oController.modelName);
  oController.sectionRef[sectionID].setModel(oController.getModel(vui5.modelName), vui5.modelName);
  oController.sectionRef[sectionID].snappingHeaderProcess();


},
_processSummary: function (cfg) {
  var oController = this, section, index, sectionID, dataArea, sectionConfig, sectionPath, dataPath, sectionModelPath;
  var model = oController.getModel(oController.modelName);
  section = cfg.section;
  index = cfg.index;
  sectionID = section['SECTN'];
  sectionPath = oController._getPath(true);
  dataPath = oController._getPath();
  sectionModelPath = sectionPath + index;
  var mainModel = oController.getModel(global.vui5.modelName);
  var dmode = mainModel.getProperty("/DOCUMENT_MODE");
  var editable = (dmode !== global.vui5.cons.mode.display && section['DISOL'] === '');
  sectionConfig = oController.sectionConfig[sectionID];

  jQuery.sap.require("bdoUtilsPath" + "/Controls/BdoReportingView");
  oController.sectionRef[section['SECTN']] = new bdo.utility.ReportingView({
    sectionId: sectionID,
    controller: oController,
    modelName: oController.modelName,
    chartDetailsPath: sectionModelPath + "/SUMDATA/",
    chartDataPath: dataPath,
    editable: editable
  });

// oController.sectionRef[section['SECTN']].renderSummaryView();

  // oController.sectionRef[section['SECTN']].chartObjectGet();
  oController.sectionRef[sectionID].setModel(model, oController.modelName);
},
getBindingExpression: function (name, section, index) {
  var result;
  var oController = this;
  var mainModel = oController.getModel(global.vui5.modelName);
  var model = oController.getCurrentModel();
  var path = oController._getPath(true);
  var dataPath = oController._getPath();
  switch (name) {
  case 'pageTitle':
    result = "{" + oController.modelName + ">" + dataPath + "APTIT}";
    break;
  case 'visible':
    result = "{= ${" + oController.modelName + ">" + path + index + "/HDSCT} === ''}";
    break;
  case 'title':
    result = section['DESCR'] + " (" + "{" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.maxItems + "}" + ")";
    break;
  case 'totalNumberOfRows':
    result = "{parseInt(" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.maxItems + ")}";
    break;
  case 'pageSize':
    // result = "{parseInt(" + oController.modelName +
    // ">/SECCFG/" + section['SECTN'] + "/attributes/" +
    // global.vui5.cons.attributes.pageSize + ")}";
    result = "{" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.pageSize + "}";
    break;
  case 'pageType':
    result = "{" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.pageType + "}";
    break;
  case 'showFilterConfiguration':
    result = oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.showFilterConfiguration;
    break;
  case 'editable':
    "{= ${" + vui5.modelName+ ">/DOCUMENT_MODE} !== 'A' &&" + " ${"
    + oController.modelName + ">" + "/SECTN/" + index + "/INEDT} === 'X' &&" + " ${"
    + oController.modelName + ">" + "/SECTN/" + index + "/DISOL} === '' }";
    break;
  case 'fullScreen':
    result = "{= (${" + vui5.modelName + ">/DOCUMENT_MODE} !== 'A' || ${" + oController.modelName + ">" + path + index + "/EDIT} === 'X' ) && " +
    " ${" + oController.modelName + ">" + path + index + "/INEDT} === 'X' &&" + " ${" + oController.modelName + ">" + path + index + "/DISOL} === '' }";

    if (name === 'fullScreen') {
      result = oController._formDialog ? mainModel.getProperty("/FULLSCREEN") ? true : false : result;
      //result = oController._formDialog ? false : result;
    }
    break;
  case 'enableLocalSearch':
    result = "{= ${" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.enableLocalSearch + "} === 'X' }";
    break;
  case 'noteEditable':
    result = "{= ${" + vui5.modelName + ">/DOCUMENT_MODE} !== 'A' &&" +
    " ${" + oController.modelName + ">" + path + index + "/DISOL} === '' }"
    break;
  case 'handle':
    result = "{" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.handle + "}";
    break;
  case 'enablePersonalization':
    result = "{= ${" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.enablePersonalization + "} === 'X' }";
    break;
  case 'mode':
    result = "{= ${" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.rowSelection + "} === 'X' ? " +
    sap.m.ListMode.MultiSelect + ":" + sap.m.ListMode.None + "}";
    break;
  case 'listTitle':
    result = "{" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.title + "}";
    break;
  case 'description':
    result = "{" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.description + "}";
    break;
  case 'iconField':
    result = "{" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.iconField + "}";
    break;
  case 'counter':
    result = "{" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.counter + "}";
    break;
  case 'backendSortFilter':
    result = "{= ${" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.backendSortFilter + "} === 'X' }";
    break;
  case 'totalNumberOfPages':
    result = "{" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.totalNumberofPages + "}";
    break;
  case 'descriptionField':
    result = "{" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.descriptionField + "}";
    break;
  case 'selectedField':
    result = "{" + oController.modelName + ">/SECCFG/" + section['SECTN'] + "/attributes/" + global.vui5.cons.attributes.selectedField + "}";
    break;
  case 'sectionVisible':
    result = "{= ${" + oController.modelName + ">" + path + index + "/HDSCT} === '' &&  ${" + oController.modelName + ">" + path + index + "/SCGRP} === ''}";
  }
  return result;
},
_processTreeTable: function(cfg) {
  var oController = this, section, index, sectionID, dataArea, sectionPath, dataPath;
  var model = oController.getModel(oController.modelName);
  var mainModel = oController.getModel(vui5.modelName);
  var enableSearchAndReplace, enableSetValues, oMode, oListItemType, tableRef, maxItems, hasDrillDown, sectionModelPath, sectionModelFullPath, sectionConfig;
  section = cfg.section;
  index = cfg.index;
  sectionID = section['SECTN'];
  dataArea = section['DATAR'];
  sectionPath = oController._getPath(true);
  dataPath = oController._getPath();
  sectionModelPath = sectionPath + index;
  sectionModelFullPath = oController.modelName + ">" + sectionModelPath;
  sectionConfig = oController.sectionConfig[sectionID];

  /* Process Attributes */

// hasDrillDown = !sectionConfig.onDrillDownAction;

  tableRef = oController.sectionRef[section['SECTN']] = new global.vui5.ui.controls.TreeTable({
    sectionID: section['SECTN'],
    controller: oController,
    modelName: oController.modelName,
    fieldPath: sectionModelPath + "/FIELDS/",
    dataPath: dataPath + section['DATAR'] + "/",
    dataAreaPath: sectionModelPath + "/DATAR/",
    enableSearchAndReplace: enableSearchAndReplace,
    enableSetValues: enableSetValues,
    showTitle: true,
    enableColumnFreeze: true,
    enableCustomFilter: true,

// hideDetailButton: hasDrillDown,
title: section['DESCR'],
// enablePersonalization: oController.getBindingExpression("enablePersonalization", section, index),
// handle: oController.getBindingExpression('handle', section, index),
// visible: oController.getBindingExpression('visible', section, index),
visible : true,
// totalNumberOfRows: oController.getBindingExpression("totalNumberOfRows", section, index),
// editable: oController.getBindingExpression("editable", section, index),
// enableLocalSearch: oController.getBindingExpression("enableLocalSearch", section, index),
// onPageChange: [oController.onNRServerSidePaging, oController]
});
tableRef.setSelectionMode(sap.ui.table.SelectionMode.None);

// if (hasDrillDown) {
// tableRef.attachOnDetailButton(function(evt) {
// oController.processAction.call(oController, sectionID, sectionConfig.onDrillDownAction, evt.getParameter('record'))
// });
// }

  tableRef.attachOnFieldClick(function(evt) {
    oController.preProcessFieldClickEvent(sectionID, evt);
  });

  tableRef.processOnInputChange = function(oEvent) {
    return oController.processOnInputChange(sectionID, oEvent);
  };

  // tableRef.setOnF4HelpRequest(oController.onValueHelpRequest.bind(oController));
  // tableRef.attachOnSortFilter(oController.onSortFilter.bind(oController));
  tableRef.addStyleClass("sapUiResponsiveContentPadding");
  tableRef.setModel(mainModel, vui5.modelName);
  tableRef.setModel(oController.getModel("i18n"), "i18n");
  tableRef.setModel(model, oController.modelName);
  if(dataPath && section['DATAR']){
    var data = tableRef.getModel(oController.modelName).getProperty(dataPath + section['DATAR']);
    if(data){
      oController.processTreeTableData(section, data);
    }
  }
  tableRef.prepareTable();
  oController._prepareToolBarContent(sectionID, model.getProperty(sectionModelPath + "/FUNC"));


},
_prepareToolBarContent: function(sectionID, functions) {
  var oController = this, oButtonControl, sectionFunctions, visible, oType, priority, buttonType, buttonConfig, showIcon, funcIndex;
  var mainModel = oController.getModel(vui5.modelName);
  var model = oController.getModel(oController.modelName);
  var dmode = mainModel.getProperty("/DOCUMENT_MODE");
  var path = oController._getPath(true);
  var index = underscoreJS.findIndex(model.getProperty(path), { SECTN: sectionID });

  sectionFunctions = underscoreJS.where(oController.functionRef, {
    "SECTN": sectionID
  });
  underscoreJS.each(sectionFunctions, function(object) {
    if (object && object['CONTROL']) {
      oController.sectionRef[sectionID].removeToolBarButton(object['CONTROL']);
    }
  });

  sectionFunctions = undefined;
  if (dmode == vui5.cons.mode.change) {
    sectionFunctions = underscoreJS.where(functions,{SFCHG : 'X'});
  } else if (dmode == vui5.cons.mode.display) {
    sectionFunctions = underscoreJS.where(functions,{SFDSP : 'X'});
  } else if (dmode == vui5.cons.mode.create) {
    sectionFunctions = underscoreJS.where(functions,{SFCRT : 'X'});
  }


  sectionFunctions = _.reject(sectionFunctions,function(object){
    return object['FNCNM'] == "MTCH";
  });

  underscoreJS.each(sectionFunctions, function(object) {

// if (object['BTNTP'] == vui5.cons.buttonType.menuButton) {
// if (!underscoreJS.isEmpty(object['MNITM'])) {
// var sMenu = [];
// funcIndex = underscoreJS.findIndex(model.getProperty(path + index + "/FUNC"), { FNCNM: object['FNCNM'] });
// var visible = "{=${" + oController.modelName + ">" + path + index + "/FUNC/" + funcIndex + "/HIDFN} === '' &&" + " ${" + oController.modelName + ">" + path + index + "/DISOL} === '' }";
// underscoreJS.each(object['MNITM'], function(obj) {
// var subactions = new sap.m.MenuItem({
// text: obj['VALUE'],
// key: obj['NAME']
// });
// sMenu.push(subactions);
// });
// var oMenu = new sap.m.Menu({
// items: sMenu,
// itemSelected: function(oEvt) {
// var params = {};
// var selectedAction = oEvt.getParameter('item');
// params['$SELMNITM'] = selectedAction.getKey();
// oController.processAction(sectionID, object, null, params)
// }
// });
// oButtonControl = new sap.m.MenuButton({
// menu: oMenu,
// icon: object['FNICN'],
// visible: visible
// });
// if (object['FDTYP'] == vui5.cons.functionDisplayType.text) {
// oButtonControl.setText(object['DESCR'])
// }
// }
// oController.sectionRef[sectionID].addToolBarButton(oButtonControl);

// }
// else {
oButtonControl = oController._prepareButtonControl(object, sectionID, true);
oController.sectionRef[sectionID].addToolBarButton(oButtonControl);

    //}
    oController.functionRef.push({
      "SECTN": sectionID,
      "FNCNM": object['FNCNM'],
      "CONTROL": oButtonControl
    });

  });

},
processTreeTableData: function(section, data) {
  var oController = this;
  var attributes = oController._flattenAttributes(section['ATTRB']);
  var parentColumn = attributes.parentColumn;
  var keyColumn = attributes.keyColumn;
  var childCheck = attributes.childCheckColumn;
  var data_temp = [];
  var finalTree;
  var n = 0;
  for (var i = n; i < data.length ; i++) {
    if (data[i] === undefined) {
      break;
    }

    if (data[i][childCheck]) {
      data[i]['CHILDNODE'] = oController.childNodePrepare(data[i], parentColumn, keyColumn, childCheck, data, i + 1);
    }
  }
},
childNodePrepare: function(parentNode, parentColumn, keyColumn, childCheck, data, j) {
  var oController = this;
  var treeTable = [];
  var n = 0;

  while (data[j][parentColumn] === parentNode[keyColumn]) {
    treeTable.push(data[j]);

    if (data[j][childCheck]) {
      data[j]['CHILDNODE'] = oController.childNodePrepare(data[j], parentColumn, keyColumn, childCheck, data, j + 1);
    }
    data.splice(j, 1);
    if (!data[j]) {
      break;
    }
  }
  return treeTable;
},

processAction: function(sectionID, actionObject, rowData, urlParams) {
  var action = $.extend({}, actionObject);
  if (underscoreJS.isEmpty(action)) {
    return false;
  }
  var oController = this, promise;
  var dmode = oController.getMainModel().getProperty("/DOCUMENT_MODE");
  var lineLayout = oController.getProfileInfo()['UILYT'] === vui5.cons.layoutType.line;
  var objDefer = $.Deferred();

  if (action['FNCNM'] == vui5.cons.eventName.expand) {
    oController._onExpandAction = action;
  }

  if (oController.checkRequiredFields(sectionID) && action['ACTYP'] != vui5.cons.actionType.cancel
      && action['FNCNM'] != 'CANCEL') {
    objDefer.reject();
    return objDefer.promise();
  }
  if (action['SVCFM'] && dmode !== vui5.cons.mode.display) {
    oController._handleSaveConfirmation(sectionID, action, rowData, urlParams);

  }
  else {
    switch (action['ACTYP']) {
    case vui5.cons.actionType.section_change:
      oController.processSectionChange(action);
      objDefer.resolve();
      return objDefer.promise();
      break;
    case vui5.cons.actionType.drilldown:
    case vui5.cons.actionType.back:
      promise = oController._UpdateChanges(sectionID, action);
      promise.then(function() {
        switch (action['ACTYP']) {
        case vui5.cons.actionType.drilldown:
          if (lineLayout && oController.ObjectPageLayout) {
            oController._storeSectionKeys();
          }

          if (!sectionID) {
            sectionID = action['FNCNM'];
            action['FNCNM'] = vui5.cons.eventName.expand
          }

          oController.processEvent(sectionID, action, rowData, urlParams, true).then(function() {
            oController.processDrillDownNavigation(sectionID, action, rowData);
          });
          break;

        case vui5.cons.actionType.back:
          promise = oController._checkDocumentChanges(action);
          promise.then(function() {
            oController.processEvent(sectionID, action, rowData, urlParams);
          });
          break;

        }
      });
      break;
    case vui5.cons.actionType.refresh:
      if (lineLayout && oController.ObjectPageLayout) {
        oController._storeSectionKeys();
      }
      oController.processEvent(sectionID, action, rowData, urlParams);
      break;
    default:
      return oController.processEvent(sectionID, action, rowData, urlParams);
    }
  }
},
exportAllData: function(sectionID, cfg){
	var oController = this,objDefer = $.Deferred();

// var _currentEvent = $.extend(true,{},oEvent);
// var exportAll = oEvent.getParameter("exportAll");
var fieldPath = cfg.table.getFieldPath();
var infocusModel = oController.getModel(oController.modelName);
var mainModel = oController.getModel(vui5.modelName);
var fields = infocusModel.getProperty(fieldPath);
var sectionPath = cfg.table.getDataAreaPath().split('DATAR')[0];
var section = infocusModel.getProperty(sectionPath);
var downloadData = {
Data : [],
Columns : []
};
var tableData = {
COLUMNS : [],
SORT : [],
FILTER : []
};

		if(cfg.columns && cfg.columns.length > 0){
			_.each(cfg.columns,function(object){
				if(object['VISIBLE'] == true || object['VISIBLE'] == "true"){
					var field = _.find(fields,{FLDNAME : object['COLUMNKEY']});
					if(field['ELTYP'] == 'GROUP'){
						_.each(field['FIELDS'],function(fieldObj){
							tableData.COLUMNS.push({
								FIELDNAME :  fieldObj['FLDNAME']
							});
							if(fieldObj['TXTFL'] != ''){
								if(fieldObj['SDSCR'] == vui5.cons.fieldValue.value){
									downloadData.Columns.push({
										Name : fieldObj['FLDNAME'],
										Desc : fieldObj['LABEL']
									});
								}else{
									downloadData.Columns.push({
										Name : fieldObj['TXTFL'],
										Desc : fieldObj['LABEL']
									});
								}
							}else{
								downloadData.Columns.push({
									Name : fieldObj['FLDNAME'],
									Desc : fieldObj['LABEL']
								});
							}
						});
					}else{
						tableData.COLUMNS.push({
							FIELDNAME :  field['FLDNAME']
						});
						if(field['TXTFL'] != ''){
							if(field['SDSCR'] == vui5.cons.fieldValue.value){
								downloadData.Columns.push({
									Name : field['FLDNAME'],
									Desc : field['LABEL']
								});
							}else{
								downloadData.Columns.push({
									Name : field['TXTFL'],
									Desc : field['LABEL']
								});
							}
						}else{
							downloadData.Columns.push({
								Name : field['FLDNAME'],
								Desc : field['LABEL']
							});
						}
					}
				}
			});
		}else{
			_.each(fields,function(field){
				if(field['NO_OUT'] == ""){
					if(field['ELTYP'] == 'GROUP'){
						_.each(field['FIELDS'],function(fieldObj){
							tableData.COLUMNS.push({
								FIELDNAME :  fieldObj['FLDNAME']
							});
							if(fieldObj['TXTFL'] != ''){
								if(fieldObj['SDSCR'] == vui5.cons.fieldValue.value){
									downloadData.Columns.push({
										Name : fieldObj['FLDNAME'],
										Desc : fieldObj['LABEL']
									});
								}else{
									downloadData.Columns.push({
										Name : fieldObj['TXTFL'],
										Desc : fieldObj['LABEL']
									});
								}
							}else{
								downloadData.Columns.push({
									Name : fieldObj['FLDNAME'],
									Desc : fieldObj['LABEL']
								});
							}
						});
					}else{
						tableData.COLUMNS.push({
							FIELDNAME :  field['FLDNAME']
						});
						
						if(field['TXTFL'] != ''){
							if(field['SDSCR'] == vui5.cons.fieldValue.value){
								downloadData.Columns.push({
									Name : field['FLDNAME'],
									Desc : field['LABEL']
								});
							}else{
								downloadData.Columns.push({
									Name : field['TXTFL'],
									Desc : field['LABEL']
								});
							}
						}else{
							downloadData.Columns.push({
								Name : field['FLDNAME'],
								Desc : field['LABEL']
							});
						}
					}
				}
			});
		}

		if(cfg.sorters){
			tableData.SORT = cfg.sorters;
		}

		if(cfg.filters){
			tableData.FILTER = cfg.filters;
		}

		var data = [];
		var params = [];
		params.push({
			"NAME" : "SECTN",
			"VALUE" : section['SECTN']
		});
		params.push({
			"NAME" : "DATAR",
			"VALUE" : section['DATAR']
		});
		if(oController.padar){
			 params.push({ "NAME" : "PADAR" , "VALUE": oController.padar });
		}
		if(oController.psectn){
		 params.push({ "NAME" : "PSECTN" , "VALUE": oController.psectn });
		}
		if(oController.selectedItem){
			params.push({
		          "NAME" : oController.itemKeyField,
		          "VALUE" : oController.selectedItem
		        });
		}
		data.push({
			"DATA" : [tableData],
			"PARAMS" : params,
			"DTAREA" : vui5.cons.dataarea.functions,
			"EVENT" : "DNDL"
		});
		data.push({
			"DATA" : [],
			"PARAMS" : [],
			"DTAREA" : vui5.cons.dataarea.messages,
			"EVENT" : vui5.cons.event.read
		});

		$.when(commonUtils.callServer({
			data : data,
			reqType : 'POST'
		})).then(function(result) {
			
			var messages = _.findWhere(result,{DTAREA : vui5.cons.dataarea.messages, EVENT : vui5.cons.event.read });
			if (messages['RESULT']['MESSAGES_DATA']) {
				oController.messageDataPrepare(messages['RESULT']['MESSAGES_DATA']);
			}
			
			var data  = _.findWhere(result,{DTAREA : vui5.cons.dataarea.functions, EVENT : "DNDL" });
			if(data['RESULT'] && data['RESULT']['DATA'] && data['RESULT']['DATA'][section['DATAR']]){

// downloadData.Data = data['RESULT']['DATA'][section['DATAR']];
infocusModel.setProperty("/EXCEL_DATA",data['RESULT']['DATA'][section['DATAR']]);
}
objDefer.resolve();

		});

	return objDefer.promise();
},  
_processExport: function (details) {
    sap.ui.core.BusyIndicator.show(0);
    var that = this, oController, oModel, mainModel, oColumns, oFields, oRows, darid, drpdowns, sectionID, section, oContent, editable, exp, oContent;
    oController = this;
    oModel = oController.getModel(oController.modelName);
    mainModel = oController.getMainModel();
    if (details.table) {
        oFields = oModel.getProperty(details.table.getFieldPath());
        editable = details.table.getEditable();
        sectionID = details.table.getSectionID();
        section = oController.getSectionBy('SECTN', sectionID);
        darid = section['DARID']
        
        oColumns = [];
        _.each(oFields,function(object){
        	if(object['ELTYP'] == "GROUP"){
        		_.each(object['FIELDS'],function(obj){
        			oColumns.push(obj);
        		});
        	}else{
        		oColumns.push(object);
        	}
        });
        
        drpdowns = this.getModel(global.vui5.modelName).getProperty("/DROPDOWNS/" + darid + "/");
        oColumns = _.filter(oColumns, function (obj) {
            editable ? exp = obj['NO_OUT'] === "" : exp = (obj['NO_OUT'] === "" && obj['ADFLD'] === "");
            //if(obj['NO_OUT'] !="X")
            if (exp)
                return obj;
        });
        this.tabRef = details.table;
    }
    if (!details.fromServer && details.table) {
        oRows = oModel.getProperty(details.table.getDataPath());
    }
    else {
        oRows = oModel.getProperty("/EXCEL_DATA");
    }
    if (!oRows || oRows.length == 0) {
      sap.ui.core.BusyIndicator.hide();
        sap.m.MessageToast.show("No Data To Import");
        return;
    }


    this.oGenerator = new ExcelPlus();
    this.oGenerator.createFile("export");


    if (oColumns && oColumns.length != 0) {
        var exportColumns = oController._prepareExportColumns({
            oColumns: oColumns,
            generator: this.oGenerator
        })
    }
    /*
     * Start adding the rows to the excel file
     */
    var index = 0;
    //
    this.intervalId = jQuery.sap.intervalCall(1, null, function () {

        oContent = [];
        if (exportColumns) {

            _.each(exportColumns, function (obj) {
                var fldname = obj['field'];
                var desc = obj['description'];
                var eltyp = obj['eltyp'];
                var value = oRows[index][fldname];
                if (eltyp == "C") {
                    var drpdownData = drpdowns ? drpdowns[fldname] : undefined;
                    value = Formatter.dropdownDescriptionGet(value, drpdownData);
                }
                else if (eltyp == "D") {
                    value = Formatter.dateFormat(value, that.tabRef);
                }
                oContent.push(value);

            }, that)

            that.oGenerator.writeRow(index + 2, oContent);

        }
        else {

            oContent = oRows[index].split("\t");

            that.oGenerator.writeRow(index + 1, oContent);
        }

        index++;

        if (index >= oRows.length) {
            jQuery.sap.clearIntervalCall(that.intervalId);
            sap.ui.core.BusyIndicator.hide();
            that.oGenerator.saveAs(details.fileName ? details.fileName : section['DESCR']);
        }
    }, this);
},


startLoader: function() {
        if (vui5.fromOtherApp && parent.vui5 && parent.commonUtils && parent.vui5.showBusyIndicator) {
            parent.commonUtils.stopLoader();
        }
        sap.ui.core.BusyIndicator.show();
    },
    stopLoader: function() {
        sap.ui.core.BusyIndicator.hide();
    },
    callServer: function (config) {
        if (!config.NoLoader)
            this.startLoader();
        if(config.navigation)
        {
          vui5.showBusyIndicator = true;
          commonUtils.busyIndicatorCount = 0; //As this is the last backend call before Navigating
                              //So we are setting the Busy Indicator count to 0 so that
                            //Busy indicator will hide before Application 1st backend call
          config.data.push({
            "DATA": "",
            "PARAMS": "",
            "DTAREA": "NAVTYP",
            "EVENT":"READ"
          });

        }

        var deffered = $.Deferred();

        var options = {};

        options.url = vui5.server.url.get(config);

        if (!config.reqType)
            config.reqType = 'POST';

        if (config.mimeType) {
            options.mimeType = config.mimeType;
            options.contentType = false;
            options.processData = false;
        }

        if (config.async) {
            options.async = config.async;
        }
        options.method = config.reqType;
        options.cache = false;// IE
        options.withCredentials = true;
        options.xhrFields = {};
        options.xhrFields['withCredentials'] = true;
        options.crossDomain = true;
        options.stopMessages = config.stopMessages;

        if (config.data && config.reqType == 'POST') {
            if (config.mimeType) {
                options.data = config.data;
            } else {
                if (_.isArray(config.data)) {
                    _.each(config.data, function (obj) {
                        if (_.has(obj, 'DATA')) {
                            obj['DATA'] = JSON.stringify(obj['DATA']).replace(/\"/g, "@!@");
                            if (obj['DATA']) {
                                obj['DATA'] = obj['DATA'].replace(/\\r/g, "");
                            }

                        }
                    });
                } else if (_.has(config.data, 'DATA')) {
                    config.data['DATA'] = JSON.stringify(config.data['DATA']).replace(/\"/g, "@!@");
                }

                options.data = JSON.stringify(config.data).replace(/@!@/g, '\\\"');
                if (options.data.indexOf('%') != -1) {
                    options.contentType = 'text/plain';
                }
            }
        }

        options.beforeSend = function (request) {
            request.setRequestHeader('x-csrf-token', commonUtils.server.initialCall ? 'fetch' : commonUtils.server.xcsrftoken);
        };
        vui5.session.counterPause = false;
        $.ajax(options).done(function (data, status, xhr) {

          commonUtils.sessionTimeReset();
            if (vui5.session.fromFioriLaunchpad == false)
            {
                vui5.session.counterPause = true;
            }
            if (data.indexOf("_--3") !== -1) {
                data = data.replace(/_--3/g, '');
            }
            data = JSON.parse(data);
            if(config.navigation)
            {
                var oNavTypeResponse = _.findWhere(data,{DTAREA: "NAVTYP", EVENT: "READ"});
                  if(oNavTypeResponse['RESULT']['NAVTYPE'] != "U")
                  {
                    vui5.showBusyIndicator = false;
                    commonUtils.busyIndicatorCount = 1; //As it is not a UI Application, we need to stop Busy Indicator
                  }
            }
            if (!config.NoLoader)
              if(vui5.showBusyIndicator == false)
              {
                commonUtils.stopLoader();

              }

            commonUtils.server.initialCall = false;
            commonUtils.server.xcsrftoken = xhr.getResponseHeader("x-csrf-token");

            deffered.resolve(data);
        })
        .fail(function () {
            if (!config.NoLoader)
                commonUtils.stopLoader();

            deffered.reject();

        });

        return deffered.promise();
    },

});
});`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant