report z_test7.
data:gv_fname like rlgrap-filename," filename
gv_filename type string.
data:begin of gt_sflight_down_header occurs 0,
carrid(20),
fldate(20),
cityfrom(20),
cityto(20),
fltime(20),
price(20),
currency(20),
end of gt_sflight_down_header.
*define the download internal table
data:begin of gt_sflight_down occurs 0, "存放表体数据
carrid like sflight-carrid,
fldate like sflight-fldate,
cityfrom like spfli-cityfrom,
cityto like spfli-cityto,
fltime like spfli-fltime,
price like sflight-price,
currency like sflight-currency,
end of gt_sflight_down.
perform download.
"下面是要call的function:
*&---------------------------------------------------------------------*
*& Form download
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form download .
clear gt_sflight_down_header[]. "必须要清空,否则会出现数据重复下载的情况
clear gt_sflight_down[].
*set the data header
gt_sflight_down_header-carrid = 'companyid'.
gt_sflight_down_header-fldate = 'flightdate'.
gt_sflight_down_header-cityfrom = 'origin'.
gt_sflight_down_header-cityto = 'destination'.
gt_sflight_down_header-fltime = 'flighttime'.
gt_sflight_down_header-price = 'cost'.
gt_sflight_down_header-currency = 'currency'.
append gt_sflight_down_header.
*set the main download data
* loop at gt_sflight.
*
* gt_sflight_down-carrid = gt_sflight-carrid.
*
* gt_sflight_down-fldate = gt_sflight-fldate.
*
* gt_sflight_down-cityfrom = gt_sflight-cityfrom.
*
* gt_sflight_down-cityto = gt_sflight-cityto.
*
* gt_sflight_down-fltime = gt_sflight-fltime.
*
* gt_sflight_down-price = gt_sflight-price.
*
* gt_sflight_down-currency = gt_sflight-currency.
*
* append gt_sflight_down.
*
* endloop.
gt_sflight_down-carrid = 1.
gt_sflight_down-fldate = 2.
gt_sflight_down-cityfrom = 3.
gt_sflight_down-cityto = 3.
gt_sflight_down-fltime = 3.
gt_sflight_down-price = 3.
gt_sflight_down-currency = 3.
append gt_sflight_down.
call function 'WS_FILENAME_GET'
exporting
mask = ',*.xls,*.xlsx.'
mode = 'S'
title = 'choose the location'
importing
filename = gv_fname
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
concatenate gv_fname '.xls' into gv_filename. "给返回的文件路径加上后缀名
call function 'GUI_DOWNLOAD' "第一次调用,先下载表头数据
exporting
filename = gv_filename
filetype = 'ASC'
write_field_separator = 'X'
tables
data_tab = gt_sflight_down_header[]
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22.
*download the main data
call function 'GUI_DOWNLOAD' "第二次调用,下载表体数据
exporting
filename = gv_filename
filetype = 'ASC'
write_field_separator = 'X'
append = 'X' "指定下载模式为附加
tables
data_tab = gt_sflight_down[]
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22.
if sy-subrc = 0.
message i012(zeduc132_m).
endif.
endform. "" download
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com