首页 > 代码库 > 冲销收货
冲销收货
FUNCTION zrfc_mm004. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" VALUE(CALLNO) TYPE ZCALLNO *" VALUE(MAT_DOC) TYPE BAPI2017_GM_HEAD_02-MAT_DOC *" VALUE(DOC_YEAR) TYPE BAPI2017_GM_HEAD_02-DOC_YEAR *" VALUE(PSTNG_DATE) TYPE BAPI2017_GM_HEAD_02-PSTNG_DATE DEFAULT *" SY-DATUM *" VALUE(PR_UNAME) TYPE BAPI2017_GM_HEAD_01-PR_UNAME OPTIONAL *" EXPORTING *" VALUE(MBLNR) LIKE BAPI2017_GM_HEAD_RET-MAT_DOC *" VALUE(MJAHR) LIKE BAPI2017_GM_HEAD_RET-DOC_YEAR *" VALUE(FLAG) LIKE BAPIRET2-TYPE *" VALUE(MESSAGE) LIKE BAPIRET2-MESSAGE *"---------------------------------------------------------------------- DATA:ls_goodsmvt_headret LIKE bapi2017_gm_head_ret, lv_message LIKE bapiret2-message. DATA lv_datano TYPE zdatano. CLEAR:gt_return,gs_return,mblnr,mjahr,flag,ls_goodsmvt_headret,message. CALL FUNCTION ‘BAPI_GOODSMVT_CANCEL‘ EXPORTING materialdocument = mat_doc matdocumentyear = doc_year goodsmvt_pstng_date = pstng_date goodsmvt_pr_uname = pr_uname IMPORTING goodsmvt_headret = ls_goodsmvt_headret TABLES return = gt_return. READ TABLE gt_return INTO gs_return WITH KEY type = ‘E‘. IF sy-subrc NE 0. flag = ‘S‘. CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT‘ EXPORTING wait = ‘X‘. mblnr = ls_goodsmvt_headret-mat_doc. "物料凭证 mjahr = ls_goodsmvt_headret-doc_year. "年度 CONCATENATE ‘生成凭证号:‘ mblnr ‘年度:‘ mjahr INTO message. ELSE. CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK‘. LOOP AT gt_return INTO gs_return WHERE type CA ‘AEX‘. MESSAGE ID gs_return-id TYPE gs_return-type NUMBER gs_return-number WITH gs_return-message_v1 gs_return-message_v2 gs_return-message_v3 gs_return-message_v4 INTO lv_message. CONCATENATE message lv_message INTO message SEPARATED BY ‘|‘. ENDLOOP. SHIFT message LEFT DELETING LEADING ‘|‘. flag = ‘E‘. ENDIF. *记录日志 CLEAR:gt_log,gs_log. gs_log-name = ‘ZRFC_MM004‘. gs_log-cdate = sy-datum. lv_datano = lv_datano + 1. gs_log-datano = lv_datano. GET TIME. gs_log-ctime = sy-uzeit. gs_log-callno = callno. gs_log-flag = flag. gs_log-log = message. CONCATENATE mat_doc doc_year pstng_date pr_uname mblnr mjahr INTO gs_log-content SEPARATED BY ‘|‘. CONDENSE gs_log-content NO-GAPS. gs_log-length = STRLEN( gs_log-content ). APPEND gs_log TO gt_log. IF gt_log IS NOT INITIAL. INSERT zrfc_mm01in_log FROM TABLE gt_log. IF sy-subrc = 0. COMMIT WORK. ENDIF. ENDIF. ENDFUNCTION.
冲销收货
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。