欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SAP SELECT内表查询

程序员文章站 2022-05-18 14:15:46
...

SAP Select内表查询,对内表进行Select

注意事项

  1. 内表前面必须加@

  2. 内表必须为不带Header Line的内表

  3. 740版本以上

    若内表带Header Line则报错:Tables with headers are not allowed.

    感谢lev提供解决思路

    SAP SELECT内表查询

代码示例:

TYPES: BEGIN OF ty_lips,
         matnr TYPE lips-matnr,
         posnr TYPE lips-posnr,
         werks TYPE lips-werks,
         lgort TYPE lips-lgort,
         vbeln TYPE lips-vbeln,
         bwart TYPE lips-bwart,
         lfimg TYPE lips-lfimg,
         vrkme TYPE lips-vrkme,
         kzbew TYPE lips-kzbew,
         vgbel TYPE lips-vgbel,
         vgpos TYPE lips-vgpos,
         xchar TYPE marc-xchar,
         charg TYPE lips-charg,
       END OF ty_lips.

DATA: gt_lips1 TYPE TABLE OF ty_lips,
      gt_lips2 TYPE TABLE OF ty_lips,
      wa_lips TYPE ty_lips.

        SELECT
          A~MATNR,
          A~POSNR,
          A~WERKS,
          A~LGORT,
          A~VBELN,
          A~BWART,
          A~LFIMG,
          A~VRKME,
          A~KZBEW,
          A~VGBEL,
          A~VGPOS,
          B~XCHAR
          FROM LIPS AS A
          INNER JOIN MARC AS B
          ON A~MATNR = B~MATNR
          AND A~WERKS = B~WERKS
          WHERE VBELN = @GS_VBELN-VBELN
          INTO CORRESPONDING FIELDS OF TABLE @GT_LIPS1.

          SELECT SUM( lfimg )
            FROM @GT_LIPS1 AS A
            INTO @GV_LFIMG1.