从 ABAP SAP 中的表或结构中获取字段


如果你需要确定结构中的字段和字段编号,那么你应该使用运行时类型服务。在这种情况下使用运行时类型服务更有意义,因为如果我们的环境中有一些数据,那么调用数据库来获取相同的字段是不理想的。

DATA(structure) = VALUE <your structure>( )
DATA(Descriptor) = CAST cl_abap_structdescr( cl_abap_datadescr=>describe_by_data
                   (structure) )
DATA(Fields = LINES(Descriptor ->components ) 

这将给你表或结构组件的计数。

如果你不想使用运行时类型服务,你还可以尝试另一个选项。下面的查询可以让你获得计数

SELECT COUNT(*) INTO @data(count)
FROM DD03l (// this table stores the fields information of SAP tables)
WHERE tabname = <Structure name>
                AND AS4LOCAL = 'A'

更新于:14-Feb-2020

3K+ 浏览量

开始您的 职业

通过完成课程获得认证

开始
广告
© . All rights reserved.