转自http://blog.sina.com.cn/s/blog_4d1570de0100pvhd.html

*@---------------------------------------------------------------------*
*@ Report ZZXUE01 下载程序代码
*@ T-code
*@---------------------------------------------------------------------*
*@ Created by Xavery Hsueh on --
*@ Lasted Edited date:
*@---------------------------------------------------------------------*
REPORT zzxue01 NO STANDARD PAGE HEADING. ***********************************************************************@
** 声明数据库表
***********************************************************************@
TABLES:rs38m,
trdir. "
***********************************************************************@
** 内表结构类型的定义
***********************************************************************@
DATA BEGIN OF dynpfields OCCURS .
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() 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 + .
wa_fieldcat-col_pos = g_pos.
wa_fieldcat-fieldname = &.
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 = &.
wa_fieldcat-outputlen = &.
append wa_fieldcat to gt_fieldcat.
END-OF-DEFINITION.
*@---------------------------------------------------------------------*
*@ MACRO MCR_RANGE 初始化选择条件
*@---------------------------------------------------------------------*
* & RANGE 变量
* & 操作符
* & LOW
* & HIGH
*----------------------------------------------------------------------*
DEFINE mcr_range.
clear &.
&-sign = 'I'.
&-option = &.
&-low = &.
&-high = &.
append &.
END-OF-DEFINITION.
***********************************************************************@
** 屏幕定义
***********************************************************************@
SELECTION-SCREEN BEGIN OF BLOCK xavery WITH FRAME TITLE text_001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT () 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 () 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 () 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 .
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() = '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 = .
ELSE.
CALL FUNCTION 'REPOSITORY_INFO_SYSTEM'
EXPORTING
object_type = info_object
action = 'S'
object_name = programm
IMPORTING
object_name_selected = programm
EXCEPTIONS
cancel =
wrong_type = .
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 =
no_batch =
gui_refuse_filetransfer =
invalid_type =
no_authority =
unknown_error =
header_not_allowed =
separator_not_allowed =
filesize_not_allowed =
header_too_long =
dp_error_create =
dp_error_send =
dp_error_write =
unknown_dp_error =
access_denied =
dp_out_of_memory =
disk_full =
dp_timeout =
file_not_found =
dataprovider_exception =
control_flush_error =
OTHERS = . IF sy-subrc = .
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 = .
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' '顺序号' ''.
mcr_field 'NAME' '程序名称' ''.
mcr_field 'CNAM' '程序创建人' ''.
mcr_field 'UNAM' '最后修改人' ''.
mcr_field 'CODE' '程序描述' ''.
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 =
OTHERS = .
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 源代码的更多相关文章

  1. 下载abap 源代码

    转自http://blog.sina.com.cn/s/blog_4d1570de0100pvhd.html *@------------------------------------------- ...

  2. (国内)完美下载android源代码(文章已经丢失)

    刚刚文章莫名其妙的丢了,我重写了一篇,http://blog.csdn.net/song19891121/article/details/50099857 我们在很多时候需要下载android源代码进 ...

  3. 推荐下载App,如果本地安装则直接打开本地App(Android/IOS)

    推荐下载App,如果本地安装则直接打开本地App(Android/IOS) - 纵观现在每家移动网站,打开首页的时候,都有各种各样的形式来提示你下载自身的移动App(Android/IOS),这是做移 ...

  4. Java 推荐读物与源代码阅读

    Java 推荐读物与源代码阅读                                                     江苏无锡  缪小东 1. Java语言基础     谈到Java ...

  5. windows平台下载android源代码

    最近观看<android核心分析>,所以很多细节都没有详细看代码很难理解.请记住,印象不深.感觉是最好再一起去的源代码,返回下载android源代码,遇到了许多问题,最后开始下载.合并流程 ...

  6. 在Mac OS X中下载Android源代码的一些经验

    首先说明.随着最近(2014年6月開始)GFW的升级.这个站点:http://www.android.com/ 已经不能正常訪问了,以下的这些操作均是在我连接VPN的时候进行的. 首先,须要做一些准备 ...

  7. 下载android4.4.2源代码全过程(附已下载的源代码)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/maosidiaoxian/article/details/36625727 今天在下载andriod ...

  8. Git GUI下载远程源代码简单使用介绍

    学习编程,适当的时候弄些开源项目的源代码来学习实践,对技术是很有帮助的.如果学习.NET.C#的话,codeplex上面有许多不错的源代码,推荐一个ASP.ENT的:HoverTree http:// ...

  9. 给你的移动网站加点料:推荐下载App,如果本地安装则直接打开本地App(Android/IOS)

    纵观现在每家移动网站,打开首页的时候,都有各种各样的形式来提示你下载自身的移动App(Android/IOS),这是做移动客户端产品的一个很好地引流的手段.当然各家引流下载的交互和视觉各不相同,有的是 ...

随机推荐

  1. ExcelHelper类

    /// <summary> /// ExcelHelper类 /// </summary> using System; using System.IO; using Syste ...

  2. Django 利用 Pagination 分页

    Django自身提供了一些类来实现管理分页,数据被分在不同的页面中,并带有“上一页/下一页”标签.这个类叫做Pagination,其定义位于 django/core/paginator.py 中. 一 ...

  3. BZOJ——1620: [Usaco2008 Nov]Time Management 时间管理

    Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 920  Solved: 569[Submit][Status][Discuss] Description ...

  4. git alias

    alias|grep git g=git ga='git add' gaa='git add --all' gapa='git add --patch' gb='git branch' gba='gi ...

  5. VirtualApp技术黑产利用研究报告

    一. 前言 VirtualApp(以下称VA)是一个App虚拟化引擎(简称VA).VirtualApp创建了一个虚拟空间,你可以在虚拟空间内任意的安装.启动和卸载APK,这一切都与外部隔离,如同一个沙 ...

  6. 第六讲_图像分割Image Segmentation

    第六讲_图像分割Image Segmentation 语义分割(semantic segmentation) 常用神经网络介绍对比-FCN SegNet U-net DeconvNet 目录 +三大数 ...

  7. GDB调试多线程程序

    gdb有thread相关命令,如info thread(简写成info th)显示线程消息,b xx thread yy可以针对某个thread设置断点,thread xx(简写成thr xx)切换到 ...

  8. FreeBSD 8

    FreeBSD 8.0的安装过程和7.2区别不大.先在FreeBSD官方网站上下载安装镜像,我一般都下载DVD的ISO,也有人爱好下最小的安装包,然后通过FTP或HTTP方式从网上下载各个程序包. 这 ...

  9. C 标准库 - <math.h>

    C 标准库 - <math.h> 简介 math.h 头文件定义了各种数学函数和一个宏.在这个库中所有可用的功能都带有一个 double 类型的参数,且都返回 double类型的结果. 库 ...

  10. react className 有多个值时的处理 / react 样式使用 百分比(%) 报错

    1.react className 有多个值时的处理 <fieldset className={`${styles.formFieldset} ${styles.formItem}`}> ...