zoukankan      html  css  js  c++  java
  • ABAP

    1、当where条件中某一个参数有多个值时
    错误做法:

    View Code
        "包装材料
      SELECT SINGLE * FROM kotp001 WHERE kappl = 'PO'
                                    AND  kschl = 'SHIP'
                                    AND  matnr in p_matnr .
                                   " AND  datab <= p_erdat
                                    "AND  datbi >= p_erdat.

      IF sy-subrc = 0.
          CLEAR lt_packpo[].

          SELECT
               packpo~packnr
               packpo~paitemtype
               packpo~matnr
               packpo~trgqty
               packpo~unitqty

           packkp~POBJID
            INTO CORRESPONDING FIELDS OF TABLE lt_packpo FROM packpo
            INNER JOIN kondp ON packpo~packnr = kondp~packnr"包装对象 KBvbEBiG2X3X0800hAWA
             INNER JOIN packkp on packpo~packnr = packkp~packnr
            WHERE kondp~knumh = kotp001-knumh.  "条件记录号0000056149

    正确做法:

    View Code
       "包装材料
      SELECT  *
         into CORRESPONDING FIELDS OF table lt_kotp001
         FROM kotp001
         WHERE kappl = 'PO' AND  kschl = 'SHIP'
               AND  matnr in  p_matnr . " '000000101100001566'.  "

      IF sy-subrc = 0.
          CLEAR lt_packpo[].

          SELECT
               packpo~packnr
               packpo~paitemtype
               packpo~matnr
               packpo~trgqty
               packpo~unitqty
               packkp~POBJID
            FROM packpo
              INNER JOIN kondp ON packpo~packnr = kondp~packnr"包装对象 KBvbEBiG2X3X0800hAWA
              INNER JOIN packkp on packpo~packnr = packkp~packnr
            INTO CORRESPONDING FIELDS OF TABLE lt_packpo
            FOR ALL ENTRIES IN lt_kotp001  "用于where条件有多个值*******
            WHERE kondp~knumh = lt_kotp001-knumh.  "条件记录号0000056149

    2.将一个内表数据导入到另一个内表中,但有前提条件(lt_packpo导入到lt_pack

    View Code
          SELECT
               packkp~POBJID
               "packpo~packnr
               packpo~paitemtype
               packpo~matnr
               packpo~trgqty
               packpo~unitqty
            FROM packpo
              INNER JOIN kondp ON packpo~packnr = kondp~packnr"包装对象 KBvbEBiG2X3X0800hAWA
              INNER JOIN packkp on packpo~packnr = packkp~packnr
            INTO CORRESPONDING FIELDS OF TABLE lt_packpo
            FOR ALL ENTRIES IN lt_kotp001  "用于where条件有多个值*******
            WHERE kondp~knumh = lt_kotp001-knumh.  "条件记录号0000056149

          "将成品数据全部导入内表lt_pack (将纸盒与成品合并成一条语句)
           LOOP AT lt_packpo into wa_packpo WHERE  paitemtype = 'I'."成品
              IF sy-subrc = 0.
                  wa_pack-POBJID = wa_packpo-POBJID.
                  wa_pack-paitemtype = wa_packpo-paitemtype.
                  wa_pack-matnr = wa_packpo-matnr.
                  wa_pack-trgqty = wa_packpo-trgqty.
                  wa_pack-unitqty = wa_packpo-unitqty.
                  APPEND wa_pack TO lt_pack.
              ENDIF.
            ENDLOOP.
  • 相关阅读:
    步步为营-15-文件夹的操作
    步步为营-14-文件操作
    步步为营-13-日期转化
    步步为营-12-Dictionary-翻译
    步步为营-11-List<T>泛型的简单练习
    步步为营-10-string的简单操作
    步步为营-09-简单工厂类-计算器
    B. Fixed Points
    C. Cd and pwd commands
    Queries on a String
  • 原文地址:https://www.cnblogs.com/Snowfun/p/2822983.html
Copyright © 2011-2022 走看看