冲销收货
Posted 学习笔记
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了冲销收货相关的知识,希望对你有一定的参考价值。
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.
以上是关于冲销收货的主要内容,如果未能解决你的问题,请参考以下文章