1.可以在SE38或者用函數(shù)“ RPY_PROGRAM_READ”查看代碼
所有的代碼都是存放在表REPOSRC中并以壓縮模式存放
不能查看源代碼峰鄙。
2.代碼加密程序如下,不過要謹(jǐn)慎使用,一旦代碼加密正蛙,在SAP中將不能查看源代碼
參考鏈接 https://archive.sap.com/discussions/thread/740272
REPORT z_hide_abap
NO STANDARD PAGE HEADING.
DATA: gt_code(72) TYPE c OCCURS 0,
gv_code LIKE LINE OF gt_code,
gt_code2(72) TYPE c OCCURS 0.
PARAMETERS: program LIKE sy-repid.
START-OF-SELECTION.
READ REPORT program INTO gt_code.
IF sy-subrc NE 0.
MESSAGE e398(00) WITH 'Report' program 'not found.'.
* ATTENTION:
* READ REPORT on a hidden source code return SY-SUBRC=8 !!!
ENDIF. "IF sy-subrc NE 0
READ TABLE gt_code INDEX 1 INTO gv_code.
* append *special* 1st line to hide cource code
APPEND '*@#@@[SAP]' TO gt_code2.
LOOP AT gt_code INTO gv_code.
APPEND gv_code TO gt_code2.
ENDLOOP.
INSERT REPORT program FROM gt_code2.
3.代碼還原
參考鏈接 https://www.daniel-berlin.de/devel/sap-dev/decompress-abap-source-code/
下載代碼https://github.com/daberlin/sap-reposrc-decompressor
用vs2015編譯源代碼生成命令行程序抚太,例如decompress.exe
使用下面代碼下載加密代碼塘幅,如ztme11
*&---------------------------------------------------------------------*
*& Report ZS_REPOSRC_DOWNLOAD
*&---------------------------------------------------------------------*
*& Purpose: Download compressed source code from table REPOSRC
*& Author : Daniel Berlin
*& Version: 1.0.1
*& License: CC BY 3.0 (http://creativecommons.org/licenses/by/3.0/)
*&---------------------------------------------------------------------*
REPORT zs_reposrc_download.
DATA: v_fnam TYPE rlgrap-filename, " Local file name
v_file TYPE string, " Same, but as a string
v_xstr TYPE xstring, " Source (compressed)
v_xlen TYPE i, " Length of source
t_xtab TYPE TABLE OF x255. " Source plugged into a table
PARAMETERS: report TYPE progname DEFAULT sy-repid "#EC *
MATCHCODE OBJECT progname OBLIGATORY.
START-OF-SELECTION.
" -- Select local file name
WHILE v_fnam IS INITIAL.
v_fnam = report.
CALL FUNCTION 'NAVIGATION_FILENAME_HELP'
EXPORTING
default_path = v_fnam
mode = 'S'
IMPORTING
selected_filename = v_fnam.
ENDWHILE.
v_file = v_fnam.
" -- Fetch compressed source code
SELECT SINGLE data INTO v_xstr FROM reposrc
WHERE progname = report AND r3state = 'A'.
v_xlen = XSTRLEN( v_xstr ).
" -- Plug source into a table
CALL METHOD cl_swf_utl_convert_xstring=>xstring_to_table
EXPORTING
i_stream = v_xstr
IMPORTING
e_table = t_xtab
EXCEPTIONS
OTHERS = 1.
" -- Download to local file
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'BIN'
filename = v_file
bin_filesize = v_xlen
TABLES
data_tab = t_xtab
EXCEPTIONS
OTHERS = 0.
假如下載的程序?yàn)閦tme11,將ztme11移到decompress.exe所在的目錄尿贫。
在cmd中切換到decompress.exe所在的目錄电媳,運(yùn)行如下命令:
decompress.exe ztme11 ztme11.abap -u
用文本編輯器打開當(dāng)前目錄中的ztme11.abap,就可以查看加密之前的代碼了