ABAP Program to Hide Source Code of a Program

1
782

Although this method is not recommended by SAP and I have not found any ‘Rollback’ to retrieve the source code for this hide, still it can be used for Source Code Hiding taking following points into consideration:

1. Please do take a backup of the code (.txt).

2. At the time of unhiding( source code 2 in the following sample code), source code is lost/blanked. Copy-paste the code from the backup.

 

Enter Program Name to Hide
Enter Program Name to Hide

 

 

Program 1 : Hide Source code

 

REPORT  ZTST_HIDE .
DATA: g_code(72) TYPE c OCCURS 0,
g_code1 LIKE LINE OF g_code,
g_code2(72) TYPE c OCCURS 0.
PARAMETERS: program LIKE sy-repid.
START-OF-SELECTION.
READ REPORT program INTO g_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.
READ TABLE g_code INDEX 1 INTO g_code1.
* append *special* 1st line to hide cource code
APPEND ‘*@#@@[SAP]’ TO g_code2.
LOOP AT g_code INTO g_code1.
APPEND g_code1 TO g_code2.
ENDLOOP.
INSERT REPORT program FROM g_code2.

 

The following special line is inserted into the program source code:

 

Inserted Special Line in code
Inserted Special Line in code

 

Now when you try to access the program, it will give the following message:

 

Message when accessing Hidden program
Message when accessing Hidden program

 

 

Program 2 : Un-hide Source code

 

REPORT  ZTST_UNHIDE .
DATA: g_code(72) TYPE c OCCURS 0,
g_code1 LIKE LINE OF g_code,
g_code2(72) TYPE c OCCURS 0.
PARAMETERS: program LIKE sy-repid.
START-OF-SELECTION.
read report program into g_code.
DELETE g_code INDEX 1.
insert report program from g_code.

 

 

Although the above program un-hides the hidden program but the source code is lost. Please copy-paste the downloaded / backup version of the program.

 

 

read report program into g_code.
DELETE g_code INDEX 1.
insert report program from g_code.

 

 

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here