文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>ABAP 动态 SQL

ABAP 动态 SQL

时间:2011-04-30  来源:Edison-技术

关于Abap 动态字段及指针处理方法,最近整理了一下简单的应用,以供参考:

应用一: Dynamic Field Apply 1
DATA: zpor_wa type z1td1106.
data: begin of itab OCCURS 0,
        zMODEL LIKE z1td1106-ZMODEL,
        ZQTY LIKE z1td1106-QTY01,
      END OF ITAB.

field-SYMBOLS: <wa> type any,
               <wa2> TYPE any.
ASSIGN zpor_wa to <wa>.
select single *
  from z1td1106 into zpor_wa.
while sy-subrc = 0.
  ASSIGN COMPONENT sy-index of STRUCTURE <wa> to <wa2>.
  if sy-index = 5.
    itab-Zmodel = <wa2>.
  endif.
  IF sy-index > 9 and sy-index < 25.
    itab-ZQTY = <wa2>.
  ENDIF.
  APPEND itab.
ENDWHILE.
LOOP AT itab.
  write:/ itab-Zmodel ,':',itab-ZQTY.
ENDLOOP.


* 应用二:Dynamic Field Apply 2
DATA :
  T_A(15) TYPE C VALUE 'ITAB100-',
  T_B(15) TYPE C,
BEGIN OF ITAB100 OCCURS 0,
  A(15) TYPE C,
  B TYPE I,
END OF ITAB100,

BEGIN OF ITAB200 OCCURS 0,
  A1(15) TYPE C,
  A2(15) TYPE C,
  A3(15) TYPE C,
END OF ITAB200.

FIELD-SYMBOLS: <A>.

ITAB100-A = 'A'.
ITAB100-B = 100.
APPEND ITAB100.
ITAB100-A = 'B'.
ITAB100-B = 200.
APPEND ITAB100.
ITAB100-A = 'C'.
ITAB100-B = 300.
APPEND ITAB100.

CLEAR:ITAB200[].
LOOP AT ITAB100.
  CONCATENATE T_A ITAB100-A INTO T_B.
  ASSIGN (T_B) TO <A>.
  ITAB200-A1 = <A>.
  APPEND ITAB200.
ENDLOOP.

LOOP AT ITAB200.
  Write:/ ITAB200-A1,',',ITAB200-A2,',',ITAB200-A3.
ENDLOOP.


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载