Application Development and Automation 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: 
Read only

EXPORT PIVOT CHART TO EXCEL

Former Member
0 Likes
780

Hi Experts ,

I want to export the internal table data to the excel graph or chart .

using OLE .( or any other method which u can suggest.)

my internal table in having three col

name

val1

val2

Name should be Y Axis.

Please suggest me the solution.

right now am just displaying the graph using Business Object.

But the requirment is the EXCEL OUTPUT with GRAPH or chart.

3 REPLIES 3
Read only

Former Member
0 Likes
577

Get your data into an ALV GRID (OO --NOT THE OLD SLIS FUNCTION MODULE VERSION)

and a Toolbar with Transfer to EXCEL button on it.

*Click on the EXCEL button you created and the Popup prompt will give you options of a Pivot table amongst others.*

*The EXCEL spreadsheet will be displayed in the Foreground with the pivot table options you want*

*From here just use the Chart Wizard (built into EXCEL) to get your chart.*

*You can of course save etc. On exit from excel you are returned to the GRID where you can EXIT or perform further functions.*

*You probably could use excel macros to generate a graph / chart automatically -- the EXCEL prompt also allows you to run macros --you need to see the popup to understand what I'm trying to post here --but I haven't tried that option yet.*




method on_toolbar .
type-pools icon.
 clear ls_toolbar.
     move  0 to ls_toolbar-butn_type.
     move 'EXCEL' to ls_toolbar-function.
     move  space to ls_toolbar-disabled.
     move  icon_xxl to ls_toolbar-icon.
     move 'Excel' to ls_toolbar-quickinfo.
     move  'EXCEL' to ls_toolbar-text.  
     append ls_toolbar to e_object->mt_toolbar.
    perform   toolbar  in program (caller) if found
     using e_object.

* ...
endmethod.



case e_ucomm.


      when 'EXIT'.
        leave program.
      when 'EXCEL'.
       call method me->download_to_excel.
      when 'SAVE'.
      when 'PROC'.
        call method me->process.
      when 'REFR'.
        call method me->refresh.
        when 'SWITCH'.
        call method me->switch.
       when 'TEST'.
        call method me->get_cell.

       endcase.

* ...
endmethod.



method download_to_excel.
field-symbols:
       <fs0> type standard table,
       <fs1> type standard table.
    assign g_outtab1->* to <fs0>.
    assign g_fldcat1->* to <fs1>.
       call function  'LVC_TRANSFER_TO_KKBLO'
      exporting
        it_fieldcat_lvc   = <fs1>
*     is_layout_lvc     = m_cl_variant->ms_layout
         is_tech_complete  = ' '
      importing
        es_layout_kkblo   = ls_layout
        et_fieldcat_kkblo = lt_fieldcat.

    loop at lt_fieldcat into lt_fieldcat_wa.
      clear lt_fieldcat_wa-tech_complete.
      if lt_fieldcat_wa-tabname is initial.
        lt_fieldcat_wa-tabname = '1'.
        modify lt_fieldcat from lt_fieldcat_wa.
      endif.
      l_tabname = lt_fieldcat_wa-tabname.
    endloop.
    call function 'ALV_XXL_CALL'
         exporting
              i_tabname           = l_tabname
              is_layout           = ls_layout
              it_fieldcat         = lt_fieldcat
              i_title             = sy-title
         tables
              it_outtab           = <fs0>
         exceptions
              fatal_error         = 1
              no_display_possible = 2
              others              = 3.
    if  sy-subrc <> 0.
      message id sy-msgid type 'S' number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.

* ...
endmethod.

You might be able to use FM 'ALV_XXL_CALL' directly but you need to be aware that the field catalog is slightly different which is why you need FM 'LVC_TRANSFER_TO_KKBLO' to convert your ALV GRID field catalog to the one required by the XXL call.

Cheers

Jimbo

Read only

0 Likes
577

Hi James,

Thanks for the reply.

The method you suggest works. but what the requirement I am having is that I can't change the SLIS to LVC so can you please sugest me any other method.

Edited by: Prashant Bonde on Feb 1, 2008 3:10 PM

Read only

0 Likes
577

I don't use SLIS anymore so I can't be of any help here.

You might find somewhere to add custom functions and then bolt in the Method I've shown. You could change the method to a FM call with parameters but this is really "going backwards".

Cheers

jimbo