‎2007 Aug 01 2:07 PM
Hi ,
I am currently working on SAP 4.0B version, i hided my code using the code: <b>*@#@@[SAP]</b>. It is getting executed but i am not able to see the code. Is there any way to get the code back. Or is there any place where the system stores the code after hiding it using the above statement.
thanks,
Navneeth K.
‎2007 Aug 01 2:11 PM
From http://abap4.tripod.com/Other_Useful_Tips.html
<i>Hiding ABAP Source Code
.....
There is no easy way to get your source code back, so make sure you make a backup and save it to a local drive!</i>
Regards,
RIch Heilman
‎2007 Aug 01 2:11 PM
From http://abap4.tripod.com/Other_Useful_Tips.html
<i>Hiding ABAP Source Code
.....
There is no easy way to get your source code back, so make sure you make a backup and save it to a local drive!</i>
Regards,
RIch Heilman
‎2007 Aug 01 2:22 PM
Hi Rich,
Is there no way to get the code back. Does the system not store it in any table or some buffer. I had a doubt then how the execution takes place, it should be taking source code from some place for execution.
Thanks,
Navneeth K.
‎2007 Aug 01 2:27 PM
You know, I have no idea, cuz, I have never had a reason to hide code, therefore never had to retrieve it. Your issue is exactly the reason why an ABAP Developer should never "Hide" the code.
You can try to use the statement READ REPORT...... in another program but I would assume that it would bring you no source code back, but it is worth a try.
Regards,
Rich Heilman
‎2007 Aug 01 2:33 PM
Thanks Rich, I tried the Read command and also used SCAN command put it did not work. Actually i was just trying this piece of code which hides source code to see how it works.
‎2007 Aug 01 2:44 PM
Rich is totally correct. As an employee I can't think of a single good reason to hide code <b>or editor lock a program.</b>
I work for a Fortune 50 Company & we bought a 3rd party app that had hidden code - our QA team refused to approve transport to Production.
We were literally on the phone to the president of the software vendor's company telling them they had to show us the code if they wanted our payment.
guess what? they gave us the code.
‎2007 Aug 01 2:48 PM
Hi Robert and Rich,
i have no intentions to hide a code, i was just experimenting with this piece of code, to see actually how it functions. Ya i understand that no developer should hide his code.
thanks,
Navneeth K.
‎2007 Aug 01 2:12 PM
You can't see the hided code. How could you expect the code to be seen if you are executing it. <b>The basic functionality of code is to hide.</b>
Here is a sample code.
PROGRAM ZHIDE NO STANDARD PAGE HEADING.
************************************************************************
This program hides any ABAP's source code and protects it with a
password in this source code. So the first candidate to be hidden
should be ZHIDE itself.
*
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
unhides it.
*
To execute this program, change the user name and password in this
source code first.
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK BLOCK.
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.
PARAMETERS: PROGRAM(8).
SELECTION-SCREEN END OF BLOCK BLOCK.
*
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 passsword check
IF SY-UNAME <> 'SAP' OR PASSWORD <> 'PASSWORD'.
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(8), I TYPE I, J TYPE I.
NEW_NAME = PROGRAM.
DO 8 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 in d010s (already hidden)
DATA: F5(8).
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.
ELSE.
There is already a hidden program there, unhide it
EXEC SQL.
UPDATE D010S SET PROG = :PROGRAM WHERE PROG = :NEW_NAME
ENDEXEC.
ENDIF.
Regards,
Pavan
‎2007 Aug 01 2:30 PM
there is no way to get the hidden code back but it will get stored in tables, so only u can execute the same.
‎2007 Aug 01 2:34 PM
‎2007 Aug 01 2:37 PM
‎2007 Aug 01 2:33 PM
check below code....
Program to Hide ABAP's Source Code and Protects it
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 Aug 01 2:56 PM
Hi,
Try to Run this program in debug mode. With this you can see and get the source code back while the program is running.
Good look,
Marcelo Ramos