Liquid UI - Documentation - 10.22 Display material positions in an array

10.22 Display material positions in an array


Prerequisites


Purpose:

You will learn how to find the position of the values in the indexed variable and display them. Here, the set command will assign indexed variable values into a temporary variable. You can access and display the temporary variable values in the console window. We will walk you through the following steps.

  1. Delete unnecessary elements
  2. Add an array with material numbers

//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 redundant/unneeded screen elements on the SAP Easy Access screen.
    del("X[IMAGE_CONTAINER]");
    
     

     
  2. Add an array with material numbers.
    // array with material numbers
    materialnumber = ["1001","1002","1003","1004","1005"]; 
    

     
  3. Add a for loop to display materials at their position in the array. Here, we used set command to assign material number in the array to a temporary variable(z-temp).
    for(idx=0;idx<5;idx++){     
     // assigning values to temp variable using index
       set("V[z_temp]" , materialnumber[idx]);
        // conditions for checking value in temp variable           
       if (z_temp == "1005") {  
          println("Material at 5th position in materialnumber array>>>" +z_temp);            
       }
       if (z_temp == "1004") {            
          println("Material at 4th position in materialnumber array>>>" +z_temp);            
       }
       if (z_temp == "1003") {            
          println("Material at 3th position in materialnumber array>>>" +z_temp);            
       }
       if (z_temp == "1002") {            
          println("Material at 2th position in materialnumber array>>>" +z_temp);            
       }
       if (z_temp == "1001") {            
          println("Material at 1th position in materialnumber array>>>" +z_temp);            
       }
    }
    

     
  4. Navigate to SAP Easy Access screen. The material numbers with their positions in the indexed variable is displayed as shown in the console window.
     

     

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