cancel
Showing results for 
Search instead for 
Did you mean: 

Hiding tabs in a Web-interface

Former Member
0 Kudos

Hi!

we have a BPS Web-interface with several tabs, each containing a Web-layout. User access is restricted via R_PARAM to certain tabs/layouts ... and this works fine (user gets a message "no access" when he tries to open an restricted tab).

Is there a way to hide these tabs that are restricted for a certain user?

Thanks,

Holger

Accepted Solutions (1)

Accepted Solutions (1)

former_member93896
Active Contributor
0 Kudos

Hello Holger,

here's how to do it. First create a numeric variable in BPS of type exit. In the exit you do the auth.check and return for example 0 if all tabs should be displayed and 1 if certain tabs should be hidden. This logic can be of course more sophisticated.

Add this variable to the end of the web interface (component name = VarAuthCheck). Then add a text component (HTML = true) with the following script:

<script language="JavaScript">
function wif_hide_tab(wif_tabstrip, wif_tabpage) {
  var tabitem = wif_tabstrip + "-itm-" + wif_tabpage;

  // Alternative 1: Disable Tab
  document.all(tabitem).onclick = new Function ('return false;');
  document.all(tabitem).onkeydown = new Function ('return false;');
  document.all(tabitem).style.cursor = "default";
  document.all(tabitem + "-txt").innerHTML = "(not authorized)";

  // Alternative 2: Hide tab
  document.all(tabitem).style.display = "none";
  var tabstrip = wif_tabstrip + "-tbl";
  var tabfocus = document.all(tabstrip).getAttribute("focusedtab");
  var tabcount = document.all(tabstrip).getAttribute("tabcount") - 1;
  if ( tabcount == wif_tabpage ) {
    tabitem = wif_tabstrip + "-n";
    document.all(tabitem).style.display = "none"; 
    tabitem = wif_tabstrip + "-itm-" + wif_tabpage + "-a";
    tabcount -= 1;
    if ( tabcount == tabfocus ) 
      document.all(tabitem).className = "urTbsLastOnNextOff";    
    else
      document.all(tabitem).className = "urTbsLastOffNextOff";    
  }
  else {
    if ( tabfocus < wif_tabpage ) wif_tabpage += 1;
    tabitem = wif_tabstrip + "-itm-" + wif_tabpage + "-a";
    document.all(tabitem).style.display = "none"; 
  }
}

var wif_varcheck = "VarAuthCheck";

var theForm = getForm();

if ( theForm.elements(wif_varcheck).value == 1 ) {
  // note: tab numbering starts with zero
  wif_hide_tab("TabStrip1", 1);
  wif_hide_tab("TabStrip1", 2);
}
  
theForm.elements(wif_varcheck).style.display = "none";
</script>

In this example, the tabstrip is called "TabStrip1" and the second and third tabpage are hidden.

Of course the logic of passing the return code of the auth check in the script and evaluating, which tabs should be hidden, could be much more complex.

Regards,

Marc

SAP NetWeaver RIG

Former Member
0 Kudos

Hi Marc,

your solution is verygood,I used your code and solved my problem,but I found maybe there's a little bug in it.I have 2 tabpage under my Tabstrip1,when I hide the second tabpage,everything is fine,but when I hide my first tabpage and run my Web application,I can still see the first tabpage at the first time,when I click the second tabpage(Not hide) and back to click the first tabpage,it disabled,how can I hide the first tabpage successfully?

hope for the answer,thank you very much!

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Holger Mertens,

I working on same application as you mentioned here,

could you tell me what is mean by User access is restricted via R_PARAM to certain tabs/layouts ... what is R_PARAM.

Former Member
0 Kudos

Hi denni,

I should use this process for my WIB. Could you provide example of your exit ?

Thanks in advance

Former Member
0 Kudos

Hi Jacques,

the EXIT is not complicated,you can define a numeric variable and it's type is USER-EXIT, the EXIT function you can refer to UPF_VARIABLE_USER_EXIT_NUM,you can create your own logic in your EXIT and return a numeric value,if it return 1 do something A,return 0 do something B.