cancel
Showing results for 
Search instead for 
Did you mean: 

Need to create "GO" button on Template

Former Member
0 Kudos
61

Hello Colleagues,

I have 4 dropdowns on Web template (plant, Material, Material Gr and Date). Whenever selected any entries in any of the 4 dropdowns (say plant-1000 from PLANT dropdown), the whole screen gets refreshed.

I am looking for something...say, select the desired value from all 4 dropdowns and then click one one extra button "GO" and then refreshed the whole screen.

Please do provide some suggestions.

Regards

Milind

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Milinda,

you have to define your own form and dropdownboxes for this. To fill your dropdownboxes you can use the web item dropdowns with the parameter ONLY_VALUES = X.

Then define a button on your web template and generate with javascript the right URL-command.

the code below is a short example with one dropdownbox and a button. Hope you can adapt this code to your requirements.

<HEAD>
<META NAME="GENERATOR" Content="Microsoft DHTML Editing Control">
<TITLE>BW Web Application</TITLE>
      <link href="https://answers.sap.com/sap/bw/Mime/BEx/StyleSheets/BWReports.css" type="text/css" rel="stylesheet"/>

<script type="text/javascript"> 
function filter () {
var url = SAP_BW_URL_Get()+'&DATA_PROVIDER=*';
url = url + '&MULTI=X&FILTER_IOBJNM_1=0CALMONTH&';
url = url + 'FILTER_VALUE_1='+document.selects.CALMONTH.value + '&FILTER_COLLAPSE=';
SAPBWOpenURL(url);
}
</script> 
</HEAD>
<BODY>
<form name="selects" action="" enctype="text/plain">
<select name="CALMONTH">
<object>
         <param name="OWNER" value="SAP_BW"/>
         <param name="CMD" value="GET_ITEM"/>
         <param name="NAME" value="DROPDOWNBOX_1"/>
         <param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_FILTER_DDOWN"/>
         <param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>
         <param name="BORDER_STYLE" value="NO_BORDER"/>
         <param name="GENERATE_CAPTION" value=""/>
         <param name="IOBJNM" value="0CALMONTH"/>
         <param name="ONLY_VALUES" value="X"/>
         <param name="TARGET_DATA_PROVIDER_1" value="DATAPROVIDER_1"/>
         ITEM:            DROPDOWNBOX_1
</object> </select> 
<input type="button" name="go" value="GO" onClick="filter()"> 
</form>
</P>
<P><object>
         <param name="OWNER" value="SAP_BW"/>
         <param name="CMD" value="GET_ITEM"/>
         <param name="NAME" value="TABLE_1"/>
         <param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_GRID"/>
         <param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>
         ITEM:            TABLE_1
</object></P>

regards

Alex

former_member184494
Active Contributor
0 Kudos

Just to expand on that..

you can use a command url by which you pass these as filter values to the query string. you can refer the WEB API for the same about using filters with command URLs.

Arun

Former Member
0 Kudos

I was bored. Try this

1st , copy the below code into your head tag

<script>

function init(){

//for each form in our template, we need to disable the action

for (var i=0;i<document.forms.length;i++)

document.forms<i>.setAttribute("action","javascript:;");

}///end function

function ggo(){

var target_url = "";

//loop thru all forms, get iobjnm for each char/kf and get the selected value

for (var i=0;i<document.forms.length;i++){

//for this form, get the iobjnm

inputs = document.forms<i>.getElementsByTagName("input")

for (var j=0;j<inputs.length;j++){

if( inputs[j].name.indexOf("FILTER_IOBJNM")>=0 ){

//this is our char/kf technical name

iobjnm = inputs[j].value;

break;//exits loop

}//end if

}//end for

//get selected filter value

filter_value = document.forms<i>.getElementsByTagName("select")[0].value;

target_url+="&FILTER_IOBJNM_" + (i+1) + "=" + iobjnm + "&FILTER_VALUE_" + (i+1) +"=" + filter_value;

}//end for

target_url = "&DATA_PROVIDER=*&MULTI=X" + target_url

url = SAP_BW_URL_Get() + target_url

SAPBWOpenURL(url)

}//end function

</script>

2nd

Add this to your <body> tag

<body onload="init()">

3rd

Put a button on your template

<input type="button" onclick="ggo()" value="GO">

That should do it.

good luck !

Former Member
0 Kudos

hi david,

interesting idea, but you had some little bugs in your functions.

I've corrected them. here's the corrected code.

Hi milinda,

with the solution of david and this code, you can use the Dropdownboxes of SAP without the option "only_values". And you can use as many dropdownboxes you want.

Now the code:

<script>
function init(){
//for each form in our template, we need to disable the action
for (var n=0;n<document.forms.length;n++)
document.forms[n].setAttribute("action","javascript:;"); 
}///end function 

function ggo(){ 
var target_url = "";
//loop thru all forms, get iobjnm for each char/kf and get the selected value
for (var n=0;n<document.forms.length;n++){
//for this form, get the iobjnm
iobjnm = null;
inputs = document.forms[n].getElementsByTagName("input");
for (var j=0;j<inputs.length;j++){
if( inputs[j].name.indexOf("FILTER_IOBJNM")>=0 ){
//this is our char/kf technical name
iobjnm = inputs[j].value;
break;//exits loop
}//end if 
}//end for 
//get selected filter value
if (iobjnm != null) {
filter_value = document.forms[n].FILTER_VALUE_1.value;
target_url+="&FILTER_IOBJNM_" + (n+1) + "=" + iobjnm + "&FILTER_VALUE_" + (n+1) +"=" + filter_value;
}
}//end for
target_url = "&DATA_PROVIDER=*&MULTI=X" + target_url;
var url = SAP_BW_URL_Get() + target_url;
SAPBWOpenURL(url);
}//end function
</script>

Alex

Now I understand your problem david, the SDN removes some parts of the code by publishing. AHHH

Message was edited by: Alexander Mader

Message was edited by: Alexander Mader

Former Member
0 Kudos

Hi Alex and David,

I need a little help over this post of your if you please remember it let me know.

I need to do the same thing but for CheckBoxes and not Drop Down.

Kindly Please let me know how to do it.

<b>

Also, whenever i write this code and execute my initial screen goes blank in WAD.

ANyidea why this is happeneing.</b>

Best Regards,

Den

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks a lot to all of you....it is woking absolutely perfect.

Points are awarded.

Regards

Former Member
0 Kudos

Any response would be really appreciated