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: 

How to get multiple tabs output in excel from alv display?

Former Member
0 Kudos

I have a requirement of getting multiple tabs output in excel from an alv display. I looked up in internet and found some functionality regarding OLE, didn't understand anything. I'm a newbie in sap ABAP. An explanation regarding OLE or any other method will be really helpful.

Thaniks,

Pritish

2 REPLIES 2

roberto_vacca2
Active Contributor

Hi.

I suppose that once you've created your I_OI_SPREADSHEET instance, you can use method

    CALL METHOD SPREADSHEETINTF->add_sheet
           EXPORTING name     = psheet
                     no_flush  = ' '
           IMPORTING error     = zjncerror
                     retcode   = zjncretcode.

To get your spreadsheetintf instance you'll have to call in sequence:





  CREATE OBJECT zjnccontainer
    EXPORTING
      CONTAINER_NAME              = 'MYCONTROL'
    EXCEPTIONS
      CNTL_ERROR                  = 1
      CNTL_SYSTEM_ERROR           = 2
      CREATE_ERROR                = 3
      LIFETIME_ERROR              = 4
      LIFETIME_DYNPRO_DYNPRO_LINK = 5.
  IF sy-subrc NE 0.
*      add your handling
  ENDIF.
  CALL METHOD zjnccontrol->init_control
    EXPORTING
      r3_application_name      = 'R/3 Basis'                "#EC NOTEXT
      inplace_enabled          = 'X'
      inplace_scroll_documents = 'X'
      parent                   = zjnccontainer
      register_on_close_event  = 'X'
      register_on_custom_event = 'X'
      no_flush                 = 'X'
    IMPORTING
      error                    = zjncerror.
  IF sy-subrc NE 0.
    CALL FUNCTION 'POPUP_TO_INFORM'
      EXPORTING
        titel = zjnc_repid
        txt2  = 'INIT OLE zjnccontrol Failed'
        txt1  = 'to init Excel zjnccontrol'.
    Leave Program.
  ENDIF.
  CALL METHOD zjnccontrol->get_document_proxy
     EXPORTING document_type       = zjncexcelsheet
*                document_format     = document_format
*                register_container  = register_container
               no_flush            = ' '
     IMPORTING document_proxy       = zjncdocument
               retcode              = zjncretcode
               error                = zjncerror.
  IF sy-subrc NE 0.
    CALL FUNCTION 'POPUP_TO_INFORM'
      EXPORTING
        titel = zjnc_repid
        txt2  = 'Create zjncdocument PROXY Failed'
        txt1  = 'to make Excel zjncdocument'.
    Leave Program.
  ENDIF.
  CALL METHOD zjncdocument->create_document
    EXPORTING open_inplace     = ' '
*               create_view_data = create_view_data
*               onsave_macro     = onsave_macro
*               startup_macro    = startup_macro
              document_title   = 'Excel'
              no_flush         = ' '
   IMPORTING error            = zjncerror
*               retcode          = retcode
              .
  IF sy-subrc NE 0.
    CALL FUNCTION 'POPUP_TO_INFORM'
      EXPORTING
        titel = zjnc_repid
        txt2  = 'Create zjncdocument Failed'
        txt1  = 'to make Excel zjncdocument'.
    Leave Program.
  ENDIF.
  CALL METHOD zjncdocument->get_spreadsheet_interface
    EXPORTING
      no_flush        = ' '
    IMPORTING
      sheet_interface = zjncspreadsheet
      error           = zjncerror
      retcode         = zjncretcode.
  IF sy-subrc NE 0.
    CALL FUNCTION 'POPUP_TO_INFORM'
      EXPORTING
        titel = zjnc_repid
        txt2  = 'Create zjncspreadsheet INTERFACE Failed'
        txt1  = 'to make Excel zjncspreadsheet'.
    Leave Program.
  ENDIF.

Sorry for the variable names and some missing references but this is only to give you an idea..

Hope to help

Bye

0 Kudos

Thank You Roberto.