Liquid UI - Documentation - 23.09 Processing Statistics Calculation

23.09 Processing Statistics Calculation


Prerequisites


Purpose

You will learn how to calculate the statistics of the process defined in a function and display on the inputfields on the SAP Easy Access screen. We will walk you through the following steps.

  1. Delete unnecessary elements
  2. Add inputfields
  3. Add pushbuttons
  4. Add function to convert time
  5. Add function to display process statistics.

//Create this file inside your script folder for customizing SAP Easy Access screen: SAPLSMTR_NAVIGATION.E0100.sjs
//Now let's start adding the content to the above file

  1. Delete the image container on the SAP Easy Access screen.
    del("X[IMAGE_CONTAINER]");
    
     

     
  2. Add five inputfields to display the total transactions worked on, execution time of the script, average time taken for a transaction, Material Number and Notification Number.
    IW32_functions.sjs
    //Creates inputfield with a label as Total Transactions, technical name as z_transactions and it is non editable
    inputfield([2,0], "Total Transactions", [2,25], {"size":2, "name":"z_transactions", "readonly":true});
    //Creates inputfield with a label as Executed Time, technical name as z_executed_time and it is non editable
    inputfield([3,0], "Executed Time", [3,25], {"size":10, "name":"z_executed_time", "readonly":true});
    //Creates inputfield with a label as Average Time/Transaction, technical name as z_avg_time and it is non editable
    inputfield([4,0], "Average Time/Transaction", [4,25], {"size":10, "name":"z_avg_time", "readonly":true});
    //Creates inputfield with a label as Material Number, technical name as z_mm01_num and it is non editable
    inputfield([5,0], "Material Number", [5,25], {"size":10, "name":"z_mm01_num", "readonly":true});
    //Creates inputfield with a label as Notification Number, technical name as z_iw21_num and it is non editable
    inputfield([6,0], "Notification Number", [6,25], {"size":10, "name":"z_iw21_num", "readonly":true});
    
     

     
  3. Add a pushbutton to execute the processingStatistics function to calculate and display the statistics of a process defined.
    //Creates pushbutton with a label as Process Statistics, and executes processingStatistics function on click
    pushbutton([1,0], "Process Statistics", {"process":processingStatistics});
    
     

     
  4. Add a function to convert time defined in milliseconds to either Seconds/Minutes/Hours/Days.
    // 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"
        }
    }    
    

     
  5. Add a function to execute the block of code to navigate to various transactions and display the statistics of the process defined in the function.
     
    // 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('?');
    }
    
    
     
  6. Click the processingStatistics pushbutton to display the statistics of the process defined in the fields as shown below:
     

     


Next Steps

Add time delay in a process/function
Learn how to add a time delay in a process to perform required actions.

10 min.

This article is part of the Invoking functions tutorial.

Read selected grid data
Learn how to retrieve required information from a grid screen and display them in input fields.

10 min.

This article is also a part of the Javascript functions tutorial.


Can't find the answers you're looking for?