Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Excel Toolbar missing in HTML Viewer

Former Member
0 Kudos
316

Dear experts,

I have written a program that generates an excel file and the displays this excel in a screen.

--> requirement was not to open MS Excel as an application, but to display the excel file in the SAP screen

--> excel is NOT an ALV report

I used the HTML Viewer to display the excel in my screen (CL_GUI_HTML_VIEWER).

Everything works fine, only in the excel file displayed in the HTML viewer, the excel toolbar (is not displayed).

Can anybody help me in how to display the excel file with excel toolbar (as the user needs to make modifications, and then needs to save the file)...

Thank you for your valuable inputs.

Rgds,

Michiel Strybol

1 ACCEPTED SOLUTION

pepl
Active Participant
0 Kudos
119

Hello Michael!

Could u share your code, please? What technique do u use to open it?

I suggest u technique i would apply.

1) On your screen place a custom container control (I've used CC_EXCEL)

2) Put this code into your program

report zjdtest.

DATA: go_control        type ref to I_OI_CONTAINER_CONTROL,
      go_container      type ref to cl_gui_custom_container,
      go_document_proxy type ref to i_oi_document_proxy.
data: gt_file type FILETABLE,
      gd_rc   type i.

parameters p_file type localfile.

at selection-screen on value-request for p_file.

    CALL METHOD cl_gui_frontend_services=>file_open_dialog
      EXPORTING
         window_title            = 'Open file'
         file_filter             = cl_gui_frontend_services=>filetype_excel
      CHANGING
        file_table              = gt_file
        rc                      = gd_rc.

    check gd_rc ne -1.
    read table gt_file into p_file index 1.

start-of-selection.
  call screen 0100.

module STATUS_0100 output.
  SET PF-STATUS 'TEST'.
endmodule.

module HANDLE_EXIT input.
  leave program.
endmodule.

module OPEN_EXCEL output.
    data: ld_document_url type localfile.

    check go_control is initial.
    CALL METHOD c_oi_container_control_creator=>get_container_control
      IMPORTING control = go_control.

    CREATE OBJECT go_container EXPORTING container_name = 'CC_EXCEL'.
    CALL METHOD go_control->init_control
      EXPORTING r3_application_name     = 'R/3 TR'
                inplace_enabled         = 'X'
                parent                  = go_container.

    CALL METHOD go_control->get_document_proxy
      EXPORTING document_type      = 'Excel.Sheet'
      IMPORTING document_proxy     = go_document_proxy.

    concatenate 'file://' p_file into ld_document_url.
    CALL METHOD go_document_proxy->open_document
      EXPORTING document_url     = ld_document_url
                open_inplace     = 'X'
                open_readonly    = 'X'.
endmodule.

4 REPLIES 4

pepl
Active Participant
0 Kudos
120

Hello Michael!

Could u share your code, please? What technique do u use to open it?

I suggest u technique i would apply.

1) On your screen place a custom container control (I've used CC_EXCEL)

2) Put this code into your program

report zjdtest.

DATA: go_control        type ref to I_OI_CONTAINER_CONTROL,
      go_container      type ref to cl_gui_custom_container,
      go_document_proxy type ref to i_oi_document_proxy.
data: gt_file type FILETABLE,
      gd_rc   type i.

parameters p_file type localfile.

at selection-screen on value-request for p_file.

    CALL METHOD cl_gui_frontend_services=>file_open_dialog
      EXPORTING
         window_title            = 'Open file'
         file_filter             = cl_gui_frontend_services=>filetype_excel
      CHANGING
        file_table              = gt_file
        rc                      = gd_rc.

    check gd_rc ne -1.
    read table gt_file into p_file index 1.

start-of-selection.
  call screen 0100.

module STATUS_0100 output.
  SET PF-STATUS 'TEST'.
endmodule.

module HANDLE_EXIT input.
  leave program.
endmodule.

module OPEN_EXCEL output.
    data: ld_document_url type localfile.

    check go_control is initial.
    CALL METHOD c_oi_container_control_creator=>get_container_control
      IMPORTING control = go_control.

    CREATE OBJECT go_container EXPORTING container_name = 'CC_EXCEL'.
    CALL METHOD go_control->init_control
      EXPORTING r3_application_name     = 'R/3 TR'
                inplace_enabled         = 'X'
                parent                  = go_container.

    CALL METHOD go_control->get_document_proxy
      EXPORTING document_type      = 'Excel.Sheet'
      IMPORTING document_proxy     = go_document_proxy.

    concatenate 'file://' p_file into ld_document_url.
    CALL METHOD go_document_proxy->open_document
      EXPORTING document_url     = ld_document_url
                open_inplace     = 'X'
                open_readonly    = 'X'.
endmodule.

pepl
Active Participant
0 Kudos
119

I mean make a test program with this code to understand how it works))

Former Member
0 Kudos
119

Thank you so much!

This helped me too today

Former Member
0 Kudos
119

Thank you Petr.Plenkov,

Your solution works perfect !!