sd 买送服务,自动带出销售订单行项目

 需要先配置自动带出一行行项目,然后增强代码里去修改带出来的数量,注意事务码的判断,不然影响程序效率

 

 

 

  

 

 

 

FV45PF0N_NATRAB_SELECTION

  IF SY-TCODE = 'VA03'.
  ELSE.
*  natrab_new = abap_true.
*    LOOP AT yvbap ASSIGNING FIELD-SYMBOL(<LS_YVBAP>).
*      IF <LS_YVBAP>-pstyv <> 'ZTNN'.
*        natrab_new = abap_true.
*       ENDIF.
*    ENDLOOP.
    IF VBAP-MVGR1 <> *VBAP-mvgr1
      OR VBAP-mvgr2 <> *VBAP-mvgr2
      OR VBAP-mvgr3 <> *VBAP-mvgr3
      OR VBAP-mvgr4 <> *VBAP-mvgr4 .
      natrab_new = abap_true.
    ENDIF.
  ENDIF.

 

*
  "//试样件处理逻辑
*  BREAK MMQM_XIEHL.

  DATA LRNG_POSNR TYPE RANGE OF POSNR.
  CLEAR LRNG_POSNR.
  DATA:lv_KWMENG TYPE menge_d.
  DATA(lv_zcl_hb) = NEW zcl_hb( ).
  data ls_vbap type VBAP.
  DATA rs_qty TYPE zsds_tpr01.

  LOOP AT KONDN_MAT_TAB ASSIGNING FIELD-SYMBOL(<LS_MAT_TAB>) .
 READ TABLE xvbap ASSIGNING FIELD-SYMBOL(<LS_VBAP>) .
    IF SY-SUBRC = 0.
      clear lv_KWMENG.
      lv_KWMENG = <LS_VBAP>-kwmeng.
      clear ls_vbap.
      clear rs_qty.
      MOVE-CORRESPONDING <LS_VBAP> to ls_vbap.
       CALL METHOD lv_zcl_hb->get_qty
         EXPORTING
           iv_tp_cat = <LS_VBAP>-mvgr1
           iv_posnr  = <LS_VBAP>-posnr
           iv_matnr  = <LS_VBAP>-matnr
           iv_menge  = lv_KWMENG
*          iv_mvgr1  = <ls_so_dsf>-mvgr1
           iv_mvgr2  = <LS_VBAP>-mvgr2
           iv_mvgr3  = <LS_VBAP>-mvgr3
           is_vbap   = ls_vbap
         RECEIVING
           rs_qty    = rs_qty.
      if rs_qty-menge_customer is not INITIAL.
        "//如何识别是用户更改的,保留下来? 默认免费数量会计算出来
        <LS_MAT_TAB>-NRMENGE = rs_qty-menge_customer.
*        natrab_new = abap_true.
      ELSE.
        LRNG_POSNR = value #( base LRNG_POSNR ( sign = 'I' option = 'EQ' low = <LS_MAT_TAB>-KPOSN ) ).
      ENDIF.
    ENDIF.
  ENDLOOP.

  if LRNG_POSNR is NOT INITIAL.
    delete kondn_mat_tab[] where KPOSN in LRNG_POSNR.
  endif.


ENDENHANCEMENT.
*$*$-End:   (2)---------------------------------------------------------------------------------$*$*

 

posted @ 2022-03-08 19:13  蜡哲图  阅读(55)  评论(0编辑  收藏  举报
目录内容