Skip to Content

Call Javascript function on Click of a button in UI in .htm page


Hi ,

I am trying to implement export to excel functionality as mentioned in the below given wiki.

Download data from web ui to Excel and PPT - CRM - SCN Wiki

but when I click on the button then nothing happens in Web UI. Could you please help me and let me know if I am missing anything.

Thanks & Regards,

Kumar Gaurav

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Nov 18, 2014 at 05:22 AM

    Below is the code I have written in .htm page:

    <%@page language="abap" %>

    <%@extension name="htmlb" prefix="htmlb" %>

    <%@extension name="thtmlb" prefix="thtmlb" %>

    <%@extension name="chtmlb" prefix="chtmlb" %>

    <%@extension name="bsp" prefix="bsp" %>

    <%

    data: lv_xml type string.

    DATA : lv_visible_row_count type i value 10.

    lv_xml = controller->CONFIGURATION_DESCR->GET_CONFIG_DATA( ).

    data: lv_iterator type ref to CL_CRM_TPMOE_ADSEARE_ITERATOR2.

    create object lv_iterator

    exporting

    ir_context_node = advancedsearchresult

    iv_mass_approve_flag = controller->GV_CUCOTRADE->mass_approve_flag.

    lv_visible_row_count = controller->GET_VISIBLE_ROW_COUNT( ).

    if lv_visible_row_count is initial or lv_visible_row_count = 0.

    lv_visible_row_count = controller->GET_VISIBLE_ROW_COUNT( ).

    endif.

    %>

    <%--<thtmlb:tray height = "100%"

    id = "RPC">



    <thtmlb:trayBody> --%>



    <chtmlb:tableExtension tableId = "Table"

    layout = "FIXED" >

    <chtmlb:configCellerator id = "theCellerator"

    actions = "<%= controller->gt_button %>"

    actionsMaxInRow = "10"

    iterator2 = "<%= lv_iterator %>"

    table = "//ADVANCEDSEARCHRESULT/table"

    usage = "SEARCHRESULT"

    selectionMode = "MULTI"

    onRowSelection = "select"

    tableLayout = "FIXED"

    selectedRowIndexTable = "<%= ADVANCEDSEARCHRESULT->SELECTION_TAB %>"

    scrollRowCount = "20"

    hasExpander = " "

    horizontalScrolling = "TRUE"

    expandedObjectIndexTable = "<%= controller->GT_EXPANDALL %>"

    visibleRowCount = "<%= lv_visible_row_count %>"

    isExpanded = "FROMREQUEST"

    downloadToExcel = "TRUE" />

    </chtmlb:tableExtension>



    <%--****RPC Mass change Upload and download buttons --GAP043--%>

    <% DATA: v_vkorg TYPE VKORG,

    lv_org TYPE VKORG.

    CALL METHOD zcl_crm_webui_org_data_helper=>get_active_sales_org

    IMPORTING

    ev_vkorg = v_vkorg.



    SELECT SINGLE SALESORG from zvt_rpcmasschang INTO lv_org WHERE salesorg eq v_vkorg.

    if sy-subrc eq 0.

    %>



    <%-- CLEAR i_button.--%>

    <BR>

    <thtmlb:button id = "RPCDownload"

    design = "EMPHASIZED"

    text = "RPC Download"

    enabled = "TRUE"

    onClientClick = "javascript:dwnToExcel( );" />

    <%--<bsp:htmlbEvent name = "namedown"

    id = "iddown"

    onClick = "serverEvent"

    p1 = "p1"

    p2 = "p2"

    p3 = "p3" />--%>



    <script language="javascript">

    <%--var button = document.getElementById("RPCDownload");

    button.focus();

    button.click();--%>



    function dwnToExcel( )

    {

    var Excel, Workbook;

    var count=1;

    Excel = NEW ActiveXObject("Excel.Application");

    Workbook = Excel.Workbooks.Add();

    Workbook.ActiveSheet.Cells(1,1).Value = "Product ID";

    Workbook.ActiveSheet.Cells(1,2).Value = "SoldToParty";

    Workbook.ActiveSheet.Cells(1,3).Value = "Condition Value";

    Workbook.ActiveSheet.Cells(1,4).Value = "Currency";

    Workbook.ActiveSheet.Cells(1,5).Value = "Valid from";

    Workbook.ActiveSheet.Cells(1,6).Value = "ValidTo";



    Workbook.ActiveSheet.Range("A1:F1").Interior.ColorIndex = 43;

    Workbook.ActiveSheet.Range("A1:F6").Borders(7).LineStyle = 2;

    Workbook.ActiveSheet.Range("A1:F6").Borders(8).LineStyle = 2;

    Workbook.ActiveSheet.Range("A1:F6").Borders(9).LineStyle = 2;

    Workbook.ActiveSheet.Range("A1:F6").Borders(10).LineStyle = 2;

    Workbook.ActiveSheet.Range("A1:F6").Font.Size = 10;







    Workbook.ActiveSheet.Cells(1,1).Value = "<%= '50' %>";

    Workbook.ActiveSheet.Cells(2,2).Value = "<%= '60' %>";

    Workbook.ActiveSheet.Cells(3,3).Value = "<%= '70' %>";

    Workbook.ActiveSheet.Cells(4,4).Value = "<%= '80' %>";

    Workbook.ActiveSheet.Cells(5,5).Value = "<%= '90' %>";

    Workbook.ActiveSheet.Cells(6,6).Value = "<%= '100' %>";





    Excel.Visible = "true";

    }

    </Script>

    <% endif.

    %>

    <%--</thtmlb:trayBody>

    </thtmlb:tray>--%>



    <%

    CLEAR controller->GT_EXPANDALL.

    %>

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 23, 2016 at 10:08 AM

    Hey Kumar,

    I have a requirement to call UI5 app from button of BSP component.

    So, could you please direct me the right path?

    Thanks,

    Devashish 😊

    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.