这个方法可以修改标准表。请谨慎使用!
DATA : G_TABNAME ( 30 ) TYPE C VALUE '/1BCDWB/DB' ,
ACTION TYPE SY -UCOMM VALUE 'ANZE' ,
GLOBAL_AUTH ( 4 ) TYPE C ,
G_DATA_EXIT LIKE RS38L -NAME VALUE 'UPDA' .
DATA : MEM_ID ( 16 ) VALUE 'TABELLENANZEIGER' .
*----------------------------------------------------------------------*
* SELECTION-SCREEN *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK FRM1 WITH FRAME TITLE TEXT - 001 .
PARAMETERS : TABNAME LIKE DATABROWSE -TABLENAME MEMORY ID DTB .
SELECTION-SCREEN END OF BLOCK FRM1 .
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR TABNAME .
PERFORM F4_OBJNAME .
AT SELECTION-SCREEN .
PERFORM CHECK_TABNAME .
*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION .
IF ( TABNAME ( 1 ) <> 'Y' AND TABNAME ( 1 ) <> 'Z' ) .
MESSAGE '无法修改Standard Table' TYPE 'E' .
EXIT .
ENDIF .
CONCATENATE G_TABNAME TABNAME INTO G_TABNAME .
DD02L -MAINFLAG = 'X' .
EXPORT ACTION DD02L -MAINFLAG GLOBAL_AUTH
TO MEMORY ID MEM_ID .
SUBMIT (G_TABNAME ) VIA SELECTION-SCREEN AND RETURN .
*&---------------------------------------------------------------------*
*& Form F4_OBJNAME
*&---------------------------------------------------------------------*
FORM F4_OBJNAME .
DATA : L_DNUM LIKE D020S -DNUM ,
L_REPID LIKE SY -REPID .
L_DNUM = SY -DYNNR .
L_REPID = SY -REPID .
CALL FUNCTION 'RS_HELP_HANDLING'
EXPORTING
DYNPFIELD = 'TABNAME'
DYNPNAME = L_DNUM
OBJECT = 'TB '
PROGNAME = L_REPID
SUPPRESS_SELECTION_SCREEN = 'X' .
ENDFORM . " F4_OBJNAME
*&---------------------------------------------------------------------*
*& Form check_tabname
*&---------------------------------------------------------------------*
FORM CHECK_TABNAME .
IF TABNAME IS INITIAL .
MESSAGE '请输入TABLE ID' TYPE 'E' .
ENDIF .
CHECK TABNAME IS NOT INITIAL .
SELECT SINGLE *
FROM DD02L
WHERE TABNAME = TABNAME
AND AS4LOCAL = 'A'
AND ( TABCLASS <> 'INTTAB' AND TABNAME <> 'APPEND' AND
TABCLASS <> 'VIEW' ) .
IF SY -SUBRC <> 0 .
MESSAGE E402 (MO ) WITH TABNAME . "表 &没有在 Dictionary激活
ENDIF .
ENDFORM. " check_tabnameve2