BSEG _ BSAD problems

Hi,
1) BSEG -- NEBTR is in document currency. How can we convert it to local currency? Is this value already calculated by SAP or do we have to do manual calculation for this?
Scenario:
I have to pull the data in a customer statement form for all the customers who have paid their invoices in local currency. Right now the BSEG table only holds the payments in document currency.  What is the fastest way of obtaining the NEBTR in local currency?
2) Also is there a way to know in BSAD whether the payments made are full/partial/residual payments? I know there there is a field called REBZT but it is not getting populated in this table. Is there a way for us to know the fully paid cleared items?
3) Any way to know the fully paid cleared items?
Thanks and points will be assigned

Hi,
Based on the co.code, get the currency code from t001 and use fm: BAPI_GET_EXCHANGERATE to fetch the exchange rate for that currency, and then calculate to get the local currency or group currency amount.
Regards
Subramanian

Similar Messages

  • BAPI to update Business Area in table BSEG and BSAD

    Hi,
    Is there any BAPI that will update the field Business Area in table BSEG and BSAD?
    Thanks,
    Ekit
    Moderator: Please, search SDN

    Hi,
    You can not update the business area in the posted documents.
    You need to reverse them and have to recreate.
    Regards,
    Gaurav

  • OXK3  add  custom field  to  bseg  bsid bsad

    Hi  all ,
    I have  a  custom  field  added to  bseg table using  transactioin OCK3,  but  i dont  see  this  field in  others  tables BSID,BSAD . Can someone  tell  me the way  to  add   this field in the others tables using  tcode  OCK3 .
    Thanks in advance,
    Karim

    This field will not be automatically added to secondary indexes (only BSEG, CI_COBL and CI_COBL_BI). You may manually add this field to the secondary indexes via append structure, it will be automatically copied as those tables are filled via move-corresponding like statements. (source [Note 62435 - F-03: Selection by purchasing documents|https://service.sap.com/sap/support/notes/62435])
    Regards,
    Raymond

  • BSEG - shzkg

    Hi Gurus,
    I am trying to extract all payments from the table bseg but the problem is that in the table there is a problem with the field shzkg whereby it has two types of values H and S but the problem is that I dont know which one to use.
    For payments made to vendors which value should I use 'H' or 'S'.

    Hi
    U shouldn't care it, the payment shoudl have a particular account keys BSEG-BSCHL, the field TBSL-XZAHL should be equal to X.
    But I think the payment should be posted with a particular document type (it used to do it): don't use BSEG table for the query, but BSID/BSAD for customer or BSIK/BASK for vendor.
    Max

  • ALV TEXT problem

    Hi Abaper ,
    In my alv repoer i  am doing sum base on the bkpf-month to the field
    bseg-DMBTR .
    my problem is i want  text when summing in every month .
    like
    Amount in month June is           
    how can  i do ? if any one can face same problem help me .
    Regards
    Ajay pandey

    hi Ajay,
    Check this out
    Re: ALV Subtotals
    Regards,
    santosh

  • It's urgent - - - Real time Problem

    hi experts,
    i am working on aging report. its a interactive report.
    now wht i want is that document type DR should also get totalled in the base report
    but this report is not doing so.
    please help me out that how can i include dr in the aging also.
    attaching u the code for the base report
    *& Report  ZAGING1
    REPORT  zage_ver1  NO STANDARD PAGE HEADING LINE-SIZE 250.
    TABLES : bseg, kna1 ,bsad, bsid, vbrk.
    SELECT-OPTIONS: s_kunnr FOR kna1-kunnr OBLIGATORY.
    PARAMETERS : key_date TYPE bldat OBLIGATORY.
    PARAMETERS : ccode    TYPE bukrs OBLIGATORY.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 01(30) text-001 FOR FIELD int1.
    SELECTION-SCREEN POSITION POS_LOW.
    PARAMETERS: int1(3) TYPE n DEFAULT '030'.
    PARAMETERS: int2(3) TYPE n DEFAULT '060'.
    PARAMETERS: int3(3) TYPE n DEFAULT '090'.
    PARAMETERS: int4(3) TYPE n DEFAULT '120'.
    PARAMETERS: int5(3) TYPE n DEFAULT '150'.
    SELECTION-SCREEN END OF LINE.
    DATA : onacc LIKE bsid-wrbtr.
    TYPES: BEGIN OF cust,
            kunnr TYPE kna1-kunnr,
            adrnr TYPE kna1-adrnr,
            name1 TYPE kna1-name1,
            wrbtr TYPE bseg-wrbtr,
            bzirk TYPE knvv-bzirk,
            zterm TYPE knvv-zterm,
            ztag1 TYPE t052-ztag1,
           END OF cust.
    TYPES: BEGIN OF invt,
            kunnr TYPE kna1-kunnr,
            kunrg TYPE kna1-kunnr,
            wrbtr TYPE bseg-wrbtr,
            invamt TYPE bseg-wrbtr,
            name1 TYPE kna1-name1,
            vbeln TYPE vbrk-vbeln,
            belnr TYPE bseg-belnr,
           END OF invt.
    TYPES : BEGIN OF ytab,
              kunnr TYPE bsid-kunnr,
              wrbtr TYPE bsid-wrbtr,
              sinv_amt TYPE bsid-wrbtr,
              paid_amt TYPE bsid-wrbtr,
              adj_amt   TYPE bsid-wrbtr,
              cncl_amt TYPE bsid-wrbtr,
              baln_amt TYPE bsid-wrbtr,
              onac_amt TYPE bsid-wrbtr,
              ac_amt   TYPE bsid-wrbtr,
              age_amt TYPE bsid-wrbtr,
              wrbtr_rvh TYPE bsid-wrbtr,
              wrbtr_rvs TYPE bsid-wrbtr,
              wrbtr_obh TYPE bsid-wrbtr,
              wrbtr_obs TYPE bsid-wrbtr,
              wrbtr_dg TYPE bsid-wrbtr,
              wrbtr_dr TYPE bsid-wrbtr,
              wrbtr_dzs TYPE bsid-wrbtr,
              wrbtr_dzh TYPE bsid-wrbtr,
              wrbtr_sas TYPE bsid-wrbtr,
              wrbtr_sah TYPE bsid-wrbtr,
              wrbtr_abs TYPE bsid-wrbtr,
              wrbtr_abh TYPE bsid-wrbtr,
              baln1 TYPE bsid-wrbtr,
              baln2 TYPE bsid-wrbtr,
              baln3 TYPE bsid-wrbtr,
              baln4 TYPE bsid-wrbtr,
              baln5 TYPE bsid-wrbtr,
              baln6 TYPE bsid-wrbtr,
              blart TYPE bsid-blart,
              vbeln TYPE bsid-vbeln,
              fkdat TYPE vbrk-fkdat,
              belnr TYPE bsid-belnr,
              rebzg TYPE bsid-rebzg,
              shkzg TYPE bsid-shkzg,
              zuonr TYPE bsid-zuonr,
              od_days(4) TYPE n,
            END OF ytab.
    TYPES : BEGIN OF ftab,
              kunnr TYPE bsid-kunnr,
              name1 TYPE kna1-name1,
             WRBTR TYPE BSID-WRBTR,
              sinv_amt TYPE bsid-wrbtr,
              paid_amt TYPE bsid-wrbtr,
              adj_amt   TYPE bsid-wrbtr,
              cncl_amt TYPE bsid-wrbtr,
              baln_amt TYPE bsid-wrbtr,
              ac_amt   TYPE bsid-wrbtr,
              onac_amt TYPE bsid-wrbtr,
              outs_amt TYPE bsid-wrbtr,
              age_amt TYPE bsid-wrbtr,
              wrbtr_rvh TYPE bsid-wrbtr,
              wrbtr_rvs TYPE bsid-wrbtr,
              wrbtr_obh TYPE bsid-wrbtr,
              wrbtr_obs TYPE bsid-wrbtr,
              wrbtr_dg TYPE bsid-wrbtr,
              wrbtr_dr TYPE bsid-wrbtr,
              wrbtr_dzs TYPE bsid-wrbtr,
              wrbtr_dzh TYPE bsid-wrbtr,
              wrbtr_sas TYPE bsid-wrbtr,
              wrbtr_sah TYPE bsid-wrbtr,
              wrbtr_abs TYPE bsid-wrbtr,
              wrbtr_abh TYPE bsid-wrbtr,
              baln1 TYPE bsid-wrbtr,
              baln2 TYPE bsid-wrbtr,
              baln3 TYPE bsid-wrbtr,
              baln4 TYPE bsid-wrbtr,
              baln5 TYPE bsid-wrbtr,
              baln6 TYPE bsid-wrbtr,
              blart TYPE bsid-blart,
              vbeln TYPE bsid-vbeln,
              belnr TYPE bsid-belnr,
              rebzg TYPE bsid-rebzg,
              shkzg TYPE bsid-shkzg,
              bzirk TYPE knvv-bzirk,
              zterm TYPE knvv-zterm,
              ztag1 TYPE t052-ztag1,
              zuonr TYPE bsid-zuonr,
              od_days(4) TYPE n,
              sno(3) TYPE n,
            END OF ftab.
    data : wrbtr_note like bsid-wrbtr.
            DATA : BEGIN OF itab1 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
            xblnr LIKE bsid-xblnr,
            abc LIKE bsid-wrbtr,
            aaa LIKE bsid-wrbtr,
            sgtxt LIKE bsid-sgtxt,
            bcd LIKE bsid-wrbtr,
            bbb LIKE bsid-wrbtr,
            flag TYPE c,
            flag1(3) TYPE c,
            flag2(15) TYPE c,
            bldat like bsid-bldat,
            END OF itab1.
            DATA : BEGIN OF itab2 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
           txt50 LIKE skat-txt50,  " GL A/C TEXT
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
    xblnr LIKE bsid-xblnr,
    sgtxt LIKE bsid-sgtxt,
    abc LIKE bsid-wrbtr,
    aaa LIKE bsid-wrbtr,
    bcd LIKE bsid-wrbtr,
    bbb LIKE bsid-wrbtr,
    flag TYPE c,
    flag1(3) TYPE c,
    flag2(15) TYPE c,
    bldat like bsid-bldat,
            END OF itab2.
    DATA : BEGIN OF itab3 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
           txt50 LIKE skat-txt50,  " GL A/C TEXT
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
            xblnr LIKE bsid-xblnr,
            abc LIKE bsid-wrbtr,
    aaa LIKE bsid-wrbtr,
    bcd LIKE bsid-wrbtr,
    bbb LIKE bsid-wrbtr,
    flag TYPE c,
    flag1(3) TYPE c,
    flag2(15) TYPE c,
    sgtxt LIKE bsid-sgtxt,
    bldat like bsid-bldat,
            END OF itab3.
    DATA : BEGIN OF itab4 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
           txt50 LIKE skat-txt50,  " GL A/C TEXT
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
    xblnr LIKE bsid-xblnr,
    aaa LIKE bsid-wrbtr,
    abc LIKE bsid-wrbtr,
    bbb LIKE bsid-wrbtr,
    bcd LIKE bsid-wrbtr,
    flag TYPE c,
    flag1(3) TYPE c,
    flag2(15) TYPE c,
    sgtxt LIKE bsid-sgtxt,
    bldat like bsid-bldat,
            END OF itab4.
    DATA : BEGIN OF itab5 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
           txt50 LIKE skat-txt50,  " GL A/C TEXT
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
    xblnr LIKE bsid-xblnr,
    abc LIKE bsid-wrbtr,
    aaa LIKE bsid-wrbtr,
    bcd LIKE bsid-wrbtr,
    bbb LIKE bsid-wrbtr,
    flag TYPE c,
    flag1(3) TYPE c,
    flag2(15) TYPE c,
    sgtxt LIKE bsid-sgtxt,
    bldat like bsid-bldat,
            END OF itab5.
    DATA : BEGIN OF itab6 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
           txt50 LIKE skat-txt50,  " GL A/C TEXT
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
            xblnr LIKE bsid-xblnr,
            sgtxt LIKE bsid-sgtxt,
            bldat like bsid-bldat,
            abc LIKE bsid-wrbtr,
            aaa LIKE bsid-wrbtr,
            bcd LIKE bsid-wrbtr,
    bbb LIKE bsid-wrbtr,
    flag TYPE c,
    flag1(3) TYPE c,
    flag2(15) TYPE c,
            END OF itab6.
    data : dr_deduct like bsid-wrbtr.
    DATA : BEGIN OF itab7 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
           txt50 LIKE skat-txt50,  " GL A/C TEXT
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
    xblnr LIKE bsid-xblnr,
    sgtxt LIKE bsid-sgtxt,
    bldat like bsid-bldat,
            END OF itab7.
    DATA : BEGIN OF itab8 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
           txt50 LIKE skat-txt50,  " GL A/C TEXT
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
    xblnr LIKE bsid-xblnr,
    abc LIKE bsid-wrbtr,
    aaa LIKE bsid-wrbtr,
    bcd LIKE bsid-wrbtr,
    bbb LIKE bsid-wrbtr,
    flag TYPE c,
    flag1(3) TYPE c,
    flag2(15) TYPE c,
    sgtxt LIKE bsid-sgtxt,
    bldat like bsid-bldat,
            END OF itab8.
    DATA : wa_ctab TYPE cust.
    DATA : wa_btab TYPE invt.
    DATA : wa_bsid TYPE bsid.
    DATA : wai_bsid TYPE ytab.
    DATA : wac_bsid TYPE ytab.        " CREDIT - INVOICE
    DATA : wad_bsid TYPE ytab.        " DEBIT  - PAYMENT
    DATA : wao_bsid TYPE ytab.        " ON ACCOUNT
    DATA : wa_itab  TYPE ftab.
    DATA : ctab TYPE cust OCCURS 0.
    DATA : btab TYPE invt OCCURS 0.
    DATA : it_bsid TYPE bsid OCCURS 0.
    DATA : iti_bsid TYPE ytab OCCURS 0.        " CANCELLED INVOICES
    DATA : itc_bsid TYPE ytab OCCURS 0.        " CREDIT - INVOICE
    DATA : itd_bsid TYPE ytab OCCURS 0.        " DEBIT  - PAYMENT
    DATA : ito_bsid TYPE ytab OCCURS 0.        " ON ACCOUNT
    DATA : itab     TYPE ftab OCCURS 0 with header line.        " OUTPUT
    DATA : inv_amt LIKE bseg-wrbtr.
    DATA : paid_amt LIKE bseg-wrbtr.
    DATA : cncl_amt LIKE bseg-wrbtr.
    DATA : adj_amt LIKE bseg-wrbtr.
    DATA : billing_date LIKE sy-datum.
    DATA : overdue_date LIKE sy-datum.
    DATA : overdue_days LIKE rfposx-verzn.
    DATA : credit_days(4) TYPE n.
    DATA : int1s(3) TYPE n VALUE 0,
           int1e(3) TYPE n VALUE 0,
           int2s(3) TYPE n VALUE 0,
           int2e(3) TYPE n VALUE 0,
           int3s(3) TYPE n VALUE 0,
           int3e(3) TYPE n VALUE 0,
           int4s(3) TYPE n VALUE 0,
           int4e(3) TYPE n VALUE 0,
           int5s(3) TYPE n VALUE 0,
           int5e(3) TYPE n VALUE 0,
           int TYPE i,
           slno(5)  TYPE n VALUE 0.
    CLEAR : inv_amt, ctab, btab, wa_itab, wac_bsid, wad_bsid, wao_bsid.
    REFRESH : ctab, btab,itab, itc_bsid, itd_bsid, ito_bsid.
    START-OF-SELECTION.
    SELECT kunnr name1 adrnr FROM kna1 INTO CORRESPONDING FIELDS OF wa_ctab WHERE kunnr IN s_kunnr.
      SELECT SINGLE bzirk zterm FROM knvv INTO (wa_ctab-bzirk, wa_ctab-zterm) WHERE kunnr = wa_ctab-kunnr.
      SELECT SINGLE ztag1 FROM t052 INTO wa_ctab-ztag1 WHERE zterm = wa_ctab-zterm.
       WRITE : /5 WA_CTAB-KUNNR COLOR 5, WA_CTAB-NAME1 COLOR 5.
    APPEND wa_ctab TO ctab.
    ENDSELECT.
    SELECT * FROM bsid INTO TABLE it_bsid FOR ALL ENTRIES IN ctab WHERE kunnr = ctab-kunnr
                                                                  AND   budat =< key_date
                                                                 AND   gjahr = fyear
                                                                  AND   bukrs = ccode.
    SORT it_bsid BY kunnr.
    LOOP AT IT_BSID INTO WA_BSID.
      IF  WA_BSID-BLART = 'RV' AND WA_BSID-SHKZG = 'S' OR
          WA_BSID-BLART = 'OB' AND WA_BSID-SHKZG = 'S' or
          wa_bsid-blart = 'DR'.
          WAC_BSID-KUNNR = WA_BSID-KUNNR.
          WAC_BSID-BLART = WA_BSID-BLART.
          WAC_BSID-VBELN = WA_BSID-VBELN.
          WAC_BSID-BELNR = WA_BSID-BELNR.
          WAC_BSID-REBZG = WA_BSID-REBZG.
          WAC_BSID-WRBTR = WA_BSID-WRBTR.
          WAC_BSID-ZUONR = WA_BSID-ZUONR.
          WAC_BSID-SHKZG = WA_BSID-SHKZG.
          IF WAC_BSID-VBELN IS NOT INITIAL.
             SELECT SINGLE FKDAT FROM VBRK INTO WAC_BSID-FKDAT WHERE VBELN = WAC_BSID-VBELN.
          ELSEIF WAC_BSID-VBELN IS INITIAL.
            IF WAC_BSID-BELNR IS NOT INITIAL.
             SELECT SINGLE BuDAT FROM BSID INTO WAC_BSID-FKDAT WHERE BELNR = WAC_BSID-BELNR.
            ENDIF.
          ENDIF.
       WAC_BSID = WA_BSID.
        APPEND WAC_BSID TO ITC_BSID.
    ELSEIF  WA_BSID-BLART = 'DZ' AND WA_BSID-VBELN <> ' '.
      ELSEIF  WA_BSID-BLART = 'DZ' .
       WAD_BSID = WA_BSID.
        WAD_BSID-KUNNR = WA_BSID-KUNNR.
        WAD_BSID-BLART = WA_BSID-BLART.
        WAD_BSID-VBELN = WA_BSID-VBELN.
        WAD_BSID-BELNR = WA_BSID-BELNR.
        WAD_BSID-REBZG = WA_BSID-REBZG.
        WAD_BSID-WRBTR = WA_BSID-WRBTR.
        WAD_BSID-ZUONR = WA_BSID-ZUONR.
        WAD_BSID-SHKZG = WA_BSID-SHKZG.
        APPEND WAD_BSID TO ITD_BSID.
      ELSEIF  WA_BSID-BLART = 'RV' AND WA_BSID-SHKZG = 'H' AND WA_BSID-ZUONR <> ' '.
        WAI_BSID-KUNNR = WA_BSID-KUNNR.
        WAI_BSID-BLART = WA_BSID-BLART.
        WAI_BSID-VBELN = WA_BSID-VBELN.
        WAI_BSID-BELNR = WA_BSID-BELNR.
        WAI_BSID-REBZG = WA_BSID-REBZG.
        WAI_BSID-WRBTR = WA_BSID-WRBTR.
        WAI_BSID-ZUONR = WA_BSID-ZUONR.
        WAI_BSID-SHKZG = WA_BSID-SHKZG.
        APPEND WAI_BSID TO ITI_BSID.
      ENDIF.
        MODIFY IT_BSID FROM WA_BSID.
    ENDLOOP.
    CLEAR : WAC_BSID.
    LOOP AT ITC_BSID INTO WAC_BSID.
      CLEAR : WAD_BSID, INV_AMT, PAID_AMT, CNCL_AMT, ADJ_AMT.
      IF WAC_BSID-BLART = 'RV' AND WAC_BSID-SHKZG = 'S'.
          WAC_BSID-SINV_AMT = WAC_BSID-WRBTR.
          INV_AMT = WAC_BSID-SINV_AMT.
        READ TABLE ITD_BSID INTO WAD_BSID WITH KEY KUNNR = WAC_BSID-KUNNR VBELN = WAC_BSID-VBELN.
        LOOP AT ITD_BSID INTO WAD_BSID WHERE KUNNR = WAC_BSID-KUNNR AND VBELN = WAC_BSID-VBELN.
         IF SY-SUBRC = 0.
           WAC_BSID-PAID_AMT = WAD_BSID-WRBTR.
            PAID_AMT = PAID_AMT + WAD_BSID-WRBTR.
         ENDIF.
        ENDLOOP.
         IF PAID_AMT IS NOT INITIAL.
           WAC_BSID-BALN_AMT = WAC_BSID-SINV_AMT - WAC_BSID-PAID_AMT.
            WAC_BSID-PAID_AMT = PAID_AMT.
            WAC_BSID-BALN_AMT = WAC_BSID-SINV_AMT - PAID_AMT.
            WAC_BSID-AGE_AMT  = WAC_BSID-BALN_AMT.
         ELSE.
            WAC_BSID-PAID_AMT = 0.
            WAC_BSID-BALN_AMT = WAC_BSID-SINV_AMT.
            WAC_BSID-AGE_AMT  = WAC_BSID-BALN_AMT.
         ENDIF.
        LOOP AT ITI_BSID INTO WAI_BSID WHERE KUNNR = WAC_BSID-KUNNR AND ZUONR = WAC_BSID-VBELN.
        IF SY-SUBRC = 0.
           WAC_BSID-PAID_AMT = WAD_BSID-WRBTR.
            CNCL_AMT = CNCL_AMT + WAI_BSID-WRBTR.
        ENDIF.
        ENDLOOP.
         IF CNCL_AMT IS NOT INITIAL.
           WAC_BSID-BALN_AMT = WAC_BSID-SINV_AMT - WAC_BSID-PAID_AMT.
            WAC_BSID-CNCL_AMT = CNCL_AMT.
            WAC_BSID-BALN_AMT = WAC_BSID-BALN_AMT - CNCL_AMT.
            WAC_BSID-AGE_AMT  = WAC_BSID-BALN_AMT.
         ELSE.
            WAC_BSID-BALN_AMT = WAC_BSID-BALN_AMT.
            WAC_BSID-AGE_AMT  = WAC_BSID-BALN_AMT.
         ENDIF.
      ELSEIF WAC_BSID-BLART = 'OB' AND WAC_BSID-SHKZG = 'S'.
          IF WAC_BSID-ZUONR <> ' '.
             LOOP AT ITD_BSID INTO WAD_BSID WHERE KUNNR = WAC_BSID-KUNNR AND VBELN = ' ' AND ZUONR = WAC_BSID-ZUONR.
               IF SY-SUBRC = 0.
                  ADJ_AMT = ADJ_AMT + WAD_BSID-WRBTR.
               ENDIF.
             ENDLOOP.
             WAC_BSID-ADJ_AMT  = ADJ_AMT.
             WAC_BSID-BALN_AMT = WAC_BSID-WRBTR - ADJ_AMT.
             WAC_BSID-AGE_AMT  = WAC_BSID-BALN_AMT.
          ELSEIF WAC_BSID-ZUONR = ' '.
            WAC_BSID-BALN_AMT = WAC_BSID-WRBTR.
            WAC_BSID-AGE_AMT  = WAC_BSID-BALN_AMT.
          ENDIF.
      ENDIF.
        PERFORM AGING_CALCULATION.
        WA_ITAB-KUNNR = WAC_BSID-KUNNR.
        WA_ITAB-SINV_AMT = WAC_BSID-SINV_AMT.
        WA_ITAB-PAID_AMT = WAC_BSID-PAID_AMT.
        WA_ITAB-CNCL_AMT = WAC_BSID-CNCL_AMT.
        WA_ITAB-BALN_AMT = WAC_BSID-BALN_AMT.
       WA_ITAB-OD_DAYS  = WAC_BSID-OD_DAYS.
        WA_ITAB-BALN1 = WAC_BSID-BALN1.
        WA_ITAB-BALN2 = WAC_BSID-BALN2.
        WA_ITAB-BALN3 = WAC_BSID-BALN3.
        WA_ITAB-BALN4 = WAC_BSID-BALN4.
        WA_ITAB-BALN5 = WAC_BSID-BALN5.
        WA_ITAB-BALN6 = WAC_BSID-BALN6.
        COLLECT WA_ITAB INTO ITAB.
      MODIFY ITC_BSID FROM WAC_BSID.
    COLLECT WAC_BSID.
    ENDLOOP.
    CLEAR : WA_ITAB, WA_CTAB.
    LOOP AT CTAB INTO WA_CTAB.
    CLEAR : WAO_BSID.
    LOOP AT IT_BSID INTO WA_BSID WHERE KUNNR = WA_CTAB-KUNNR.
      IF WA_BSID-BLART = 'RV' OR
         WA_BSID-BLART = 'OB' OR
         WA_BSID-BLART = 'DG' OR
         WA_BSID-BLART = 'DR' OR
         WA_BSID-BLART = 'DZ' OR
         WA_BSID-BLART = 'SA' OR
         WA_BSID-BLART = 'AB'.
         WAO_BSID-KUNNR = WA_BSID-KUNNR.
         WAO_BSID-BLART = WA_BSID-BLART.
         WAO_BSID-VBELN = WA_BSID-VBELN.
         WAO_BSID-BELNR = WA_BSID-BELNR.
         WAO_BSID-REBZG = WA_BSID-REBZG.
         WAO_BSID-WRBTR = WA_BSID-WRBTR.
         WAO_BSID-SHKZG = WA_BSID-SHKZG.
         WAO_BSID-ZUONR = WA_BSID-ZUONR.
         WAO_BSID-SHKZG = WA_BSID-SHKZG.
         APPEND WAO_BSID TO ITO_BSID.
       ENDIF.
    ENDLOOP.
    CLEAR : WAO_BSID.
    LOOP AT ITO_BSID INTO WAO_BSID WHERE KUNNR = WA_CTAB-KUNNR.
      IF WAO_BSID-BLART = 'OB' AND WAO_BSID-SHKZG = 'H'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT - WAO_BSID-WRBTR.
          WAO_BSID-WRBTR_OBH = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'OB' AND WAO_BSID-SHKZG = 'S'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT - WAO_BSID-WRBTR.
          WAO_BSID-WRBTR_OBS = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'DG'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT - WAO_BSID-WRBTR.
          WAO_BSID-WRBTR_DG = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'DR'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT + WAO_BSID-WRBTR.
         WAO_BSID-WRBTR_DR = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'DZ' AND WAO_BSID-SHKZG = 'H'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT - WAO_BSID-WRBTR.
         WAO_BSID-WRBTR_DZH = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'DZ' AND WAO_BSID-SHKZG = 'S'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT - WAO_BSID-WRBTR.
         WAO_BSID-WRBTR_DZS = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'SA' AND WAO_BSID-SHKZG = 'S'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT + WAO_BSID-WRBTR.
          WAO_BSID-WRBTR_SAS = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'SA' AND WAO_BSID-SHKZG = 'H'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT - WAO_BSID-WRBTR.
         WAO_BSID-WRBTR_SAH = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'AB' AND WAO_BSID-SHKZG = 'S'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT + WAO_BSID-WRBTR.
          WAO_BSID-WRBTR_ABS = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'AB' AND WAO_BSID-SHKZG = 'H'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT - WAO_BSID-WRBTR.
         WAO_BSID-WRBTR_ABH = WAO_BSID-WRBTR.
    ELSEIF WAO_BSID-BLART = 'RV' AND WAO_BSID-SHKZG = 'H' AND WAO_BSID-ZUONR = ' '.
      ELSEIF WAO_BSID-BLART = 'RV' AND WAO_BSID-SHKZG = 'H'.
         WAO_BSID-WRBTR_RVH = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'RV' AND WAO_BSID-SHKZG = 'S'.
         WAO_BSID-WRBTR_RVS = WAO_BSID-WRBTR.
      ENDIF.
        WA_ITAB-KUNNR    = WAO_BSID-KUNNR.
        WA_ITAB-WRBTR_DG = WAO_BSID-WRBTR_DG.
        WA_ITAB-WRBTR_DR = WAO_BSID-WRBTR_DR.
        WA_ITAB-WRBTR_DZS = WAO_BSID-WRBTR_DZS.
        WA_ITAB-WRBTR_DZH = WAO_BSID-WRBTR_DZH.
        WA_ITAB-WRBTR_OBH = WAO_BSID-WRBTR_OBH.
        WA_ITAB-WRBTR_OBS = WAO_BSID-WRBTR_OBS.
        WA_ITAB-WRBTR_SAH = WAO_BSID-WRBTR_SAH.
        WA_ITAB-WRBTR_SAS = WAO_BSID-WRBTR_SAS.
        WA_ITAB-WRBTR_RVH = WAO_BSID-WRBTR_RVH.
        WA_ITAB-WRBTR_RVS = WAO_BSID-WRBTR_RVS.
        WA_ITAB-WRBTR_ABH = WAO_BSID-WRBTR_ABH.
        WA_ITAB-WRBTR_ABS = WAO_BSID-WRBTR_ABS.
       WA_ITAB-AC_AMT    = WAO_BSID-AC_AMT.
        COLLECT WA_ITAB INTO ITAB.
      MODIFY ITO_BSID FROM WAO_BSID.
    ENDLOOP.
    ENDLOOP.
    CLEAR : SLNO.
    clear : wa_itab.
    SORT ITAB BY KUNNR.
    LOOP AT ITAB INTO WA_ITAB.
    SLNO = SLNO + 1.
    WA_ITAB-SNO = SLNO.
    READ TABLE CTAB INTO WA_CTAB WITH KEY KUNNR = WA_ITAB-KUNNR.
         WA_ITAB-NAME1 = WA_CTAB-NAME1.
         WA_ITAB-BZIRK = WA_CTAB-BZIRK.
         WA_ITAB-ZTAG1 = WA_CTAB-ZTAG1.
        WA_ITAB-AC_AMT =     WA_ITAB-WRBTR_SAS
                           - WA_ITAB-WRBTR_SAH
                           - WA_ITAB-WRBTR_OBH
                           + WA_ITAB-WRBTR_OBS
                           + WA_ITAB-WRBTR_RVS
                           - WA_ITAB-WRBTR_RVH
                           - WA_ITAB-WRBTR_ABH
                           + WA_ITAB-WRBTR_ABS
                           - WA_ITAB-WRBTR_DG
                           + WA_ITAB-WRBTR_DR
                           - WA_ITAB-WRBTR_DZH
                           + WA_ITAB-WRBTR_DZS.
    *WRITE : / WA_ITAB-WRBTR_DR.
                           data : aaaa type p decimals 2,
                           bbbb type p decimals 2,
                           cccc type p decimals 2,
                           wrbtr_shkzg like bsid-shkzg.
    SELECT      shkzg wrbtr
                FROM bsid
                INTO (wrbtr_shkzg , wrbtr_note )
                WHERE kunnr = wa_itab-kunnr
                AND UMSKZ = 'G'.
                if wrbtr_shkzg = 'S'.
      aaaa = wrbtr_note + aaaa.
      elseif wrbtr_shkzg = 'H'.
      bbbb = wrbtr_note + bbbb.
      endif.
    endselect.
    cccc = BBBB - AAAA.
    wa_itab-outs_amt = wa_itab-ac_amt.
    wa_itab-onac_amt = wa_itab-baln_amt - wa_itab-outs_amt.
    onacc = wa_itab-onac_amt.
    wa_itab-vbeln = wac_bsid-vbeln.
    WRITE : /    wa_itab-sno,
             5   wa_itab-kunnr  LEFT-JUSTIFIED HOTSPOT ON,
             16  wa_itab-name1,
             50  wa_itab-bzirk,
             63  wa_itab-ztag1 RIGHT-JUSTIFIED,
             69  CCCC LEFT-JUSTIFIED,
             85  wa_itab-outs_amt,
             105 wa_itab-baln1,
             125 wa_itab-baln2,
             145 wa_itab-baln3,
             165 wa_itab-baln4,
             185 wa_itab-baln5,
             205 wa_itab-baln6,
             225 wa_itab-onac_amt
    MODIFY itab FROM wa_itab.
    HIDE : wa_itab-kunnr , wa_itab-name1.
    ENDLOOP.
    WRITE : / sy-uline.
    TOP-OF-PAGE.
    WRITE :  / 'SNo',
              5  'C-Code',
             16  'Customer Name',
             50  'Region',
             58  ' CR-DAYS',
             72  'SEC.AMOUNT',
             86  'Net O/S Amount',
             107  '0 to', int1e, 'Days',
             125  int2s, 'to', int2e, 'Days',
             145 int3s, 'to', int3e, 'Days',
             165 int4s, 'to', int4e, 'Days',
             185 int5s, 'to', int5e, 'Days',
             210 '>',int5e, 'Days',
             230 'On Account',
             / sy-uline.
            'Invoice Amount',
            80  'Paid Amount',
            100 'Balance Amount',.
    FORM aging_calculation.
    CLEAR : billing_date, credit_days, wa_ctab.
    DATA : shiftdays TYPE tb_days_to_pos.
    CLEAR : shiftdays, overdue_days.
    READ TABLE ctab INTO wa_ctab WITH KEY kunnr = wac_bsid-kunnr.
      billing_date = wac_bsid-fkdat.
      credit_days  = wa_ctab-ztag1.
         overdue_date = billing_date.
      CALL FUNCTION 'FAGL_ITEM_OVERDUE_DAYS'
        EXPORTING
         key_date                =  key_date
        PAY_DATE                =
          due_date                = overdue_date
        CLEAR_DATE              =
       IMPORTING
        OVER_SKONTO1_DAYS       =
         overdue_days            =  overdue_days
        wac_bsid-od_days = overdue_days.
           IF int1 IS INITIAL.
            int1s = 0.
            int1e = 0.
           ELSEIF int1 IS NOT INITIAL.
            int1s = 0.
            int1e = int1.
           ENDIF.
           IF int2 IS INITIAL.
            int2s = 0.
            int2e = 0.
           ELSE.
            int2s = int1 + 1.
            int2e = int2.
           ENDIF.
           IF int3 IS INITIAL.
            int3s = 0.
            int3e = 0.
           ELSE.
            int3s = int2 + 1.
            int3e = int3.
           ENDIF.
           IF int4 IS INITIAL.
            int4s = 0.
            int4e = 0.
           ELSE.
            int4s = int3 + 1.
            int4e = int4.
           ENDIF.
           IF int5 IS INITIAL.
            int5s = 0.
            int5e = 0.
           ELSE.
            int5s = int4 + 1.
            int5e = int5.
           ENDIF.
          IF  wac_bsid-od_days BETWEEN int1s AND int1e.
                  wac_bsid-baln1 =  wac_bsid-age_amt.
          ELSEIF  wac_bsid-od_days BETWEEN int2s AND int2e.
            wac_bsid-baln2 =  wac_bsid-age_amt.
          ELSEIF  wac_bsid-od_days BETWEEN int3s AND int3e.
            wac_bsid-baln3 =  wac_bsid-age_amt.
          ELSEIF  wac_bsid-od_days BETWEEN int4s AND int4e.
            wac_bsid-baln4 =  wac_bsid-age_amt.
          ELSEIF  wac_bsid-od_days BETWEEN int5s AND int5e.
            wac_bsid-baln5 =  wac_bsid-age_amt.
          ELSEIF  wac_bsid-od_days > int5e.
            wac_bsid-baln6 =  wac_bsid-age_amt.
          ENDIF.
    ENDFORM.
    please tell me how can i include blart = dr in this report for that specific period in this report
    every thing except this working fine
    points will be awarded

    Hi,
    In this way you can get the summation dr in the base list.
    LOOP AT ITAB INTO WA_ITAB.
    dr_total = dr_total + WA_ITAB-WRBTR_DR.
    endloop.
    If you want to include  blart = dr in this report for that specific period what you can do is write HIDE inside loop and hide DR
    Later on you can read it directly from the hide table for that specific periord and can make blart = dr.
    Reward some points
    Bye,
    Anomitro

  • Profit Center in Aging Reports

    Dear All,
    I have a requirement of creating an Aging report (Which we have built on AR Data Source, 0FI_AR_4).
    Now, i have a requirement to show the Profit Center drilldown in this report. Profit Center is present in the Base tables (BSID / BSAD (AR EXTRACTOR)) but cannot be used as its not getting populated (due to Document Split Principle in ECC, which only updates data in new GL tables).
    Our understanding is that the details of profit center gets populated in FAGLFLEXA table and not in and of the old FI table (BSEG /BSID / BSAD) which makes it very difficult to pull profit center for Account receivables data.
    We are not sure whether taking GL and AR data in an DSO will solve my problem but thatu2019s the last option we have and the receivables (not aging) break-up can be shown only by Customer ( Like in SAP Report S_AC0_52000887 ).
    Please let us know if you have any suggestions / solutions / inputs for this issue or if we have some wrong understanding here.
    Regards,
    Dennis

    Here goes the code. Enhance your Data source 0FI_AR_4 for profit center. (here ZZPRCTR)
    Unhide the field in RSA6. Then write this code in your CMOD user exit for 0FI_AR_4 extractor.
    DATA: L_SYTABIX LIKE SY-TABIX.
    DATA: WA_DTFIAR_3 LIKE DTFIAR_3.
    DATA: IT_DTFIAR_3 LIKE DTFIAR_3 OCCURS 0 WITH HEADER LINE.
    TYPES: BEGIN OF TP_JOIN,
        RBUKRS TYPE DTFIAR_3-BUKRS,
        FISCPER TYPE DTFIAR_3-FISCPER,
        BELNR TYPE DTFIAR_3-BELNR,
        BUZEI TYPE DTFIAR_3-BUZEI,
        UPOSZ TYPE DTFIAR_3-UPOSZ,
        STATUSPS TYPE DTFIAR_3-STATUSPS,
        KUNNR TYPE DTFIAR_3-KUNNR,
        KKBER TYPE DTFIAR_3-KKBER,
        MABER TYPE DTFIAR_3-MABER,
        KOART TYPE DTFIAR_3-KOART,
        UMSKZ TYPE DTFIAR_3-UMSKZ,
        BLART TYPE DTFIAR_3-BLART,
        BSCHL TYPE DTFIAR_3-BSCHL,
        FISCVAR TYPE DTFIAR_3-FISCVAR,
        BLDAT TYPE DTFIAR_3-BLDAT,
        BUDAT TYPE DTFIAR_3-BUDAT,
        CPUDT TYPE DTFIAR_3-CPUDT,
        AUGDT TYPE DTFIAR_3-AUGDT,
        MADAT TYPE DTFIAR_3-MADAT,
        NETDT TYPE DTFIAR_3-NETDT,
        SK1DT TYPE DTFIAR_3-SK1DT,
        SK2DT TYPE DTFIAR_3-SK2DT,
        ZFBDT TYPE DTFIAR_3-ZFBDT,
        ZBD1T TYPE DTFIAR_3-ZBD1T,
        ZBD2T TYPE DTFIAR_3-ZBD2T,
        ZBD3T TYPE DTFIAR_3-ZBD3T,
        ZBD1P TYPE DTFIAR_3-ZBD1P,
        ZBD2P TYPE DTFIAR_3-ZBD2P,
        LAND1 TYPE DTFIAR_3-LAND1,
        ZLSCH TYPE DTFIAR_3-ZLSCH,
        ZTERM TYPE DTFIAR_3-ZTERM,
        ZLSPR TYPE DTFIAR_3-ZLSPR,
        RSTGR TYPE DTFIAR_3-RSTGR,
        MANSP TYPE DTFIAR_3-MANSP,
        MSCHL TYPE DTFIAR_3-MSCHL,
        MANST TYPE DTFIAR_3-MANST,
        LCURR TYPE DTFIAR_3-LCURR,
        DMSOL TYPE DTFIAR_3-DMSOL,
        DMHAB TYPE DTFIAR_3-DMHAB,
        HSL TYPE DTFIAR_3-DMSHB,
        SKNTO TYPE DTFIAR_3-SKNTO,
        RTCUR TYPE DTFIAR_3-WAERS,
        WRSOL TYPE DTFIAR_3-WRSOL,
        WRHAB TYPE DTFIAR_3-WRHAB,
        TSL TYPE DTFIAR_3-WRSHB,
        SKFBT TYPE DTFIAR_3-SKFBT,
        WSKTO TYPE DTFIAR_3-WSKTO,
        KTOPL TYPE DTFIAR_3-KTOPL,
        HKONT TYPE DTFIAR_3-HKONT,
        SAKNR TYPE DTFIAR_3-SAKNR,
        FILKD TYPE DTFIAR_3-FILKD,
        AUGBL TYPE DTFIAR_3-AUGBL,
        XBLNR TYPE DTFIAR_3-XBLNR,
        REBZG TYPE DTFIAR_3-REBZG,
        REBZJ TYPE DTFIAR_3-REBZJ,
        REBZZ TYPE DTFIAR_3-REBZZ,
        VBELN TYPE DTFIAR_3-VBELN,
        XREF1 TYPE DTFIAR_3-XREF1,
        XREF2 TYPE DTFIAR_3-XREF2,
        XREF3 TYPE DTFIAR_3-XREF3,
        SGTXT TYPE DTFIAR_3-SGTXT,
        XNEGP TYPE DTFIAR_3-XNEGP,
        XARCH TYPE DTFIAR_3-XARCH,
        UMSKS TYPE DTFIAR_3-UMSKS,
        UPDMOD TYPE DTFIAR_3-UPDMOD,
        ZUONR TYPE DTFIAR_3-ZUONR,
        AWTYP TYPE DTFIAR_3-AWTYP,
        AWKEY TYPE DTFIAR_3-AWKEY,
        BSTAT TYPE DTFIAR_3-BSTAT,
        DMBTR TYPE DTFIAR_3-DMBTR,
        DMBE2 TYPE DTFIAR_3-DMBE2,
        DMBE3 TYPE DTFIAR_3-DMBE3,
        GJAHR TYPE DTFIAR_3-GJAHR,
        HWAE2 TYPE DTFIAR_3-HWAE2,
        HWAE3 TYPE DTFIAR_3-HWAE3,
        MONAT TYPE DTFIAR_3-MONAT,
        PROJK TYPE DTFIAR_3-PROJK,
        DRCRK TYPE DTFIAR_3-SHKZG,
        WRBTR TYPE DTFIAR_3-WRBTR,
        PRCTR TYPE DTFIAR_3-ZZPRCTR,
        END OF TP_JOIN.
    DATA: IT_JOIN TYPE TP_JOIN OCCURS 0 WITH HEADER LINE.
    FI_AR_4 data source enhancement for Profit ctr.
      WHEN '0FI_AR_4'.
        MOVE C_T_DATA[] TO IT_DTFIAR_3[].
        SELECT
        BELNR
        BUZEI
        BUDAT
        RBUKRS
        HSL
        GJAHR
        TSL
        PRCTR
        RTCUR
        DRCRK
        FROM FAGLFLEXA INTO CORRESPONDING FIELDS OF TABLE IT_JOIN
        FOR ALL ENTRIES IN IT_DTFIAR_3 WHERE BELNR = IT_DTFIAR_3-BELNR
                                        AND  BUZEI = IT_DTFIAR_3-BUZEI
                                        AND  GJAHR = IT_DTFIAR_3-GJAHR
                                        AND  RBUKRS = IT_DTFIAR_3-BUKRS.
       LOOP AT IT_JOIN.
       L_SYTABIX = SY-TABIX.
        READ TABLE IT_DTFIAR_3 WITH KEY BELNR = IT_JOIN-BELNR
                                    BUZEI = IT_JOIN-BUZEI
                                    GJAHR = IT_JOIN-GJAHR
                                    BUKRS = IT_JOIN-RBUKRS.
      IF SY-SUBRC = 0.
        IT_JOIN-AUGBL = IT_DTFIAR_3-AUGBL.
        IT_JOIN-AUGDT = IT_DTFIAR_3-AUGDT.
        IT_JOIN-AWKEY = IT_DTFIAR_3-AWKEY.
        IT_JOIN-AWTYP = IT_DTFIAR_3-AWTYP.
        IT_JOIN-BELNR = IT_DTFIAR_3-BELNR.
        IT_JOIN-BLART = IT_DTFIAR_3-BLART.
        IT_JOIN-BLDAT = IT_DTFIAR_3-BLDAT.
        IT_JOIN-BSCHL = IT_DTFIAR_3-BSCHL.
        IT_JOIN-BSTAT = IT_DTFIAR_3-BSTAT.
        IT_JOIN-BUDAT = IT_DTFIAR_3-BUDAT.
        IT_JOIN-BUZEI = IT_DTFIAR_3-BUZEI.
         IT_JOIN-CPUDT = IT_DTFIAR_3-CPUDT.
         IT_JOIN-DMBE2 = IT_DTFIAR_3-DMBE2.
         IT_JOIN-DMBE3 = IT_DTFIAR_3-DMBE3.
         IT_JOIN-DMBTR = IT_JOIN-HSL.
         IF IT_DTFIAR_3-SHKZG = 'H'.
           IT_JOIN-DMHAB = IT_JOIN-HSL.
         ELSEIF IT_DTFIAR_3-SHKZG = 'S'.
            IT_JOIN-DMSOL = IT_JOIN-HSL.
         ENDIF.
         IT_JOIN-FILKD = IT_DTFIAR_3-FILKD.
         IT_JOIN-FISCPER = IT_DTFIAR_3-FISCPER.
         IT_JOIN-FISCVAR = IT_DTFIAR_3-FISCVAR.
         IT_JOIN-GJAHR = IT_DTFIAR_3-GJAHR.
         IT_JOIN-HKONT = IT_DTFIAR_3-HKONT.
         IT_JOIN-HWAE2 = IT_DTFIAR_3-HWAE2.
         IT_JOIN-HWAE3 = IT_DTFIAR_3-HWAE3.
         IT_JOIN-KKBER = IT_DTFIAR_3-KKBER.
         IT_JOIN-KOART = IT_DTFIAR_3-KOART.
         IT_JOIN-KTOPL = IT_DTFIAR_3-KTOPL.
         IT_JOIN-KUNNR = IT_DTFIAR_3-KUNNR.
         IT_JOIN-LAND1 = IT_DTFIAR_3-LAND1.
         IT_JOIN-LCURR = IT_DTFIAR_3-LCURR.
         IT_JOIN-MABER = IT_DTFIAR_3-MABER.
         IT_JOIN-MADAT = IT_DTFIAR_3-MADAT.
         IT_JOIN-MANSP = IT_DTFIAR_3-MANSP.
         IT_JOIN-MANST = IT_DTFIAR_3-MANST.
         IT_JOIN-MONAT = IT_DTFIAR_3-MONAT.
         IT_JOIN-MSCHL = IT_DTFIAR_3-MSCHL.
         IT_JOIN-NETDT = IT_DTFIAR_3-NETDT.
         IT_JOIN-PROJK = IT_DTFIAR_3-PROJK.
         IT_JOIN-REBZG = IT_DTFIAR_3-REBZG.
         IT_JOIN-REBZJ = IT_DTFIAR_3-REBZJ.
         IT_JOIN-REBZZ = IT_DTFIAR_3-REBZZ.
         IT_JOIN-RSTGR = IT_DTFIAR_3-RSTGR.
         IT_JOIN-SAKNR = IT_DTFIAR_3-SAKNR.
         IT_JOIN-SGTXT = IT_DTFIAR_3-SGTXT.
         IT_JOIN-SK1DT = IT_DTFIAR_3-SK1DT.
         IT_JOIN-SK2DT = IT_DTFIAR_3-SK2DT.
         IT_JOIN-SKFBT = IT_DTFIAR_3-SKFBT.
         IT_JOIN-SKNTO = IT_DTFIAR_3-SKNTO.
         IT_JOIN-STATUSPS = IT_DTFIAR_3-STATUSPS.
         IT_JOIN-UMSKS = IT_DTFIAR_3-UMSKS.
         IT_JOIN-UMSKZ = IT_DTFIAR_3-UMSKZ.
         IT_JOIN-UPDMOD = IT_DTFIAR_3-UPDMOD.
         IT_JOIN-UPOSZ = IT_DTFIAR_3-UPOSZ.
         IT_JOIN-VBELN = IT_DTFIAR_3-VBELN.
         IT_JOIN-WRBTR = IT_JOIN-TSL.
         IF IT_DTFIAR_3-SHKZG = 'H'.
              IT_JOIN-WRHAB = IT_JOIN-TSL.
         ELSEIF  IT_DTFIAR_3-SHKZG = 'S'.
              IT_JOIN-WRSOL = IT_JOIN-TSL.
         ENDIF.
         IT_JOIN-WSKTO = IT_DTFIAR_3-WSKTO.
         IT_JOIN-XARCH = IT_DTFIAR_3-XARCH.
         IT_JOIN-XBLNR = IT_DTFIAR_3-XBLNR.
         IT_JOIN-XNEGP = IT_DTFIAR_3-XNEGP.
         IT_JOIN-XREF1 = IT_DTFIAR_3-XREF1.
         IT_JOIN-XREF2 = IT_DTFIAR_3-XREF2.
         IT_JOIN-XREF3 = IT_DTFIAR_3-XREF3.
         IT_JOIN-ZBD1P = IT_DTFIAR_3-ZBD1P.
         IT_JOIN-ZBD1T = IT_DTFIAR_3-ZBD1T.
         IT_JOIN-ZBD2P = IT_DTFIAR_3-ZBD2P.
         IT_JOIN-ZBD2T = IT_DTFIAR_3-ZBD2T.
         IT_JOIN-ZBD3T = IT_DTFIAR_3-ZBD3T.
         IT_JOIN-ZFBDT = IT_DTFIAR_3-ZFBDT.
         IT_JOIN-ZLSCH = IT_DTFIAR_3-ZLSCH.
         IT_JOIN-ZLSPR = IT_DTFIAR_3-ZLSPR.
         IT_JOIN-ZTERM = IT_DTFIAR_3-ZTERM.
         IT_JOIN-ZUONR = IT_DTFIAR_3-ZUONR.
      ENDIF.
        MODIFY IT_JOIN FROM IT_JOIN index L_SYTABIX.
       ENDLOOP.
      MOVE IT_JOIN[] to C_T_DATA[].

  • Link between invoice no and payment clearing document no

    Hi sap gurus,
    in a reoprt i have to show the payment receive date against the invoice no. i can have the invoice no by customer no (KUNNR) and date range. now i am facing problem how to link invoice document no with payment clearing document no. Because while receiving payment from customer (t code F-28) we are receiving against a invoice. But i checked in BSEG,BSID BSAD but nowhere i was able to track the linkage. Please help.
    regards,
    BKR

    In billing document at header level,  you can see two fields, viz.
    a)  XBLNR   Reference Document Number  and
    b)  ZUONR   Assignment number
    These two fields you can see in FBL5N.  Whatever copy control you set in VTFL at header level for these two fields, based on that values will be populated in billing document which will then be passed on to FI just for information.
    But these two fields are not stored in any table but in structure.  However, you can check in BKPF with field XBLNR which will have link between VBRK (billing document ) and BKPF (Accounting document)
    thanks
    G. Lakshmipathi

  • Please help---give me the logic(very-2 urgent)

    Hi Experts,,
    i am struck in a very difficult situation.
    actually its a ageing report,the problem is that when i run this report for a single customer it shows the correct output.
    but when i run it for a range suppose for 0610000021 to 0610000024 it starts showing me the the wrong report although i have debugged it and found the problem that instead of picking data for a single customer at a time it picks for all customer in the loop.but i was not able to find out to exit it wen it it encounters a different customer and starts the outer loop again with different customer.please help as this has made my life hell..........plz help. i am attaching the code where the problem is please suggest.......
    loop at ctab into wa_ctab. (for customer)
    loop at itab_bb where shkzg <> 'C' and augdt > key_date and budat <= key_date and kunnr = wa_ctab-kunnr.
    if itab_bb-budat between cc AND d.
    amount214 = amount214 + itab_bb-wrbtr + itab_bb-bbb.
    endif.
    if itab_bb-budat between a AND b.
    amount216 = amount216 + itab_bb-wrbtr + itab_bb-bbb.
    endif.
    if itab_bb-budat between e AND f.
    amount210 = amount210 + itab_bb-wrbtr + itab_bb-bbb.
    endif.
    if itab_bb-budat between g AND h.
    amount218 = amount218 + itab_bb-wrbtr + itab_bb-bbb.
    endif.
    if itab_bb-budat  BETWEEN gg AND hh.
    amount212 = amount212 + itab_bb-wrbtr + itab_bb-bbb.
    endif.
    if itab_bb-budat <= j.
    amt212 = amt212 + itab_bb-wrbtr + itab_bb-bbb.
    endif.
    endloop.
    (wen i use exit here it only run onece and shows the right data for the first customer encounter)
    endloop.

    attaching u the whole code please tell wht changes should i make
    *& Report  ZAGING1
    REPORT  zage  NO STANDARD PAGE HEADING LINE-SIZE 250.
    TABLES : bseg, kna1 ,bsad, bsid, vbrk.
    SELECT-OPTIONS: s_kunnr FOR kna1-kunnr OBLIGATORY.
    PARAMETERS : key_date TYPE bldat OBLIGATORY.
    PARAMETERS : ccode    TYPE bukrs OBLIGATORY.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 01(30) text-001 FOR FIELD int1.
    SELECTION-SCREEN POSITION POS_LOW.
    PARAMETERS: int1(3) TYPE n DEFAULT '030'.
    PARAMETERS: int2(3) TYPE n DEFAULT '060'.
    PARAMETERS: int3(3) TYPE n DEFAULT '090'.
    PARAMETERS: int4(3) TYPE n DEFAULT '120'.
    PARAMETERS: int5(3) TYPE n DEFAULT '150'.
    SELECTION-SCREEN END OF LINE.
    DATA : onacc LIKE bsid-wrbtr,
    ind TYPE i.
    TYPES: BEGIN OF cust,
            kunnr TYPE kna1-kunnr,
            adrnr TYPE kna1-adrnr,
            name1 TYPE kna1-name1,
            wrbtr TYPE bseg-wrbtr,
            bzirk TYPE knvv-bzirk,
            zterm TYPE knvv-zterm,
            ztag1 TYPE t052-ztag1,
           END OF cust.
    data : amount208 like bsad-wrbtr.
    TYPES: BEGIN OF invt,
            kunnr TYPE kna1-kunnr,
            kunrg TYPE kna1-kunnr,
            wrbtr TYPE bseg-wrbtr,
            invamt TYPE bseg-wrbtr,
            name1 TYPE kna1-name1,
            vbeln TYPE vbrk-vbeln,
            belnr TYPE bseg-belnr,
           END OF invt.
    TYPES : BEGIN OF ytab,
              kunnr TYPE bsid-kunnr,
              wrbtr TYPE bsid-wrbtr,
              sinv_amt TYPE bsid-wrbtr,
              paid_amt TYPE bsid-wrbtr,
              adj_amt   TYPE bsid-wrbtr,
              cncl_amt TYPE bsid-wrbtr,
              baln_amt TYPE bsid-wrbtr,
              onac_amt TYPE bsid-wrbtr,
              ac_amt   TYPE bsid-wrbtr,
              age_amt TYPE bsid-wrbtr,
              wrbtr_rvh TYPE bsid-wrbtr,
              wrbtr_rvs TYPE bsid-wrbtr,
              wrbtr_obh TYPE bsid-wrbtr,
              wrbtr_obs TYPE bsid-wrbtr,
              wrbtr_dg TYPE bsid-wrbtr,
              wrbtr_dr TYPE bsid-wrbtr,
              wrbtr_dzs TYPE bsid-wrbtr,
              wrbtr_dzh TYPE bsid-wrbtr,
              wrbtr_sas TYPE bsid-wrbtr,
              wrbtr_sah TYPE bsid-wrbtr,
              wrbtr_abs TYPE bsid-wrbtr,
              wrbtr_abh TYPE bsid-wrbtr,
              wrbtr_DAs TYPE bsid-wrbtr,
              wrbtr_DAh TYPE bsid-wrbtr,
              UMSKZ TYPE BSID-UMSKZ,
              baln1 TYPE bsid-wrbtr,
              baln2 TYPE bsid-wrbtr,
              baln3 TYPE bsid-wrbtr,
              baln4 TYPE bsid-wrbtr,
              baln5 TYPE bsid-wrbtr,
              baln6 TYPE bsid-wrbtr,
              blart TYPE bsid-blart,
              vbeln TYPE bsid-vbeln,
              fkdat TYPE vbrk-fkdat,
              belnr TYPE bsid-belnr,
              rebzg TYPE bsid-rebzg,
              shkzg TYPE bsid-shkzg,
              zuonr TYPE bsid-zuonr,
              od_days(4) TYPE n,
            END OF ytab.
    DATA :  aa(3) TYPE n,
            bb(3) TYPE n,
            dd(3) TYPE n,
            ee(3) TYPE n,
           ind TYPE i,
            it TYPE i.
    TYPES : BEGIN OF ftab,
              kunnr TYPE bsid-kunnr,
              name1 TYPE kna1-name1,
             WRBTR TYPE BSID-WRBTR,
              sinv_amt TYPE bsid-wrbtr,
              paid_amt TYPE bsid-wrbtr,
              adj_amt   TYPE bsid-wrbtr,
              cncl_amt TYPE bsid-wrbtr,
              baln_amt TYPE bsid-wrbtr,
              ac_amt   TYPE bsid-wrbtr,
              onac_amt TYPE bsid-wrbtr,
              outs_amt TYPE bsid-wrbtr,
              age_amt TYPE bsid-wrbtr,
              wrbtr_rvh TYPE bsid-wrbtr,
              wrbtr_rvs TYPE bsid-wrbtr,
              wrbtr_obh TYPE bsid-wrbtr,
              wrbtr_obs TYPE bsid-wrbtr,
              wrbtr_dg TYPE bsid-wrbtr,
              wrbtr_dr TYPE bsid-wrbtr,
              wrbtr_dzs TYPE bsid-wrbtr,
              wrbtr_dzh TYPE bsid-wrbtr,
              wrbtr_sas TYPE bsid-wrbtr,
              wrbtr_sah TYPE bsid-wrbtr,
              wrbtr_abs TYPE bsid-wrbtr,
              wrbtr_abh TYPE bsid-wrbtr,
              wrbtr_DAs TYPE bsid-wrbtr,
              wrbtr_DAh TYPE bsid-wrbtr,
              UMSKZ TYPE BSID-UMSKZ,
              baln1 TYPE bsid-wrbtr,
              baln2 TYPE bsid-wrbtr,
              baln3 TYPE bsid-wrbtr,
              baln4 TYPE bsid-wrbtr,
              baln5 TYPE bsid-wrbtr,
              baln6 TYPE bsid-wrbtr,
              blart TYPE bsid-blart,
              vbeln TYPE bsid-vbeln,
              belnr TYPE bsid-belnr,
              rebzg TYPE bsid-rebzg,
              shkzg TYPE bsid-shkzg,
              bzirk TYPE knvv-bzirk,
              zterm TYPE knvv-zterm,
              ztag1 TYPE t052-ztag1,
              zuonr TYPE bsid-zuonr,
              od_days(4) TYPE n,
              sno(3) TYPE n,
            END OF ftab.
    data : wrbtr_note like bsid-wrbtr.
            DATA : BEGIN OF itab1 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
            xblnr LIKE bsid-xblnr,
            abc LIKE bsid-wrbtr,
            aaa LIKE bsid-wrbtr,
            sgtxt LIKE bsid-sgtxt,
            bcd LIKE bsid-wrbtr,
            bbb LIKE bsid-wrbtr,
            flag TYPE c,
            flag1(3) TYPE c,
            flag2(15) TYPE c,
            bldat like bsid-bldat,
            zuonr like bsid-zuonr,
            umskz like bsid-umskz,
            END OF itab1.
            DATA : BEGIN OF itab2 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
           txt50 LIKE skat-txt50,  " GL A/C TEXT
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
            xblnr LIKE bsid-xblnr,
            sgtxt LIKE bsid-sgtxt,
            abc LIKE bsid-wrbtr,
            aaa LIKE bsid-wrbtr,
            bcd LIKE bsid-wrbtr,
            bbb LIKE bsid-wrbtr,
            flag TYPE c,
            flag1(3) TYPE c,
            flag2(15) TYPE c,
            bldat like bsid-bldat,
            GJAHR like bsid-GJAHR,
            zuonr like bsid-zuonr,
            umskz like bsid-umskz,
            END OF itab2.
    DATA : BEGIN OF itab3 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
            xblnr LIKE bsid-xblnr,
            abc LIKE bsid-wrbtr,
            aaa LIKE bsid-wrbtr,
            bcd LIKE bsid-wrbtr,
            bbb LIKE bsid-wrbtr,
            flag TYPE c,
            flag1(3) TYPE c,
            flag2(15) TYPE c,
            sgtxt LIKE bsid-sgtxt,
            bldat like bsid-bldat,
                    zuonr like bsid-zuonr,
                    umskz like bsid-umskz,
            END OF itab3.
    DATA : BEGIN OF itab4 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
           txt50 LIKE skat-txt50,  " GL A/C TEXT
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
            xblnr LIKE bsid-xblnr,
            aaa LIKE bsid-wrbtr,
            abc LIKE bsid-wrbtr,
            bbb LIKE bsid-wrbtr,
            bcd LIKE bsid-wrbtr,
            flag TYPE c,
            flag1(3) TYPE c,
            flag2(15) TYPE c,
            sgtxt LIKE bsid-sgtxt,
            bldat like bsid-bldat,
                    zuonr like bsid-zuonr,
                    umskz like bsid-umskz,
            END OF itab4.
    DATA : BEGIN OF itab5 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
           txt50 LIKE skat-txt50,  " GL A/C TEXT
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
            xblnr LIKE bsid-xblnr,
            abc LIKE bsid-wrbtr,
            aaa LIKE bsid-wrbtr,
            bcd LIKE bsid-wrbtr,
            bbb LIKE bsid-wrbtr,
            flag TYPE c,
            flag1(3) TYPE c,
            flag2(15) TYPE c,
            sgtxt LIKE bsid-sgtxt,
            bldat like bsid-bldat,
                    zuonr like bsid-zuonr,
                    umskz like bsid-umskz,
            END OF itab5.
    data : amount207 like bsad-wrbtr,
            amount210 like bsad-wrbtr,
            amount212 like bsad-wrbtr,
            amount213 like bsad-wrbtr,
            amount214 like bsad-wrbtr,
            amount215 like bsad-wrbtr,
            amount216 like bsad-wrbtr,
            amount217 like bsad-wrbtr,
            amount218 like bsad-wrbtr,
            amt like bsad-wrbtr,
            amt1 like bsad-wrbtr,
            amt212 like bsad-wrbtr,
            amt213 like bsad-wrbtr,
            amount219 like bsad-wrbtr.
    DATA : BEGIN OF itab6 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
           txt50 LIKE skat-txt50,  " GL A/C TEXT
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
            xblnr LIKE bsid-xblnr,
            sgtxt LIKE bsid-sgtxt,
            bldat like bsid-bldat,
            umskz like bsid-umskz,
            abc LIKE bsid-wrbtr,
            aaa LIKE bsid-wrbtr,
            bcd LIKE bsid-wrbtr,
            bbb LIKE bsid-wrbtr,
            flag TYPE c,
            flag1(3) TYPE c,
            flag2(15) TYPE c,
            xzahl like bsid-xzahl,
            rebzg like bsid-rebzg,
    zuonr like bsid-zuonr,
            END OF itab6.
    data : dr_deduct like bsid-wrbtr.
    DATA : a TYPE sy-datum,
           b TYPE sy-datum,
           cc TYPE sy-datum,
           d TYPE sy-datum,
           e TYPE sy-datum,
           f TYPE sy-datum,
           g TYPE sy-datum,
           h TYPE sy-datum,
           i TYPE sy-datum,
           gg TYPE sy-datum,
           hh TYPE sy-datum,
           j TYPE sy-datum.
    DATA : BEGIN OF itab7 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
           txt50 LIKE skat-txt50,  " GL A/C TEXT
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
            xblnr LIKE bsid-xblnr,
            sgtxt LIKE bsid-sgtxt,
            bldat like bsid-bldat,
            umskz like bsid-umskz,
            END OF itab7.
    DATA : BEGIN OF itab8 OCCURS 0,
            hkont LIKE bsid-hkont,   " General Ledger Account
            kunnr LIKE bsid-kunnr,   " Customer Number 1
           txt50 LIKE skat-txt50,  " GL A/C TEXT
            dmbtr LIKE bsid-dmbtr,  " Amount
            shkzg LIKE bsid-shkzg,  " Debit/Credit Indication
            budat LIKE bsid-budat,  " Posting date
            kostl LIKE bsid-kostl,  " Cost center
            opnbl LIKE bsid-dmbtr,  " Opening Balance Amount
            clsbl LIKE bsid-dmbtr,  " Closing balnce Amount
            vbeln LIKE bsid-vbeln,
            blart LIKE bsid-blart,
            wrbtr LIKE bsid-wrbtr,
            bukrs LIKE bsid-bukrs,
            belnr LIKE bsid-belnr,
            xblnr LIKE bsid-xblnr,
            abc LIKE bsid-wrbtr,
            aaa LIKE bsid-wrbtr,
            bcd LIKE bsid-wrbtr,
            bbb LIKE bsid-wrbtr,
            flag TYPE c,
            flag1(3) TYPE c,
            flag2(15) TYPE c,
            sgtxt LIKE bsid-sgtxt,
            bldat like bsid-bldat,
            zuonr like bsid-zuonr,
            umskz like bsid-umskz,
            END OF itab8.
    DATA : BEGIN OF itab_b OCCURS 0,
           bukrs like bsad-bukrs,
           kunnr like bsad-kunnr,
           wrbtr like bsad-wrbtr,
           belnr like bsad-belnr,
           AUGDT like bsad-AUGDT,
           AUGBL like bsad-AUGBL,
           budat like bsad-budat,
           shkzg like bsad-shkzg,
           blart like bsad-blart,
           vbeln like bsad-vbeln,
           bldat like bsad-bldat,
           abc LIKE bsad-wrbtr,
           aaa LIKE bsad-wrbtr,
           bcd LIKE bsad-wrbtr,
           bbb LIKE bsad-wrbtr,
           flag TYPE c,
           flag1(3) TYPE c,
           flag2(15) TYPE c,
           END OF itab_b.
    DATA : BEGIN OF itab_bb OCCURS 0,
           bukrs like bsad-bukrs,
           kunnr like bsad-kunnr,
           wrbtr like bsad-wrbtr,
           belnr like bsad-belnr,
           AUGDT like bsad-AUGDT,
           AUGBL like bsad-AUGBL,
           budat like bsad-budat,
           shkzg like bsad-shkzg,
           blart like bsad-blart,
           vbeln like bsad-vbeln,
           bldat like bsad-bldat,
           abc LIKE bsad-wrbtr,
           aaa LIKE bsad-wrbtr,
           bcd LIKE bsad-wrbtr,
           bbb LIKE bsad-wrbtr,
           flag TYPE c,
           flag1(3) TYPE c,
           flag2(15) TYPE c,
           END OF itab_bb.
    DATA : BEGIN OF itab_rv OCCURS 0,
           bukrs like bsid-bukrs,
           kunnr like bsid-kunnr,
           wrbtr like bsid-wrbtr,
           belnr like bsid-belnr,
           budat like bsid-budat,
           shkzg like bsid-shkzg,
           blart like bsid-blart,
           vbeln like bsid-vbeln,
           bldat like bsid-bldat,
           abc LIKE bsid-wrbtr,
           aaa LIKE bsid-wrbtr,
           bcd LIKE bsid-wrbtr,
           bbb LIKE bsid-wrbtr,
           flag TYPE c,
           flag1(3) TYPE c,
           flag2(15) TYPE c,
           END OF itab_rv.
    DATA : BEGIN OF itab_da OCCURS 0,
           bukrs like bsid-bukrs,
           kunnr like bsid-kunnr,
           wrbtr like bsid-wrbtr,
           belnr like bsid-belnr,
           budat like bsid-budat,
           shkzg like bsid-shkzg,
           blart like bsid-blart,
           vbeln like bsid-vbeln,
           bldat like bsid-bldat,
           abc LIKE bsid-wrbtr,
           aaa LIKE bsid-wrbtr,
           bcd LIKE bsid-wrbtr,
           bbb LIKE bsid-wrbtr,
           flag TYPE c,
           flag1(3) TYPE c,
           flag2(15) TYPE c,
           END OF itab_da.
    DATA : wa_ctab TYPE cust.
    DATA : wa_btab TYPE invt.
    DATA : wa_bsid type bsid.
    DATA : wai_bsid TYPE ytab.
    DATA : wac_bsid TYPE ytab.        " CREDIT - INVOICE
    DATA : wad_bsid TYPE ytab.        " DEBIT  - PAYMENT
    DATA : wao_bsid TYPE ytab.        " ON ACCOUNT
    DATA : wa_itab  TYPE ftab.
    DATA : ctab TYPE cust OCCURS 0.
    DATA : btab TYPE invt OCCURS 0.
    DATA : it_bsid type bsid OCCURS 0.
    DATA : iti_bsid TYPE ytab OCCURS 0.        " CANCELLED INVOICES
    DATA : itc_bsid TYPE ytab OCCURS 0.        " CREDIT - INVOICE
    DATA : itd_bsid TYPE ytab OCCURS 0.        " DEBIT  - PAYMENT
    DATA : ito_bsid TYPE ytab OCCURS 0.        " ON ACCOUNT
    DATA : itab     TYPE ftab OCCURS 0 with header line.        " OUTPUT
    DATA : inv_amt LIKE bseg-wrbtr.
    DATA : paid_amt LIKE bseg-wrbtr.
    DATA : cncl_amt LIKE bseg-wrbtr.
    DATA : adj_amt LIKE bseg-wrbtr.
    DATA : billing_date LIKE sy-datum.
    DATA : overdue_date LIKE sy-datum.
    DATA : overdue_days LIKE rfposx-verzn.
    DATA : credit_days(4) TYPE n.
    DATA : int1s(3) TYPE n VALUE 0,
           int1e(3) TYPE n VALUE 0,
           int2s(3) TYPE n VALUE 0,
           int2e(3) TYPE n VALUE 0,
           int3s(3) TYPE n VALUE 0,
           int3e(3) TYPE n VALUE 0,
           int4s(3) TYPE n VALUE 0,
           int4e(3) TYPE n VALUE 0,
           int5s(3) TYPE n VALUE 0,
           int5e(3) TYPE n VALUE 0,
           int TYPE i,
           slno(5)  TYPE n VALUE 0.
    CLEAR : INV_AMT, CTAB, BTAB, WA_ITAB, WAC_BSID, WAD_BSID, WAO_BSID, itab_bb , amount210 , amount212 ,amount214 , amount216 , amount218.
    REFRESH : CTAB, BTAB,ITAB, ITC_BSID, ITD_BSID, ITO_BSID , itab_bb .
    START-OF-SELECTION.
    cc = key_date - int1.
    d = key_date.
    aa = int1 + 1.
    a = key_date - int2.
    b = cc - 1.
    bb = int2 + 1.
    e = key_date - int3.
    f = a - 1.
    dd = int3 + 1.
    g = key_date - int4.
    h = e - 1.
    dd = int4 + 1.
    gg = key_date - int5.
    hh = g - 1.
    ee = int5 + 1.
    j = key_date - ee.
    SELECT KUNNR NAME1 ADRNR FROM KNA1 INTO CORRESPONDING FIELDS OF WA_CTAB WHERE KUNNR IN S_KUNNR.
      SELECT SINGLE BZIRK ZTERM FROM KNVV INTO (WA_CTAB-BZIRK, WA_CTAB-ZTERM) WHERE KUNNR = WA_CTAB-KUNNR.
      SELECT SINGLE ZTAG1 FROM T052 INTO WA_CTAB-ZTAG1 WHERE ZTERM = WA_CTAB-ZTERM.
    APPEND WA_CTAB TO CTAB.
    ENDSELECT.
    hide wa_ctab.
    select bukrs kunnr wrbtr belnr AUGDT AUGBL budat shkzg blart vbeln bldat from bsad into
    corresponding fields of table itab_bb where kunnr in s_kunnr and augdt > key_date and budat <= key_date.
    *if sy-subrc = 0.
    *loop at itab_bb.
    *write : / 'yes' , itab_bb-wrbtr , itab_bb-kunnr.
    *endloop.
    *else.
    *write : / 'no'.
    *endif.
    loop at itab_bb.
         IF itab_bb-blart = 'RV'.
                itab_bb-flag2 = 'INVOICE'.
                MODIFY itab_bb.
          ELSEIF itab_bb-blart = 'DR'.
                itab_bb-flag2 = 'DR-NOTE'.
                MODIFY itab_bb.
          ELSEIF itab_bb-blart = 'OB'.
                itab_bb-flag2 = 'OPN-BAL'.
                MODIFY itab_bb.
          ELSEIF itab_bb-blart = 'DG'.
                itab_bb-flag2 = 'CR-NOTE'.
                MODIFY itab_bb.
          ELSEIF itab_bb-blart = 'DZ'.
                itab_bb-flag2 = 'RECEIPTS'.
                MODIFY itab_bb.
          ELSEIF itab_bb-blart = 'SA'.
                itab_bb-flag2 = 'JOURNAL'.
                MODIFY itab_bb.
          ELSEIF itab_bb-blart = 'DA'.
                itab_bb-flag2 = 'CREDIT'.
                MODIFY itab_bb.
          ELSEIF itab_bb-blart = 'AB'.
                itab_bb-flag2 = 'ADJUSTMENTS'.
                MODIFY itab_bb.
          ENDIF.
                IF itab_bb-shkzg = 'S'.
                itab_bb-shkzg = 'D'.
                MODIFY itab_bb.
                else.
                itab_bb-shkzg = 'C'.
                MODIFY itab_bb.
                ENDIF.
                endloop.
                loop at itab_bb.
                ind  = sy-tabix.
      IF itab_bb-vbeln IS NOT INITIAL.
    SELECT   wrbtr FROM bsad INTO itab_bb-abc WHERE vbeln = itab_bb-vbeln and augdt > key_date and budat <= key_date and kunnr = itab_bb-kunnr.
    itab_bb-aaa = itab_bb-aaa + itab_bb-abc.
    ENDSELECT.
      ENDIF.
          IF itab_bb-vbeln IS NOT INITIAL.
    SELECT   wrbtr FROM bsid INTO itab_bb-abc WHERE vbeln = itab_bb-vbeln  and budat <= key_date  and kunnr = itab_bb-kunnr and blart = 'DZ' .
    itab_bb-aaa = itab_bb-aaa + itab_bb-abc.
    ENDSELECT.
    endif.
      IF itab_bb-vbeln IS NOT INITIAL.
    SELECT SINGLE  wrbtr FROM bsad INTO itab_bb-bcd WHERE vbeln = itab_bb-vbeln and augdt > key_date and budat <= key_date and kunnr = itab_bb-kunnr.
    itab_bb-bbb = itab_bb-bcd - itab_bb-aaa.
    ENDIF.
       IF itab_bb-vbeln IS INITIAL.
    SELECT SINGLE  wrbtr FROM bsad INTO itab_bb-bcd WHERE belnr = itab_bb-belnr and augdt > key_date and budat <= key_date and kunnr = itab_bb-kunnr.
    itab_bb-bbb = itab_bb-bcd - itab_bb-aaa.
    ENDIF.
    MODIFY itab_bb INDEX ind.
    endloop.
    *loop at ctab into wa_ctab.
    sort itab_bb by kunnr.
    data xyz like kna1-kunnr.
    loop at itab_bb where shkzg <> 'C' and augdt > key_date and budat <= key_date.
    amt = amt + itab_bb-bbb.
    endloop.
    loop at itab_bb where shkzg = 'C'. " ON ACCOUNT
    amount207 = amount207 + itab_bb-wrbtr.
    endloop.
    loop at ctab into wa_ctab.
    loop at itab_bb where shkzg <> 'C' and augdt > key_date and budat <= key_date and kunnr = wa_ctab-kunnr.
    if itab_bb-budat between cc AND d.
    amount214 = amount214 + itab_bb-wrbtr + itab_bb-bbb.
    endif.
    if itab_bb-budat between a AND b.
    amount216 = amount216 + itab_bb-wrbtr + itab_bb-bbb.
    endif.
    if itab_bb-budat between e AND f.
    amount210 = amount210 + itab_bb-wrbtr + itab_bb-bbb.
    endif.
    if itab_bb-budat between g AND h.
    amount218 = amount218 + itab_bb-wrbtr + itab_bb-bbb.
    endif.
    if itab_bb-budat  BETWEEN gg AND hh.
    amount212 = amount212 + itab_bb-wrbtr + itab_bb-bbb.
    endif.
    if itab_bb-budat <= j.
    amt212 = amt212 + itab_bb-wrbtr + itab_bb-bbb.
    endif.
    endloop.
    endloop.
    SELECT * FROM BSID INTO TABLE IT_BSID FOR ALL ENTRIES IN CTAB WHERE KUNNR = CTAB-KUNNR
                                                                  AND   BuDAT =< KEY_DATE
                                                                 AND   BUKRS = CCODE.
    SORT IT_BSID BY KUNNR.
    LOOP AT IT_BSID INTO WA_BSID.
      IF  WA_BSID-BLART = 'RV' AND WA_BSID-SHKZG = 'S' OR
          WA_BSID-BLART = 'OB' AND WA_BSID-SHKZG = 'S' or
          wa_bsid-blart = 'DR'.
          WAC_BSID-KUNNR = WA_BSID-KUNNR.
          WAC_BSID-BLART = WA_BSID-BLART.
          WAC_BSID-VBELN = WA_BSID-VBELN.
          WAC_BSID-BELNR = WA_BSID-BELNR.
          WAC_BSID-REBZG = WA_BSID-REBZG.
          WAC_BSID-WRBTR = WA_BSID-WRBTR.
          WAC_BSID-ZUONR = WA_BSID-ZUONR.
          WAC_BSID-SHKZG = WA_BSID-SHKZG.
    *write : / WAC_BSID-WRBTR , wac_bsid-blart ,WAC_BSID-VBELN.
          IF WAC_BSID-VBELN IS NOT INITIAL.
             SELECT SINGLE FKDAT FROM VBRK INTO WAC_BSID-FKDAT WHERE VBELN = WAC_BSID-VBELN.
          ELSEIF WAC_BSID-VBELN IS INITIAL.
            IF WAC_BSID-BELNR IS NOT INITIAL.
             SELECT SINGLE BuDAT FROM BSID INTO WAC_BSID-FKDAT WHERE BELNR = WAC_BSID-BELNR.
            ENDIF.
          ENDIF.
       WAC_BSID = WA_BSID.
        APPEND WAC_BSID TO ITC_BSID.
    ELSEIF  WA_BSID-BLART = 'DZ' AND WA_BSID-VBELN <> ' '.
      ELSEIF  WA_BSID-BLART = 'DZ' .
       WAD_BSID = WA_BSID.
        WAD_BSID-KUNNR = WA_BSID-KUNNR.
        WAD_BSID-BLART = WA_BSID-BLART.
        WAD_BSID-VBELN = WA_BSID-VBELN.
        WAD_BSID-BELNR = WA_BSID-BELNR.
        WAD_BSID-REBZG = WA_BSID-REBZG.
        WAD_BSID-WRBTR = WA_BSID-WRBTR.
        WAD_BSID-ZUONR = WA_BSID-ZUONR.
        WAD_BSID-SHKZG = WA_BSID-SHKZG.
        APPEND WAD_BSID TO ITD_BSID.
      ELSEIF  WA_BSID-BLART = 'RV' AND WA_BSID-SHKZG = 'H' AND WA_BSID-ZUONR <> ' '.
        WAI_BSID-KUNNR = WA_BSID-KUNNR.
        WAI_BSID-BLART = WA_BSID-BLART.
        WAI_BSID-VBELN = WA_BSID-VBELN.
        WAI_BSID-BELNR = WA_BSID-BELNR.
        WAI_BSID-REBZG = WA_BSID-REBZG.
        WAI_BSID-WRBTR = WA_BSID-WRBTR.
        WAI_BSID-ZUONR = WA_BSID-ZUONR.
        WAI_BSID-SHKZG = WA_BSID-SHKZG.
       write : / 'rv-h ' , WAI_BSID-WRBTR.
        APPEND WAI_BSID TO ITI_BSID.
      ENDIF.
        MODIFY IT_BSID FROM WA_BSID.
    ENDLOOP.
    CLEAR : WAC_BSID.
    LOOP AT ITC_BSID INTO WAC_BSID.
      CLEAR : WAD_BSID, INV_AMT, PAID_AMT, CNCL_AMT, ADJ_AMT.
      IF WAC_BSID-BLART = 'RV' AND WAC_BSID-SHKZG = 'S'.
          WAC_BSID-SINV_AMT = WAC_BSID-WRBTR.
          INV_AMT = WAC_BSID-SINV_AMT.
    *WRITE : / WAC_BSID-SINV_AMT.
        READ TABLE ITD_BSID INTO WAD_BSID WITH KEY KUNNR = WAC_BSID-KUNNR VBELN = WAC_BSID-VBELN.
        LOOP AT ITD_BSID INTO WAD_BSID WHERE KUNNR = WAC_BSID-KUNNR AND VBELN = WAC_BSID-VBELN.
         IF SY-SUBRC = 0.
           WAC_BSID-PAID_AMT = WAD_BSID-WRBTR.
            PAID_AMT = PAID_AMT + WAD_BSID-WRBTR.
         ENDIF.
        WRITE : / PAID_AMT.
        ENDLOOP.
         IF PAID_AMT IS NOT INITIAL.
           WAC_BSID-BALN_AMT = WAC_BSID-SINV_AMT - WAC_BSID-PAID_AMT.
            WAC_BSID-PAID_AMT = PAID_AMT.
            WAC_BSID-BALN_AMT = WAC_BSID-SINV_AMT - PAID_AMT.
            WAC_BSID-AGE_AMT  = WAC_BSID-BALN_AMT.
         ELSE.
            WAC_BSID-PAID_AMT = 0.
            WAC_BSID-BALN_AMT = WAC_BSID-SINV_AMT.
           WRITE : / WAC_BSID-BALN_AMT.
            WAC_BSID-AGE_AMT  = WAC_BSID-BALN_AMT.
         ENDIF.
        LOOP AT ITI_BSID INTO WAI_BSID WHERE KUNNR = WAC_BSID-KUNNR AND ZUONR = WAC_BSID-VBELN.
        IF SY-SUBRC = 0.
           WAC_BSID-PAID_AMT = WAD_BSID-WRBTR.
            CNCL_AMT = CNCL_AMT + WAI_BSID-WRBTR.
           write :/ 'cancelled' , cncl_amt.
        ENDIF.
        ENDLOOP.
         IF CNCL_AMT IS NOT INITIAL.
           WAC_BSID-BALN_AMT = WAC_BSID-SINV_AMT - WAC_BSID-PAID_AMT.
            WAC_BSID-CNCL_AMT = CNCL_AMT.
            WAC_BSID-BALN_AMT = WAC_BSID-BALN_AMT." - CNCL_AMT.
            WAC_BSID-AGE_AMT  = WAC_BSID-BALN_AMT.
         ELSE.
            WAC_BSID-BALN_AMT = WAC_BSID-BALN_AMT.
            WAC_BSID-AGE_AMT  = WAC_BSID-BALN_AMT.
         ENDIF.
      ELSEIF WAC_BSID-BLART = 'DR'.
          IF WAC_BSID-ZUONR <> ' '.
             LOOP AT ITD_BSID INTO WAD_BSID WHERE KUNNR = WAC_BSID-KUNNR AND VBELN = ' ' AND ZUONR = WAC_BSID-ZUONR.
               IF SY-SUBRC = 0.
                  ADJ_AMT = ADJ_AMT + WAD_BSID-WRBTR.
               ENDIF.
             ENDLOOP.
             WAC_BSID-ADJ_AMT  = ADJ_AMT.
             WAC_BSID-BALN_AMT = WAC_BSID-WRBTR - ADJ_AMT.
             WAC_BSID-AGE_AMT  = WAC_BSID-BALN_AMT.
          ELSEIF WAC_BSID-ZUONR = ' '.
            WAC_BSID-BALN_AMT = WAC_BSID-WRBTR.
            WAC_BSID-AGE_AMT  = WAC_BSID-BALN_AMT.
          ENDIF.
      ELSEIF WAC_BSID-BLART = 'OB' AND WAC_BSID-SHKZG = 'S'.
          IF WAC_BSID-ZUONR <> ' '.
             LOOP AT ITD_BSID INTO WAD_BSID WHERE KUNNR = WAC_BSID-KUNNR AND VBELN = ' ' AND ZUONR = WAC_BSID-ZUONR.
               IF SY-SUBRC = 0.
                  ADJ_AMT = ADJ_AMT + WAD_BSID-WRBTR.
               ENDIF.
             ENDLOOP.
             WAC_BSID-ADJ_AMT  = ADJ_AMT.
             WAC_BSID-BALN_AMT = WAC_BSID-WRBTR - ADJ_AMT.
             WAC_BSID-AGE_AMT  = WAC_BSID-BALN_AMT.
          ELSEIF WAC_BSID-ZUONR = ' '.
            WAC_BSID-BALN_AMT = WAC_BSID-WRBTR.
            WAC_BSID-AGE_AMT  = WAC_BSID-BALN_AMT.
          ENDIF.
      ENDIF.
        PERFORM AGING_CALCULATION.
        WA_ITAB-KUNNR = WAC_BSID-KUNNR.
        WA_ITAB-SINV_AMT = WAC_BSID-SINV_AMT.
        WA_ITAB-PAID_AMT = WAC_BSID-PAID_AMT.
        WA_ITAB-CNCL_AMT = WAC_BSID-CNCL_AMT.
        WA_ITAB-BALN_AMT = WAC_BSID-BALN_AMT.
       WA_ITAB-OD_DAYS  = WAC_BSID-OD_DAYS.
        WA_ITAB-BALN1 = WAC_BSID-BALN1.
        WA_ITAB-BALN2 = WAC_BSID-BALN2.
        WA_ITAB-BALN3 = WAC_BSID-BALN3.
        WA_ITAB-BALN4 = WAC_BSID-BALN4.
        WA_ITAB-BALN5 = WAC_BSID-BALN5.
        WA_ITAB-BALN6 = WAC_BSID-BALN6.
        COLLECT WA_ITAB INTO ITAB.
      MODIFY ITC_BSID FROM WAC_BSID.
    COLLECT WAC_BSID.
    ENDLOOP.
    CLEAR : WA_ITAB, WA_CTAB.
    LOOP AT CTAB INTO WA_CTAB.
    CLEAR : WAO_BSID.
    LOOP AT IT_BSID INTO WA_BSID WHERE KUNNR = WA_CTAB-KUNNR.
      IF WA_BSID-BLART = 'RV' OR
         WA_BSID-BLART = 'OB' OR
         WA_BSID-BLART = 'DG' OR
         WA_BSID-BLART = 'DR' OR
         WA_BSID-BLART = 'DZ' OR
         WA_BSID-BLART = 'DA' OR
         WA_BSID-BLART = 'SA' OR
         WA_BSID-BLART = 'AB'.
         WAO_BSID-KUNNR = WA_BSID-KUNNR.
         WAO_BSID-BLART = WA_BSID-BLART.
         WAO_BSID-VBELN = WA_BSID-VBELN.
         WAO_BSID-BELNR = WA_BSID-BELNR.
         WAO_BSID-REBZG = WA_BSID-REBZG.
         WAO_BSID-WRBTR = WA_BSID-WRBTR.
         WAO_BSID-SHKZG = WA_BSID-SHKZG.
         WAO_BSID-ZUONR = WA_BSID-ZUONR.
         WAO_BSID-SHKZG = WA_BSID-SHKZG.
         WAO_BSID-UMSKZ = WA_BSID-UMSKZ.
         APPEND WAO_BSID TO ITO_BSID.
       ENDIF.
    ENDLOOP.
    CLEAR : WAO_BSID.
    LOOP AT ITO_BSID INTO WAO_BSID WHERE KUNNR = WA_CTAB-KUNNR.
      IF WAO_BSID-BLART = 'OB' AND WAO_BSID-SHKZG = 'H'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT - WAO_BSID-WRBTR.
          WAO_BSID-WRBTR_OBH = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'OB' AND WAO_BSID-SHKZG = 'S'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT - WAO_BSID-WRBTR.
          WAO_BSID-WRBTR_OBS = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'DG'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT - WAO_BSID-WRBTR.
          WAO_BSID-WRBTR_DG = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'DZ' AND WAO_BSID-SHKZG = 'H'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT - WAO_BSID-WRBTR.
         WAO_BSID-WRBTR_DZH = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'DZ' AND WAO_BSID-SHKZG = 'S'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT - WAO_BSID-WRBTR.
         WAO_BSID-WRBTR_DZS = WAO_BSID-WRBTR.
         ELSEIF WAO_BSID-BLART = 'DR'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT + WAO_BSID-WRBTR.
         WAO_BSID-WRBTR_DR = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'SA' AND WAO_BSID-SHKZG = 'S'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT + WAO_BSID-WRBTR.
          WAO_BSID-WRBTR_SAS = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'SA' AND WAO_BSID-SHKZG = 'H'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT - WAO_BSID-WRBTR.
         WAO_BSID-WRBTR_SAH = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'AB' AND WAO_BSID-SHKZG = 'S'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT + WAO_BSID-WRBTR.
          WAO_BSID-WRBTR_ABS = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'AB' AND WAO_BSID-SHKZG = 'H'.
        WAO_BSID-ONAC_AMT = WAO_BSID-ONAC_AMT - WAO_BSID-WRBTR.
         WAO_BSID-WRBTR_ABH = WAO_BSID-WRBTR.
    ELSEIF WAO_BSID-BLART = 'RV' AND WAO_BSID-SHKZG = 'H' AND WAO_BSID-ZUONR = ' '.
      ELSEIF WAO_BSID-BLART = 'RV' AND WAO_BSID-SHKZG = 'H'.
         WAO_BSID-WRBTR_RVH = WAO_BSID-WRBTR.
        WRITE : / WAO_BSID-WRBTR_RVH .
      ELSEIF WAO_BSID-BLART = 'RV' AND WAO_BSID-SHKZG = 'S'.
         WAO_BSID-WRBTR_RVS = WAO_BSID-WRBTR.
      ELSEIF WAO_BSID-BLART = 'DA' AND WAO_BSID-SHKZG = 'H' AND WAO_BSID-UMSKZ <> 'G'.
         WAO_BSID-WRBTR_DAH = WAO_BSID-WRBTR.
      ENDIF.
        WA_ITAB-KUNNR    = WAO_BSID-KUNNR.
        WA_ITAB-WRBTR_DG = WAO_BSID-WRBTR_DG.
        WA_ITAB-WRBTR_DR = WAO_BSID-WRBTR_DR.
        WA_ITAB-WRBTR_DZS = WAO_BSID-WRBTR_DZS.
        WA_ITAB-WRBTR_DZH = WAO_BSID-WRBTR_DZH.
        WA_ITAB-WRBTR_OBH = WAO_BSID-WRBTR_OBH.
        WA_ITAB-WRBTR_OBS = WAO_BSID-WRBTR_OBS.
        WA_ITAB-WRBTR_SAH = WAO_BSID-WRBTR_SAH.
        WA_ITAB-WRBTR_SAS = WAO_BSID-WRBTR_SAS.
        WA_ITAB-WRBTR_RVH = WAO_BSID-WRBTR_RVH.
        WA_ITAB-WRBTR_RVS = WAO_BSID-WRBTR_RVS.
        WA_ITAB-WRBTR_ABH = WAO_BSID-WRBTR_ABH.
        WA_ITAB-WRBTR_ABS = WAO_BSID-WRBTR_ABS.
        WA_ITAB-WRBTR_DAH = WAO_BSID-WRBTR_DAH.
        WA_ITAB-WRBTR_DAS = WAO_BSID-WRBTR_DAS.
       WA_ITAB-AC_AMT    = WAO_BSID-AC_AMT.
        COLLECT WA_ITAB INTO ITAB.
      MODIFY ITO_BSID FROM WAO_BSID.
    ENDLOOP.
    ENDLOOP.
    CLEAR : SLNO.
    clear : wa_itab.
    SORT ITAB BY KUNNR.
    LOOP AT ITAB INTO WA_ITAB.
    SLNO = SLNO + 1.
    WA_ITAB-SNO = SLNO.
    READ TABLE CTAB INTO WA_CTAB WITH KEY KUNNR = WA_ITAB-KUNNR.
         WA_ITAB-NAME1 = WA_CTAB-NAME1.
         WA_ITAB-BZIRK = WA_CTAB-BZIRK.
         WA_ITAB-ZTAG1 = WA_CTAB-ZTAG1.
        WA_ITAB-AC_AMT =     WA_ITAB-WRBTR_SAS
                           - WA_ITAB-WRBTR_SAH
                           - WA_ITAB-WRBTR_OBH
                           + WA_ITAB-WRBTR_OBS
                           + WA_ITAB-WRBTR_RVS
                           - WA_ITAB-WRBTR_RVH
                           - WA_ITAB-WRBTR_ABH
                           + WA_ITAB-WRBTR_ABS
                           - WA_ITAB-WRBTR_DAH
                           - WA_ITAB-WRBTR_DG
                           + WA_ITAB-WRBTR_DR
                           - WA_ITAB-WRBTR_DZH
                           + WA_ITAB-WRBTR_DZS.
    data : amount211 like bsad-wrbtr,
    amount_t like bsad-wrbtr.
                           data : aaaa type p decimals 2,
                           bbbb type p decimals 2,
                           cccc type p decimals 2,
                           wrbtr_shkzg like bsid-shkzg.
    SELECT      shkzg wrbtr
                FROM bsid
                INTO (wrbtr_shkzg , wrbtr_note )
                WHERE kunnr = wa_itab-kunnr
                AND UMSKZ = 'G'.
                if wrbtr_shkzg = 'S'.
      aaaa = wrbtr_note + aaaa.
      elseif wrbtr_shkzg = 'H'.
      bbbb = wrbtr_note + bbbb.
      endif.
    endselect.
    cccc = BBBB - AAAA.
    amount211 = wa_itab-baln3 + amount210.
    amount213 = wa_itab-baln5 + amount212.
    amount215 = wa_itab-baln1 + amount214.
    amount217 = wa_itab-baln2 + amount216.
    amount219 = wa_itab-baln4 + amount218.
    amt213    = amt212 + wa_itab-baln6.
    amount_t = amount215 + amount217 + amount211 + amount219 + amount213 + amt213.
    wa_itab-outs_amt = wa_itab-ac_amt.
    wa_itab-onac_amt = wa_itab-baln_amt - wa_itab-outs_amt + amount207 + amt.
    onacc = wa_itab-onac_amt.
    wa_itab-vbeln = wac_bsid-vbeln.
    wa_itab-outs_amt = wa_itab-ac_amt + amount210 + amount212 - amount207.
    amount_t = amount_t -  wa_itab-onac_amt.
    WRITE : /    wa_itab-sno,
             5   wa_itab-kunnr  LEFT-JUSTIFIED HOTSPOT ON,
             16  wa_itab-name1,
             50  wa_itab-bzirk,
             63  wa_itab-ztag1 RIGHT-JUSTIFIED,
             69  CCCC,
             85  amount_t,
             105 amount215,
             125 amount217,
             145 amount211,
             165 amount219,
             185 amount213,
             205 AMT213,
             225 wa_itab-onac_amt.
    MODIFY itab FROM wa_itab.
    clear  : aaaa, bbbb, cccc ,amount215, amount217, amount211, amount219 ,AMT212, AMT213,  amount213 ,AMOUNT210 , AMOUNT212 , AMOUNT214 ,AMOUNT216 ,AMOUNT218 , AMOUNT207 , amount_t, cc , d , aa ,
    a , b , bb , e , f , dd , g , h , dd, gg , hh , wa_itab-baln1 , wa_itab-baln2 , wa_itab-baln3 , wa_itab-baln4 , wa_itab-baln5 , wa_itab-baln6 ,wa_itab-onac_amt, amt.
    HIDE : wa_itab-kunnr , wa_itab-name1.
    ENDLOOP.
    WRITE : / sy-uline.
    TOP-OF-PAGE.
    WRITE : 'SAKATA INX INDIA LTD.',
            / 'Age wise analysis as on', key_date,
            / sy-uline.
    WRITE :  / 'SNo',
              5  'C-Code',
             16  'Customer Name',
             50  'Region',
             58  ' CR-DAYS',
             72  'SEC.AMOUNT',
             86  'Net O/S Amount',
             107  '0 to', int1, 'Days',
             125  int2s, 'to', int2e, 'Days',
             145 int3s, 'to', int3e, 'Days',
             165 int4s, 'to', int4e, 'Days',
             185 int5s, 'to', int5e, 'Days',
             210 '>',int5e, 'Days',
             230 'On Account',
             / sy-uline.
            'Invoice Amount',
            80  'Paid Amount',
            100 'Balance Amount',.
    FORM aging_calculation.
    CLEAR : billing_date, credit_days, wa_ctab.
    DATA : shiftdays TYPE tb_days_to_pos.
    CLEAR : shiftdays, overdue_days.
    READ TABLE ctab INTO wa_ctab WITH KEY kunnr = wac_bsid-kunnr.
      billing_date = wac_bsid-fkdat.
      credit_days  = wa_ctab-ztag1.
         overdue_date = billing_date.
      CALL FUNCTION 'FAGL_ITEM_OVERDUE_DAYS'
        EXPORTING
         key_date                =  key_date
        PAY_DATE                =
          due_date                = overdue_date
        CLEAR_DATE              =
       IMPORTING
        OVER_SKONTO1_DAYS       =
         overdue_days            =  overdue_days
        wac_bsid-od_days = overdue_days.
           IF int1 IS INITIAL.
            int1s = 0.
            int1e = 0.
           ELSEIF int1 IS NOT INITIAL.
            int1s = 0.
            int1e = int1.
           ENDIF.
           IF int2 IS INITIAL.
            int2s = 0.
            int2e = 0.
           ELSE.
            int2s = int1 + 1.
            int2e = int2.
           ENDIF.
           IF int3 IS INITIAL.
            int3s = 0.
            int3e = 0.
           ELSE.
            int3s = int2 + 1.
            int3e = int3.
           ENDIF.
           IF int4 IS INITIAL.
            int4s = 0.
            int4e = 0.
           ELSE.
            int4s = int3 + 1.
            int4e = int4.
           ENDIF.
           IF int5 IS INITIAL.
            int5s = 0.
            int5e = 0.
           ELSE.
            int5s = int4 + 1.
            int5e = int5.
           ENDIF.
          write : / WAO_BSID-WRBTR_DR.
          IF  wac_bsid-od_days BETWEEN int1s AND int1e.
            wac_bsid-baln1 =  wac_bsid-age_amt.
          ELSEIF  wac_bsid-od_days BETWEEN int2s AND int2e.
            wac_bsid-baln2 =  wac_bsid-age_amt .
          ELSEIF  wac_bsid-od_days BETWEEN int3s AND int3e.
            wac_bsid-baln3 =   wac_bsid-age_amt.
          ELSEIF  wac_bsid-od_days BETWEEN int4s AND int4e.
            wac_bsid-baln4 =  wac_bsid-age_amt .
          ELSEIF  wac_bsid-od_days BETWEEN int5s AND int5e.
            wac_bsid-baln5 =  wac_bsid-age_amt .
          ELSEIF  wac_bsid-od_days > int5e.
            wac_bsid-baln6 =  wac_bsid-age_amt .
          ENDIF.
    ENDFORM.
    AT LINE-SELECTION.
    CASE sy-lsind.
    WHEN ' 1'.
    WRITE : / sy-uline.
    WRITE : 'SAKATA INX INDIA LTD.',
            / 'Age wise analysis as on', key_date,
            / 'Customer-Code : ' , wa_itab-kunnr, 'Customer-Name : ' , wa_itab-name1,
            / sy-uline.
    DATA : amount1 LIKE bsid-dmbtr,
           amount2 LIKE bsid-dmbtr,
           amount3 LIKE bsid-dmbtr,
           amount4 LIKE bsid-dmbtr,
           amount5 LIKE bsid-dmbtr,
           amount6 LIKE bsid-dmbtr,
           amount7 LIKE bsid-dmbtr,
           amount8 LIKE bsid-dmbtr,
           amount9 LIKE bsid-dmbtr,
           amount10 LIKE bsid-dmbtr,
           amount11 LIKE bsid-dmbtr,
           amount12 LIKE bsid-dmbtr,
           amount13 LIKE bsid-dmbtr,
           amount14 LIKE bsid-dmbtr,
           amount15 LIKE bsid-dmbtr,
           amount17 LIKE bsid-dmbtr,
           amount16 LIKE bsid-dmbtr,
           amount19 LIKE bsid-dmbtr,
           amount22 LIKE bsid-dmbtr,
           amount23 LIKE bsid-dmbtr,
           amount200 LIKE bsid-dmbtr,
           amount201 LIKE bsid-dmbtr,
           amount202 LIKE bsid-dmbtr,
           amount203 LIKE bsid-dmbtr,
           amount204 LIKE bsid-dmbtr,
           amount205 LIKE bsid-dmbtr,
           amount206 LIKE bsid-dmbtr,
           amount233 LIKE bsid-dmbtr,
           amount234 LIKE bsid-dmbtr,
           amount235 LIKE bsid-dmbtr,
           amount550 LIKE bsid-dmbtr,
           amt202 LIKE bsid-dmbtr,
           amt205 LIKE bsid-dmbtr,
           amt13 LIKE bsid-dmbtr,
           amt111 LIKE bsid-dmbtr,
           amount236 LIKE bsid-dmbtr.
             select bukrs kunnr wrbtr belnr AUGDT AUGBL budat shkzg blart vbeln bldat from bsad into corresponding fields of table itab_b where bukrs = 'SAIL' and kunnr = wa_itab-kunnr and augdt > key_date and budat <= key_date.
    loop at itab_b.
         IF itab_b-blart = 'RV'.
                itab_b-flag2 = 'INVOICE'.
                MODIFY itab_b.
          ELSEIF itab_b-blart = 'DR'.
                itab_b-flag2 = 'DR-NOTE'.
                MODIFY itab2.
          ELSEIF itab_b-blart = 'OB'.
                itab_b-flag2 = 'OPN-BAL'.
                MODIFY itab_b.
          ELSEIF itab_b-blart = 'DG'.
                itab_b-flag2 = 'CR-NOTE'.
                MODIFY itab_b.
          ELSEIF itab_b-blart = 'DZ'.
                itab_b-flag2 = 'RECEIPTS'.
                MODIFY itab_b.
          ELSEIF itab_b-blart = 'SA'.
                itab_b-flag2 = 'JOURNAL'.
                MODIFY itab_b.
          ELSEIF itab_b-blart = 'DA'.
                itab_b-flag2 = 'CREDIT'.
                MODIFY itab_b.
          ELSEIF itab_b-blart = 'AB'.
                itab_b-flag2 = 'ADJUSTMENTS'.
                MODIFY itab_b.
          ENDIF.
                IF itab_b-shkzg = 'S'.
                itab_b-shkzg = 'D'.
                MODIFY itab_b.
                else.
                itab_b-shkzg = 'C'.
                MODIFY itab_b.
                ENDIF.
                endloop.
                loop at itab_b.
                ind  = sy-tabix.
          IF itab_b-vbeln IS NOT INITIAL.
    SELECT   wrbtr FROM bsad INTO itab_b-abc WHERE vbeln = itab_b-vbeln and augdt > key_date and budat <= key_date and blart = 'DZ' and kunnr = itab_b-kunnr.
    itab_b-aaa = itab_b-aaa + itab_b-abc.
    ENDSELECT.
      ENDIF.
          IF itab_b-vbeln IS NOT INITIAL.
    SELECT   wrbtr FROM bsid INTO itab_b-abc WHERE vbeln = itab_b-vbeln and budat <= key_date  and kunnr = itab_b-kunnr.
    itab_b-aaa = itab_b-aaa + itab_b-abc.
    ENDSELECT.
    endif.
      IF itab_b-vbeln IS NOT INITIAL.
    SELECT SINGLE  wrbtr FROM bsad INTO itab_b-bcd WHERE vbeln = itab_b-vbeln and augdt > key_date and budat <= key_date and kunnr = itab_b-kunnr.
    itab_b-bbb = itab_b-bcd - itab_b-aaa.
    ENDIF.
       IF itab_b-vbeln IS INITIAL.
    SELECT SINGLE  wrbtr FROM bsad INTO itab_b-bcd WHERE belnr = itab_b-belnr and augdt > key_date and budat <= key_date and kunnr = itab_b-kunnr.
    itab_b-bbb = itab_b-bcd - itab_b-aaa.
    ENDIF.
    MODIFY itab_b INDEX ind.
    *write : / itab_b-vbeln , itab_b-bbb.
    endloop.
    cc = key_date - int1.
    d = key_date.
    SELECT      hkont      " General Ledger Account
                kunnr      " Customer Number 1
               

  • Reporting for clearing, residual and payment of AR documents

    The request is to create a report (ALV) that will show the billing document/accounting document, the clearing document with amount, the residual document with amount and if it is a shortpay.
    The BSEG and BSAD tables have been looked at but some cases are not easy to break apart to code.
    Is function module available that will generate this information?
    Much appreciated!

    BSEG provided all the answers, but the coding to get all the required information is tricky and complex.
    Start with the invoice document and get the clearing document. This could be a DZ or an AB. If an AB, go back to BSEG and find the DZ using the clearing document. Finally, get residual using the AB where the document is both the clearing document and the document number.
    Many variations can exist so be sure to check for business process on how clearing is accomplished.

  • Need to develop new Report

    Please use a meaningful subject in future
    Hi,
    can any one please tell me from which table i have to fetch data (i think bseg and bkpf) is it correct.give me an  idea for fetching
    data and developing report.if possible please give the field names along with table name of below info  i would be thankfull.
    Report will contain the following information:
    -General Ledger account number
    -Name of Account
    -Amount of Entry
    -Date of the document
    -Document number
    -Debit & Credit side of entry with     general ledger and customer account numbers (if applicable).
    The filter data will contain:
    -User ID
    -General Ledger Range fields: From & To
    - Date fields: From & To.
    The purpose of this report is to list all general ledger entries made by a User for a certain time frame.
    Edited by: mohd  khan2 on Aug 25, 2009 11:34 AM
    Edited by: Matt on Aug 25, 2009 1:08 PM

    Hi,
    BSEG is the master table(Has all GL/Vendor/Customer) and hence try to restrict the usage. Instead you can use the below tables(they form the child tables for BSEG). This will be performance issues.
    Since your requirement is to fetch the GL account and Customer account items,
    BSAD :(Accounting: Secondary index for customers (cleared items))
    BSID :(Accounting: Secondary index for customers)-Open items
    You can also fetch the header details from the table BKPF.
    Below are the fields:
    General Ledger account number(HKONT)
    -Name of Account(You need to get the desciption from SKA1 or SKB1 for the above HKONT)
    -Amount of Entry (BSEG/BSAD/BSID-WRBTR)
    -Date of the document (BKPF-BUDAT)
    -Document number(BKPF-BELNR/BSAD-BELNR/BSID-BELNR/BSEG-BELNR)
    -Debit & Credit side of entry with general ledger and customer account numbers (if applicable).(BSEG/BSID/BSAD-SHKZG)
    Additioally you need the field KOART which will differentaiat if the line items is for GL/Vendor(K)/Customer(D). This is available in BSEG. For BSAD/BSID you need not check because the table will store only customer line items
    Hope this helps
    Regards
    Shiva

  • Error Message for the cancellation of paid billing document

    Hi,
    Can i create and error message for the cancellation of paid billing document? If yes, how can i create such.
    Overview:
    Accounting document is created upon creation of billing document. Upon payment, document cleared is the accounting document created. There are instances wherein accounting document was already cleared but our user is still able to reversed billing document. Now, i want to create an error message or user exist wherein, when a user will not be able to reverse the billing document if the accounting document attached to this billing document is already paid.
    Thank you and best regards.
    Rachelle

    Hi Rachel,
    You can make use of the exit (Include) MV45AFZZ. The corresponding form routine is FORM USEREXIT_SAVE_DOCUMENT_PREPARE.
    In this exit, For the given billing document ( which is going to be cancelled ), pick up the accouting document from BSEG tables.
    For this accouting document, Pass this to BSAD Table ( Customer clleared items) 
    If BSEG-BELNR = BSAD-BELNR and
      BSEG-Acc.Year = BSAD-Acc,year )..
    Then throw a error message and EXIT.
    So for all the cleared docments , user can not cancel the invoices.
    Regards,
    Sai

  • Error message for double entry of a phone type.

    Hi. From "Phone Number" form i am trying to add for second time the phone type "Home" and i get an Error Message "APP-PAY-51530: Only one active phone number is allowed. Action: Delete existing home phone, or use secondary home phone type."
    This message is correct. I want to add the same message also for phone type "Mobile" because now the application allows to add it more than one time.
    Does anybody knows how can i add a new error massage?

    Hi Rachel,
    You can make use of the exit (Include) MV45AFZZ. The corresponding form routine is FORM USEREXIT_SAVE_DOCUMENT_PREPARE.
    In this exit, For the given billing document ( which is going to be cancelled ), pick up the accouting document from BSEG tables.
    For this accouting document, Pass this to BSAD Table ( Customer clleared items) 
    If BSEG-BELNR = BSAD-BELNR and
      BSEG-Acc.Year = BSAD-Acc,year )..
    Then throw a error message and EXIT.
    So for all the cleared docments , user can not cancel the invoices.
    Regards,
    Sai

  • Crystal Reports 2008 can't access R/3 queries

    Hi there,
    My company is in the middle of SAP implementation and our go-live is in 2 months. We don't have a BW system in place and are (for the most part) using the Standard SAP Reports available out of the box to facilitate the requirements of the different business users. But as we all know, there are always some reports that require customization. So, for that we decided to use Crystal Report 2008 (ver. 12.3.0.601) to design custom reports while accessing data from the Standard SAP Tables. I am able to access the Standard SAP Tables in R/3 (built on Oracle database) and the fields in those tables from the Crystal Report 2008 Database Expert option and have created an A/R Aging Report successfully. However, while working on my second report (GL Journal Entry By Invoice#) I am struggling to maintain and improve the query execution time since I am accessing data from huge standard FI-CO tables (BSEG, BSID, BSAD). Our 3rd party implementation team has already designed a custom report in R/3 that is available in all the clients using the T-Code in NetWeaver for the end users but it's missing some fields that the end users would need for go-live and it's not possible to ask the 3rd party implementation team to make the needed changes to the already customized report (for whatever reasons). And, that's why, I am asked to customize this report in Crystal. I suspect the execution time is so bad in Crystal because of lack of filtering of the data when I am pointing at the huge Standard Tables. I would have added some SQL clause and filters to bring in only the required fields from the table into the Crystal environment but I don't have that option since the R/3 system is sitting on Oracle. I have couple questions:
    1) Would it be advantageous to build the custom Crystal Report on top the custom R/3 report that is already in place since in the R/3 report I can create a default variant with the conditions I want and it gets executed every time I call it in Crystal giving me only the data I am interested in? And, is it even possible?
    2)  Why am I not able to see the R/3 custom report from the Database Expert option even though the report is accessible from NetWeaver? I am able to access all the Standard SAP Tables from Database Expert in Crystal 2008.
    And I forgot to add, we don't have an ABAP expert in house to create ABAP function modules that might help me filter the data in the R/3 system.
    Is there any suggestions that will get the job done? Am I doing anything wrong here?
    Sorry for the long story but I wanted to give you guys a full background of the issue.
    Any help will be greatly appreciated.
    -RBora

    RohitBora wrote:
    Hi there,
    > My company is in the middle of SAP implementation and our go-live is in 2 months. We don't have a BW system in place and are (for the most part) using the Standard SAP Reports available out of the box to facilitate the requirements of the different business users. But as we all know, there are always some reports that require customization. So, for that we decided to use Crystal Report 2008 (ver. 12.3.0.601) to design custom reports while accessing data from the Standard SAP Tables. I am able to access the Standard SAP Tables in R/3 (built on Oracle database) and the fields in those tables from the Crystal Report 2008 Database Expert option and have created an A/R Aging Report successfully. However, while working on my second report (GL Journal Entry By Invoice#) I am struggling to maintain and improve the query execution time since I am accessing data from huge standard FI-CO tables (BSEG, BSID, BSAD). Our 3rd party implementation team has already designed a custom report in R/3 that is available in all the clients using the T-Code in NetWeaver for the end users but it's missing some fields that the end users would need for go-live and it's not possible to ask the 3rd party implementation team to make the needed changes to the already customized report (for whatever reasons). And, that's why, I am asked to customize this report in Crystal. I suspect the execution time is so bad in Crystal because of lack of filtering of the data when I am pointing at the huge Standard Tables. I would have added some SQL clause and filters to bring in only the required fields from the table into the Crystal environment but I don't have that option since the R/3 system is sitting on Oracle. I have couple questions:
    >
    > 1) Would it be advantageous to build the custom Crystal Report on top the custom R/3 report that is already in place since in the R/3 report I can create a default variant with the conditions I want and it gets executed every time I call it in Crystal giving me only the data I am interested in? And, is it even possible?
    No - this is not possible; you can only report in Crystal against ECC tables, ABAP functions, and SAP Query/Infosets
    > 2)  Why am I not able to see the R/3 custom report from the Database Expert option even though the report is accessible from NetWeaver? I am able to access all the Standard SAP Tables from Database Expert in Crystal 2008.
    ABAP Reports are not a datasource in Crystal
    >
    > And I forgot to add, we don't have an ABAP expert in house to create ABAP function modules that might help me filter the data in the R/3 system.
    > Is there any suggestions that will get the job done? Am I doing anything wrong here?
    > Sorry for the long story but I wanted to give you guys a full background of the issue.
    >
    > Any help will be greatly appreciated.
    >
    > -RBora
    Hello,
    Those are some big tables to be reporting against in Crystal
    Have you considered creating an InfoSet using logical database BRM (Financial Documents) that could then be used to report against Crystal?
    We do use Crystal / SAP Query against the logical database BRM as an InfoSet and so far we haven't seen the performance issues you are describing.
    Also, have you considered upgrading to Crystal Reports 2011?  Not sure that it would help the performance issues you are describing.
    Regards,
    Tammy

  • GLPCT has entries from MM, SD & other origin objects but not in GLPCA

    Hello,
    We have a situation as below: amounts are not actuals to simpliy problem:
    GL account involved is ABC which is a Retained earnings account.
    FBL3N displays 100
    GLPCA displays 100 with origin object as 35 - entries from FI
    But GLPCT displays 160.
    Reason is that in GLPCT there are lines with many more origin objects. There exists a line with origin object 35 which is exactly displaying the figure of 100.
    But there are additional lines with origin ojects like :
    1 Profit center
    2 Cost center
    4 Production order
    5 Billing document
    7 WBS Element
    9 Network activity
    45 Reconcilation object
    Of these I could understand that if suppose we have a direct entry in PCA then in GLPCA & GLPCT we have lines with origin object 1. But currently we dont have any line in GLPCA with origin object 1.
    Also a major question is how other origin objects are updated in GLPCT without reference in GLPCA & no link in GL line items BSEG.
    The problem is that users want to run report S_ALR87013340 & are comparing with total of FBL3N. But the report shows the total of all the origin objects in GLPCT & hence the balance is never balancing with FBL3N.
    Note - No archiving has been carried out.
    Please help in understanding the GLPCT updates.
    Thanks & Regards
    Shreenath

    Hello Eli,
    Thanks for the prompt response. I have read the note. It doesnt explain however from where these various origin objects are getting updated in GLPCT.
    The problem is not that the total for origin object 35 is different. It is exactly matching in GLPCT, GLPCA & GL line items.
    But how to understand & trace what are the entries which are updating different origin objects in GLPCT directly.
    Please help.
    Thanks & Regards
    Shreenath

Maybe you are looking for

  • Group values on Barchart - Please help Urgent

    Hi I am plotting a bar chart. I am plotting chart "on change of" first group name.and showing 3 values which i get in formulas. I had to place these formulas in lowest level of subgroup just above the details ( i don`t need any details). i am getting

  • G6-2321dx hangs on hp logo with spinning wheel

    Andrew9534 Andrew9534 Student 3:24 PM Hello hp, I am trying to fix an hp pavilion g6-2321dx running Windows 8.1. Every 10 or so restarts, the computer gets stuck at the hp logo with the spinning wheel when trying to boot. I then have to hard reset th

  • Recover video from Memory Card in a N73 ME

    How can I recover a video from my memory card I have deleted from N73 My Personal Blog http://www.megablogsite.com

  • HT204088 iTunes billing without making a purchase???

    I have been charged & debited large sums from my credit card.... iTunes purchases which I did not make... I am a disabled pensioner & I need to rectify this problem IMMEDIATELY... Who do I contact??????

  • Edge 2010 server unable to relay internally

    Hi, I have exchange 2010 environment; all the roles are running on individual servers. Recently I have setup an additional edge server and have completed with edge subscription as well. The outgoing email from the internal network have no issue. Howe