*&---------------------------------------------------------------------*
*& 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-批下载的更多相关文章

  1. ajax下载多文件,并且打包 C#中 ,文件批下载zip

    //提交要下载的文件 $.ajax({ url:"/sub/ZipFile.aspx", data:"paras="+datas, type: 'HEAD', ...

  2. C# 程序实现功能目录

    1.根据年月日获取 星期几  http://www.cnblogs.com/liwp/p/5943226.html 2.json对象转换为泛型集合 http://www.cnblogs.com/liw ...

  3. req、js

    requests库中,可不写为headers内各键值对的部分参数:   s=requests.Session()  #或.session() s.allow_redirects=False #禁止重定 ...

  4. [译文]详细解析如何做一款成功的APP应用

    译者注: 本文作者从自身丰富的应用开发设计实践经验和大量的优秀应用实例中,总结提炼了从产品概念.设计.开发到市场推广等一系列的相关原则,指导移动开发人员怎样来打造一款成功赚钱的应用.姗姗来迟的这篇文章 ...

  5. windows 10预览版升级win10 7月29 10240.16384

    一路追着win10 从预览版到今天10240.16384 昨晚是中国区第一批下载win10的,不过不是第一批安装的. 早上才安装成功. win10预览版更新 7月29 1024016384 使用esd ...

  6. 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 ...

  7. 【干货分享】流程DEMO-事务呈批表

    流程名: 事务呈批表  业务描述: 办公采购.会议费用等事务的申请.流程发起时,会检查预算,如果预算不够,将不允许发起费用申请,如果预算够用,将发起流程,同时占用相应金额的预算,但撤销流程会释放相应金 ...

  8. 用java 代码下载Samba服务器上的文件到本地目录以及上传本地文件到Samba服务器

    引入: 在我们昨天架设好了Samba服务器上并且创建了一个 Samba 账户后,我们就迫不及待的想用JAVA去操作Samba服务器了,我们找到了一个框架叫 jcifs,可以高效的完成我们工作. 实践: ...

  9. 记一次TFS 的 垃圾提示(无法下载 未获取项目 的 代码)

    提示 “ 所有文件都是最新的 ”,但是在 源码管理 里面 确是 “未下载” 我艹,第一次遇到.如图.~~ 最后发现是 TFS 的项目权限设置问题. 你妈个马批的,啥子鸡巴破B提示,太阳你妈B 的 .要 ...

  10. VG.net矢量图和矢量动画开发平台拓扑图软件免费下载

    VG.net拓扑图软件是一个基于.net平台的矢量图开发工具,可广泛应用于包括:电力.军工.煤炭.化工.科研.能源等各种监控软件.工作流设计器.电力.化工.煤炭.工控组态软件.仿真.地理信息系统.工作 ...

随机推荐

  1. [像黑客一样生活] shell终端听音乐之网易云shell版

    这是一个Python程序,使用Python构建,并以mpg123作为后端.Follow me... 特点: Vim 式的流畅操作,支持快捷键绑定 支持电台.收藏等各种特色功能 支持 OS X 及各类 ...

  2. jquery总结05-常用事件01-鼠标事件

    鼠标事件 .click()单机事件  包括.mousedown()(鼠标按下).mouseup()(放松鼠标)两个事件 .dbclick()双击事件 两个click事件,中间的间隔由系统而定 .mou ...

  3. 深入浅出设计模式——适配器模式(Adapter Pattern)

    模式动机 在软件开发中采用类似于电源适配器的设计和编码技巧被称为适配器模式. 通常情况下,客户端可以通过目标类的接口访问它所提供的服务.有时,现有的类可以满足客户类的功能需要,但是它所提供的接口不一定 ...

  4. 《BI项目笔记》历年外观质量均值变化分析Cube的建立

    分析主题主要维度:烟叶级别.烟叶级别按等级信息.烟叶级别按分级标准(标准维度)产地(父子维度)检测时间(时间维度,以Tqc_Raw_PresentationQuality . CheckTime字段派 ...

  5. Android Studio build dex jar

    Gradle配置 Build配置文件gradle.build中添加如下task task clearJar(type: Delete) { delete 'build/outputs/mylib.ja ...

  6. python成长之路【第七篇】:面向对象

    概述 面向过程:根据业务逻辑从上到下写垒代码 函数式:将某功能代码封装到函数中,日后便无需重复编写,仅调用函数即可 面向对象:对函数进行分类和封装,让开发“更快更好更强...” 面向对象三大特性 面向 ...

  7. 谷歌 火狐 CSS兼容

    @media screen and (-webkit-min-device-pixel-ratio:0){}谷歌@-moz-document url-prefix(){}火狐

  8. Zepto与jQuery的区别

    1. 事件绑定 var isTouch= !!navigator.userAgent.match(/AppleWebKit.*Mobile.*/), eStart = isTouch ? 'touch ...

  9. JavaWeb前端: JavaScript 简介

    JavaScript基本概念 什么是JavaScript JS是运行在浏览器里的解释性语言,能实现浏览器端和用户的直接交互(HTML输出/响应事件/改变HTML内容图像样式):除了变量不区分类型以外, ...

  10. 关于BS响应式的网站建设

    一.首先是导航 html部分: <!-- 导航 --> <nav class="navbar navbar-default navbar-fixed-top"&g ...