一:首先我们需要知道SAP的资源类型
PGMID :程序ID
OBJECT :对象类型
OBJ_NAME:对象名称 SY-REPID
我们可以通过SE09/SE10来创建一个请求号也能看的出来
也可以通过SE03来查找
请求号相关的数据都在E07*的表里这边就不多说了
接下来我们建一个数据库表的请求需要用到的函数有
RS_CORR_INSERT
TADIR-OBJECT 对象类型
DDIF_TABL_PUT DDIF_TADIR-OBJECT_PUT
DDIF_TABL_ACTIVATE DDIF_TADIR-OBJECT_ACTIVATE
TABLES:tadir.
DATA: it_dd03 TYPE TABLE OF dd03p WITH HEADER LINE.
PERFORM fill_dd03 USING : 'MANDT ' 'MANDT' 'X',
'TABNAME ' 'TABNAME' 'X',
'OBJECTID ' 'CDOBJECTV' 'X',
'FIELDNAME' 'FIELDNAME' 'X',
'ERDAT ' 'ERDAT' 'X',
'ERZET ' 'ERZET' 'X',
'ERNAM ' 'ERNAM' 'X',
'VALUE_OLD' 'CDFLDVALO' '',
'VALUE_NEW' 'CDFLDVALN' ''.
“获取当前程序所在的包
SELECT SINGLE * FROM tadir
WHERE pgmid = 'R3TR' AND
object = 'PROG' AND
obj_name = sy-repid.
PERFORM create_table TABLES it_dd03
USING '表名' '简短描述' tadir-devclass .
*&---------------------------------------------------------------------*
*& Form fill_dd03
*&---------------------------------------------------------------------*
FORM fill_dd03 USING fldname rollname key.
it_dd03-fieldname = fldname. "字段名
it_dd03-rollname = rollname. "数据元素 (语义域)
it_dd03-keyflag = key. "标识表格的关键字段
APPEND it_dd03. CLEAR it_dd03.
ENDFORM. "fill_dd03
*&---------------------------------------------------------------------*
*& 创建透明表
*&---------------------------------------------------------------------*
FORM create_table TABLES transfld STRUCTURE dd03p
USING transtab ddtext devclass .
DATA: objstr(40),
reqnum TYPE trkorr.
DATA: wa_02v TYPE dd02v ,
wa_09l TYPE dd09v ,
subrc TYPE sy-subrc.
DATA: lt_03p TYPE TABLE OF dd03p WITH HEADER LINE .
SELECT SINGLE * INTO wa_02v FROM dd02v
WHERE tabname = transtab AND
tabclass = 'TRANSP'.
IF sy-subrc = 0.
MESSAGE s000(oo) WITH '透明表' transtab '已存在'.
RETURN.
ENDIF.
***传输请求
CONCATENATE 'TABL' transtab INTO objstr.
CALL FUNCTION 'RS_CORR_INSERT'
EXPORTING
object = objstr
object_class = 'DICT'
devclass = devclass
korrnum = reqnum
master_language = sy-langu
global_lock = 'X'
mode = 'I'
suppress_dialog = ''
IMPORTING
ordernum = reqnum
EXCEPTIONS
cancelled = 1
permission_failure = 2
unknown_objectclass = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
***创建透明表并激活
wa_02v-tabname = transtab.
wa_02v-ddtext = ddtext.
wa_02v-ddlanguage = sy-langu.
wa_02v-tabclass = 'TRANSP'.
wa_02v-as4user = sy-uname.
wa_02v-contflag = 'C'.
wa_02v-mainflag = 'X'.
wa_09l-tabname = transtab.
wa_09l-tabart = 'APPL1'.
wa_09l-tabkat = 6.
LOOP AT transfld.
lt_03p-tabname = transtab.
lt_03p-ddlanguage = sy-langu.
lt_03p-position = sy-tabix.
lt_03p-fieldname = transfld-fieldname.
lt_03p-rollname = transfld-rollname.
lt_03p-notnull = 'X'.
lt_03p-keyflag = transfld-keyflag.
APPEND lt_03p.
CLEAR lt_03p.
ENDLOOP.
CALL FUNCTION 'DDIF_TABL_PUT'
EXPORTING
name = transtab
dd02v_wa = wa_02v
dd09l_wa = wa_09l
TABLES
dd03p_tab = lt_03p
EXCEPTIONS
tabl_not_found = 1
name_inconsistent = 2
tabl_inconsistent = 3
put_failure = 4
put_refused = 5
OTHERS = 6.
"激活这个表
IF sy-subrc = 0.
CALL FUNCTION 'DDIF_TABL_ACTIVATE'
EXPORTING
name = transtab
IMPORTING
rc = subrc
EXCEPTIONS
not_found = 1
put_failure = 2
OTHERS = 3.
IF sy-subrc <> 0 OR ( subrc > 4 ).
MESSAGE s000(oo) WITH '创建成功,激活失败,请手工激活表'.
ELSE.
MESSAGE s000(oo) WITH '创建成功,激活成功'.
ENDIF.
ELSE.
MESSAGE s000(oo) WITH '创建失败'.
ENDIF.
ENDFORM. "create_table