很恐怖ABAP修改程式(千萬不要亂用!!!!!!!!!)

liuhaimiao發表於2015-09-02
*& Report  **************
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  **************.

types: abapline(255) type c.
data: it_repsrc type standard table of abapline.
DATA: ZBACK type standard table of abapline.
DATA: wa_repsrc TYPE  abapline.
data : fcode like sy-ucomm.
DATA:changed like s38e-buf_varied.

DATA:IT_MESSAGE TYPE TABLE OF ZTEXT_EDITOR_MESSAGE WITH HEADER LINE.
DATA: BEGIN OF INCTABL OCCURS 10,
   LINE(100),
END OF INCTABL.

PARAMETERS:Zname LIKE RS38M-PROGRAMM.

start-of-selection.
set pf-status 'PFSTA00'.
write: /1 '你編輯好的程式:' color 2.
read report Zname into it_repsrc.
read report Zname into ZBACK.

  LOOP AT it_repsrc INTO wa_repsrc.
    WRITE :/ wa_repsrc.
  ENDLOOP.



at user-command.


if sy-ucomm = 'ZWRITE'.     "寫入
  CLEAR :INCTABL[].
  LOOP AT it_repsrc INTO wa_repsrc.
    INCTABL-LINE = wa_repsrc.
    APPEND INCTABL.
  ENDLOOP.
  INSERT REPORT ZNAME FROM INCTABL.
  if sy-subrc = 0.
    MESSAGE '寫入成功,將測試執行新的程式.如果有錯誤,請點"還原"恢復.'  TYPE 'I'.
  ENDIF.
  SUBMIT Zname  AND RETURN.
  read report Zname into it_repsrc.
  LOOP AT it_repsrc INTO wa_repsrc.
    WRITE :/ wa_repsrc.
  ENDLOOP.
elseif sy-ucomm = 'EXEC'.   "還原
  it_repsrc[] = ZBACK[].
  INSERT REPORT Zname FROM ZBACK.
  LOOP AT ZBACK INTO wa_repsrc.
    WRITE :/ wa_repsrc.
  ENDLOOP.
  SUBMIT Zname  AND RETURN.
  MESSAGE '還原成功' TYPE 'I'.
ELSEIF SY-ucomm = 'EDIT'.   "編輯
  perform. editor_CHX.
  LOOP AT it_repsrc INTO wa_repsrc.
    WRITE :/ wa_repsrc.
  ENDLOOP.
elseif sy-ucomm = 'ZBACK' OR sy-ucomm = 'BACK'.    "退出
     CLEAR: inctabl[],it_repsrc[],ZBACK[],Zname.
     FREE :inctabl[],it_repsrc[],ZBACK[],Zname.
     leave to screen 0.
ELSE.
endif.

*&---------------------------------------------------------------------*
*&      Form  editor_CHX
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&gt  p1        text
*  *----------------------------------------------------------------------*
FORM. editor_CHX .
  call function 'EDITOR_APPLICATION'
       exporting
            application = 'BF'
            display     = ' '
            name        = '[編輯你的程式:]'
       importing
            fcode       = fcode
            changed     = changed
       tables
            content     = it_repsrc.
ENDFORM.                    " editor_CHX


*********************後話
用上面這個程式,可以修改SAP的任何程式.不需要申請KEY,也不會產生序列號.建議有豐富ABAP編寫經驗的人才可以使用,如果你一定要使用,請記住"寫入程式"後的提示.在測試正確前,不要退出本程式,這樣,你還有機會還原!!!!!!!!!(想想吧,如果使用不慎,即使幾百萬的SAP系統不會全毀了,某個模組也會可能毀壞.所以,一定慎重使用).

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/223653/viewspace-1789362/,如需轉載,請註明出處,否則將追究法律責任。

相關文章