************************************************************************ * This program hides any ABAP's source code and protects it with a * password in this source code. * * After hiding, you can still run the abap (the load version is intact) * but it cannot be displayed, edited, traced, transported or generated. * * If the ABAP is not hidden, the program hides it, if it is hidden, it * unhide it. * Remember to hide this program first! ************************************************************************
* User name and password check IF password <> 'ABCDEFG'. WRITE: / 'Wrong password'. EXIT. ENDIF.
* SAP owned? IFNOTprogramCP'Z*'ANDNOTprogramCP'Y*'. WRITE: / 'Do not hide original SAP programs!'. EXIT. ENDIF.
* Exists? SELECTSINGLE * FROM trdir WHERE name = program. IF sy-subrc <> 0. WRITE: / 'Program does not exists!'. EXIT. ENDIF.
* Does it have a current generated version? DATA: f1 TYPE d, f3 TYPE d. DATA: f2 TYPE t, f4 TYPE t. EXECSQL. SELECT UDAT, UTIME, SDAT, STIME INTO :F1, :F2, :F3, :F4 FROM D010LINF WHERE PROG = :PROGRAM ENDEXEC.
IF f1 < f3 OR ( f1 = f3 AND f2 < f4 ). WRITE: / 'The program has no recent generated version!'. EXIT. ENDIF.
* Compose a new program name DATA: new_name(30), iTYPEi, j TYPEi.
new_name = program.
DO30TIMES. i = sy-index - 1.
new_name+i(1) = '_'.
* Search for acceptable program name variations
j = 0.
SELECT * FROM trdir WHERE name LIKE new_name.
j = j + 1. ENDSELECT.
IF j = 1. EXIT. ENDIF.
new_name = program. ENDDO.
* Cannot generate appropriate program name IF j > 1. WRITE: / 'Cannot generate appropriate program name'. EXIT. ENDIF.
* Check if it is already hidden DATA: f5(30).
EXECSQL. SELECT PROG INTO :F5 FROM D010S WHERE PROG = :NEW_NAME ENDEXEC.
IF f5 ISINITIAL.
* There is no such hidden program, hide it EXECSQL. UPDATE D010S SET PROG = :NEW_NAME WHERE PROG = :PROGRAM ENDEXEC. CONCATENATE'Program' :program'was hidden.' INTOmessageSEPARATEDBY space. ELSE.
* There is already a hidden program there, unhide it EXECSQL. UPDATE D010S SET PROG = :PROGRAMWHERE PROG = :NEW_NAME ENDEXEC.
Social Plugin