cancel
Showing results for 
Search instead for 
Did you mean: 

Reg:how to download the table data to excel sheet

Former Member
0 Kudos

Hi

Can any one  please share the code for exporting table to excel sheet .

Thanks & Regards

Deepika

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Deepika,

Please follow the link

http://scn.sap.com/docs/DOC-25024

Regards,

Sayan

Former Member
0 Kudos

hii deepika there is a lot of links for downloading table data into excel sheet..

pls go through the links....

i tried with these links nd i got output ..

http://scn.sap.com/thread/1184543

http://scn.sap.com/thread/1786781

Former Member
0 Kudos

Hello Deepika, Please use the following to check the integration of different options for WD http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/b9157c878a2d67e10000000a42189c/frameset.htm

Rohit

Former Member
0 Kudos

Hi

I have used the below code for exporting table data to excel .

data str type string.

  data xstr type xstring.

    DATA LO_ND_ITAB TYPE REF TO IF_WD_CONTEXT_NODE.

    DATA LT_ITAB TYPE WD_THIS->ELEMENTS_ITAB.

    DATA Lw_ITAB TYPE WD_THIS->ELEMENT_ITAB.

*   navigate from <CONTEXT> to <ITAB> via lead selection

    LO_ND_ITAB = WD_CONTEXT->PATH_GET_NODE( PATH = `ZHR_SUBORDINATES_FM.CHANGING.ITAB` ).

*   @TODO handle non existant child

*   IF lo_nd_itab IS INITIAL.

*   ENDIF.

    LO_ND_ITAB->GET_STATIC_ATTRIBUTES_TABLE( IMPORTING TABLE = LT_ITAB ).

*

*    DATA lo_nd_p0001 TYPE REF TO if_wd_context_node.

*

*    DATA: lt_p0001 TYPE wd_this->elements_p0001,

*          lw_p0001 like line of lt_p0001.

*   navigate from <CONTEXT> to <P0001> via lead selection

*    lo_nd_p0001 = wd_context->get_child_node( name = wd_this->wdctx_p0001 ).

*   @TODO handle non existant child

*   IF lo_nd_p0001 IS INITIAL.

*   ENDIF.

*    lo_nd_p0001->get_static_attributes_table( IMPORTING table = lt_p0001 ).

loop at LT_ITAB into Lw_ITAB.

   concatenate str

              Lw_ITAB-EMPNO

              Lw_ITAB-EMPLOYEENAME

              Lw_ITAB-MANAGERNAME

                     Lw_ITAB-LOCATION

                            Lw_ITAB-EMAILID

                                   Lw_ITAB-USRID

              cl_abap_char_utilities=>newline into str

               separated by cl_abap_char_utilities=>horizontal_tab.

endloop.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

    text           = str

   MIMETYPE       = ' '

*   ENCODING       =

IMPORTING

   BUFFER         = xstr

EXCEPTIONS

   FAILED         = 1

          .

CALL METHOD cl_wd_runtime_services=>attach_file_to_response

  EXPORTING

    i_filename      = 'TIMESHEET.xls'

    i_content       = xstr

    i_mime_type     = 'EXCEL'

*    i_in_new_window = ABAP_FALSE

*    i_inplace       = ABAP_FALSE

.

*

But in the excel I am able to see only item data ,no header data is avaiable .

More over when i am trying to download first i am getting one popup task bar as shown in the screen shot and when I click on download file it trigger automatically to the main page instead of downloading the excel and again for the second time when exe the application that time it is able to export the data to excel.

How to  achieve exporting data to excel  for the first time only and how to get header data in the excel sheet.

Former Member
0 Kudos

hiii ..

i think that is the property of browser ..it will ask as a popup in task bar ...

try with changing browser .. ?

Former Member
0 Kudos

Hi Lokeswar Reddy

Any idea abt how to get header data in the excel sheet .

Thanks & Regards

Deepika

former_member282968
Contributor
0 Kudos

Hi Deepika,

Why dont you use webdynpro ALV where by default you get the export option to download the data?

With regards,