Author Topic: Dependent Dropdownlists using WS  (Read 1857 times)

Sai Siddhartha

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 47
    • View Profile
Dependent Dropdownlists using WS
« on: September 28, 2017, 09:45:54 AM »
Purpose:
Creating dependent dropdownlist using WS dropdownlist command.

Interface:
On 'VA01' transaction initial screen, a dropdown for 'Sales Organization' is displayed.                 
On selecting an option in that dropdown another dropdown for 'Distribution Channel' is displayed dynamically
With options varying based on selection Criteria.

Liquid UI Script:
////////////////////////////// SAPMV45A.E0101.sjs /////////////////////////

String.prototype.trim = function() { //trim function
   return this.replace(/^\s+|\s+$/g,"");
}

function isBlank(jvar){ // isBlank function to check value of variable
      if(typeof jvar == 'string') {
               jvar = jvar.trim();
     }
     if(typeof jvar == 'undefined') {
              jvar = '';
      }
      return(jvar == 'undefined' || jvar == undefined || jvar == null || jvar == "" || jvar == void 0);
}

// dropdownlist for sales organization
set("V[z_salesorg_list]", "=--- Select Sales Organization ---;1000=Germany Frankfurt;2000=UK Heathrow/Hayes;3000=USA Philadelphia;");
dropdownlist([5, 30], "z_salesorg_list", {"refer":"z_va01_salesorg","width":25,"process":z_set_sorg});

if(!isBlank(z_va01_salesorg)){
     switch(z_va01_salesorg){  // switch case for changing selection list based on sales organization value
          case "1000":
          set("V[z_dchl_list]", "=--- Select Distribution Channel ---;01=General Trade;02=Exports;10=Final customer sales;");
          break;

          case "2000":
          set("V[z_dchl_list]", "=--- Select Distribution Channel ---;10=Final customer sales;12=Sold for resale;14=Service;16=Factory sales;30=Internet Sales;");
          break;

          case "3000":
          set("V[z_dchl_list]", "=--- Select Distribution Channel ---;01=General Trade;02=Exports;10=Final customer sales;12=Sold for resale;14=Service;");
          break;
     }
     dropdownlist([6, 30], "z_dchl_list", {"refer":"z_va01_dchl","width":25,"process":z_set_dchl}); // Distribution channel dropdown list
}

function z_set_sorg(){ // function to set value dropdown option into "Sales Organization" field
   set("F[Sales Organization]","&V[z_va01_salesorg]");
   println("-------------------z_va01_salesorg--------------"+z_va01_salesorg);
   enter('?');
}

function z_set_dchl(){ // function to set value dropdown option into "Distribution Channel" field
   set("F[Distribution Channel]","&V[z_va01_dchl]");
   println("-------------------z_va01_dchl--------------"+z_va01_dchl);
   enter('?');
}

See attachment for screenshots