下载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中了.新版本 ...
随机推荐
- sql 如何过滤重复记录
distinct : select distinct ID from table1
- 启动 nginx 失败 "fastcgi_pass" directive is duplicate
[emerg] 4953#0: "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default: ...
- 【同行说技术】Python程序员小白变大神必读资料汇总( 三)
在文章<Python开发.调试.爬虫类工具大全>里面向大家总结了各种实用工具和爬虫技术,今天小编收集了5篇带有实例干货的资料,赶紧来看看吧!另外,喜欢写博客的博主可以申请加工程师博主交流群 ...
- 【个人使用.Net类库】(2)Log日志记录类
开发接口程序时,要保证程序稳定运行就要时刻监控接口程序发送和接收的数据,这就需要一个日志记录的类将需要的信息记录在日志文件中,便于自己维护接口程序.(Web系统也是如此,只是对应的日志实现比这个要复杂 ...
- centos7 学习1 KDE配置中文
安装kde桌面后没有中文,可以用以下方法配置中文 #yum list kde*chinese 会显示可以安装的包,我的显示如下 kde-l10n-Chinese.noarch -.fc14 @upda ...
- HDU 2594 扩展kmp模板题
题目大意: 给定两个字符串,在第一个字符串中找到一个最大前缀作为第二个字符串的后缀 #include <iostream> #include <cstdio> #include ...
- java.io.IOException: open failed: EACCES (Permission denied)问题解决
1. 问题描述:在Android中,用程序访问Sdcard时,有时出现“java.io.IOException: open failed: EACCES (Permission denied)&qu ...
- struts2内Action方法调用
1.struts2流程: jsp页面-->web.xml-->struts.xml-->user.acrion-->UserAction.java 中的execute()--r ...
- HTML--4格式布局
一.position:fixed 锁定位置(相对于浏览器的位置),例如有些网站的右下角的弹出窗口. 示例: 二.position:absolute 1.外层没有position:absolute(或r ...
- HDU 4737 A Bit Fun
题意:定义F(i,j)为数组a中从ai到aj的或运算,求使F(i,j)<m的对数. 思路:或运算具有单调性,也就是只增不减,如果某个时刻结果大于等于m了,那么再往后一定也大于等于m.所以可以用两 ...