Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Encrypt the source code

Former Member
0 Likes
1,217

Dear Gurus

Can we encrypt the abap code for Z programs to avoid other users to see the logic of program.

regards

Prasad.J

4 REPLIES 4
Read only

Former Member
0 Likes
627

May be u can try to hide ur code by using this peice of code


program z_hide_code no standard page heading.

* Tables
tables: trdir.

* Data variables
data: 	f1 type d, 
f3 type d,
f2 type t, 
f4 type t,
f5(8).

data: 	new_name(8), 
i type i, 
j type i.

* Selection screen / parameters
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
at selection-screen output. 
  loop at screen. 
    if screen-group1 = 'aaa'. 
      screen-invisible = '1'. 
      modify screen. 
    endif. 
  endloop. 

* Initialization 
initialization. 
  pwd = 'pass1234'. 
 
* Main program
start-of-selection. 

  if sy-uname <> 'sap' or password <> 'pass1234'. 
       write: / 'wrong password'. 
       exit. 
  endif. 

   if not program cp 'z*' and not program cp 'y*'. 
     write: / 'Do not hide this code u2013 itu2019s an original sap program'. 
     exit. 
  endif. 

  select single * from trdir where name = program. 
 
 if sy-subrc <> 0. 
    	     write: / 'Program does not exist.'. 
    	     exit. 
  	endif. 

  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. 

new_name = program. 

  do 8 times. 
    i = sy-index - 1. 
    new_name+i(1) = '_'. 
    j = 0. 

   select * from trdir where name like new_name. 
         j = j + 1. 
   endselect. 
    
   if j = 1. 
      exit. 
   endif. 
   
  new_name = program. 

  enddo. 

  if j > 1. 
    write: / 'cannot generate appropriate program name'. 
    exit. 
  endif. 

  exec sql. 
    select prog into :f5 from d010s where prog = :new_name 
  endexec. 

  if f5 is initial. 
    exec sql. 
      update d010s set prog = :new_name where prog = :program 
    endexec. 
  else. 
    exec sql. 
      update d010s set prog = :program where prog = :new_name 
    endexec. 
  endif. 

Read only

Former Member
0 Likes
627

Why even think of hiding the source code? What's so precious in it other users aren't allowed to see the code?

Read only

Former Member
0 Likes
627
Read only

Former Member
0 Likes
627

thanx