技术干货SAP收藏文章

结构、内表、工作区

2017-06-20  本文已影响28人  Mmm_余安
TYPES :BEGIN OF tys_t001,
           bukrs TYPE t001-bukrs,
           butxt TYPE t001-butxt,
         END OF tys_t001.
DATA :BEGIN OF ty_t001,
          bukrs TYPE t001-bukrs,
          butxt TYPE t001-butxt,
        END OF ty_t001.

根据结构创建用TYPE,根据工作区创建用LIKE

SELECT SINGLE
   t001~bukrs
   t001~butxt
   INTO CORRESPONDING FIELDS OF ty_t001
   FROM t001
   WHERE bukrs = p_bukrs.

工作区只能存储一条值,用SINGLE取出一条值

APPEND LINES OF gt_t001  TO gt_t002.

GT_T001,GT_T002为两个结构相同的内表

Select到内表的值需要通过Loop循环传递值。

  LOOP AT GT_ANEP INTO GS_ANEP.
    GS_ANEP-GJAHR = ''.
    GS_ANEP-LNRAN = ''.
    GS_ANEP-BUKRS = ''.
    COLLECT GS_ANEP INTO GT_ANEP3.
  ENDLOOP.

COLLECT 将除金额字段其他字段一致的汇总

上一篇下一篇

猜你喜欢

热点阅读