Skip to Content
author's profile photo Former Member
Former Member

Template with tabs Export to excel with variable dataprovider

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

I have a web template with 2 tabs, 1 dataprovider on each. The template has an icon button for "export to excel". The code came from 0QUERY_TEMPLATE. The tabs require 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. I need somehow to have a variable for dataprovider on the command to export.

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>

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Posted on Feb 07, 2005 at 08:50 PM

    Have you tried using something like:

    <A href="<SAP_BW_URL CMD='EXPORT' FORMAT='XLS' DATA_PROVIDER='DATAPROVIDER*' MULTI='X'>

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Yes, I have. When exporting you have to reference the specific dataprovider.

      I have seen some JavaScript functions shown in this forum that work, but cannot get them to work with my specific situation due to the tabs and the excel icon.

  • Posted on Feb 08, 2005 at 03:59 PM

    Hi Kevin,

    just create two different links and place each in the SPANs or use JavaScript to solve your problem.

    I got no time but i will look for a working JS.

    Regards,

    Adem

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Adem: Thanks for your reply.

      I don't think that I can place 2 links, 1 in each of the SPANs because the icon button has to be at the top of the template in a toolbar.

      If you have a working JavaScript to solve this problem I would greatly appreciate it. Thanks.

      Kevin

  • author's profile photo Former Member
    Former Member
    Posted on Feb 08, 2005 at 10:17 PM

    Kevin,

    Try calling a javascript function (e.g. excel_export) when the export icon is clicked on.

    Using the prop array find the tab that is not hidden and then use that index to build your export command. i.e. if tab1 is visible then pass dataprovider_1 to the excel download command.

    Another method would be to place a hidden field on the form to store the dataprovider and then read that field in the javascript function. You would have to update this field when you switched between the tabs.

    Cheers,

    Kelly

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.