问题描述
我正在尝试通过 ERPConnect 的 ABAP API 查询 SAP 的数据字典.下面的代码可以很好地检索表名和各种字段属性,但无法显示字段描述.有谁知道为什么?
I'm trying to query SAP's data dictionary through ERPConnect's ABAP API. The code below retrieves the table names and various field properties fine but fails to show the field description. Anyone knows why?
谢谢
REPORT ZSELECTCOMMAND.
TABLES: DD02L,
DD03L,
DD02T, DD04T.
DATA: BEGIN OF tb_meta,
tabname TYPE DD02L-tabname,
fieldname TYPE DD03L-fieldname,
datatype TYPE DD03L-datatype,
leng TYPE DD03L-leng,
decimals TYPE DD03L-decimals,
position TYPE DD03L-position,
desc TYPE DD04T-ddtext,
END OF tb_meta.
DATA utb_meta LIKE STANDARD TABLE OF tb_meta.
DATA: ln_meta LIKE LINE OF utb_meta, m1 TYPE i, m2 TYPE i.
SELECT
tb~tabname
fld~fieldname
fld~datatype fld~leng
fld~decimals fld~position
x~ddtext
INTO CORRESPONDING FIELDS OF TABLE utb_meta
FROM
dd02L AS tb
INNER JOIN dd03L AS fld
ON tb~tabname = fld~tabname
INNER JOIN DD04T AS x
ON fld~ROLLNAME = x~ROLLNAME
AND x~DDLANGUAGE = 'EN'
WHERE
CONTFLAG IN ('A', 'C', 'S')
AND
APPLCLASS <> ''
AND
tb~TABNAME NOT LIKE '/%'
AND
tb~TABNAME NOT LIKE '%_BAK'
AND
tb~TABNAME = 'BSAK'.
*GET RUN TIME FIELD m1.
loop at utb_meta into ln_meta.
write:/
ln_meta-tabname
&& '>>' && ln_meta-fieldname
&& '>>' && ln_meta-datatype
&& '>>' && ln_meta-leng
&& '>>' && ln_meta-decimals
&& '>>' && ln_meta-position
&& '>>' && ln_meta-desc.
endloop.
推荐答案
表字段或结构字段的文本信息可以存储在不同的地方.您从 DD04T
中选择的数据元素文本只是这些文本的一处.您可以使用内置数据类型而不是字典数据类型定义表格组件,然后将文本存储在DD03T
(例如)
There are different places where text information of a table field or structure field can be stored. The data element texts that you are selecting from DD04T
are only one place for those texts. You can define table components with built-in data types instead of dictionary data types, then the texts will be stored in DD03T
(for example)
出于这些原因(DD*
表的技术细节),我强烈建议您使用功能模块DDIF_FIELDINFO_GET
而不是滚动您自己的DD*
选择.只需传递参数TABNAME
和LANGU
,生成的内表DFIES_TAB
将包含您需要的所有信息,包括文本.
For these reasons (technical details of the DD*
tables), I would strongly recommend you to use the function module DDIF_FIELDINFO_GET
instead of rolling your own DD*
select. Just pass the parameters TABNAME
and LANGU
, and the resulting internal table DFIES_TAB
will contain all the information you need, including texts.
这篇关于以编程方式获取表字段描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!