web dynpro for abap中如何实现下载文件的功能
2个回答
展开全部
这里我写了一个例子, 先在view那里加一个按扭, 再在onAction里加个Action, 然后写代码如下:
METHOD onactiondownload .
types: begin of ty_po_all,
ebeln type ekko-ebeln,
ebelp type ekpo-ebelp,
matnr type ekpo-matnr,
werks type ekpo-werks,
lgort type ekpo-werks,
end of ty_po_all.
data: lt_po_all type standard table of ty_po_all,
lw_po_all type ty_po_all.
select ebeln
ebelp
matnr
werks
lgort
into lt_po_all
from ekko
inner join ekpo
on ekko~ebeln = ekpo~ebeln.
CONCATENATE 'Docu No.'
cl_abap_char_utilities=>horizontal_tab
'Item No.'
cl_abap_char_utilities=>horizontal_tab
'Material'
cl_abap_char_utilities=>horizontal_tab
'Plant'
cl_abap_char_utilities=>horizontal_tab
'Storage Loc.'
cl_abap_char_utilities=>newline
INTO text.
CLEAR lw_po_all.
LOOP AT lt_po_all INTO lw_po_all.
CONCATENATE text
lw_po_all-ebeln
cl_abap_char_utilities=>horizontal_tab
lw_po_all-ebelp
cl_abap_char_utilities=>horizontal_tab
lw_po_all-matnr
cl_abap_char_utilities=>horizontal_tab
lw_po_all-werks
cl_abap_char_utilities=>horizontal_tab
lw_po_all-lgort
cl_abap_char_utilities=>newline
INTO text.
CLEAR lw_po_all.
ENDLOOP.
* Convert to Excel
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = text
encoding = '8400'
IMPORTING
buffer = xtext.
*
wdr_task=>client_window->client->attach_file_to_response(
**path to the word file
i_filename = 'po.xls'
* String Variable
i_content = xtext
* File Type
i_mime_type = 'EXCEL' ).
ENDMETHOD.
METHOD onactiondownload .
types: begin of ty_po_all,
ebeln type ekko-ebeln,
ebelp type ekpo-ebelp,
matnr type ekpo-matnr,
werks type ekpo-werks,
lgort type ekpo-werks,
end of ty_po_all.
data: lt_po_all type standard table of ty_po_all,
lw_po_all type ty_po_all.
select ebeln
ebelp
matnr
werks
lgort
into lt_po_all
from ekko
inner join ekpo
on ekko~ebeln = ekpo~ebeln.
CONCATENATE 'Docu No.'
cl_abap_char_utilities=>horizontal_tab
'Item No.'
cl_abap_char_utilities=>horizontal_tab
'Material'
cl_abap_char_utilities=>horizontal_tab
'Plant'
cl_abap_char_utilities=>horizontal_tab
'Storage Loc.'
cl_abap_char_utilities=>newline
INTO text.
CLEAR lw_po_all.
LOOP AT lt_po_all INTO lw_po_all.
CONCATENATE text
lw_po_all-ebeln
cl_abap_char_utilities=>horizontal_tab
lw_po_all-ebelp
cl_abap_char_utilities=>horizontal_tab
lw_po_all-matnr
cl_abap_char_utilities=>horizontal_tab
lw_po_all-werks
cl_abap_char_utilities=>horizontal_tab
lw_po_all-lgort
cl_abap_char_utilities=>newline
INTO text.
CLEAR lw_po_all.
ENDLOOP.
* Convert to Excel
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = text
encoding = '8400'
IMPORTING
buffer = xtext.
*
wdr_task=>client_window->client->attach_file_to_response(
**path to the word file
i_filename = 'po.xls'
* String Variable
i_content = xtext
* File Type
i_mime_type = 'EXCEL' ).
ENDMETHOD.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |