REPORT zproghide NO STANDARD PAGE HEADING.
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.
Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP MM SD Consultant
Contact : serkurumsal@yandex.com
Social Plugin