cancel
Showing results for 
Search instead for 
Did you mean: 

Compute_BCD_overlow dump

0 Kudos
180

Hi Friends, Pl help me. I operation 1 SAP ECC6 system, every quater i use tcode ZGL07( this tcode another persional dev)for dump account, this time is error( friends look attach file), only 2 account 3311100000(must payment for seller) ,1311100000 (must get buyer) is error, all another account is ok, i can't solve this problem.

Pl help me. Thanks and BR
FUNCTION ZCORE_FM_GET_BALANCE_ACCOUNT .
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(I_GET_BEGIN_PERIOD) TYPE  CHAR1 OPTIONAL
*"     REFERENCE(I_GET_IN_PERIOD) TYPE  CHAR1 OPTIONAL
*"     REFERENCE(I_INCLUDE_REVERSE) TYPE  CHAR1 OPTIONAL
*"     REFERENCE(I_INCLUDE_CORRES) TYPE  CHAR1 OPTIONAL
*"  TABLES
*"      IT_BUKRS STRUCTURE  ZST_RSELOPTION_BUKRS
*"      IT_BUDAT STRUCTURE  ZST_RSELOPTION_BUDAT
*"      IT_MONAT STRUCTURE  ZST_RSELOPTION_MONAT OPTIONAL
*"      IT_GJAHR STRUCTURE  ZST_RSELOPTION_GJAHR OPTIONAL
*"      IT_HKONT STRUCTURE  ZST_RSELOPTION_HKONT OPTIONAL
*"      IT_BALANCE_ACCOUNT STRUCTURE  ZFI_ST_BALANCE_ACCOUNT
*"----------------------------------------------------------------------
    TYPES:  BEGIN OF GST_FAGLFLEXT,
            BUKRS TYPE BUKRS,
            RACCT TYPE RACCT,
            RTCUR TYPE RTCUR,
            DRCRK TYPE SHKZG,
            HSLVT TYPE HSLXX12,
            HSL01 TYPE HSLXX12,
            HSL02 TYPE HSLXX12,
            HSL03 TYPE HSLXX12,
            HSL04 TYPE HSLXX12,
            HSL05 TYPE HSLXX12,
            HSL06 TYPE HSLXX12,
            HSL07 TYPE HSLXX12,
            HSL08 TYPE HSLXX12,
            HSL09 TYPE HSLXX12,
            HSL10 TYPE HSLXX12,
            HSL11 TYPE HSLXX12,
            HSL12 TYPE HSLXX12,
            HSL13 TYPE HSLXX12,
            HSL14 TYPE HSLXX12,
            HSL15 TYPE HSLXX12,
            HSL16 TYPE HSLXX12,
            TSLVT TYPE TSLXX12,
            TSL01 TYPE TSLXX12,
            TSL02 TYPE TSLXX12,
            TSL03 TYPE TSLXX12,
            TSL04 TYPE TSLXX12,
            TSL05 TYPE TSLXX12,
            TSL06 TYPE TSLXX12,
            TSL07 TYPE TSLXX12,
            TSL08 TYPE TSLXX12,
            TSL09 TYPE TSLXX12,
            TSL10 TYPE TSLXX12,
            TSL11 TYPE TSLXX12,
            TSL12 TYPE TSLXX12,
            TSL13 TYPE TSLXX12,
            TSL14 TYPE TSLXX12,
            TSL15 TYPE TSLXX12,
            TSL16 TYPE TSLXX12,
          END OF GST_FAGLFLEXT.
  TYPES:  BEGIN OF GST_J_3RKKRS,
            BUKRS         TYPE BUKRS,
            BELNR         TYPE BELNR_D,
            GJAHR         TYPE GJAHR,
            BUDAT         TYPE BUDAT,
            MONAT         TYPE MONAT,
            XNEGPD        TYPE XNEGP,
            XNEGPK        TYPE XNEGP,
            SHKZG         TYPE SHKZG,
            BUZEI         TYPE BUZEI,
            BUZEI_CORRES  TYPE BUZEI,
            HKONT         TYPE HKONT,
            HKONT_CORRES  TYPE HKONT,
            WAERS         TYPE WAERS,
            WRBTR         TYPE WRBTR,
            DMBTR         TYPE DMBTR,
          END OF GST_J_3RKKRS.
  DATA:   LW_KTOPL                TYPE KTOPL,
          LW_RLDNR                TYPE RLDNR,
          LW_WAERS_T001           TYPE WAERS.
  DATA:   LT_SKB1                 TYPE TABLE OF SKB1,
          LS_SKB1                 TYPE          SKB1.
  DATA:   LW_GJAHR_BALANCE        TYPE GJAHR,
          LW_MONAT_BAlANCE        TYPE MONAT,
          LW_GJAHR_PLUS_BALANCE   TYPE GJAHR,
          LW_MONAT_PLUS_BALANCE   TYPE MONAT,
          LW_TDATE_PLUS_BALANCE   TYPE BUDAT.
  DATA:   LT_FAGLFLEXT            TYPE TABLE OF GST_FAGLFLEXT,
          LS_FAGLFLEXT            TYPE          GST_FAGLFLEXT,
          LT_FAGLFLEXA            TYPE TABLE OF ZFI_ST_BALANCE_ACCOUNT,
          LS_FAGLFLEXA            TYPE          ZFI_ST_BALANCE_ACCOUNT,
          LT_BKPF                 TYPE TABLE OF BKPF,
          LS_BKPF                 TYPE          BKPF,
          LT_J_3RKKRS_DEBIT       TYPE TABLE OF GST_J_3RKKRS,
          LS_J_3RKKRS_DEBIT       TYPE          GST_J_3RKKRS,
          LT_J_3RKKRS_CREDIT      TYPE TABLE OF GST_J_3RKKRS,
          LS_J_3RKKRS_CREDIT      TYPE          GST_J_3RKKRS,
          LT_J_3RKKRS             TYPE TABLE OF GST_J_3RKKRS,
          LS_J_3RKKRS             TYPE          GST_J_3RKKRS,
          LT_BEGIN_PERIOD         TYPE TABLE OF ZFI_ST_BALANCE_ACCOUNT,
          LS_BEGIN_PERIOD         TYPE          ZFI_ST_BALANCE_ACCOUNT,
          LT_IN_PERIOD            TYPE TABLE OF ZFI_ST_BALANCE_ACCOUNT,
          LS_IN_PERIOD            TYPE          ZFI_ST_BALANCE_ACCOUNT,
          LT_BALANCE_ACCOUNT      TYPE TABLE OF ZFI_ST_BALANCE_ACCOUNT,
          LS_BALANCE_ACCOUNT      TYPE          ZFI_ST_BALANCE_ACCOUNT.
  DATA:   LW_CUR_MONTH            TYPE NUMC2,
          LW_FIELD_STR            TYPE CHAR100.
  FIELD-SYMBOLS:
          <FS_THANG>              TYPE VGCUR12.
  DATA:   LW_REVERSE              TYPE CHAR1,
          LW_BUZEI_CORRES         TYPE BUZEI,
          LW_HKONT_CORRES         TYPE HKONT,
          LW_WRBTR                TYPE WRBTR,
          LW_DMBTR                TYPE DMBTR,
          LW_EXIST_CORRES         TYPE CHAR1.
 CALL FUNCTION 'ZCORE_FM_GET_COA'
    IMPORTING
      E_KTOPL   = LW_KTOPL
      E_RLDNR   = LW_RLDNR
      E_WAERS   = LW_WAERS_T001
    TABLES
      IT_BUKRS  = IT_BUKRS.
 SELECT *
  INTO CORRESPONDING FIELDS OF TABLE LT_SKB1
  FROM SKB1
  WHERE
    BUKRS IN IT_BUKRS
    AND SAKNR IN IT_HKONT.
  IF IT_MONAT IS INITIAL OR IT_GJAHR IS INITIAL.
    IF IT_BUDAT-LOW+4(2) = '01'.
      LW_GJAHR_BALANCE = IT_BUDAT-LOW+0(4).
      LW_MONAT_BALANCE = '00'.
    ELSE.
      LW_GJAHR_BALANCE = IT_BUDAT-LOW+0(4).
      LW_MONAT_BALANCE = IT_BUDAT-LOW+4(2) - 1.
    ENDIF.
    LW_GJAHR_PLUS_BALANCE = IT_BUDAT-LOW+0(4).
    LW_MONAT_PLUS_BALANCE = IT_BUDAT-LOW+4(2).
    LW_TDATE_PLUS_BALANCE = IT_BUDAT-LOW - 1.
  ELSE.
   IF IT_MONAT-LOW = '1'.
      LW_GJAHR_BALANCE = IT_GJAHR-LOW.
      LW_MONAT_BALANCE = '00'.
    ELSE.
      LW_GJAHR_BALANCE = IT_GJAHR-LOW.
      LW_MONAT_BALANCE = IT_MONAT-LOW - 1.
    ENDIF.
    LW_GJAHR_PLUS_BALANCE = IT_GJAHR-LOW.
    LW_MONAT_PLUS_BALANCE = IT_MONAT-LOW.
    LW_TDATE_PLUS_BALANCE = IT_BUDAT-LOW - 1.
  ENDIF.
   CLEAR:  LT_FAGLFLEXT,
          LT_FAGLFLEXA,
          LT_BEGIN_PERIOD.
  IF I_GET_BEGIN_PERIOD IS NOT INITIAL.
    SELECT
      FAGLFLEXT~RBUKRS AS BUKRS
      FAGLFLEXT~RACCT
      FAGLFLEXT~RTCUR
      FAGLFLEXT~DRCRK
      SUM( HSLVT ) AS HSLVT
      SUM( HSL01 ) AS HSL01
      SUM( HSL02 ) AS HSL02
      SUM( HSL03 ) AS HSL03
      SUM( HSL04 ) AS HSL04
      SUM( HSL05 ) AS HSL05
      SUM( HSL06 ) AS HSL06
      SUM( HSL07 ) AS HSL07
      SUM( HSL08 ) AS HSL08
      SUM( HSL09 ) AS HSL09
      SUM( HSL10 ) AS HSL10
      SUM( HSL11 ) AS HSL11
      SUM( HSL12 ) AS HSL12
      SUM( HSL13 ) AS HSL13
      SUM( HSL14 ) AS HSL14
      SUM( HSL15 ) AS HSL15
      SUM( HSL16 ) AS HSL16
      SUM( TSLVT ) AS TSLVT
      SUM( TSL01 ) AS TSL01
      SUM( TSL02 ) AS TSL02
      SUM( TSL03 ) AS TSL03
      SUM( TSL04 ) AS TSL04
      SUM( TSL05 ) AS TSL05
      SUM( TSL06 ) AS TSL06
      SUM( TSL07 ) AS TSL07
      SUM( TSL08 ) AS TSL08
      SUM( TSL09 ) AS TSL09
      SUM( TSL10 ) AS TSL10
      SUM( TSL11 ) AS TSL11
      SUM( TSL12 ) AS TSL12
      SUM( TSL13 ) AS TSL13
      SUM( TSL14 ) AS TSL14
      SUM( TSL15 ) AS TSL15
      SUM( TSL16 ) AS TSL16
    FROM FAGLFLEXT
    INTO CORRESPONDING FIELDS OF TABLE LT_FAGLFLEXT
    WHERE
      RBUKRS IN IT_BUKRS
      AND FAGLFLEXT~RACCT IN IT_HKONT
      AND FAGLFLEXT~RLDNR = LW_RLDNR
      AND FAGLFLEXT~RYEAR = LW_GJAHR_BALANCE
    GROUP BY
      FAGLFLEXT~RBUKRS
      FAGLFLEXT~RACCT
      FAGLFLEXT~RTCUR
      FAGLFLEXT~DRCRK.
    LOOP AT LT_FAGLFLEXT INTO LS_FAGLFLEXT.
      LS_BEGIN_PERIOD-BUKRS = LS_FAGLFLEXT-BUKRS.
      LS_BEGIN_PERIOD-HKONT = LS_FAGLFLEXT-RACCT.
      CLEAR LS_SKB1.
      READ TABLE LT_SKB1 INTO LS_SKB1 WITH KEY BUKRS = LS_FAGLFLEXT-BUKRS SAKNR = LS_FAGLFLEXT-RACCT.
      LS_BEGIN_PERIOD-WAERS_SKB1 = LS_SKB1-WAERS.
      LS_BEGIN_PERIOD-WAERS_T001 = LW_WAERS_T001.
      LS_BEGIN_PERIOD-WAERS = LS_FAGLFLEXT-RTCUR.
      LS_BEGIN_PERIOD-SHKZG = LS_FAGLFLEXT-DRCRK.
      LS_BEGIN_PERIOD-DMBTR = LS_BEGIN_PERIOD-DMBTR + LS_FAGLFLEXT-HSLVT.
      LS_BEGIN_PERIOD-WRBTR = LS_BEGIN_PERIOD-WRBTR + LS_FAGLFLEXT-TSLVT.
      LW_CUR_MONTH = '01'.
      WHILE ( LW_CUR_MONTH <= LW_MONAT_BALANCE ).
        UNPACK LW_CUR_MONTH TO LW_CUR_MONTH.
        CONCATENATE 'LS_FAGLFLEXT-HSL' LW_CUR_MONTH INTO LW_FIELD_STR.
        ASSIGN (LW_FIELD_STR) TO <FS_THANG>.
        LS_BEGIN_PERIOD-DMBTR = LS_BEGIN_PERIOD-DMBTR + <FS_THANG>.
        CONCATENATE 'LS_FAGLFLEXT-TSL' LW_CUR_MONTH INTO LW_FIELD_STR.
        ASSIGN (LW_FIELD_STR) TO <FS_THANG>.
        LS_BEGIN_PERIOD-WRBTR = LS_BEGIN_PERIOD-WRBTR + <FS_THANG>.
        LW_CUR_MONTH = LW_CUR_MONTH + 1.
      ENDWHILE.
      LS_BEGIN_PERIOD-BEGIN_PERIOD = 'X'.
      APPEND LS_BEGIN_PERIOD TO LT_BEGIN_PERIOD.
      CLEAR LS_BEGIN_PERIOD.
    ENDLOOP.
   SELECT
      BKPF~BUKRS
      FAGLFLEXA~RACCT AS HKONT
      FAGLFLEXA~GJAHR
      BKPF~MONAT
      FAGLFLEXA~BELNR
      FAGLFLEXA~RWCUR AS WAERS
      FAGLFLEXA~BUDAT
      BKPF~BLDAT
      BKPF~XBLNR
      FAGLFLEXA~BUZEI
      FAGLFLEXA~DRCRK AS SHKZG
      FAGLFLEXA~TSL AS WRBTR
      FAGLFLEXA~HSL AS DMBTR
    FROM FAGLFLEXA  INNER JOIN BKPF ON BKPF~BUKRS = FAGLFLEXA~RBUKRS
                                    AND BKPF~BELNR = FAGLFLEXA~BELNR
                                    AND BKPF~GJAHR = FAGLFLEXA~GJAHR
    INTO CORRESPONDING FIELDS OF TABLE LT_FAGLFLEXA
    WHERE
      FAGLFLEXA~RLDNR = LW_RLDNR
      AND FAGLFLEXA~RBUKRS IN IT_BUKRS
      AND FAGLFLEXA~RACCT IN IT_HKONT
      AND FAGLFLEXA~RYEAR = LW_GJAHR_PLUS_BALANCE
      AND FAGLFLEXA~POPER = LW_MONAT_PLUS_BALANCE
      AND FAGLFLEXA~BUDAT <= LW_TDATE_PLUS_BALANCE.
    LOOP AT LT_FAGLFLEXA INTO LS_FAGLFLEXA.
      CLEAR: LW_REVERSE.
      IF I_INCLUDE_REVERSE IS INITIAL.
        CALL FUNCTION 'ZCORE_FM_CHECK_REVERSE'
          EXPORTING
            I_BUKRS       = LS_FAGLFLEXA-BUKRS
            I_BELNR       = LS_FAGLFLEXA-BELNR
            I_BUDAT       = LS_FAGLFLEXA-BUDAT
          IMPORTING
            I_EXIST       = LW_REVERSE.
      ENDIF.
      IF LW_REVERSE IS NOT INITIAL.
        DELETE LT_FAGLFLEXA WHERE BUKRS = LS_FAGLFLEXA-BUKRS AND BELNR = LS_FAGLFLEXA-BELNR AND GJAHR = LS_FAGLFLEXA-GJAHR.
      ELSE.
        LS_BEGIN_PERIOD-BUKRS = LS_FAGLFLEXA-BUKRS.
        LS_BEGIN_PERIOD-HKONT = LS_FAGLFLEXA-HKONT.
        LS_BEGIN_PERIOD-BEGIN_PERIOD = 'X'.
        LS_BEGIN_PERIOD-GJAHR = LS_FAGLFLEXA-GJAHR.
        LS_BEGIN_PERIOD-MONAT = LS_FAGLFLEXA-MONAT.
        LS_BEGIN_PERIOD-BELNR = LS_FAGLFLEXA-BELNR.
        CLEAR LS_SKB1.
       READ TABLE LT_SKB1 INTO LS_SKB1 WITH KEY BUKRS = LS_FAGLFLEXA-BUKRS SAKNR = LS_FAGLFLEXA-HKONT.
        LS_BEGIN_PERIOD-WAERS_SKB1 = LS_SKB1-WAERS.
        LS_BEGIN_PERIOD-WAERS_T001 = LW_WAERS_T001.
        LS_BEGIN_PERIOD-WAERS = LS_FAGLFLEXA-WAERS.
        LS_BEGIN_PERIOD-BUDAT = LS_FAGLFLEXA-BUDAT.
        LS_BEGIN_PERIOD-BLDAT = LS_FAGLFLEXA-BLDAT.
        LS_BEGIN_PERIOD-XBLNR = LS_FAGLFLEXA-XBLNR.
        LS_BEGIN_PERIOD-BUZEI = LS_FAGLFLEXA-BUZEI.
        LS_BEGIN_PERIOD-BUZEI_CORRES = ''.
        LS_BEGIN_PERIOD-HKONT_CORRES = ''.
        LS_BEGIN_PERIOD-DESCRIPTION = ''.
        LS_BEGIN_PERIOD-SHKZG = LS_FAGLFLEXA-SHKZG.
        SELECT SINGLE XNEGP
        INTO LS_BEGIN_PERIOD-XNEGP
        FROM BSEG
        WHERE BUKRS = LS_FAGLFLEXA-BUKRS
          AND GJAHR = LS_FAGLFLEXA-GJAHR
          AND BELNR = LS_FAGLFLEXA-BELNR
          AND BUZEI = LS_FAGLFLEXA-BUZEI.
        LS_BEGIN_PERIOD-WRBTR = LS_FAGLFLEXA-WRBTR.
        LS_BEGIN_PERIOD-DMBTR = LS_FAGLFLEXA-DMBTR.
        LS_BEGIN_PERIOD-WRBTR_S = ''.
        LS_BEGIN_PERIOD-WRBTR_H = ''.
        LS_BEGIN_PERIOD-DMBTR_S = ''.
        LS_BEGIN_PERIOD-DMBTR_H = ''.
        APPEND LS_BEGIN_PERIOD TO LT_BEGIN_PERIOD.
        CLEAR LS_BEGIN_PERIOD.
      ENDIF.
    ENDLOOP.
  ENDIF.
  CLEAR:  LT_FAGLFLEXT,
          LT_FAGLFLEXA,
          LT_IN_PERIOD.
  IF I_GET_IN_PERIOD IS NOT INITIAL.
    SELECT *
    INTO CORRESPONDING FIELDS OF TABLE LT_BKPF
    FROM BKPF
    WHERE
      BUKRS IN IT_BUKRS
      AND GJAHR IN IT_GJAHR
      AND MONAT IN IT_MONAT
      AND BUDAT IN IT_BUDAT.
      SELECT
      BKPF~BUKRS
      FAGLFLEXA~RACCT AS HKONT
      FAGLFLEXA~GJAHR
      BKPF~MONAT
      FAGLFLEXA~BELNR
      FAGLFLEXA~RWCUR AS WAERS
      FAGLFLEXA~BUDAT
      BKPF~BLDAT
      BKPF~XBLNR
      FAGLFLEXA~BUZEI
      FAGLFLEXA~DRCRK AS SHKZG
      FAGLFLEXA~TSL AS WRBTR
      FAGLFLEXA~HSL AS DMBTR
    FROM FAGLFLEXA  INNER JOIN BKPF ON BKPF~BUKRS = FAGLFLEXA~RBUKRS
                                    AND BKPF~BELNR = FAGLFLEXA~BELNR
                                    AND BKPF~GJAHR = FAGLFLEXA~GJAHR
    INTO CORRESPONDING FIELDS OF TABLE LT_FAGLFLEXA
    WHERE
      FAGLFLEXA~RLDNR = LW_RLDNR
      AND FAGLFLEXA~RBUKRS IN IT_BUKRS
      AND FAGLFLEXA~RACCT IN IT_HKONT
      AND FAGLFLEXA~RYEAR IN IT_GJAHR
      AND FAGLFLEXA~POPER IN IT_MONAT
      AND FAGLFLEXA~BUDAT IN IT_BUDAT.
    IF I_INCLUDE_CORRES IS NOT INITIAL.
      SELECT
        BUKRS
        BELNR
        GJAHR
        BUDAT
        MONAT
        XNEGPD
        XNEGPK
        BUZEID AS BUZEI
        BUZEIK AS BUZEI_CORRES
        DEBET AS HKONT
        KREDIT AS HKONT_CORRES
        WAERS
        WRBTR
        DMBTR
      INTO CORRESPONDING FIELDS OF TABLE LT_J_3RKKRS_DEBIT
      FROM J_3RKKRS
      WHERE
        BUKRS IN IT_BUKRS
        AND GJAHR IN IT_GJAHR
        AND MONAT IN IT_MONAT
        AND BUDAT IN IT_BUDAT
        AND DEBET IN IT_HKONT.
      SELECT
        BUKRS
        BELNR
        GJAHR
        BUDAT
        MONAT
        XNEGPD
        XNEGPK
        BUZEIK AS BUZEI
        BUZEID AS BUZEI_CORRES
        KREDIT AS HKONT
        DEBET AS HKONT_CORRES
        WAERS
        WRBTR
        DMBTR
      INTO CORRESPONDING FIELDS OF TABLE LT_J_3RKKRS_CREDIT
      FROM J_3RKKRS
      WHERE
        BUKRS IN IT_BUKRS
        AND GJAHR IN IT_GJAHR
        AND MONAT IN IT_MONAT
        AND BUDAT IN IT_BUDAT
        AND KREDIT IN IT_HKONT.
     LOOP AT LT_J_3RKKRS_DEBIT INTO LS_J_3RKKRS_DEBIT.
        MOVE-CORRESPONDING LS_J_3RKKRS_DEBIT TO LS_J_3RKKRS.
        CLEAR: LS_J_3RKKRS-SHKZG,
               LS_J_3RKKRS-WRBTR,
               LS_J_3RKKRS-DMBTR.
        LS_J_3RKKRS-SHKZG = 'S'.
        LS_J_3RKKRS-WRBTR = LS_J_3RKKRS_DEBIT-WRBTR.
        LS_J_3RKKRS-DMBTR = LS_J_3RKKRS_DEBIT-DMBTR.
        IF LS_J_3RKKRS-XNEGPD = 'X'.
          LS_J_3RKKRS-SHKZG = 'H'.
          LS_J_3RKKRS-WRBTR = -1 * -1 * LS_J_3RKKRS-WRBTR.
          LS_J_3RKKRS-DMBTR = -1 * -1 * LS_J_3RKKRS-DMBTR.
        ENDIF.
        APPEND LS_J_3RKKRS TO LT_J_3RKKRS.
        CLEAR: LS_J_3RKKRS.
      ENDLOOP.
      LOOP AT LT_J_3RKKRS_CREDIT INTO LS_J_3RKKRS_CREDIT.
        MOVE-CORRESPONDING LS_J_3RKKRS_CREDIT TO LS_J_3RKKRS.
        CLEAR: LS_J_3RKKRS-SHKZG,
               LS_J_3RKKRS-WRBTR,
               LS_J_3RKKRS-DMBTR.
        LS_J_3RKKRS-SHKZG = 'H'.
        LS_J_3RKKRS-WRBTR = -1 * LS_J_3RKKRS_CREDIT-WRBTR.
        LS_J_3RKKRS-DMBTR = -1 * LS_J_3RKKRS_CREDIT-DMBTR.
       IF LS_J_3RKKRS-XNEGPK = 'X'.
          LS_J_3RKKRS-SHKZG = 'S'.
          LS_J_3RKKRS-WRBTR = -1 * -1 * LS_J_3RKKRS-WRBTR.
          LS_J_3RKKRS-DMBTR = -1 * -1 * LS_J_3RKKRS-DMBTR.
        ENDIF.
        APPEND LS_J_3RKKRS TO LT_J_3RKKRS.
        CLEAR: LS_J_3RKKRS.
      ENDLOOP.
    ENDIF.
   LOOP AT LT_BKPF INTO LS_BKPF.
      CLEAR: LW_REVERSE.
      IF I_INCLUDE_REVERSE IS INITIAL.
        CALL FUNCTION 'ZCORE_FM_CHECK_REVERSE'
          EXPORTING
            I_BUKRS       = LS_BKPF-BUKRS
            I_BELNR       = LS_BKPF-BELNR
            I_BUDAT       = LS_BKPF-BUDAT
          IMPORTING
            I_EXIST       = LW_REVERSE.
      ENDIF.
      IF LW_REVERSE IS NOT INITIAL.
       DELETE LT_BKPF WHERE BUKRS = LS_BKPF-BUKRS AND BELNR = LS_BKPF-BELNR AND GJAHR = LS_BKPF-GJAHR.
      ELSE.
        CLEAR: LW_EXIST_CORRES.
        IF I_INCLUDE_CORRES IS NOT INITIAL.
          CALL FUNCTION 'ZCORE_FM_CHECK_EXIST_CORRES'
            EXPORTING
              I_BUKRS       = LS_BKPF-BUKRS
              I_BELNR       = LS_BKPF-BELNR
              I_GJAHR       = LS_BKPF-GJAHR
            IMPORTING
              I_EXIST       = LW_EXIST_CORRES.
        ENDIF.
        IF LW_EXIST_CORRES = 'X'.
          LOOP AT LT_J_3RKKRS INTO LS_J_3RKKRS WHERE BUKRS = LS_BKPF-BUKRS AND GJAHR = LS_BKPF-GJAHR AND BELNR = LS_BKPF-BELNR.
            LS_IN_PERIOD-BUKRS = LS_BKPF-BUKRS.
            LS_IN_PERIOD-HKONT = LS_J_3RKKRS-HKONT.
            LS_IN_PERIOD-BEGIN_PERIOD = ''.
            LS_IN_PERIOD-GJAHR = LS_BKPF-GJAHR.
            LS_IN_PERIOD-MONAT = LS_BKPF-MONAT.
            LS_IN_PERIOD-BELNR = LS_BKPF-BELNR.
            CLEAR LS_SKB1.
            READ TABLE LT_SKB1 INTO LS_SKB1 WITH KEY BUKRS = LS_J_3RKKRS-BUKRS SAKNR = LS_J_3RKKRS-HKONT.
            LS_IN_PERIOD-WAERS_SKB1 = LS_SKB1-WAERS.
            LS_IN_PERIOD-WAERS_T001 = LW_WAERS_T001.
            LS_IN_PERIOD-WAERS = LS_BKPF-WAERS.
            LS_IN_PERIOD-BUDAT = LS_BKPF-BUDAT.
            LS_IN_PERIOD-BLDAT = LS_BKPF-BLDAT.
            LS_IN_PERIOD-XBLNR = LS_BKPF-XBLNR.
            LS_IN_PERIOD-BUZEI = LS_J_3RKKRS-BUZEI.
            LS_IN_PERIOD-BUZEI_CORRES = LS_J_3RKKRS-BUZEI_CORRES.
            LS_IN_PERIOD-HKONT_CORRES = LS_J_3RKKRS-HKONT_CORRES.
            CALL FUNCTION 'ZCORE_FM_GET_DOC_DES'
              EXPORTING
                I_BUKRS           = LS_IN_PERIOD-BUKRS
                I_GJAHR           = LS_IN_PERIOD-GJAHR
                I_BELNR           = LS_IN_PERIOD-BELNR
                I_BUZEI           = LS_IN_PERIOD-BUZEI
                I_BUZEI_CORRES    = LS_IN_PERIOD-BUZEI_CORRES
              IMPORTING
                E_DESCRIPTION     = LS_IN_PERIOD-DESCRIPTION.
            LS_IN_PERIOD-SHKZG = LS_J_3RKKRS-SHKZG.
            SELECT SINGLE XNEGP
            INTO LS_IN_PERIOD-XNEGP
            FROM BSEG
            WHERE BUKRS = LS_BKPF-BUKRS
              AND GJAHR = LS_BKPF-GJAHR
              AND BELNR = LS_BKPF-BELNR
              AND BUZEI = LS_J_3RKKRS-BUZEI.
            LS_IN_PERIOD-WRBTR = LS_J_3RKKRS-WRBTR.
            LS_IN_PERIOD-DMBTR = LS_J_3RKKRS-DMBTR.
            LS_IN_PERIOD-WRBTR_S = ''.
            LS_IN_PERIOD-WRBTR_H = ''.
            LS_IN_PERIOD-DMBTR_S = ''.
            LS_IN_PERIOD-DMBTR_H = ''.
            APPEND LS_IN_PERIOD TO LT_IN_PERIOD.
          ENDLOOP.
        ELSE.
          LOOP AT LT_FAGLFLEXA INTO LS_FAGLFLEXA WHERE BUKRS = LS_BKPF-BUKRS AND GJAHR = LS_BKPF-GJAHR AND BELNR = LS_BKPF-BELNR..
            LS_IN_PERIOD-BUKRS = LS_FAGLFLEXA-BUKRS.
            LS_IN_PERIOD-HKONT = LS_FAGLFLEXA-HKONT.
            LS_IN_PERIOD-BEGIN_PERIOD = ''.
            LS_IN_PERIOD-GJAHR = LS_FAGLFLEXA-GJAHR.
            LS_IN_PERIOD-MONAT = LS_FAGLFLEXA-MONAT.
            LS_IN_PERIOD-BELNR = LS_FAGLFLEXA-BELNR.
            CLEAR LS_SKB1.
            READ TABLE LT_SKB1 INTO LS_SKB1 WITH KEY BUKRS = LS_FAGLFLEXA-BUKRS SAKNR = LS_FAGLFLEXA-HKONT.
            LS_IN_PERIOD-WAERS_SKB1 = LS_SKB1-WAERS.
            LS_IN_PERIOD-WAERS_T001 = LW_WAERS_T001.
            LS_IN_PERIOD-WAERS = LS_FAGLFLEXA-WAERS.
            LS_IN_PERIOD-BUDAT = LS_FAGLFLEXA-BUDAT.
            LS_IN_PERIOD-BLDAT = LS_FAGLFLEXA-BLDAT.
            LS_IN_PERIOD-XBLNR = LS_FAGLFLEXA-XBLNR.
            LS_IN_PERIOD-BUZEI = LS_FAGLFLEXA-BUZEI.
            LS_IN_PERIOD-BUZEI_CORRES = ''.
            LS_IN_PERIOD-HKONT_CORRES = ''.
            CALL FUNCTION 'ZCORE_FM_GET_DOC_DES'
              EXPORTING
                I_BUKRS           = LS_IN_PERIOD-BUKRS
                I_GJAHR           = LS_IN_PERIOD-GJAHR
                I_BELNR           = LS_IN_PERIOD-BELNR
                I_BUZEI           = LS_IN_PERIOD-BUZEI
                I_BUZEI_CORRES    = LS_IN_PERIOD-BUZEI_CORRES
              IMPORTING
                E_DESCRIPTION     = LS_IN_PERIOD-DESCRIPTION.
            LS_IN_PERIOD-SHKZG = LS_FAGLFLEXA-SHKZG.
            SELECT SINGLE XNEGP
            INTO LS_IN_PERIOD-XNEGP
            FROM BSEG
            WHERE BUKRS = LS_FAGLFLEXA-BUKRS
              AND GJAHR = LS_FAGLFLEXA-GJAHR
              AND BELNR = LS_FAGLFLEXA-BELNR
              AND BUZEI = LS_FAGLFLEXA-BUZEI.
            LS_IN_PERIOD-WRBTR = LS_FAGLFLEXA-WRBTR.
            LS_IN_PERIOD-DMBTR = LS_FAGLFLEXA-DMBTR.
            LS_IN_PERIOD-WRBTR_S = ''.
            LS_IN_PERIOD-WRBTR_H = ''.
            LS_IN_PERIOD-DMBTR_S = ''.
            LS_IN_PERIOD-DMBTR_H = ''.
          APPEND LS_IN_PERIOD TO LT_IN_PERIOD.
          ENDLOOP.
        ENDIF.
      ENDIF.
    ENDLOOP.
  ENDIF.
  APPEND LINES OF LT_BEGIN_PERIOD TO LT_BALANCE_ACCOUNT.
  APPEND LINES OF LT_IN_PERIOD TO LT_BALANCE_ACCOUNT.
 LOOP AT LT_BALANCE_ACCOUNT INTO LS_BALANCE_ACCOUNT.
    CASE LS_BALANCE_ACCOUNT-SHKZG.
      WHEN 'S'.
        LS_BALANCE_ACCOUNT-WRBTR_S = LS_BALANCE_ACCOUNT-WRBTR.
        LS_BALANCE_ACCOUNT-WRBTR_H = 0.
        LS_BALANCE_ACCOUNT-DMBTR_S = LS_BALANCE_ACCOUNT-DMBTR.
        LS_BALANCE_ACCOUNT-DMBTR_H = 0.
      WHEN 'H'.
        LS_BALANCE_ACCOUNT-WRBTR_S = 0.
        LS_BALANCE_ACCOUNT-WRBTR_H = -1 * LS_BALANCE_ACCOUNT-WRBTR.
        LS_BALANCE_ACCOUNT-DMBTR_S = 0.
        LS_BALANCE_ACCOUNT-DMBTR_H = -1 * LS_BALANCE_ACCOUNT-DMBTR.
      WHEN OTHERS.
    ENDCASE.
    MODIFY LT_BALANCE_ACCOUNT FROM LS_BALANCE_ACCOUNT.
  ENDLOOP.
  APPEND LINES OF LT_BALANCE_ACCOUNT TO IT_BALANCE_ACCOUNT.
ENDFUNCTION.
former_member751591
Participant
0 Kudos

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend you to read this overview Community Q&A, and to take our Q&A tutorial . With these tips you'll be able to prepare questions that draw responses from our members.

The more details you provide, the more likely it is that members will be able to answer your question.

Should you wish, you can revise your question by selecting Actions, then Edit.

By adding a Picture to your profile you encourage readers to respond.

Sandra_Rossi
Active Contributor

I hope you understand why there is an overflow: if a number can hold maximum number 999 (3 digits), and you add 1, it makes 1000 which can't be stored and that makes an overflow error. Compute_BCD_overflow has been discussed a lot in the forum (and also in ABAP documentation).

0 Kudos

Hi Sandra Rossi

i run this tcode for another account is ok, only 2 that account is error, pl help me step by step.

Accepted Solutions (0)

Answers (0)