sap-abap-交貨出口-交貨單儲存前設定所有行項發貨倉位且過賬前檢查是否倉位一致
阿新 • • 發佈:2018-12-29
開發要求:製作交貨單的人員,需要同一張單的交貨倉位保持一致,設計成在儲存前將所有行都改為和第一行項的倉位一致。
在發貨過時會檢查如發現不一致,不於過賬。
使用者出口如下:
修改 Userexit_save_document_prepare 例程
程式碼如下:
*---------------------------------------------------------------------* * 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