会计凭证抬头文本增强的问题

场景说明:使用BADI_AC_DOCUMENT,凭证抬头文本丢失问题。
解决办法:将im_document-header-bktxt的值赋值到ex_document-header-bktxt即可

代码示例:
METHOD if_ex_ac_document~change_initial.

DATA: ls_item     TYPE accit,
      ls_sub_item TYPE accit_sub,
      lv_sgtxt    TYPE bseg-sgtxt,
      lv_bktxt    TYPE bkpf-bktxt,
      lv_vbeln    TYPE vbak-vbeln,
      lv_kunnr    TYPE vbak-kunnr,
      lv_ebeln    TYPE bseg-ebeln,
      lv_sortl    TYPE kna1-sortl.

CLEAR: lv_sgtxt,lv_bktxt.

LOOP AT im_document-item INTO ls_item WHERE blart = 'AF'.

  CLEAR ls_sub_item.
  MOVE-CORRESPONDING ls_item TO ls_sub_item.
  CONCATENATE '计提' ls_item-budat+0(4) '年' ls_item-budat+4(2) '月折旧' INTO lv_sgtxt SEPARATED BY ''.
  ls_sub_item-sgtxt = lv_sgtxt.
  lv_bktxt          = lv_sgtxt.
  APPEND ls_sub_item TO ex_document-item.

ENDLOOP.

CLEAR: lv_vbeln,lv_kunnr,lv_ebeln,lv_sortl.
LOOP AT im_document-item INTO ls_item WHERE blart = 'RV'.

  IF ls_item-aubel IS NOT INITIAL.
    IF lv_vbeln IS INITIAL.
      lv_vbeln = ls_item-aubel.
    ENDIF.
  ENDIF.

  IF ls_item-kunnr IS NOT INITIAL.
    IF lv_kunnr IS INITIAL.
      lv_kunnr = ls_item-kunnr.
    ENDIF.
  ENDIF.

  IF ls_item-ebeln IS NOT INITIAL.
    IF lv_ebeln IS INITIAL.
      lv_ebeln = ls_item-ebeln.
    ENDIF.
  ENDIF.

ENDLOOP.

IF lv_vbeln IS NOT INITIAL.
  SELECT SINGLE kunnr INTO lv_kunnr FROM vbak WHERE vbeln = lv_vbeln.
  SELECT SINGLE sortl INTO lv_sortl FROM kna1 WHERE kunnr = lv_kunnr.
  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = lv_vbeln
    IMPORTING
      output = lv_vbeln.
  CONCATENATE '收入确认' lv_sortl lv_vbeln INTO lv_sgtxt SEPARATED BY ''.
  lv_bktxt          = lv_sgtxt.
ELSEIF lv_kunnr IS NOT INITIAL.
  SELECT SINGLE sortl INTO lv_sortl FROM kna1 WHERE kunnr = lv_kunnr.
  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
      input  = lv_ebeln
    IMPORTING
      output = lv_vbeln.
  CONCATENATE '收入确认' lv_sortl lv_vbeln INTO lv_sgtxt SEPARATED BY ''.
  lv_bktxt          = lv_sgtxt.
ENDIF.

IF lv_sgtxt IS NOT INITIAL.
  LOOP AT im_document-item INTO ls_item WHERE blart = 'RV'.

    CLEAR ls_sub_item.
    MOVE-CORRESPONDING ls_item TO ls_sub_item.
    ls_sub_item-zuonr = lv_vbeln.
    ls_sub_item-sgtxt = lv_sgtxt.
    APPEND ls_sub_item TO ex_document-item.

  ENDLOOP.
ENDIF.

IF lv_bktxt IS NOT INITIAL.
  ex_document-header-bktxt = lv_bktxt.
ELSE.
  ex_document-header-bktxt = im_document-header-bktxt.
ENDIF.

ENDMETHOD.

你可能感兴趣的:(SAP-ABAP,sap)