YUSE_DOWN-批下载
*&---------------------------------------------------------------------*
*& Report YTST_CX_DOWN
*&
*&---------------------------------------------------------------------*
*@---------------------------------------------------------------------*
*@ Created by Xavery Hsueh on 2011-03-01
*@ Lasted Edited date:
*@---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
report ytst_use_down no standard page heading.
***********************************************************************@
** 声明数据库表
***********************************************************************@
tables:rs38m,
trdir, "程序库
trdyse01cm.
***********************************************************************@
** 内表结构类型的定义
***********************************************************************@
data begin of dynpfields occurs 1.
include structure dynpread.
data end of dynpfields.
types:begin of typ_result,
box type c,
tabix type sytabix, "顺序号
name type char40, "程序名称
cnam type cnam, "创建人员
unam type unam, "最后修改人
code(72) type c, "程序描述
end of typ_result.
***********************************************************************@
** 变量与内表的定义
***********************************************************************@
data:gt_report type table of string with header line."TDLINE
data:gt_report1 type table of tdline with header line."TDLINE
*DATA:GT_REPORT2 TYPE TABLE OF CHAR1000 WITH HEADER LINE."TDLINE
data:gt_result type table of typ_result with header line.
data:gt_trdir type table of trdir with header line.
data:gt_btab type table of textpool with header line.
data:g_filenm type rlgrap-filename. "文件名称
ranges r_prog for rs38m-programm. "程序名称
*@------------------ ALV 相关的变量 -----------------------------------*
type-pools:slis.
data: g_repid like sy-repid,
wa_print type slis_print_alv,
gt_list_top_of_page type slis_t_listheader,
gt_events type slis_t_event with header line,
gt_sort type slis_t_sortinfo_alv,
wa_layout type slis_layout_alv,
gt_fieldcat type slis_t_fieldcat_alv with header line,
wa_fieldcat like line of gt_fieldcat,
g_save type c,
g_pos type i.
data:g_len type string.
data:g1(10000) type c.
***********************************************************************@
** 宏定义
***********************************************************************@
define mcr_field.
clear wa_fieldcat.
g_pos = g_pos + 1 .
wa_fieldcat-col_pos = g_pos.
wa_fieldcat-fieldname = &1.
wa_fieldcat-tabname = 'I_RESULT'.
* wa_fieldcat-no_out = 'X'. "field no display, choose from layout
wa_fieldcat-key = ' '. "SUBTOTAL KEY
wa_fieldcat-seltext_l = &2.
wa_fieldcat-outputlen = &3.
append wa_fieldcat to gt_fieldcat.
end-of-definition.
*@---------------------------------------------------------------------*
*@ MACRO MCR_RANGE 初始化选择条件
*@---------------------------------------------------------------------*
* &1 RANGE 变量
* &2 操作符
* &3 LOW
* &4 HIGH
*----------------------------------------------------------------------*
define mcr_range.
clear &1.
&1-sign = 'I'.
&1-option = &2.
&1-low = &3.
&1-high = &4.
append &1.
end-of-definition.
***********************************************************************@
** 屏幕定义
***********************************************************************@
selection-screen begin of block xavery with frame title text_001.
selection-screen begin of line.
*&p_prog.
selection-screen comment 1(15) text_002 for field s_prog.
select-options:s_prog for rs38m-programm memory id rid.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 1(15) text_003 for field s_cnam.
*PARAMETERS:P_CNAM TYPE CNAM DEFAULT SY-UNAME.
select-options:s_cnam for trdyse01cm-username. "MEMORY ID RID.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment 1(15) text_004 for field p_filenm.
parameters:p_filenm type rlgrap-filename.
selection-screen end of line.
selection-screen end of block xavery.
***********************************************************************@
** 执行程序事件
***********************************************************************@
initialization.
perform f_init_condition.
at selection-screen on value-request for s_prog-low.
perform sub_get_program.
start-of-selection.
perform sub_query_report.
perform sub_process_report.
end-of-selection.
perform sub_init_layout.
perform sub_create_fieldcat.
perform sub_display_as_alv. "以ALV的方式输出结果表
*@---------------------------------------------------------------------*
*@ Form F_INIT_CONDITION
*@---------------------------------------------------------------------*
* 初始化选择条件
*----------------------------------------------------------------------*
form f_init_condition .
text_001 = '查询条件'.
text_002 = '程序名称'.
text_003 = '程序创建人'.
text_004 = '下载文件名称'.
* 选择屏幕初始值
s_prog-low = 'Z*'.
p_filenm = 'C:\ABAP\'.
endform. " F_INIT_CONDITION
*&---------------------------------------------------------------------*
*& Form SUB_GET_PROGRAM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form sub_get_program .
data: repid like sy-repid.
dynpfields-fieldname = 'P_PROG'.
append dynpfields.
repid = sy-repid.
call function 'DYNP_VALUES_READ'
exporting
dyname = repid
dynumb = sy-dynnr
tables
dynpfields = dynpfields
exceptions
others.
read table dynpfields index 1.
s_prog = dynpfields-fieldvalue.
perform program_directory using s_prog-low 'X'.
endform. " SUB_GET_PROGRAM
*---------------------------------------------------------------------*
* FORM PROGRAM_DIRECTORY *
*---------------------------------------------------------------------*
form program_directory using programm like rs38m-programm
f4_call.
data: info_object like euobj-id,
l_programm like rs38m-programm.
if sy-tcode(4) = 'SE38'.
info_object = 'PROG'.
if f4_call = 'X'.
call function 'REPOSITORY_INFO_SYSTEM_F4'
exporting
object_type = info_object
object_name = programm
suppress_selection = 'X'
importing
object_name_selected = programm
exceptions
cancel = 01.
else.
call function 'REPOSITORY_INFO_SYSTEM'
exporting
object_type = info_object
action = 'S'
object_name = programm
importing
object_name_selected = programm
exceptions
cancel = 01
wrong_type = 02.
endif.
else.
l_programm = programm.
if l_programm = space.
submit rsabadab and return via selection-screen
with f4_call = f4_call.
else.
submit rsabadab and return via selection-screen
with repname cp l_programm
with f4_call = f4_call.
endif.
get parameter id 'RID' field s_prog-low.
endif.
endform. "program_directory
*&---------------------------------------------------------------------*
*& Form SUB_QUERY_REPORT
*&---------------------------------------------------------------------*
* 查询程序代码
*----------------------------------------------------------------------*
form sub_query_report .
mcr_range r_prog 'CP' s_prog-low ''.
*&程序库中找程序
select *
from trdir
into table gt_trdir
where name in r_prog
and cnam in s_cnam
and subc ne 'X'.
*&条目数
g_len = lines( gt_trdir[] ).
if g_len eq 0.
message i000(oo) with '没有找到符合条件的数据!'.
stop.
else.
message s000(oo) with '找到数据条目数:' g_len.
endif.
endform. " SUB_QUERY_REPORT
*&---------------------------------------------------------------------*
*& Form SUB_DOWNLOAD_REPORT
*&---------------------------------------------------------------------*
* 下载程序代码
*----------------------------------------------------------------------*
form sub_download_report using l_filenm type rlgrap-filename.
data: binfilesize type i.
data: l_file type string.
data: l_message type char100.
concatenate '文件已下载到:' p_filenm '文件夹中!'
into l_message.
l_file = l_filenm.
call function 'GUI_DOWNLOAD'
exporting
bin_filesize = binfilesize
filename = l_file
filetype = 'ASC'
tables
data_tab = gt_report[]
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 l_message type 'S'.
endif.
endform. " SUB_DOWNLOAD_REPORT
*&---------------------------------------------------------------------*
*& Form SUB_PROCESS_REPORT
*&---------------------------------------------------------------------*
* 处理文件名称,并放到内表中
*----------------------------------------------------------------------*
form sub_process_report .
sort gt_trdir by name.
loop at gt_trdir.
clear gt_result.
gt_result-name = gt_trdir-name.
gt_result-cnam = gt_trdir-cnam.
gt_result-unam = gt_trdir-unam.
gt_result-tabix = sy-tabix.
refresh gt_btab.
read textpool gt_trdir-name into gt_btab language sy-langu.
clear gt_btab.
read table gt_btab with key 'R'.
if sy-subrc = 0.
move gt_btab-entry to gt_result-code.
endif.
append gt_result.
endloop.
* 清空内表
free gt_trdir.
endform. " SUB_PROCESS_REPORT
*&---------------------------------------------------------------------*
*& Form SUB_CREATE_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form sub_create_fieldcat .
clear gt_fieldcat[].
mcr_field 'TABIX' '顺序号' '10'.
mcr_field 'NAME' '程序名称' '15'.
mcr_field 'CNAM' '程序创建人' '20'.
mcr_field 'UNAM' '最后修改人' '20'.
mcr_field 'CODE' '程序描述' '30'.
endform. " SUB_CREATE_FIELDCAT
*&---------------------------------------------------------------------*
*& Form SUB_INIT_LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form sub_init_layout .
wa_layout-zebra = 'X'.
wa_layout-window_titlebar = '开发程序名称清单'.
wa_layout-colwidth_optimize = 'X'.
wa_layout-box_fieldname = 'BOX'.
*WA_LAYOUT-SEL_FIELDNAME = 'BOX'.
endform. " SUB_INIT_LAYOUT
*&---------------------------------------------------------------------*
*& Form SUB_DISPLAY_AS_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form sub_display_as_alv .
g_repid = sy-repid.
*ABAP List Viewer
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
i_structure_name = 'TYP_RESULT'
i_callback_user_command = 'SUB_USER_COMMAND'
i_callback_pf_status_set = 'SUB_SET_PF_STATUS'
i_save = g_save
is_layout = wa_layout
it_fieldcat = gt_fieldcat[]
tables
t_outtab = gt_result
exceptions
program_error = 1
others = 2.
endform. " SUB_DISPLAY_AS_ALV
*@--------------------------------------------------------------------*
*@ Form sub_user_command
*@--------------------------------------------------------------------*
* -->R_UCOMM 事务功能码
* -->RS_SELFIELD ALV相关的数据
*---------------------------------------------------------------------*
form sub_user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case r_ucomm.
when '&IC1'. "双击事件的功能码
read table gt_result index rs_selfield-tabindex.
set parameter id 'RID' field gt_result-name.
call transaction 'SE38' and skip first screen.
when '&DATA_SAVE'. "下载代码
perform sub_ucomm_down.
endcase.
* 刷新ALV屏幕报表
rs_selfield-refresh = 'X'.
endform. "sub_user_command
*@---------------------------------------------------------------------*
*@ FORM SUB_SET_PF_STATUS *
*@---------------------------------------------------------------------*
* 设置ALV菜单
* 通过SE41,拷贝程序SAPLSLVC_FULLSCREEN的状态STANDARD_FULLSCREEN过来
*@---------------------------------------------------------------------*
form sub_set_pf_status using rt_extab type slis_t_extab.
set pf-status 'STANDARD_FULLSCREEN'.
endform. "sub_set_pf_status
*&---------------------------------------------------------------------*
*& Form SUB_UCOMM_DOWN
*&---------------------------------------------------------------------*
* 下载选中的行的程序代码
*----------------------------------------------------------------------*
form sub_ucomm_down .
loop at gt_result where box = 'X'.
* 得到文件名称
clear g_filenm.
concatenate p_filenm gt_result-name '-'
gt_result-code '.txt'
into g_filenm.
* 得到程序代码
clear gt_report[].
if gt_result-name is not initial.
read report gt_result-name into gt_report.
* LOOP AT GT_REPORT.
* CONCATENATE GT_REPORT G1 INTO G1.
* ENDLOOP.
endif.
* 下载程序
perform sub_download_report using g_filenm.
endloop.
endform. " SUB_UCOMM_DOWN
YUSE_DOWN-批下载的更多相关文章
- ajax下载多文件,并且打包 C#中 ,文件批下载zip
//提交要下载的文件 $.ajax({ url:"/sub/ZipFile.aspx", data:"paras="+datas, type: 'HEAD', ...
- C# 程序实现功能目录
1.根据年月日获取 星期几 http://www.cnblogs.com/liwp/p/5943226.html 2.json对象转换为泛型集合 http://www.cnblogs.com/liw ...
- req、js
requests库中,可不写为headers内各键值对的部分参数: s=requests.Session() #或.session() s.allow_redirects=False #禁止重定 ...
- [译文]详细解析如何做一款成功的APP应用
译者注: 本文作者从自身丰富的应用开发设计实践经验和大量的优秀应用实例中,总结提炼了从产品概念.设计.开发到市场推广等一系列的相关原则,指导移动开发人员怎样来打造一款成功赚钱的应用.姗姗来迟的这篇文章 ...
- windows 10预览版升级win10 7月29 10240.16384
一路追着win10 从预览版到今天10240.16384 昨晚是中国区第一批下载win10的,不过不是第一批安装的. 早上才安装成功. win10预览版更新 7月29 1024016384 使用esd ...
- 2018-2-13-windows-10预览版升级win10-7月29-10240.16384
title author date CreateTime categories windows 10预览版升级win10 7月29 10240.16384 lindexi 2018-2-13 17:2 ...
- 【干货分享】流程DEMO-事务呈批表
流程名: 事务呈批表 业务描述: 办公采购.会议费用等事务的申请.流程发起时,会检查预算,如果预算不够,将不允许发起费用申请,如果预算够用,将发起流程,同时占用相应金额的预算,但撤销流程会释放相应金 ...
- 用java 代码下载Samba服务器上的文件到本地目录以及上传本地文件到Samba服务器
引入: 在我们昨天架设好了Samba服务器上并且创建了一个 Samba 账户后,我们就迫不及待的想用JAVA去操作Samba服务器了,我们找到了一个框架叫 jcifs,可以高效的完成我们工作. 实践: ...
- 记一次TFS 的 垃圾提示(无法下载 未获取项目 的 代码)
提示 “ 所有文件都是最新的 ”,但是在 源码管理 里面 确是 “未下载” 我艹,第一次遇到.如图.~~ 最后发现是 TFS 的项目权限设置问题. 你妈个马批的,啥子鸡巴破B提示,太阳你妈B 的 .要 ...
- VG.net矢量图和矢量动画开发平台拓扑图软件免费下载
VG.net拓扑图软件是一个基于.net平台的矢量图开发工具,可广泛应用于包括:电力.军工.煤炭.化工.科研.能源等各种监控软件.工作流设计器.电力.化工.煤炭.工控组态软件.仿真.地理信息系统.工作 ...
随机推荐
- <转>关闭 程序崩溃时 windows 正在检查该问题的解决方案
本文转自:http://www.cnblogs.com/dabaopku/archive/2011/07/04/2097029.html 尤其是使用visual studio开发程序 ,自己特意thr ...
- redis windows下使用及redis命令
出自:http://www.cnblogs.com/chenping-987123/archive/2012/01/29/2331079.html Redis 是一个开源,高级的键值对的存储.它经常作 ...
- VBA中使用JavaScript脚本语言解析JSON数据
JSON:JavaScript 对象表示法(JavaScript Object Notation) 和xml相似,都是文本形式(保存在文本文件中或字符串等形式),比如: jsstr = {" ...
- python 反射调用
因为目前在写一个python的项目,用到了Python的反射机制,所以做一下笔记,把写项目过程中的感悟记下来. 先简单介绍下Demo用到的函数: sys.path 是python的模块的路径集,是一个 ...
- 解决打开CHM文件后,右侧空白
在网上下了一个chm的文件,打开后只有目录,右侧不显示内容. 不知道是文件有问题,还是系统有问题. <ignore_js_op> 右键点击文件–属性 看到 最下面有一个提示 说是这个文件是 ...
- IE6兼容性问题及IE6常见bug详细汇总
转载地址:http://www.jb51.net/css/76894.html 1.IE6怪异解析之padding与border算入宽高 原因:未加文档声明造成非盒模型解析 解决方法:加入文档声明&l ...
- 《BI项目笔记》创建多维数据集Cube(1)
有两个事实表,因此就有两个度量值组,并且向导将为非维度键的事实表中的每一个数值列创建一个度量值.由于我们这里不需要那么多,所以只选择部分度量值.另外要注意,度量值的名称源于事实表中的列,所有名称由可能 ...
- MFC编程入门之十一(对话框:模态对话框及其弹出过程)
加法计算器对话框程序大家照着做一遍后,相信对基于对话框的程序有了些解了,有个好的开始对于以后的学习大有裨益.趁热打铁,这一节讲讲什么是对话框和非模态对话框,以及模态对话框怎样弹出. 一.模态对话框和非 ...
- [css]需警惕CSS3属性的书写顺序
转载张鑫旭:http://www.zhangxinxu.com/wordpress/2010/09/%E9%9C%80%E8%AD%A6%E6%83%95css3%E5%B1%9E%E6%80%A7% ...
- .net Web开发学习日志 —C/S和B/S结构区别
查看到<C/S和B/S结构区别整理> B/S结构与C/S结构都是有各自的优缺点: 前者无需安装,只要有浏览器即可,随时随地查询相关的业务,业务扩展强,维护强,共享强.在跨浏览器较难,响应速 ...