cancel
Showing results for 
Search instead for 
Did you mean: 

Export to excel with more than 1 dataprovider

Former Member
0 Kudos

I have looked at examples in this forum of how others have used an "export to excel" button with more than 1 dataprovider but I cannot get these examples to work for my situation.

I have a web template with 2 (or more) dataproviders. The template has a button for "export to excel". The code came from 0QUERY_TEMPLATE. It also uses tabs and has a javascript function which hides all items except for the one on the selected tab and sets the property for the selected tab. I got the code for this from the WEB API reference for BW 3.x.

I cannot get the button "export to excel" to export the selected (non-hidden) data provider.

Any help would be greatly appreciated.

Provided below is my template.

<object>

<param name="OWNER" value="SAP_BW"/>

<param name="CMD" value="SET_PROPERTIES"/>

<param name="TEMPLATE_ID" value="ZTEST_EXPORT"/>

<param name="VARIABLE_SCREEN" value="X"/>

TEMPLATE PROPERTIES

</object>

<object>

<param name="OWNER" value="SAP_BW"/>

<param name="CMD" value="SET_DATA_PROVIDER"/>

<param name="NAME" value="DATAPROVIDER_1"/>

<param name="QUERY" value="ZPC_010"/>

<param name="INFOCUBE" value="ZPC_M01"/>

DATA_PROVIDER: DATAPROVIDER_1

</object>

<object>

<param name="OWNER" value="SAP_BW"/>

<param name="CMD" value="SET_DATA_PROVIDER"/>

<param name="NAME" value="DATAPROVIDER_2"/>

<param name="QUERY" value="ZPC_011"/>

<param name="INFOCUBE" value="ZPC_M01"/>

DATA_PROVIDER: DATAPROVIDER_2

</object>

<html>

<head>

<link href="/sap/bw/Mime/Customer/StyleSheets/ServicePortalBWReports.css" type="text/css" rel="stylesheet"/>

<Script type="text/javascript">

<!--

/* function goto_tab: Show all items, starting with tabname, Hide all other items */

function goto_tab(tabname) {

SAPBWOpenURL(SAP_BW_URL_Get()'&item=TAB*&multi=X&hidden=X&cmd_1=item%3d'tabname+'*%26hidden%3d %26multi%3dX');

}

/* DHTML function to set correct span-Tag visible

For each Tab in Tab-Header (head_TAB) check, if item TABx is visible

If Item is visible set Header as selected

Otherwise set corresponding span-Tag to not visible */

function set_actual_tab() {

i=0;

do {

i++;

if (document.getElementById('head_TAB'+i) != null) {

/* Check if Object tag is hidden */

var prop = SAPBWGetItemProp('TAB'+i);

var hidden=true;

if (prop != null){

for(j=1;j<prop.length;j++){

if (prop[j][0] == "HIDDEN") hidden = (prop[j][1]=='X');

}

}

if (hidden) {

document.getElementById("TAB"+i).setAttribute('style', 'display:none;visibility:false;',false);

}

else {

document.getElementById("head_TAB"+i).setAttribute('className', 'SAPBEXTbsTABsel',false);

}

}

} while (document.getElementById('head_TAB'+i) != null)

}

-->

</script>

</head>

<body>

<TABLE class=SAPBEXNavLineBorder cellSpacing=0 cellPadding=1 width=5 border=0>

<TR>

<TD width="5%">

<TABLE cellSpacing=1 cellPadding=2 width="100%" border=0>

<TR>

<!-- Display Export Excel--->

<TD class=SAPBEXNavLine><A href="<SAP_BW_URL CMD='EXPORT' FORMAT='XLS' DATA_PROVIDER='DATAPROVIDER_1'>">

<IMG alt="Export to MS Excel" src="Mime/BEx/Icons/S_X_XLS.gif" border=0></A></TD>

</TD></TR></TABLE></TD></TR></TABLE>

<TABLE cellSpacing=1 cellPadding=5 width="75%" border=0>

<TR>

<TD vAlign=top>

<P>

<TABLE cellSpacing=0 cellPadding=5 border=0>

<TR>

<TD class=SAPBEXTbsTab id=head_TAB1><A href="javascript:goto_tab('TAB1')">Tab 1</A></TD>

<TD class=SAPBEXTbsTab id=head_TAB2><A href="javascript:goto_tab('TAB2')">Tab 2</A></TD>

</TR></TABLE>

<TABLE class=SAPBEXTbsBdyEdg cellSpacing=0 cellPadding=5 width="5%"

border=0>

<TR>

<TD vAlign=top>

<SPAN id=TAB1><object>

<param name="OWNER" value="SAP_BW"/>

<param name="CMD" value="GET_ITEM"/>

<param name="NAME" value="TAB1"/>

<param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_GRID"/>

<param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>

<param name="GENERATE_CAPTION" value=""/>

ITEM: TAB1

</object></SPAN>

<SPAN id=TAB2><object>

<param name="OWNER" value="SAP_BW"/>

<param name="CMD" value="GET_ITEM"/>

<param name="NAME" value="TAB2"/>

<param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_GRID"/>

<param name="DATA_PROVIDER" value="DATAPROVIDER_2"/>

<param name="GENERATE_CAPTION" value=""/>

<param name="HIDDEN" value="X"/>

ITEM: TAB2

</object></SPAN>

</TD></TR></TABLE></P>

<SCRIPT type=text/javascript>

<!--

/* This function call is needed to set the correct state */

set_actual_tab();

-->

</SCRIPT>

</TD></TR></TABLE>

</body>

</html>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Export yo excel is currently supported only for 1 dataprovider. An alternative is to use the Javascript functionality provided in the BW 2.0 B "How to... Download from a Web Query into Excel" document for exporting to excel. In this case you will be able to download multiple dataproviders to excel provided the internet browser supports invoking Active X components.

The new How-to Paper on Web Printing with Excel which is suupossed to be released this month also provides the functionality to download multiple dataproviders to excel.

Thanks.

Former Member
0 Kudos

Thanks for your reply. I'm looking forward to the release of that how-to paper to assist with another one of my templates where I wish to export multiple DataProviders.

In this case though. I only want to export one data provider. All I need (perhaps) is a JavaScript function and a variable for the active DataProvider that I can assign to my "export to excel" icon button.

Since I am already using a JavaScript function for tabs which gets the properties of the active item, maybe I can leverage this function?

Former Member
0 Kudos

Hi Kevin,

Firstly let me check that I understand your question correctly. You want the export to excel button to export the dataprovider on the current tab? This is possible if there is just one dataprovider per tab. Here goes:

Step 1:

Add a global variable at the top of your javascript code:

/* initialize global variable to store active tab name on the sheet */

var gstrActiveTab= "";

Step 2:

Add this line at the end the only existing ELSE clause in the function set_actual_tab() (so its the 2nd line in this block):

gstrActiveTab="TAB"+i;

Step 3:

Write this function:

/* function to find visible tab and export the data provider to excel*/

function download_tab_to_excel()

{

/* This is the active tab, so this is the one that will be downloaded to excel*/

/* Get the data provider for download to excel*/

var prop = SAPBWGetItemProp(gstrActiveTab);

var data_provider = "";

if(prop != null)

{

for(j=1;j<prop.length;j++)

{

/* If object tag is "DATA_PROVIDER", set the value of variable "data_provider" to the value of the object */

if(prop[j][0] == "DATA_PROVIDER")

{

data_provider = prop[j][1];

/* download data_provider to excel */

window.open(SAP_BW_URL_Get() + '&CMD=EXPORT&FORMAT=XLS&DATA_PROVIDER=' +

data_provider,'Excel');

}

}

}

}

Step 4:

The code for the button will then be something like this:

<A href="javascript:download_tab_to_excel();"><IMG align="right" alt="Download Tab to Excel" src="Mime/BEx/Icons/S_X_XLS.gif" border=0></A>

I hope that does it for you. If it does, please assign points.

Thanks

Ian

Former Member
0 Kudos

Hi Deepu.

> The new How-to Paper on Web Printing with Excel which

> is suupossed to be released this month also provides

> the functionality to download multiple dataproviders

> to excel.

Do you happen to have any news about this How-to Paper you mentioned?

I couldn't find it in the Service Marketplace. I assume it's not released yet, right?

Thanks and Regards,

Yogen

former_member195980
Active Participant
Former Member
0 Kudos

Thanks Beat,

don't know why it didn't catch my eye. Guess I was looking for a different title.

Regards,

Yogen

Answers (0)