Skip to Content
0
Former Member
Jun 16, 2009 at 09:42 AM

download to excell

57 Views

Hi All,

I'm downloading o/p into excell file...

but for excell download i need to add header information how to add those....

my code as below..

METHOD onactiondownload .

DATA lo_nd_it_prod_req_list_item TYPE REF TO if_wd_context_node.

DATA lo_el_it_prod_req_list_item TYPE REF TO if_wd_context_element.

DATA itab TYPE wd_this->elements_n_prod_req_list_item.

DATA wa TYPE wd_this->element_n_prod_req_list_item.

DATA : text TYPE string.

DATA xtext TYPE xstring.

  • navigate from <CONTEXT> to <SFLIGHT> via lead selection

lo_nd_it_prod_req_list_item = wd_context->get_child_node( name = wd_this->wdctx_n_prod_req_list_item ).

  • get all declared attributes

lo_nd_it_prod_req_list_item->get_static_attributes_table(

IMPORTING

table = itab ).

TYPES : BEGIN OF ty_tab ,

reqno TYPE zmatreq-reqno,

zitem TYPE zmatreq-zitem,

zreqtype TYPE zmatreq-zreqtype,

maktx TYPE zmatreq-maktx,

meins TYPE zmatreq-meins,

matkl TYPE zmatreq-matkl,

zbrand TYPE zmatreq-zbrand,

zvers TYPE zmatreq-zvers,

a_material TYPE zmatreq-matnr,

a_price TYPE string,

waers TYPE zmatreq-waers,

zmenge TYPE string,

name1 TYPE string,

bill TYPE string,

zstatus TYPE zmatreq-zstatus,

lead_time TYPE zmatreq-lead_time,

END OF ty_tab.

  • itab1 like TABLE OF itab.

DATA : itab1 TYPE TABLE OF ty_tab.

DATA : wa_tab TYPE ty_tab.

LOOP AT itab INTO wa.

  • move wa-reqno to wa_tab-reqno.

wa_tab-reqno = wa-reqno.

wa_tab-zitem = wa-zitem.

wa_tab-zreqtype = wa-zreqtype.

wa_tab-maktx = wa-maktx.

wa_tab-meins = wa-meins.

wa_tab-matkl = wa-matkl.

wa_tab-zbrand = wa-zbrand.

wa_tab-zvers = wa-zvers.

wa_tab-a_material = wa-a_material.

wa_tab-a_price = wa-a_price.

wa_tab-waers = wa-waers.

wa_tab-zmenge = wa-zmenge.

wa_tab-name1 = wa-name1.

wa_tab-bill = wa-bill.

wa_tab-zstatus = wa-zstatus.

wa_tab-lead_time = wa-lead_time.

APPEND wa_tab TO itab1.

CLEAR wa_tab.

ENDLOOP.

LOOP AT itab1 INTO wa_tab.

CONCATENATE text

wa_tab-reqno

wa_tab-zitem

wa_tab-zreqtype

wa_tab-a_material

wa_tab-maktx

wa_tab-meins

wa_tab-zmenge

wa_tab-a_price

wa_tab-waers

wa_tab-matkl

wa_tab-zbrand

wa_tab-zvers

wa_tab-name1

wa_tab-bill

wa_tab-lead_time

wa_tab-zstatus

cl_abap_char_utilities=>newline INTO text SEPARATED BY

cl_abap_char_utilities=>horizontal_tab.

*append text.

ENDLOOP.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = text

IMPORTING

buffer = xtext.

wdr_task=>client_window->client->attach_file_to_response(

**path to the word file

i_filename = 'Pre_Purchase_Query.XLS'

  • String Variable

i_content = xtext

  • File Type

i_mime_type = 'EXCEL' ).

ENDMETHOD.

regards

Suprith