事务代码:KE21N
BAPI:BAPI_COPAACTUALS_POSTCOSTDATA
前台操作:
表是业务配置的
配置路径:
代码:BAPI不返回生成的凭证号和获利段,需要通过增强或者读表获取
ls_copa_data-record_id = '000001'.ls_copa_data-fieldname = 'BUDAT'.ls_copa_data-value = sy-datum.APPEND ls_copa_data TO lt_copa_data.ls_copa_field-fieldname = 'BUDAT'.APPEND ls_copa_field TO lt_copa_field.CLEAR:ls_copa_data.ls_copa_data-record_id = '000001'.ls_copa_data-fieldname = 'BUKRS'.ls_copa_data-value = lv_bukrs.APPEND ls_copa_data TO lt_copa_data.ls_copa_field-fieldname = 'BUKRS'.APPEND ls_copa_field TO lt_copa_field.CLEAR:ls_copa_data.ls_copa_data-record_id = '000001'.ls_copa_data-fieldname = 'VRGAR'.ls_copa_data-value = 'B'.APPEND ls_copa_data TO lt_copa_data.ls_copa_field-fieldname = 'VRGAR'.APPEND ls_copa_field TO lt_copa_field.CLEAR:ls_copa_data.ls_copa_data-record_id = '000001'.ls_copa_data-fieldname = 'WERKS'.ls_copa_data-value = is_header-plant.APPEND ls_copa_data TO lt_copa_data.ls_copa_field-fieldname = 'WERKS'.APPEND ls_copa_field TO lt_copa_field.CLEAR:ls_copa_data.ls_copa_data-record_id = '000001'.ls_copa_data-fieldname = 'ARTNR'.ls_copa_data-value = is_header-material.APPEND ls_copa_data TO lt_copa_data.ls_copa_field-fieldname = 'ARTNR'.APPEND ls_copa_field TO lt_copa_field.CLEAR:ls_copa_data.ls_copa_data-record_id = '000001'.ls_copa_data-fieldname = 'KNDNR'.CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'EXPORTINGinput = is_header-supp_idIMPORTINGoutput = is_header-supp_id.ls_copa_data-value = is_header-supp_id.APPEND ls_copa_data TO lt_copa_data.ls_copa_field-fieldname = 'KNDNR'.APPEND ls_copa_field TO lt_copa_field.CLEAR:ls_copa_data.CALL FUNCTION 'BAPI_COPAACTUALS_POSTCOSTDATA'EXPORTINGoperatingconcern = 'XXXX'testrun = ''TABLESinputdata = lt_copa_datafieldlist = lt_copa_fieldreturn = lt_return.CLEAR:lv_message.LOOP AT lt_return INTO ls_return WHERE type = 'E' OR type = 'A'.IF lv_message IS INITIAL.lv_message = lv_message && ls_return-message.ELSE.lv_message = lv_message && ';' && ls_return-message.ENDIF.ENDLOOP.IF sy-subrc <> 0.CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.WAIT UP TO '0.5' SECONDS.SELECT SINGLE MAX( paobjnr ) AS paobjnr FROM ce1mithWHERE vrgar = 'B'AND bukrs = @lv_bukrsAND werks = @is_header-plantAND artnr = @is_header-materialAND kndnr = @is_header-supp_idINTO @DATA(lv_paobjunr).IF lv_paobjunr IS INITIAL.ev_message = TEXT-004.ev_type = 'E'.RETURN.ENDIF.ELSE.CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.ev_message = lv_message.ev_type = 'E'.RETURN.ENDIF.