Liquid UI - WS Reference Library

Reorder table values to remove empty rows


Prerequisites


Purpose

To remove all the empty rows in a list and move the populated rows in Order.


User Interface

Log into SAP and on the SAP Easy Access Screen you will see the Liquid UI fields. Enter the materials and quantities and click on ‘Update Rows’ on the toolbar.



Liquid UI Script

//SAPLSMTR_NAVIGATION.E0100.sjs


// Purpose: Function is called to remove blank spaces
String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,'');}

// Purpose: Function is called to validate if the variable holds blank or null value
function isBlank(jvar){
    if(typeof jvar == 'string') {
        jvar = jvar.trim();
    }
    return(jvar == 'undefined' || jvar == null || jvar == "" || jvar == void 0);
}

//Move next available item in the list to blank row
function updateRows(){
    for(var i=1;i<z_endrow;i++){
        set('V[z_temp_mat]','&V[z_material_&V[i]]');
        set('V[z_temp_qty]','&V[z_quantity_&V[i]]');
        z_temp_mat = z_temp_mat.trim();
        z_temp_qty = z_temp_qty.trim();
        
        // Make Material required if Quantity is entered
        if((isBlank(z_temp_mat)) && (!isBlank(z_temp_qty))){
            return("E: Please enter Material for Item: "+i);
        }
        
        // Make Quantity required if Material is entered
        if((!isBlank(z_temp_mat)) && (isBlank(z_temp_qty))){
            return("E: Please enter Quantity for Item: "+i);
        }
            
        if((isBlank(z_temp_mat)) && (isBlank(z_temp_qty))){
            for(var j=i+1; j<z_endrow; j++){
                set("V[z_temp_next_mat]", "&V[z_material_&V[j]]");
                set(V[z_temp_next_quan]", "&V[z_quantity_&V[j]]");
                z_temp_next_mat = z_temp_next_mat.trim();
                z_temp_next_quan = z_temp_next_quan.trim();
                
                if(!isBlank(z_temp_next_mat) && !isBlank(z_temp_next_quan)){
                    //Copy the available item to blank row
                    set("V[z_material_&V[i]]","&V[z_temp_next_mat]");
                    set("V[z_quantity_&V[i]]","&V[z_temp_next_quan]");
                    
                    //Set the location to be blank
                    set("V[z_material_&V[j]]", " ");
                    set("V[z_quantity_&V[j]]", " ");
                    break;
                }
            }
        }
    }
}

// User Interface
del('X[IMAGE_CONTAINER]');        // Delete ActiveX Container on SAP Easy Access screen
del('P[User menu]');
del('P[SAP menu]');
del('P[SAP Business Workplace]');
del('P[Display role menu]');
del('P[Add to Favorites]');
del('P[Delete Favorites]');
del('P[Change Favorites]');
del('P[Move Favorites down]');
del('P[Move Favorites up]');
del('P[Create role]');
del('P[Assign users]');
del('P[Documentation]');

z_endrow = 12;                    // Update row count here
comment([1,1],"Item  Material Quantity");        
for(item_counter=1; item_counter<z_endrow; item_counter++){            // Display 10 rows on UI
    inputfield([item_counter+1,1],{"name":"z_item_&V[item_counter]", "size":4, "readonly":"true", "alignright":"true", "nolabel":"true"});
    inputfield([item_counter+1,6],{"name":"z_material_&V[item_counter]","size":18,"nolabel":"true"});        
    inputfield([item_counter+1,25],{"name":"z_quantity_&V[item_counter]","size":10,"nolabel":"true"});
    set("V[z_item_&V[item_counter]]",item_counter);
}

pushbutton([TOOLBAR],"@0Z@Update Rows",'?',{"process":updateRows});    


Was this information helpful? Send Feedback