通过ABAP程序创建透明表
最近在解决用户账号问题的时候,需要通过ABAP程序创建透明表,查询了相关资料,总结如下。
通过ABAP程序创建透明表,主要利用了4个函数:
DDIF_TABL_ACTIVATE: 激活透明表
GOX_GEN_TABLE_STD: 生成透明表
DDIF_TABL_PUT: 设置表的相关信息
DDIF_TABL_GET: 获得表的相关信息
参数说明
Import:
NAME: 数据库表的名字
STATE: 状态
STATE = ‘A’ (read the active version)
STATE = ‘M’ (read the latest version)
LANGU: 语言设定, 默认sy-langu
Export:
GOTSTATE: 状态信息
DD02V_WA: 表头
DD09L_WA: 表表的技术信息
Tables:
DD03P_TAB: 表的字段列表
DD05M_TAB: 表的外键字段
DD08V_TAB: 表的外键
DD12V_TAB: 表索引
DD17V_TAB: 表的索引字段
DD35V_TAB: 检索help相关
DD36M_TAB: 检索help相关
代码:
REPORT z_create_table. PARAMETERS: tabname TYPE char32 OBLIGATORY.
DATA: lt_new_object TYPE comt_gox_def_header,
lt_old_object LIKE lt_new_object,
lv_dbtab1_name TYPE char32,
ls_new_object LIKE LINE OF lt_new_object,
ls_new_object_details TYPE LINE OF comt_gox_table_entry_fields,
lt_returntab TYPE bapirettab,
ls_return LIKE LINE OF lt_returntab. ls_new_object-object_type = 'TABLE'.
ls_new_object-object_name = tabname. TRY.
data(lv_guid) = cl_system_uuid=>if_system_uuid_static~create_uuid_c32( ).
CATCH cx_uuid_error .
ENDTRY. * technical setting
ls_new_object-key_guid = lv_guid.
data(lv_parent_guid) = ls_new_object-key_guid.
ls_new_object_details-fieldname = 'TABCLASS'.
ls_new_object_details-fieldvalue = 'TRANSP'.
APPEND ls_new_object_details TO ls_new_object-details.
CLEAR ls_new_object_details.
ls_new_object_details-fieldname = 'TABKAT'.
ls_new_object_details-fieldvalue = ''.
APPEND ls_new_object_details TO ls_new_object-details.
CLEAR ls_new_object_details.
ls_new_object_details-fieldname = 'TABART'.
ls_new_object_details-fieldvalue = 'APPL2'.
APPEND ls_new_object_details TO ls_new_object-details.
CLEAR ls_new_object_details.
ls_new_object_details-fieldname = 'PUFFERUNG'.
ls_new_object_details-fieldvalue = 'X'.
APPEND ls_new_object_details TO ls_new_object-details.
CLEAR ls_new_object_details.
ls_new_object_details-fieldname = 'CONTFLAG'.
ls_new_object_details-fieldvalue = 'S'.
APPEND ls_new_object_details TO ls_new_object-details.
CLEAR ls_new_object_details.
ls_new_object_details-fieldname = 'MAINFLAG'.
ls_new_object_details-fieldvalue = 'X'.
APPEND ls_new_object_details TO ls_new_object-details.
CLEAR ls_new_object_details.
ls_new_object_details-fieldname = 'BUFFALLOW'.
ls_new_object_details-fieldvalue = 'X'.
APPEND ls_new_object_details TO ls_new_object-details.
CLEAR ls_new_object_details.
ls_new_object_details-fieldname = 'SCHFELDANZ'.
ls_new_object_details-fieldvalue = ''.
APPEND ls_new_object_details TO ls_new_object-details.
CLEAR ls_new_object_details.
APPEND ls_new_object TO lt_new_object.
CLEAR ls_new_object. ls_new_object-object_type = 'TABLE_FIELD'.
TRY.
lv_guid = cl_system_uuid=>if_system_uuid_static~create_uuid_c32( ).
CATCH cx_uuid_error .
ENDTRY.
ls_new_object-key_guid = lv_guid.
ls_new_object-parent_key = lv_parent_guid.
lv_parent_guid = lv_guid.
ls_new_object-object_name = 'CODE_VALUE'. "field name
ls_new_object_details-fieldname = 'POSITION'.
ls_new_object_details-fieldvalue = ''.
APPEND ls_new_object_details TO ls_new_object-details.
CLEAR ls_new_object_details.
ls_new_object_details-fieldname = 'KEYFLAG'. "Key
ls_new_object_details-fieldvalue = 'X'.
APPEND ls_new_object_details TO ls_new_object-details.
CLEAR ls_new_object_details.
ls_new_object_details-fieldname = 'NOTNULL'. "initial
ls_new_object_details-fieldvalue = 'X'.
APPEND ls_new_object_details TO ls_new_object-details.
CLEAR ls_new_object_details.
ls_new_object_details-fieldname = 'ROLLNAME'.
ls_new_object_details-fieldvalue = 'COMT_PRODUCT_ID'. "data element
APPEND ls_new_object_details TO ls_new_object-details.
CLEAR ls_new_object_details.
APPEND ls_new_object TO lt_new_object.
CLEAR ls_new_object.
REFRESH lt_returntab.
CLEAR lv_parent_guid. lv_dbtab1_name = tabname.
CALL FUNCTION 'GOX_GEN_TABLE_STD'
EXPORTING
iv_object_name = lv_dbtab1_name
it_object_new = lt_new_object
it_object_old = lt_old_object
iv_devclass = '$TMP' "local
IMPORTING
et_bapireturn = lt_returntab. CHECK lt_returntab IS INITIAL. DATA: lv_ddobjname TYPE ddobjname,
ls_dd02v TYPE dd02v. lv_ddobjname = lv_dbtab1_name.
CALL FUNCTION 'DDIF_TABL_GET'
EXPORTING
name = lv_ddobjname
state = 'A'
langu = sy-langu
IMPORTING
dd02v_wa = ls_dd02v
EXCEPTIONS
illegal_input =
OTHERS = .
IF sy-subrc <> .
RETURN.
ENDIF. ls_dd02v-mainflag = 'X'.
CALL FUNCTION 'DDIF_TABL_PUT'
EXPORTING
name = lv_ddobjname
dd02v_wa = ls_dd02v
EXCEPTIONS
tabl_not_found =
name_inconsistent =
tabl_inconsistent =
put_failure =
put_refused =
OTHERS = .
IF sy-subrc <> .
RETURN.
ENDIF. * active table
CALL FUNCTION 'DDIF_TABL_ACTIVATE'
EXPORTING
name = lv_ddobjname
auth_chk = ' '. CHECK sy-subrc = . WRITE:/ 'Table: ', lv_ddobjname, ' generated successfully'.
输入透明表名运行,即可创建成功。
进入SE11查看结果:
通过ABAP程序创建透明表的更多相关文章
- ABAP 自建透明表维护
*&---------------------------------------------------------------------* *& Report ZMMR011 ...
- sap透明表、结构、簇介绍以及查找表方法
sap透明表.结构.簇介绍以及查找表方法 一些人在写开发功能说明书的时候不知道如何去找屏幕字段对应的透明表,下面我来介绍一个比较有效的方法:首先简单介绍一下概念:在SAP中的表的种类有以下三种:Tra ...
- ABAP 动态生成内表的几种方法
最近要写个程序,既有更新的,也有删除的,需要涉及到很多系统表,如果一个表一个表进行更新或者删除太慢了,于是就想通过创建动态内表来实现这些功能,在网上找了一些资料,经过多次尝试,终于测试成功了.网上讲述 ...
- 你的ABAP程序给佛祖开过光么?来试试Jerry这个小技巧
最近Jerry在忙一个项目,技术栈换成了nodejs平台,语言换成了JavaScript,因为赶项目进度,一直没时间更新公众号.感谢大家的支持,关注人数还是慢慢地增长到了3000. 今天我们来聊聊一个 ...
- 在SAP云平台ABAP编程环境上编写第一段ABAP程序
距2017年秋季的SAP TechEd大会上一位大佬Björn Goerke,SAP's Chief Technology Officer宣布了SAP Cloud Platform即将支持ABAP至今 ...
- [渣译文] 使用 MVC 5 的 EF6 Code First 入门 系列:为ASP.NET MVC应用程序创建更复杂的数据模型
这是微软官方教程Getting Started with Entity Framework 6 Code First using MVC 5 系列的翻译,这里是第六篇:为ASP.NET MVC应用程序 ...
- Oracle 给已创建的表增加自增长列
对于已经创建的表,在特殊需求下,需要增加一个自增长列步骤: --1. 增加 自增长列 ); --2. 程序方式更新设置 IdNum 列 值 --3.查询最大 ) From Limsbusinessen ...
- [SAP ABAP开发技术总结]ABAP程序之间数据共享与传递
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- SAP 通过屏幕字段查看透明表
我要查看创建采购订单屏幕上抬头部分付款条件的这个透明表中的字段. 图1. 1.首先准备好MM模块中的常用透明表. 图2. 2.把光标放在字段上,按F1,再点击图中技术信息按钮. 图3. 3.在弹出的技 ...
随机推荐
- aspx页面导出为word
aspx页面导出为word代码: System.IO.StringWriter sw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWri ...
- 初识contiki(2.7版本)
一个偶然的机会,我接触到了contiki这个家伙. Contiki 是一个开源的.高度可移植的.采用 C 语言开发的非常小型的嵌入式操作系统,针对小内存微控制器设计,适用于联网嵌入式系统和无线传感器网 ...
- Powershell(1)
PowerShell cmdlets: Verb-Noun的命令形式, Verb一般是set, get, start, stop, invoke, 使用get-verb显示所有的动词 通过别名机制, ...
- MVC4笔记 @functions @model @using
/////@functions自定义函数////// @helper辅助方法的确可以很方便的完成辅助方法开发,不过却失去了一些弹性,例如,无法在@helper中自定义属性,只能单纯的传入参数,然后格式 ...
- Java Knowledge series 2
JVM Analysis & Design The object-oriented paradigm is a new and different way of thingking about ...
- linux系统unzip文件报错的解决方案
data.zip文件有4G多,解压的时候出问题了. Archive: data.zip End-of-central-directorysignature not found. Either th ...
- 悟空crm-0.5.4 (OpenLogic CentOS7.2)
平台: CentOS 类型: 虚拟机镜像 软件包: 5kcrm0.5.4 centos7.2 lamp stack 5.6.22 commercial crm lamp 服务优惠价: 按服务商许可协议 ...
- Centos 6/RHEL disable the IPv6 module.
http://minimallinux.blogspot.com/2013/07/centos-6rhel-disable-ipv6-module.html IPv6 was introduced t ...
- python3基础13(format的使用)
#!/usr/bin/env python# -*- coding:utf-8 -*- from string import Templatedict={'name':'python','age':2 ...
- CentOS 7.0 各版本下载说明 新增Everything版
CentOS-7.0-1406有很多可供选择的版本,对初学者来说,不知如何选择,下面做简单的介绍: CentOS-7.0-1406-x86_64-DVD.iso 标准安装版,一般下载这个就可以了 Ce ...