SAP-FI模块 处理自动生成会计凭证增强

SAP-FI模块 处理自动生成会计凭证增强_第1张图片SAP-FI模块 处理自动生成会计凭证增强_第2张图片SAP-FI模块 处理自动生成会计凭证增强_第3张图片SAP-FI模块 处理自动生成会计凭证增强_第4张图片SAP-FI模块 处理自动生成会计凭证增强_第5张图片SAP-FI模块 处理自动生成会计凭证增强_第6张图片SAP-FI模块 处理自动生成会计凭证增强_第7张图片SAP-FI模块 处理自动生成会计凭证增强_第8张图片SAP-FI模块 处理自动生成会计凭证增强_第9张图片SAP-FI模块 处理自动生成会计凭证增强_第10张图片SAP-FI模块 处理自动生成会计凭证增强_第11张图片

ENHANCEMENT 2  ZEHENC_SAPMF05A.    "active version
*  FI 20221215:固定资产业务过渡科目摘要增强功能
WAIT UP TO 1 SECONDS.

READ TABLE xbseg WITH KEY hkont = '1601990001'.
IF sy-subrc = 0.
  DATA: lt_bkdf TYPE TABLE OF bkdf,
        lt_bkpf TYPE TABLE OF bkpf,
        ls_bkpf TYPE bkpf,
        lt_bsec TYPE TABLE OF bsec,
        lt_bsed TYPE TABLE OF bsed,
        ls_bseg TYPE bseg,
        lt_bseg TYPE TABLE OF bseg,
        lt_bset TYPE TABLE OF bset.

  DATA: ls_belnr_second TYPE belnr_d.
  DATA: ls_xbkpf TYPE bkpf.
  CLEAR: ls_bkpf,lt_bkpf[],lt_bseg[],ls_xbkpf.

  DATA: ls_bkpf_judge TYPE bkpf.
  CLEAR: ls_bkpf_judge.

  ls_belnr_second = bkpf-belnr + 1.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      input  = ls_belnr_second
    IMPORTING
      output = ls_belnr_second.

  SELECT SINGLE *
    INTO CORRESPONDING FIELDS OF ls_bkpf_judge
    FROM bkpf
   WHERE bukrs eq bkpf-bukrs
     AND gjahr eq bkpf-gjahr
     AND belnr EQ ls_belnr_second.

  if ls_bkpf_judge IS NOT INITIAL.

    ls_bkpf-mandt = sy-mandt.
    ls_bkpf-bukrs = bkpf-bukrs.
    ls_bkpf-gjahr = bkpf-gjahr.
    ls_bkpf-belnr = ls_belnr_second.
    APPEND ls_bkpf TO lt_bkpf.

    LOOP AT xbseg.
      CLEAR: ls_bseg.
      ls_bseg-mandt = sy-mandt.
      ls_bseg-bukrs = xbseg-bukrs.
      ls_bseg-gjahr = xbseg-gjahr.
      ls_bseg-buzei = xbseg-buzei.
      ls_bseg-belnr = ls_belnr_second.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
        EXPORTING
          input  = xbseg-belnr
        IMPORTING
          output = xbseg-belnr.
      ls_bseg-sgtxt = xbseg-sgtxt && '-原凭证(' && xbseg-belnr && ')'.
      APPEND ls_bseg TO lt_bseg.
    ENDLOOP.

    CALL FUNCTION 'CHANGE_DOCUMENT'
      TABLES
        t_bkdf = lt_bkdf
        t_bkpf = lt_bkpf
        t_bsec = lt_bsec
        t_bsed = lt_bsed
        t_bseg = lt_bseg
        t_bset = lt_bset.

    IF sy-subrc EQ 0.
      COMMIT WORK AND WAIT.
    ENDIF.

  ENDIF.
ENDIF.
*  FI 20221215
ENDENHANCEMENT.

SAP-FI模块 处理自动生成会计凭证增强_第12张图片

ENHANCEMENT 1  Z_MIGO_CREATE_ACC_DOCUMENT.    "active version
  " FI 20221230:MIGO自动生成会计凭证增强 LIANG ED1K924636
  DATA: lt_bkdf TYPE TABLE OF bkdf,
        lt_bsec TYPE TABLE OF bsec,
        lt_bsed TYPE TABLE OF bsed,
        lt_bset TYPE TABLE OF bset.

  DATA: ls_BKPF1 TYPE BKPF,
        ls_BKPF2 TYPE BKPF,
        lt_BKPF TYPE TABLE OF BKPF.
  DATA: LT_BKPF_RESULT TYPE TABLE OF BKPF.

  DATA: ls_bseg TYPE bseg,
        lt_bseg TYPE TABLE OF bseg.

  DATA: ls_bseg_temp TYPE bseg.

  DATA: ls_AWKEY TYPE bkpf-AWKEY.

  CLEAR: lt_BKPF[],ls_BKPF1,ls_BKPF2,ls_AWKEY,ls_bseg_temp,ls_bseg,lt_bseg[],LT_BKPF_RESULT[].

  ls_AWKEY = ls_emkpf-MBLNR && ls_emkpf-MJAHR.

  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE lt_BKPF
    FROM BKPF
   WHERE AWKEY EQ ls_AWKEY.

  SORT lt_BKPF BY BELNR ASCENDING.

  IF sy-subrc EQ 0.
    READ TABLE lt_BKPF INTO ls_BKPF1 INDEX 1.
    READ TABLE lt_BKPF INTO ls_BKPF2 INDEX 2.
    APPEND ls_BKPF2 TO LT_BKPF_RESULT.
    SELECT *
      INTO CORRESPONDING FIELDS OF TABLE lt_bseg
      FROM bseg
     WHERE BUKRS EQ ls_BKPF2-bukrs
       AND BELNR EQ ls_BKPF2-BELNR
       AND GJAHR EQ ls_BKPF2-GJAHR.

    LOOP AT lt_bseg INTO ls_bseg.
      IF ls_bseg-hkont EQ '1601990001'.
        CLEAR: ls_bseg_temp.
        " 取第一个行项目的行项目文本
        SELECT SINGLE *
          INTO CORRESPONDING FIELDS OF ls_bseg_temp
          FROM bseg
         WHERE BUKRS EQ ls_bseg-bukrs
           AND BELNR EQ ls_BKPF1-BELNR
           AND GJAHR EQ ls_bseg-GJAHR
           AND BUZEI EQ ls_bseg-BUZEI.

        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
          EXPORTING
            input  = ls_bseg_temp-belnr
          IMPORTING
            output = ls_bseg_temp-belnr.

        ls_bseg-sgtxt = ls_bseg_temp-sgtxt && '-原凭证(' && ls_bseg_temp-belnr && ')'.
        MODIFY lt_bseg FROM ls_bseg.
      ENDIF.
    ENDLOOP.

    CALL FUNCTION 'CHANGE_DOCUMENT'
      TABLES
        t_bkdf = lt_bkdf
        t_bkpf = LT_BKPF_RESULT
        t_bsec = lt_bsec
        t_bsed = lt_bsed
        t_bseg = lt_bseg
        t_bset = lt_bset.

  ENDIF.
  " FI 20221230 LIANG ED1K924636
ENDENHANCEMENT.

SAP-FI模块 处理自动生成会计凭证增强_第13张图片

* 反记账替代 Modify By LIANG ED1K924602 20221226
  exits-name  = 'U305'.
  exits-param = c_exit_param_field.
  exits-title = TEXT-305.             "
  APPEND exits.
* FI 20221226 主营业务收入等科目自动反记账功能
* 
FORM u305 USING bseg-xnegp TYPE bseg-xnegp.

  DATA: ls_zfi_fjz1 TYPE zfi_fjz.
  DATA: ls_zfi_fjz2 TYPE zfi_fjz.
  CLEAR: ls_zfi_fjz1,ls_zfi_fjz2.

  SELECT SINGLE *
    INTO CORRESPONDING FIELDS OF ls_zfi_fjz1
    FROM zfi_fjz
   WHERE hkontf <= bseg-hkont
     AND hkontt >= bseg-hkont.

  IF sy-subrc EQ 0.
    IF bseg-shkzg = ls_zfi_fjz1-shkzg.
      bseg-xnegp = ''.
    ELSE.
      bseg-xnegp = 'X'.
    ENDIF.
  ELSE.
    SELECT SINGLE *
      INTO CORRESPONDING FIELDS OF ls_zfi_fjz2
      FROM zfi_fjz
     WHERE hkontf = bseg-hkont.
    IF sy-subrc EQ 0.
      IF bseg-shkzg = ls_zfi_fjz2-shkzg.
        bseg-xnegp = ''.
      ELSE.
        bseg-xnegp = 'X'.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.
* FI 20221226

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