Purpose:
Calculate the processing statistics of transactions.
Liquid UI Code:
// SAPLSMTR_NAVIGATION.E0100.sjs
// Function to convert milliseconds to Sec/Min/Hrs/Days
function timeConversion(millisec) {
var seconds = (millisec / 1000).toFixed(2);
var minutes = (millisec / (1000 * 60)).toFixed(2);
var hours = (millisec / (1000 * 60 * 60)).toFixed(2);
var days = (millisec / (1000 * 60 * 60 * 24)).toFixed(2);
if (seconds < 60) {
return seconds + " Sec";
} else if (minutes < 60) {
return minutes + " Min";
} else if (hours < 24) {
return hours + " Hrs";
} else {
return days + " Days"
}
}
// Function to calculate Processing Statistics
function processingStatistics(){
var nExecutedTransactions = 0;
var s = new Date();
onscreen 'SAPLSMTR_NAVIGATION.0100'
enter('/nMM01');
onscreen 'SAPLMGMM.0060'
set('F[Industry sector]','M');
set('F[Material Type]','FERT');
enter('/5');
onscreen 'SAPLMGMM.0070'
enter('/19');
onscreen 'SAPLMGMM.0070'
set('cell[TABLE,0,1]','X');
enter();
onscreen 'SAPLMGMM.4004'
set('F[MAKT-MAKTX]', 'Test 1');
set('F[MARA-MEINS]', 'EA');
enter('/11');
onscreen 'SAPLMGMM.0060'
set('V[z_mm01_num]',_message.match(/\d+/));
nExecutedTransactions++;
enter('/nIW21');
onscreen 'SAPLIQS0.0100'
set("F[Notification type]", "M1");
enter();
onscreen 'SAPLIQS0.7200'
set("F[VIQMEL-QMTXT]", "test");
set("F[Functional loc.]", "21-B02");
set("F[Equipment]", "TEQ-21");
enter('/11');
onscreen 'SAPLIQS0.0100'
set('V[z_iw21_num]',_message.match(/\d+/));
nExecutedTransactions++;
enter('/nMMBE');
onscreen 'RMMMBESTN.1000'
set('F[Material]','97104');
enter('/8');
onscreen 'RMMMBESTN.0300'
nExecutedTransactions++;
enter('/n');
onscreen 'SAPLSMTR_NAVIGATION.0100'
var e = new Date();
var timeElapsed = e - s;
var perTranTime = timeElapsed / nExecutedTransactions;
set('V[z_transactions]','&V[nExecutedTransactions]');
timeElapsed = timeConversion(timeElapsed);
perTranTime = timeConversion(perTranTime);
set('V[z_executed_time]','&V[timeElapsed]');
set('V[z_avg_time]','&V[perTranTime]');
enter('?');
}
// User Interface
clearscreen();
pushbutton([1,0], "Process Statistics", {"process":processingStatistics});
inputfield([2,0], "Total Transactions", [2,25], {"size":2, "name":"z_transactions", "readonly":true});
inputfield([3,0], "Executed Time", [3,25], {"size":10, "name":"z_executed_time", "readonly":true});
inputfield([4,0], "Average Time/Transaction", [4,25], {"size":10, "name":"z_avg_time", "readonly":true});
inputfield([5,0], "Material Number", [5,25], {"size":10, "name":"z_mm01_num", "readonly":true});
inputfield([6,0], "Notification Number", [6,25], {"size":10, "name":"z_iw21_num", "readonly":true});
See attachments for code samples!