2007 May 02 2:27 PM
I need code to hide ABAP source code and protect it for further references.
2007 May 02 2:30 PM
check below sample program.
report zsam_hide no standard page heading.
************************************************************************
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!
************************************************************************
selection-screen begin of block block.
parameters: program(30) obligatory.
selection-screen begin of line.
selection-screen comment 1(8) pwd.
selection-screen position 35.
parameters: password(8) modif id aaa.
selection-screen end of line.
selection-screen end of block block.
*
data: message(60) type c.
*
at selection-screen output.
loop at screen.
if screen-group1 = 'AAA'.
screen-invisible = '1'.
modify screen.
endif.
endloop.
*
initialization.
pwd = 'Password'.
*
start-of-selection.
tables: trdir.
User name and password check
if password <> 'ABCDEFG'.
write: / 'Wrong password'.
exit.
endif.
SAP owned?
if not program cp 'Z' and not program cp 'Y'.
write: / 'Do not hide original SAP programs!'.
exit.
endif.
Exists?
select single * 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.
EXEC SQL.
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), i type i, j type i.
new_name = program.
do 30 times.
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).
EXEC SQL.
SELECT PROG INTO :F5 FROM D010S WHERE PROG = :NEW_NAME
ENDEXEC.
if f5 is initial.
There is no such hidden program, hide it
EXEC SQL.
UPDATE D010S SET PROG = :NEW_NAME WHERE PROG = :PROGRAM
ENDEXEC.
concatenate 'Program' :program 'was hidden.'
into message separated by space.
else.
There is already a hidden program there, unhide it
EXEC SQL.
UPDATE D010S SET PROG = :PROGRAM WHERE PROG = :NEW_NAME
ENDEXEC.
concatenate 'Program' :program 'was restored.'
into message separated by space.
endif.
write message.
end of program
Hi you can just hide the codes as
Put this code in the first line of the editor.
*@#@@[SAP]
ensure that this should be the only code in first line first column, There is no easy way to get back codes easily. but a experienced Basis guy can retrieve it...
Take backup before trial......
If u want to hide really codes at all, use C++ classes.
Hope this will help u.
Jogdand M B
2007 May 02 2:30 PM
check below sample program.
report zsam_hide no standard page heading.
************************************************************************
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!
************************************************************************
selection-screen begin of block block.
parameters: program(30) obligatory.
selection-screen begin of line.
selection-screen comment 1(8) pwd.
selection-screen position 35.
parameters: password(8) modif id aaa.
selection-screen end of line.
selection-screen end of block block.
*
data: message(60) type c.
*
at selection-screen output.
loop at screen.
if screen-group1 = 'AAA'.
screen-invisible = '1'.
modify screen.
endif.
endloop.
*
initialization.
pwd = 'Password'.
*
start-of-selection.
tables: trdir.
User name and password check
if password <> 'ABCDEFG'.
write: / 'Wrong password'.
exit.
endif.
SAP owned?
if not program cp 'Z' and not program cp 'Y'.
write: / 'Do not hide original SAP programs!'.
exit.
endif.
Exists?
select single * 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.
EXEC SQL.
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), i type i, j type i.
new_name = program.
do 30 times.
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).
EXEC SQL.
SELECT PROG INTO :F5 FROM D010S WHERE PROG = :NEW_NAME
ENDEXEC.
if f5 is initial.
There is no such hidden program, hide it
EXEC SQL.
UPDATE D010S SET PROG = :NEW_NAME WHERE PROG = :PROGRAM
ENDEXEC.
concatenate 'Program' :program 'was hidden.'
into message separated by space.
else.
There is already a hidden program there, unhide it
EXEC SQL.
UPDATE D010S SET PROG = :PROGRAM WHERE PROG = :NEW_NAME
ENDEXEC.
concatenate 'Program' :program 'was restored.'
into message separated by space.
endif.
write message.
end of program
2007 May 02 2:32 PM
Hi you can just hide the codes as
Put this code in the first line of the editor.
*@#@@[SAP]
ensure that this should be the only code in first line first column, There is no easy way to get back codes easily. but a experienced Basis guy can retrieve it...
Take backup before trial......
If u want to hide really codes at all, use C++ classes.
Hope this will help u.
Jogdand M B
2007 May 02 2:32 PM
HI,
<b>Program to Hide ABAP's Source Code and Protects it </b>
report zsam_hide no standard page heading.************************************************************************
* 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!
************************************************************************
selection-screen begin of block block.
parameters: program(30) obligatory.
selection-screen begin of line.
selection-screen comment 1(8) pwd.
selection-screen position 35.
parameters: password(8) modif id aaa.
selection-screen end of line.
selection-screen end of block block.
*
data: message(60) type c.
*
at selection-screen output.
loop at screen.
if screen-group1 = 'AAA'.
screen-invisible = '1'.
modify screen.
endif.
endloop.
*
initialization.
pwd = 'Password'.
*
start-of-selection.
tables: trdir.
* User name and password check
if password <> 'ABCDEFG'.
write: / 'Wrong password'.
exit.
endif.
* SAP owned?
if not program cp 'Z*' and not program cp 'Y*'.
write: / 'Do not hide original SAP programs!'.
exit.
endif.
* Exists?
select single * 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.
EXEC SQL.
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), i type i, j type i.
new_name = program.
do 30 times.
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).
EXEC SQL.
SELECT PROG INTO :F5 FROM D010S WHERE PROG = :NEW_NAME
ENDEXEC.
if f5 is initial.
* There is no such hidden program, hide it
EXEC SQL.
UPDATE D010S SET PROG = :NEW_NAME WHERE PROG = :PROGRAM
ENDEXEC.
concatenate 'Program' :program 'was hidden.'
into message separated by space.
else.
* There is already a hidden program there, unhide it
EXEC SQL.
UPDATE D010S SET PROG = :PROGRAM WHERE PROG = :NEW_NAME
ENDEXEC.
concatenate 'Program' :program 'was restored.'
into message separated by space.
endif.
write message.
*** end of programEven you can implement a Exit <b>EXIT_SAPLS38E_001</b> to hide or protect ABAP source code without direct updates to SAP tables
Regards
Sudheer
2007 May 02 2:33 PM
Check if you can use Authorization objects for display purpose also...
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |