ABAP中,字段名存放在一个变量里,如何取内表的这个字段值?
如:data:name(5)typec.datalt_p0000liketableofp0000.name='pernr'.根据name的值作为需要取值的字段,此处即如何...
如: data: name(5) type c.
data lt_p0000 like table of p0000.
name = 'pernr'.
根据name的值作为需要取值的字段,此处即如何取lt_p0000-pernr 的值。 展开
data lt_p0000 like table of p0000.
name = 'pernr'.
根据name的值作为需要取值的字段,此处即如何取lt_p0000-pernr 的值。 展开
1个回答
展开全部
DATA name(5) TYPE c.
DATA it_p0000 LIKE TABLE OF p0000.
DATA wa_p0000 TYPE p0000.
name = 'PERNR'.
以上是你的代码
FIELD-SYMBOLS <fs_field> TYPE p0000-pernr.
取数我就不写了
LOOP AT it_p0000 INTO wa_p0000.
ASSIGN COMPONENT name OF STRUCTURE wa_p0000 TO <fs_field>.
WRITE: / <fs_field>.
ENDLOOP.
<fs_field> 就是你要的
PS: name = 'PERNR' 注意要大写
DATA it_p0000 LIKE TABLE OF p0000.
DATA wa_p0000 TYPE p0000.
name = 'PERNR'.
以上是你的代码
FIELD-SYMBOLS <fs_field> TYPE p0000-pernr.
取数我就不写了
LOOP AT it_p0000 INTO wa_p0000.
ASSIGN COMPONENT name OF STRUCTURE wa_p0000 TO <fs_field>.
WRITE: / <fs_field>.
ENDLOOP.
<fs_field> 就是你要的
PS: name = 'PERNR' 注意要大写
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询