SAP Table RESB 两种方法的对比

22 篇文章 0 订阅

第一种写法,稍微快一下
1.
DATA: BEGIN OF gt_order OCCURS 0,
      aufnr LIKE afko-aufnr,
      rsnum LIKE afko-rsnum,
      matnr LIKE afpo-matnr,
      psmng LIKE afpo-psmng,
      meins LIKE afpo-meins,
      objnr LIKE aufk-objnr,
      werks LIKE aufk-werks,
      gltrp LIKE afko-gltrp, "basic finish date
      gstrp LIKE afko-gstrp, "basic start date
      lead_aufnr LIKE afko-lead_aufnr,
      lead_gltrp LIKE afko-gltrp,
      model LIKE afpo-matnr,
      projn LIKE afpo-projn,
      alprf1 LIKE zcustomer-alprf, "Production lot Priority
      alprf2 LIKE zcustomer-alprf, "Model Priority
      status TYPE c LENGTH 1,
      rate(3) TYPE p DECIMALS 2,
      END OF gt_order.
DATA: BEGIN OF wa_resb,
        rsnum LIKE resb-rsnum,
        rspos LIKE resb-rspos,
        aufst TYPE char2,
        aufwg TYPE char4,
        rsart LIKE resb-rsart,
        aufnr LIKE resb-aufnr,
        plnum LIKE resb-plnum,
        werks LIKE resb-werks,
        matnr LIKE resb-matnr,
        sobkz LIKE resb-sobkz,
        baugr LIKE resb-baugr,
        sobsl LIKE marc-sobsl, "Special procurement = 50
*        matkl LIKE mara-matkl,
*        prdha LIKE mara-prdha,
        meins LIKE resb-meins,
        bdmng LIKE resb-bdmng, "Requirement qty
        enmng LIKE resb-enmng, "Quantity Withdrawn
        almng TYPE menge_d,    "Allocated Quantity
        bdter LIKE resb-bdter, "Requirement Date for Component
        alpgr LIKE resb-alpgr, "AltItemGroup
        alprf LIKE resb-alprf, "Priority
        baust LIKE resb-baust, "Find the component for planned order
        bauwg LIKE resb-bauwg, "Find the component for planned order
        status,
        pspel LIKE resb-pspel,
        xloek LIKE resb-xloek,
        dumps LIKE resb-dumps,
*        labst LIKE mard-labst,
*        insme LIKE mard-insme,
*        lblab LIKE mslb-lblab,
*        bdart LIKE resb-bdart,
      END OF wa_resb.

DATA: it_resb LIKE SORTED TABLE OF wa_resb WITH UNIQUE KEY rsnum alpgr aufst aufwg rspos rsart
      WITH HEADER LINE,
      it_resb_s LIKE SORTED TABLE OF wa_resb WITH NON-UNIQUE KEY status matnr werks pspel
      WITH HEADER LINE,
      it_resb_tem LIKE SORTED TABLE OF wa_resb WITH UNIQUE KEY rsnum alpgr aufst aufwg rspos rsart
      WITH HEADER LINE.

 

SELECT a~aufnr a~rsnum a~gstrp a~gltrp a~lead_aufnr
          b~matnr b~psmng b~meins b~projn
          c~objnr c~werks
          INTO CORRESPONDING FIELDS OF TABLE gt_order
          FROM afko AS a
          JOIN afpo AS b ON a~aufnr = b~aufnr
          JOIN aufk AS c ON a~aufnr = c~aufnr
    WHERE a~gstrp >= '20130101'
     and a~gstrp <= '20130301'
     and c~werks EQ '8101'
            AND c~loekz EQ space
            AND b~xloek EQ space.

Check gt_order[] is not initial.

    SORT gt_order.
    SELECT rsnum rspos aufnr werks matnr bdmng meins bdter
           alpgr alprf baugr sobkz enmng pspel meins dumps
           rsart aufwg aufst xloek
      INTO CORRESPONDING FIELDS OF TABLE it_resb
      FROM resb
      FOR ALL ENTRIES IN gt_order
      WHERE rsnum = gt_order-rsnum.

 

 

2.
DATA: BEGIN OF gt_order OCCURS 0,
      aufnr LIKE afko-aufnr,
      rsnum LIKE afko-rsnum,
      matnr LIKE afpo-matnr,
      psmng LIKE afpo-psmng,
      meins LIKE afpo-meins,
      objnr LIKE aufk-objnr,
      werks LIKE aufk-werks,
      gltrp LIKE afko-gltrp, "basic finish date
      gstrp LIKE afko-gstrp, "basic start date
      lead_aufnr LIKE afko-lead_aufnr,
      lead_gltrp LIKE afko-gltrp,
      model LIKE afpo-matnr,
      projn LIKE afpo-projn,
      alprf1 LIKE zcustomer-alprf, "Production lot Priority
      alprf2 LIKE zcustomer-alprf, "Model Priority
      status TYPE c LENGTH 1,
      rate(3) TYPE p DECIMALS 2,
      END OF gt_order.
DATA: BEGIN OF wa_resb,
        rsnum LIKE resb-rsnum,
        rspos LIKE resb-rspos,
        aufst TYPE char2,
        aufwg TYPE char4,
        rsart LIKE resb-rsart,
        aufnr LIKE resb-aufnr,
        plnum LIKE resb-plnum,
        werks LIKE resb-werks,
        matnr LIKE resb-matnr,
        sobkz LIKE resb-sobkz,
        baugr LIKE resb-baugr,
        sobsl LIKE marc-sobsl, "Special procurement = 50
*        matkl LIKE mara-matkl,
*        prdha LIKE mara-prdha,
        meins LIKE resb-meins,
        bdmng LIKE resb-bdmng, "Requirement qty
        enmng LIKE resb-enmng, "Quantity Withdrawn
        almng TYPE menge_d,    "Allocated Quantity
        bdter LIKE resb-bdter, "Requirement Date for Component
        alpgr LIKE resb-alpgr, "AltItemGroup
        alprf LIKE resb-alprf, "Priority
        baust LIKE resb-baust, "Find the component for planned order
        bauwg LIKE resb-bauwg, "Find the component for planned order
        status,
        pspel LIKE resb-pspel,
        xloek LIKE resb-xloek,
        dumps LIKE resb-dumps,
*        labst LIKE mard-labst,
*        insme LIKE mard-insme,
*        lblab LIKE mslb-lblab,
*        bdart LIKE resb-bdart,
      END OF wa_resb.

DATA: it_resb LIKE TABLE OF wa_resb  WITH HEADER LINE.
DATA: it_resb_tem LIKE TABLE OF wa_resb  WITH HEADER LINE.

 

SELECT a~aufnr a~rsnum a~gstrp a~gltrp a~lead_aufnr
          b~matnr b~psmng b~meins b~projn
          c~objnr c~werks
          INTO CORRESPONDING FIELDS OF TABLE gt_order
          FROM afko AS a
          JOIN afpo AS b ON a~aufnr = b~aufnr
          JOIN aufk AS c ON a~aufnr = c~aufnr
    WHERE a~gstrp >= '20130101'
     and a~gstrp <= '20130301'
     and c~werks EQ '8101'
            AND c~loekz EQ space
            AND b~xloek EQ space.

 
Check gt_order[] is not initial.
  SORT gt_order.
  LOOP AT gt_order.
    clear:it_resb_tem,it_resb_tem[].
    SELECT rsnum rspos aufnr werks matnr bdmng meins bdter
           alpgr alprf baugr sobkz enmng pspel meins dumps
           rsart aufwg aufst xloek
      INTO CORRESPONDING FIELDS OF TABLE it_resb_tem
      FROM resb
      WHERE rsnum = gt_order-rsnum.
    IF it_resb_tem[] IS INITIAL.
      CONTINUE.
    ENDIF.

    INSERT LINES OF it_resb_tem INTO TABLE it_resb.
endloop.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值