博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2016.4.26_下载abap代码【ABAP】
阅读量:4931 次
发布时间:2019-06-11

本文共 4258 字,大约阅读时间需要 14 分钟。

系统里存了很多以前写的代码,好长时间不看都忘了,还是想存到本地,挨个复制粘贴太麻烦了,有好多程序写的很正式,有很多include,复制起来就更麻烦了。

所以想着写个程序把程序名一输,自动下载所有代码。

*&---------------------------------------------------------------------**& REPORT  YZ_TEST*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*REPORT YZ_TEST NO STANDARD PAGE HEADING                   MESSAGE-ID YTEST.TYPES :BEGIN OF TYP_DATA,         DATA(200) TYPE C,       END OF TYP_DATA.DATA GT_ALLCODE TYPE STANDARD TABLE OF TYP_DATA WITH HEADER LINE.DATA GT_TEMPCODE TYPE STANDARD TABLE OF TYP_DATA WITH HEADER LINE.DATA GT_INCLUDE  TYPE STANDARD TABLE OF TYP_DATA WITH HEADER LINE.DATA LV_LENG TYPE I.DATA LV_PROGLEN TYPE I.DATA LV_FPATH TYPE STRING.DATA GV_MARK TYPE C.CONSTANTS: LC_POINT TYPE C VALUE '.'.CONSTANTS: LC_INCLUDE TYPE C LENGTH 7 VALUE 'INCLUDE'.PARAMETERS:P_REPORT TYPE RSRD1-OBJNAME OBLIGATORY DEFAULT 'YZTEST'.PARAMETERS: P_PATH TYPE IBIPPARMS-PATH OBLIGATORY                DEFAULT 'C:\Users\xabap01\Desktop\test.xls' .AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_PATH.  PERFORM F_F4_PATH  CHANGING P_PATH.START-OF-SELECTION.  LV_PROGLEN = STRLEN( P_REPORT ) + 3.  READ REPORT P_REPORT INTO GT_ALLCODE.  LOOP AT GT_ALLCODE.    SEARCH GT_ALLCODE-DATA FOR 'INCLUDE'.    IF SY-SUBRC EQ 0.      GV_MARK = 'X'.      LV_LENG = STRLEN( GT_ALLCODE-DATA ).      SHIFT GT_ALLCODE-DATA UP TO LC_INCLUDE LEFT.      GT_ALLCODE-DATA = GT_ALLCODE-DATA+8(LV_PROGLEN).      GT_INCLUDE-DATA = GT_ALLCODE-DATA.      APPEND GT_INCLUDE.      CLEAR: GT_INCLUDE,GT_ALLCODE.    ENDIF.  ENDLOOP.  IF GV_MARK EQ 'x'.  LOOP AT GT_INCLUDE.      READ REPORT GT_INCLUDE-DATA INTO GT_TEMPCODE.      IF SY-SUBRC EQ 0.        APPEND LINES OF GT_TEMPCODE TO GT_ALLCODE.        CLEAR:GT_TEMPCODE,GT_TEMPCODE[].      ENDIF.    ENDLOOP.    CLEAR GV_MARK.  ENDIF.  LV_FPATH = P_PATH.  CALL FUNCTION 'GUI_DOWNLOAD'    EXPORTING      FILENAME                = LV_FPATH      FILETYPE                = 'ASC'      WRITE_FIELD_SEPARATOR   = 'X'    TABLES      DATA_TAB                = GT_ALLCODE    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 E000 WITH 'download failed !' .    RETURN.  ENDIF.*&---------------------------------------------------------------------**&      Form  F_F4_PATH*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------**      <--P_P_PATH  text*----------------------------------------------------------------------*FORM F_F4_PATH  CHANGING P_PATH.  DATA: LV_EXTEN TYPE STRING,        LV_FILTER TYPE STRING,        LV_DIREC TYPE STRING,        LV_FP TYPE STRING,        LV_RC TYPE I,        LT_FT TYPE FILETABLE,        LS_FT LIKE LINE OF LT_FT.  CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG    EXPORTING      DEFAULT_EXTENSION       = LV_EXTEN      FILE_FILTER             = LV_FILTER      INITIAL_DIRECTORY       = LV_DIREC    CHANGING      FILE_TABLE              = LT_FT      RC                      = LV_RC    EXCEPTIONS      FILE_OPEN_DIALOG_FAILED = 1      CNTL_ERROR              = 2      ERROR_NO_GUI            = 3      NOT_SUPPORTED_BY_GUI    = 4      OTHERS                  = 5.  READ TABLE LT_FT INTO LS_FT INDEX 1.  LV_FP = LS_FT.  P_PATH = LV_FP.ENDFORM.                    " F_F4_PATH

写完以后给同事看,结果人家给了一个更好的代码:

http://blog.163.com/fuwa_beijing/blog/static/50467514201041135032400/

功能看起来很多,下载程序代码同时还能把程序中用到的表结构下载成html文件。最终还是用这个代码备份了所有程序。

转载于:https://www.cnblogs.com/fieldcatalog/p/5434714.html

你可能感兴趣的文章
项目中的Libevent(多线程)
查看>>
关闭客户端连接的两种情况
查看>>
bat----服务器重启后爬虫自动运行
查看>>
ThinkPHP 模板的包含、渲染、继承
查看>>
K-Means 聚类
查看>>
向shell脚本中传入参数
查看>>
XML解析之SAX解析
查看>>
jsp 四大域范围
查看>>
Cycloid Hydraulic Motor Use: Use Failure And Treatment
查看>>
SQA计划和验收测试规程设计
查看>>
jquery的$.extend()、$.fn和$.fn.extend()
查看>>
2015/12/29 eclipse应用 输出三角形
查看>>
IOS UI二
查看>>
ES6新增const常量、let变量
查看>>
Android 隐式 Intent 跳转注意事项
查看>>
hdu1556 Color the ball
查看>>
浏览器自动化项目【构思】(完)
查看>>
第一次开通博客了
查看>>
hihocoder #1190 : 连通性·四 点双联通分量
查看>>
Panoramic Photography
查看>>