- 註冊時間
- 2007-9-3
- 精華
- 在線時間
- 小時
- 米币
-
- 最後登錄
- 1970-1-1
累計簽到:1488 天 連續簽到:10 天
|
這個是個SAP的回傳WM盤點結果接口,大家可以看一下,給你們學習SAP做個借鑒
8 C$ u2 C) `9 F( [" `1 YCode listing for function: ZWM_RF_INPUT_PHYINVENTORY011
6 z) m% Z; H+ g8 ?. h* Q6 u% M: }! ?" N" h& u+ z
Description: 回傳WM盤點結果接口9 d) _( m3 D @! c0 b+ H: }
function zwm_rf_input_phyinventory011.*"----------------------------------------------------------------------*"*"Local interface:*" EXPORTING*" VALUE(RETURNVALUE) TYPE ZRETURNVALUE*" TABLES*" HEADER STRUCTURE ZWM_RF_INPUT_PHYINVENTORY_H011 OPTIONAL*" ITEM STRUCTURE ZWM_RF_INPUT_PHYINVENTORY_L011 OPTIONAL*" RETURN STRUCTURE ZBAPIRET2 OPTIONAL*"----------------------------------------------------------------------* Global data declarations types: begin of gty_link, lgnum like linv-lgnum, ivnum like linv-ivnum, ivpos like linv-ivpos, "庫存文件項目號 lgtyp like linv-lgtyp, "倉儲類型 lgpla like linv-lgpla, "倉位 plpos like linv-plpos, "倉位位置 matnr like linv-matnr, "物料號 werks like linv-werks, "工廠 lgort like linv-lgort, "庫存地點 charg like linv-charg, "批號 sobkz like linv-sobkz, "特殊庫存標識 sonum like linv-sonum, "特殊庫存編號* bestq like linv-bestq, "倉庫管理係統中的庫存類別 wdatu like linv-wdatu, "收貨日期 letyp like linv-letyp, "倉儲單位類型 lenum like linv-lenum, "倉儲單位編號 menga like linv-menga, "按可選計量單位的盤點數量 altme like linv-altme, "帳面庫存單位的可選計量單位 quinv like linv-quinv, "庫存數量標識 lqnum like linv-lqnum, nanum like linv-nanum, bestq like linv-bestq, end of gty_link. data: gt_link type standard table of gty_link with header line. "存儲查詢的數據內表 data: it_linv type standard table of e1linvx with header line. data: gt_linv like table of linv with header line. data: wbs_24 type ps_posid. data: flag type c. "程序內部標識 DATA: su_integer TYPE f. clear: flag,gt_link,gt_link[],return[]. "清空 read table header with key whsenumber = ''. if sy-subrc = 0. returnvalue = 1. "未輸入輸出參數置為1有未輸入的必輸項 return-type = 'E'. "消息類型 return-number = '049'. "消息編號 return-message = '表頭的倉庫號/混合倉庫必輸,請檢查輸入!'. "消息文本 append return. "添加進消息內表 clear return. flag = 'X'. "程序內部標識置為X有錯誤 endif. read table header with key physinventory = ''. if sy-subrc = 0. returnvalue = 1. "未輸入輸出參數置為1有未輸入的必輸項 return-type = 'E'. "消息類型 return-number = '049'. "消息編號 return-message = '表頭的係統盤點記錄號必輸,請檢查輸入!'. "消息文本 append return. "添加進消息內表 clear return. flag = 'X'. "程序內部標識置為X有錯誤 endif. read table item with key whsenumber = ''. if sy-subrc = 0. returnvalue = 1. "未輸入輸出參數置為1有未輸入的必輸項 return-type = 'E'. "消息類型 return-number = '050'. "消息編號 return-message = '行項目的倉庫號/混合倉庫必輸,請檢查輸入!'. "消息文本 append return. "添加進消息內表 clear return. flag = 'X'. "程序內部標識置為X有錯誤 endif. read table item with key physinventory = ''. if sy-subrc = 0. returnvalue = 1. "未輸入輸出參數置為1有未輸入的必輸項 return-type = 'E'. "消息類型 return-number = '051'. "消息編號 return-message = '行項目中的係統盤點記錄號必輸,請檢查輸入!'. "消息文本 append return. "添加進消息內表 clear return. flag = 'X'. "程序內部標識置為X有錯誤 endif. loop at item. call function 'CONVERSION_EXIT_ALPHA_INPUT' exporting input = item-material importing output = item-material. if item-su_number is not initial. catch system-exceptions conversion_errors = 1. su_integer = item-su_number. endcatch. if sy-subrc = 1. return-type = 'E'. "消息類型 return-number = '66'. "消息號 return-message = '倉儲單位編號含有非法字符,請檢查!'. "消息文本 append return. clear return. flag = 'X'. endif. endif. modify item transporting material." PHYSINVENTORY. endloop. if flag ne 'X'. loop at item. select lgnum ivnum "憑證號 ivpos "行項目號 lqnum "份號 nanum "重新盤點點 lgtyp "倉儲類型 lgpla "倉位 plpos "倉位位置 matnr "物料號 werks "工廠 lgort "庫存地點 charg "批號 sobkz "特殊庫存標識 sonum "特殊庫存編號 bestq "庫存類別 wdatu "收貨日期 letyp "倉儲單位類型 lenum "倉儲單位編號 menga "按可選計量單位的盤點數量 altme "帳面庫存單位的可選計量單位 quinv "庫存數量標識 into corresponding fields of gt_link from linv* for all entries in item where lgnum = item-whsenumber and ivnum = item-physinventory and ivpos = item-item and lqnum = item-quant and nanum = item-reventory. if sy-subrc = 0. append gt_link. endif. endselect. endloop. if gt_link[] is initial. returnvalue = 1. "輸出參數置為0成功 return-type = 'E'. "消息類型 return-number = '052'. "消息編號 return-message = '係統未能找到符合輸入的單據,請檢查倉庫號、單據號、行項目、份號、重新盤點號!'. "消息文本 append return. flag = 'X'. endif.*********將輸入參數傳遞給總表*************************** loop at item. it_linv-lgnum = item-whsenumber. it_linv-ivnum = item-physinventory. it_linv-ivpos = item-item. it_linv-lgtyp = item-storagetype. it_linv-lgpla = item-storagebin. it_linv-matnr = item-material. it_linv-werks = item-plant. it_linv-charg = item-batch. it_linv-sobkz = item-spec_stock. it_linv-lsonr = item-spec_stocknum. it_linv-lenum = item-su_number. it_linv-menga = item-quantity. it_linv-kznul = item-zero_count. it_linv-altme = item-unit. it_linv-maktx = item-materialtext. it_linv-letyp = item-su_type. it_linv-lgort = item-stge_loc. it_linv-lqnum = item-quant. it_linv-nanum = item-reventory. it_linv-bestq = item-stockcat. read table gt_link with key lgnum = item-whsenumber ivnum = item-physinventory ivpos = item-item lqnum = item-quant nanum = item-reventory. if sy-subrc = 0. if it_linv-lgtyp is initial. it_linv-lgtyp = gt_link-lgtyp. "源倉儲類型 endif. if it_linv-lgpla is initial. it_linv-lgpla = gt_link-lgpla. "源倉位 endif.* if it_linv-matnr is initial.* it_linv-matnr = gt_link-matnr.* endif. if it_linv-werks is initial. it_linv-werks = gt_link-werks. "工廠 endif. if it_linv-charg is initial. it_linv-charg = gt_link-charg. "批次 endif. if it_linv-sobkz is initial. it_linv-sobkz = gt_link-sobkz. "特殊庫存標識 endif. if it_linv-lsonr is initial. select single posid into wbs_24 from prps where pspnr = gt_link-sonum. if sy-subrc = 0. it_linv-lsonr = wbs_24. "特殊庫存編號 clear wbs_24. endif. endif. if it_linv-lenum is initial. it_linv-lenum = gt_link-lenum. "托盤號 endif. if it_linv-altme is initial. it_linv-altme = gt_link-altme. "單位 endif. if it_linv-letyp is initial. it_linv-letyp = gt_link-letyp. "托盤類型 endif. if it_linv-lgort is initial. it_linv-lgort = gt_link-lgort. "庫存地點 endif. it_linv-wdatu = gt_link-wdatu. "收貨日期 endif. read table header with key whsenumber = item-whsenumber physinventory = item-physinventory. if sy-subrc = 0. if header-acctualdate ne '1990-01-01'. it_linv-idatu = header-acctualdate . endif. endif. append it_linv. endloop.* loop at it_linv.* loop at header where whsenumber = it_linv-lgnum and physinventory = it_linv-ivnum.* if header-acctualdate = '1990-01-01'.* clear header-acctualdate.* endif.* it_linv-idatu = header-acctualdate .* modify it_linv.* clear it_linv.* endloop.* endloop.* if it_linv[] is not initial. "查詢的盤點數據不為空***********循環輸入的數據並和查詢的整合處理作為BAPI的輸入參數*************** loop at it_linv.* read table gt_link with key lgnum = it_linv-lgnum* ivnum = it_linv-ivnum* ivpos = it_linv-ivpos* lqnum = it_linv-lqnum* nanum = it_linv-nanum.* if sy-subrc = 0. "讀取到數據* it_linv-wdatu = gt_link-wdatu. "收貨日期* it_linv-altme = gt_link-altme. "帳面庫存單位的可選計量單位* modify it_linv transporting wdatu altme. "更新輸入數據* endif.* endloop.* endif. if it_linv[] is not initial and flag ne 'X'. "輸入不為空 call function 'L_INV_COUNT_EXT' "調用BAPIL錄入盤點結果 tables s_linv = it_linv[] exceptions either_quantity_or_empty_bin = 1 ivnum_not_found = 2 check_problem = 3 no_count_allowed = 4 l_inv_read = 5 bin_not_in_ivnum = 6 counts_not_updated = 7 lock_error = 8 error_message = 10 others = 9. if sy-subrc <> 0. " call function 'BAPI_MESSAGE_GETDETAIL' exporting id = sy-msgid number = sy-msgno language = '1' textformat = 'TXT' importing message = return-message. returnvalue = 1. "輸出參數置為0成功 return-type = 'E'. "消息類型 return-number = sy-msgno. "消息編號 append return. clear return. clear sy-msgid. clear sy-msgno. endif. endif. endif. read table return with key type = 'E'. if sy-subrc = 0. rollback work. returnvalue = 1. "輸出參數置為0成功 return-type = 'E'. "消息類型 return-number = '110'. "消息編號 return-message = '接口執行失敗!'. "消息文本 append return. clear return. else. commit work and wait. returnvalue = 0. "輸出參數置為0成功 return-type = 'S'. "消息類型 return-number = '000'. "消息編號 return-message = '接口執行成功!'. "消息文本 append return. clear return. endif.endfunction. Extracted by Direct Download Enterprise version 1.3.1 - E.G.Mellodew. 1998-2005 UK. Sap Release 702 " B+ ~$ i" W B0 `7 |+ Q1 E
|
|