SD 交货出口

47 篇文章 0 订阅
 在工厂的实际运用中会用到交货单保存前设定所有行项发货仓位且过账前检查是否仓位一致。

   开发要求:制作交货单的人员,需要同一张单的交货仓位保持一致,设计成在保存前将所有行都改为和第一行项的仓位一致。

    在发货过时会检查如发现不一致,不于过账。

  这个项目应该用到出口才可以解决!查找用户出口。用户出口如下

修改 Userexit_save_document_prepare 例程:


代码如下:
  1. *---------------------------------------------------------------------*    
  2. *       FORM USEREXIT_SAVE_DOCUMENT_PREPARE                           *    
  3. *---------------------------------------------------------------------*    
  4. *       This userexit can be used for changes or checks, before a     *    
  5. *       document is saved.                                            *    
  6. *                                                                     *    
  7. *       If field T180-TRTYP contents 'H', the document will be        *    
  8. *       created, else it will be changed.                             *    
  9. *                                                                     *    
  10. *       This form is called at the beginning of form BELEG_SICHERN    *    
  11. *                                                                     *    
  12. *---------------------------------------------------------------------*    
  13. FORM userexit_save_document_prepare.    
  14.     
  15.   IF sy-uname = 'HS014'.    
  16.     BREAK-POINT.    
  17.   ENDIF.    
  18.     
  19.   "只处理对客户发货,公司间交易不处理.    
  20.   IF ( tcode = 'VL02N' OR tcode = 'VL02' OR tcode = 'VL01N' OR tcode = 'VL01' ) and ( xlikp-VKORG = '1010' or  xlikp-VKORG = '1020' ).    
  21.     
  22.               "DATA: XLIPS_C LIKE LIPSVB OCCURS 0 WITH HEADER LINE.    
  23.               "DATA: I_LIPS LIKE LIPSVB OCCURS 0 WITH HEADER LINE.    
  24.               data: c_lgort like xlips-lgort , i_idx type i,i_Cnt type i, msg type string.    
  25.     
  26.               IF sy-ucomm = 'WABU_T'. "过账 需要检查 如果有不同仓位,则报错.    
  27.                c_lgort = ''.    
  28.                i_idx = 0.    
  29.                loop at xlips  .    
  30.                 if i_idx = 0 . "取得第一行的库位    
  31.                    i_idx = i_idx + 1.    
  32.                    c_lgort = c_lgort = xlips-lgort.    
  33.                 endif.    
  34.                 if c_lgort <> xlips-lgort.    
  35.                    message '交货单内存在不同的交货仓位,请通知销售助理修改正确后再过账.' type 'E'.    
  36.                 endif.    
  37.                 clear xlips.    
  38.                endloop.    
  39.               endif.    
  40.     
  41.               IF sy-ucomm = 'SICH_T' or sy-ucomm = 'YES' .  "如果是保存(或退出提示保存) ,则统一更新仓位.    
  42.                c_lgort = ''.    
  43.                i_idx = 0.    
  44.                i_Cnt = 0.    
  45.                loop at xlips  .    
  46.                   if i_idx = 0 . "取得第一行的仓位    
  47.                      i_idx = i_idx + 1.    
  48.                      c_lgort = c_lgort = xlips-lgort.    
  49.                      if c_lgort = ''.    
  50.                          message '在保存交货单前请填写第一行项的交货仓位' type 'E'.    
  51.                      else.    
  52.                          concatenate  '你在第一行项输入的仓是' c_lgort ',增强系统将按此仓位更新所有行项' into msg.    
  53.                          message msg type 'I'.    
  54.                      endif.    
  55.                   endif.    
  56.     
  57.                   if c_lgort <> xlips-lgort.    
  58.                       "更新仓位    
  59.                       xlips-lgort = c_lgort.    
  60.     
  61.                       "更新标识 U 表示该纪录被修改,需要更新,D表示删除,I表示新增    
  62.                       if  xlips-updkz = ' '.    
  63.                         xlips-updkz = 'U'.    
  64.                       endif.    
  65.                       modify xlips.    
  66.                       i_Cnt = i_Cnt + 1.    
  67.     
  68.                   endif.    
  69.                   clear xlips.    
  70.                endloop.    
  71.                if i_Cnt > 1.    
  72.                     msg = i_Cnt .    
  73.                     concatenate  '更新了' msg '个行项的仓位' into msg.    
  74.                     message msg type 'I'.    
  75.                endif.    
  76.               endif.    
  77.    ENDIF.    
  78. ENDFORM.                    "USEREXIT_SAVE_DOCUMENT_PREPARE    
  79. *eject   
*---------------------------------------------------------------------*  
*       FORM USEREXIT_SAVE_DOCUMENT_PREPARE                           *  
*---------------------------------------------------------------------*  
*       This userexit can be used for changes or checks, before a     *  
*       document is saved.                                            *  
*                                                                     *  
*       If field T180-TRTYP contents 'H', the document will be        *  
*       created, else it will be changed.                             *  
*                                                                     *  
*       This form is called at the beginning of form BELEG_SICHERN    *  
*                                                                     *  
*---------------------------------------------------------------------*  
FORM userexit_save_document_prepare.  
  
  IF sy-uname = 'HS014'.  
    BREAK-POINT.  
  ENDIF.  
  
  "只处理对客户发货,公司间交易不处理.  
  IF ( tcode = 'VL02N' OR tcode = 'VL02' OR tcode = 'VL01N' OR tcode = 'VL01' ) and ( xlikp-VKORG = '1010' or  xlikp-VKORG = '1020' ).  
  
              "DATA: XLIPS_C LIKE LIPSVB OCCURS 0 WITH HEADER LINE.  
              "DATA: I_LIPS LIKE LIPSVB OCCURS 0 WITH HEADER LINE.  
              data: c_lgort like xlips-lgort , i_idx type i,i_Cnt type i, msg type string.  
  
              IF sy-ucomm = 'WABU_T'. "过账 需要检查 如果有不同仓位,则报错.  
               c_lgort = ''.  
               i_idx = 0.  
               loop at xlips  .  
                if i_idx = 0 . "取得第一行的库位  
                   i_idx = i_idx + 1.  
                   c_lgort = c_lgort = xlips-lgort.  
                endif.  
                if c_lgort <> xlips-lgort.  
                   message '交货单内存在不同的交货仓位,请通知销售助理修改正确后再过账.' type 'E'.  
                endif.  
                clear xlips.  
               endloop.  
              endif.  
  
              IF sy-ucomm = 'SICH_T' or sy-ucomm = 'YES' .  "如果是保存(或退出提示保存) ,则统一更新仓位.  
               c_lgort = ''.  
               i_idx = 0.  
               i_Cnt = 0.  
               loop at xlips  .  
                  if i_idx = 0 . "取得第一行的仓位  
                     i_idx = i_idx + 1.  
                     c_lgort = c_lgort = xlips-lgort.  
                     if c_lgort = ''.  
                         message '在保存交货单前请填写第一行项的交货仓位' type 'E'.  
                     else.  
                         concatenate  '你在第一行项输入的仓是' c_lgort ',增强系统将按此仓位更新所有行项' into msg.  
                         message msg type 'I'.  
                     endif.  
                  endif.  
  
                  if c_lgort <> xlips-lgort.  
                      "更新仓位  
                      xlips-lgort = c_lgort.  
  
                      "更新标识 U 表示该纪录被修改,需要更新,D表示删除,I表示新增  
                      if  xlips-updkz = ' '.  
                        xlips-updkz = 'U'.  
                      endif.  
                      modify xlips.  
                      i_Cnt = i_Cnt + 1.  
  
                  endif.  
                  clear xlips.  
               endloop.  
               if i_Cnt > 1.  
                    msg = i_Cnt .  
                    concatenate  '更新了' msg '个行项的仓位' into msg.  
                    message msg type 'I'.  
               endif.  
              endif.  
   ENDIF.  
ENDFORM.                    "USEREXIT_SAVE_DOCUMENT_PREPARE  
*eject 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值