下载abap 源代码
转自http://blog.sina.com.cn/s/blog_4d1570de0100pvhd.html
*@---------------------------------------------------------------------*
*@ Report ZZXUE01 下载程序代码
*@ T-code
*@---------------------------------------------------------------------*
*@ Created by Xavery Hsueh on 2011-03-01
*@ Lasted Edited date:
*@---------------------------------------------------------------------*
REPORT zzxue01 NO STANDARD PAGE HEADING.
***********************************************************************@
** 声明数据库表
***********************************************************************@
TABLES:rs38m,
trdir. "
***********************************************************************@
** 内表结构类型的定义
***********************************************************************@
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 tdline WITH HEADER LINE.
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.
***********************************************************************@
** 宏定义
***********************************************************************@
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.
SELECTION-SCREEN COMMENT 1(15) text_002 FOR FIELD p_prog.
PARAMETERS:p_prog TYPE rs38m-programm MEMORY ID rid.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(15) text_003 FOR FIELD p_cnam.
PARAMETERS:p_cnam TYPE cnam DEFAULT sy-uname.
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 p_prog.
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 = '下载文件名称'.
* 选择屏幕初始值
p_prog = '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.
p_prog = dynpfields-fieldvalue.
PERFORM program_directory USING p_prog '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 p_prog.
ENDIF.
ENDFORM. "program_directory
*&---------------------------------------------------------------------*
*& Form SUB_QUERY_REPORT
*&---------------------------------------------------------------------*
* 查询程序代码
*----------------------------------------------------------------------*
FORM sub_query_report .
mcr_range r_prog 'CP' p_prog ''.
SELECT * FROM trdir
INTO TABLE gt_trdir
WHERE name IN r_prog AND
cnam EQ p_cnam AND
subc NE 'X'.
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'.
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'. "双击事件的功能码
WHEN 'DOWNLOAD'. "下载代码
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[].
READ REPORT gt_result-name INTO gt_report.
* 下载程序
PERFORM sub_download_report USING g_filenm.
ENDLOOP.
ENDFORM. " SUB_UCOMM_DOWN
下载abap 源代码的更多相关文章
- !推荐:下载abap 源代码
转自http://blog.sina.com.cn/s/blog_4d1570de0100pvhd.html *@------------------------------------------- ...
- windows平台下载android源代码
最近观看<android核心分析>,所以很多细节都没有详细看代码很难理解.请记住,印象不深.感觉是最好再一起去的源代码,返回下载android源代码,遇到了许多问题,最后开始下载.合并流程 ...
- (国内)完美下载android源代码(文章已经丢失)
刚刚文章莫名其妙的丢了,我重写了一篇,http://blog.csdn.net/song19891121/article/details/50099857 我们在很多时候需要下载android源代码进 ...
- 在Mac OS X中下载Android源代码的一些经验
首先说明.随着最近(2014年6月開始)GFW的升级.这个站点:http://www.android.com/ 已经不能正常訪问了,以下的这些操作均是在我连接VPN的时候进行的. 首先,须要做一些准备 ...
- 下载android4.4.2源代码全过程(附已下载的源代码)
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/maosidiaoxian/article/details/36625727 今天在下载andriod ...
- Git GUI下载远程源代码简单使用介绍
学习编程,适当的时候弄些开源项目的源代码来学习实践,对技术是很有帮助的.如果学习.NET.C#的话,codeplex上面有许多不错的源代码,推荐一个ASP.ENT的:HoverTree http:// ...
- Windows下载Android源代码
下载msysgit,安装 官方下载:http://code.google.com/p/msysgit/downloads/list, 打开Git Bash,运行命令 cd D: git clone h ...
- 关于一个下载的源代码中的”*.vssscc“文件的问题
今天下载了一份程序的源代码,老是提示我要连接源代码管理服务器,这个……你的账号密码我怎么知道,有木有.于是上网搜罗了一番找来了解决方案,在这里分享给可能出现同样问题的童鞋. 首先说明一下什么是vsss ...
- spring源代码系列(一)sring源代码编译 spring源代码下载 spring源代码阅读
想对spring框架进行深入的学习一下,看看源码,提升和沉淀下自己,工欲善其事必先利其器,还是先搭建好开发环境吧. 环境搭建 sping源代码之前是svn管理,如今已经迁移到了github中了.新版本 ...
随机推荐
- BestCoder——59
http://bestcoder.hdu.edu.cn/contests/contest_show.php?cid=640 第一题:给一堆书的序列 每次操作只能将书从中间移到最上面 求最少移动多少次 ...
- [Js]基础知识
一.JavaScript组成 1.ECMAScript 解释器.翻译(提供功能有限,如加减乘除,定义变量.函数等) 几乎没有兼容性问题 2.DOM 有一些兼容性问题 3.BOM(用的少,交互 ...
- 移动设备和SharePoint 2013 - 第4部分:定位
博客地址:http://blog.csdn.net/foxdave 原文地址 在该系列文章中,作者展示了SharePoint 2013最显著的新功能概观--对移动设备的支持. 该系列文章: 移动设备和 ...
- JVM-class文件完全解析-方法表集合
方法表集合 前面的魔数,次版本号,主板本号,常量池入口,常量池,访问标志,类索引,父类索引,接口索引集合,字段表集合,那么再接下来就是方法表了. 方法表的构造如同字段表一样,依次包括了访问标志(a ...
- Actioncontext之类的map嵌套,取值
假设图中最顶端的map设为Actioncontext的map,这种情况,用<s:property value=""/>或者EL表达式取值,可以用#key1.key2.k ...
- C#基础之程序集(一)
一.什么是程序集? 程序集 其实就是bin目录的.exe 文件或者.dll文件. 二.原理 三.程序集分类 1.系统程序集 路径:C:\Windows\assembly 2.源代码生成的程序集 使用V ...
- fragment的一些bug
自从Android3.0引入了Fragment之后,使用Activity去嵌套一些Fragment的做法也变得更加流行,这确实是 Fragment带来的一些优点,比如说:Fragment可以使你能够将 ...
- ios开发值json数据文件的存取
将Json存进本地文件夹 NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainM ...
- FMDB数据库中的一些操作
#pragma mark - 数据库的操作 - (BOOL)judgeModel:(TaskResourceModel *)model isInArray:(NSArray *)shopArray { ...
- 多比Web 3D展示(3D机房/3D监控)中间件多比Web 3D展示(3D机房/3D监控)中间件免费下载购买地址
多比3D是实现3D场景搭建的软件开发包,可以创建广泛的3D应用,适用于高端制造.能源.国防军工.教育科研.城市规划及建筑环艺.生物医学等领域的虚拟仿真,应用于虚拟展示.虚拟设计.方案评审.虚拟装配.虚 ...