Calculating WT on Payments and Invoces as well

Hi all,
I have configured EWT Codes and Tax Types for Tax, Surchatrge and Ed.Cess  for Payment and invoice separately.
Tax Type ->Tax Code ->Rate->     Tax Base->     Description
I1  ->       I1      ->  2     ->Invoice Amount ->WT Cont Inv
I2->     I2->     10->     Tax->   Surcharge on WT for Contractors Inv
I3->     I3->     2->     Tax + Surcharge     ->Ed Cess on WT for Contractors Inv
P1->     P1->     2->     Invoice Amount->      WT for Contractors Pmt
P2->     P2->     10->     Tax->     Surcharge on WT for Contractors Pmt
P3->     P3->     2     ->Tax + Surcharge->     Ed Cess on WT for Contractors Pmt
I have populated the whole in the vendor master. when posting an invoice I am able to get the Tax calculated based on invoice type codes, and when I am processing automatic pmt program, Tax is again calculated as above
Can any one guide , why this is occuring?
Regards,
Srinivas

Hi
We can change the withholding tax type in the vendor master record before making the any transaction such like down payment to vendor.
As per Indian Law, TDS has to be deducted either on the date of invoice get credited or payment date whichever is earlier.
So, if u have assign invoice withholding tax type in vendor master record and u r making down payment to vendor and u want to deduct withholding tax then First u have to change vendor master record in withholding tax type from invoice to payment type.
If any clarification is required my email id [email protected]
Avinash

Similar Messages

  • Witholding Tax calculation while payment and advance

    Dear experts,
    I have few questions as below. It would be great if you can help me out in this :
    In vendor master I have two WTH tax codes for invoice and payment and marked as liable.
    Incase of invoice (FB60) posting system is calcu;ating correctly and posting, but while posting no popup for to rectify the WTX code also no base amount is populating in WTH tax tab of invoice posting. Is this correct way??
    While making payment for the same invoice through F-53, system is again calculating on same open item and no popup, until I go to WTH tax tab and delete the tax amount. What is lacking in my customising of WTH tax code (payment type), to restrict WTH tax calcutaing twice ??
    While making advance payment by F-48, system not calculating WTX tax and showing tax code is mandatory, even though tax code  (V0-tax exempt) entered, no WTH tax calculation happening. I have checked all Field status of document type and recon account, nothing is mandatory. I dint know why?? Please help in this regard.
    Thanks in advance.
    Regards
    Abhi

    Hi madhu
    Thanks for explaining the process it works.
    Regarding the error I was facing earlier to enter the tax code in F-48 for the tax category was marked as ' * ' in the advance reconciliation GL. I have removed them and now the error is not coming.
    But now for the same or advance payment with F-48, I am not able post the document, though the payment WTX code is showing but not calculating the amount for the same.
    The error is
    "Withholding tax amount exceeds total bank line item amounts."
    Message no. 7Q320
    How to post it. Please help.
    Regards
    Abhi

  • Interest calculation on Open items and cleared items

    Dear Experts
    I am trying to do needful configuration for interest indicator on which interest can be calculated for open items and cleared items as well.  But,  system is calculating interest for open items properly, but not calculating interest on cleared items with same interest indicator,  I am repeatedly getting error "interest calculation indicator is not compatible with this type of interest calculation"
    Is it possible to use same interest indicator for open line items and cleared line items of customer?
    If possible, request you share the needful config steps to do same.
    points will be awarded for usful reply.
    Best regards,
    S. Habib Pasha.

    Hello Habib,
    depending on the requests you can setup a item interest calculation or a balance interest calculation "Define calculation types".
    IIC: check settings (item selection, all cleared items, only items with payment, no cleared items) "Prepare item interest calculation"
    I guess you have setup the item interest calculation - maybe you have mixed some entries with BAIC.
    Check in "Prepare account balance interest calculation" whether you have entries with the indicator you want to use.
    At least check your entries in "Define time-based Terms" If you have entries with Balance account interest calculation the system gives even an error.
    Hope this is helpfull.
    Best regards
       Horst

  • EWT-Tax on Down Payment and Invoice

    Hello,
    I've activated the accumulation feature in the Withholding Tax Type for both IV as well as Payments. The tax code is the same for both tax types.I've also defined the minimum base amount for Witholding Tax code as Rs.5000 for Official Withholding Tax key 194A and have also maintained formula for Tax code i.e tax should only get calculated if tax amount is more than Rs 5000.
    However I've noticed that the tax is getting calculated on the accumulated amount of both Payment and IV separately.
    Example:
    Tax Type for IV is 01
    Tax type for Payment is P0
    Tax code is T1 @ 11.33%
    I've made a down payment entry using T-code F-48 for Rs 4000 (Tax type P0 and Tax code T1). Now Tax is not getting calculated on this amount which is correct.
    Now if I post an Invoice for Rs 1500 for the same vendor (Tax type 01 and Tax code is T1), ideally my tax should get deducted on Rs 5500 (4000 of DP and 1500 of IV) @11.33%. Howver this does not happen. The accumulation feature is working for Payments and IVs separately.
    Can someone please help me on this. Is it a particular config  which I've missed?
    Thanks and Regards,
    Sumita

    Hi Sumita,
    Please follow the below mentioned steps for this issue.
    Steps:
    1. Define Withholding Tax Type for Payment Posting
    Path: FA/****/Withholding Tax/Extended Withholding Tax/Basic Settings/Calculation/Withholding Tax Type/Define Withholding Tax Type for Payment Posting
    Here create 2 Withholding Tax Types:
    1. 1st for TDS (Basic@10%) Tax Type: S1 and
    2. 2nd one for Education Cess (EC@3%) Tax Type: S2
    2. Define Withholding Tax Codes
    Path: FA/****/Withholding Tax/Extended Withholding Tax/Basic Settings/Calculation/Withholding Tax Codes/Define Withholding Tax Codes
    Create 2 Tax codes (One for Basic and another one for Education Cess)
    In that screen, give the following inputs
    Give WT Key also on the same screen
    Save the data
    WT Name    WT Type    Tax Code    Base Amount     Calculation
    1. Basic               S1               C1                             100%                    10%
    2. EC                  S2                C2                             10%                       3%
    3. Define Min/Max Amounts for Withholding Tax Codes
    Path: FA/****/Withholding Tax/Extended Withholding Tax/Basic Settings/Calculation/Minimum and Maximum Amounts/Define Min/Max Amounts for Withholding Tax Codes
    Letu2019s say there is no TDS up to Rs. 1,50,000 per annuam
    Monthly amount or Invoice amount Rs. 12,500 per month
    There is no TDS up to Rs. 12,500 and TDS will be charged if the salary exceeds Rs.12,500 p.m.
    WT Name    WT Type     Tax Code     Max Amount     Minimum Base Amt
    1. Basic                  S1                         C1                 99,999,999,999      12,501
    2. EC                      S2                         C2                99,999,999,999      375.03
    4. Assign Withholding Tax Types to Company Codes
    Path: FA/****/Withholding Tax/Extended Withholding Tax/Company Code/Assign Withholding Tax Types to Company Codes
    5. Update Withholding Tax Codes in the Vendor Master (Employees A/c u2013 Employees will be treated as vendors here)
    Give WT Type and WT code here
    WT Type     WT Code  
            S1              C1
             S2              C2
    Note:
    1. Please follow the above example and apply it in your case.
    2. We have created 2 tax codes for Basic W Tax and Education Cess.
    3. Assumed there is no Sur charge.
    Hope this is clear and let me know if you have any queries.
    Regards,
    Kannusamy S

  • Withholding tax calculation at down payment clearing F-54

    Hi,
    Can any one reply the solution
    When I am posting down payment to vendor, Basic TDS, Surcharge, Ecess on TDS and Ecess on Surcharge calculated.
    Invoice is half of the down payment and TDS and Ecess on TDS calculated properly.
    but when i am trying to clearing the down payment against invoice thru F-54, TDS and Ecess on TDS reversed and surcharge and Ecess on Surcharge is also reversed on proportionate basis.
    It should not be reversed and client wants which is TDS is raised at Invoice it should be reversed.  but we are getting more than that.
    Plz help me
    sai

    Hi,
    I think, what system doing is fine,
    Let me explain with the accounting entries,
    1. Down Payment
    Debit Vendor SPL GL a/c      1000
    Credit Bank a/c                                945
    Credit TDS Payable (all taxes)             55
    2. Invoice Verification
    Debit GR/IR or Expenses a/c           2000
    Credit Vendor a/c                                     1890
    Credit TDS Payable (all taxes)                    110
    3. Down Payment clearing
    Debit Vendor a/c                     945
    Debit TDS Payable a/c              55
    Credit Vendor SPL GL a/c                       1000
    4. Payment (Final)
    Debit Vendor a/c                     945
    Credit Bank                                               945
    5. TDS Payment
    Debit TDS Payable                      110
    Credit Bank a /c                                         110.
    Hope the above scheme of enteries would be helping you to understand this flow.
    Saravanan.A

  • Calculation of customer payment performance   by profit center

    I want to calculate customer payment performance by profit center  it is a report.
    Caluation clue.
    <b>Performance is a measure of when the payment was made versus the due date calculated by the payment terms</b>.
    i want the logic to be included in the following code.
    REPORT                                               
    TABLE DECLARATIONS
    TABLES: BFOD_A,         "FI subsequent BA/PC adjustment: Customer items
            BSID,           "Open Items
            BSAD,           "Cleared Items
            BKPF,           "Docuemnt Header
            KNA1,           "Customer Master
            CEPCT,          "Texts for Profit Center Master Data
            CEPC,           "Profit center master data table
            SKB1,           "G/L account master
            VBFA,           "Sales Document Flow
            VBAK.           "Sales Document: Header Data
    CONTROLS: TABAGING TYPE TABLEVIEW USING SCREEN 9000.
    FIELD-SYMBOLS: <COLUMN>.
    Internal tables followed by types
    TYPES: BEGIN OF T_TOTAL,
             WAERS  LIKE COEP-TWAER,
             DAYS01 LIKE COEP-WTGBTR,
             DAYS02 LIKE COEP-WTGBTR,
             DAYS03 LIKE COEP-WTGBTR,
             DAYS04 LIKE COEP-WTGBTR,
             DAYS05 LIKE COEP-WTGBTR,
             TOTAL  LIKE COEP-WTGBTR,
           END OF T_TOTAL.
    DATA: V_DISVARIANT       TYPE DISVARIANT,
          REF_CUSTOM         TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
          REF_ALV_ZRPT       TYPE REF TO CL_GUI_ALV_GRID.
    DATA: V_SAVE(1)    TYPE C,
          V_DEFAULT(1) TYPE C,
          V_VARIANT    TYPE DISVARIANT,
          V_SORT       TYPE LVC_S_SORT,
          V_LAYOUT     TYPE LVC_S_LAYO,
          V_SAVE_TABIX LIKE SY-TABIX,
          V_SAVE_TIME  LIKE SY-UZEIT,
          V_ALV_FIELDCAT TYPE LVC_S_FCAT,
          V_SAVE_INDEX LIKE SY-TABIX,
          V_ROW        TYPE LVC_S_ROW,
          V_ROWS       TYPE LINE OF LVC_T_ROW.
    DATA: BEGIN OF V_HDR,
            CURKY(9) TYPE C,
            CURR(20) TYPE C,
            COL1(20) TYPE C,
            COL2(20) TYPE C,
            COL3(20) TYPE C,
            COL4(20) TYPE C,
            TOTAL(20) TYPE C,
          END OF V_HDR.
    DATA: BEGIN OF V_FIELD,
            NAME(15) TYPE C,
            VALUE(17) TYPE C,
          END OF V_FIELD.
    DATA: BEGIN OF I_BFOD_A OCCURS 0,
            PRCTR LIKE BFOD_A-PRCTR,
            KUNNR LIKE BFOD_A-KUNNR,
            BUKRS LIKE BFOD_A-BUKRS,
            GJAHR LIKE BFOD_A-GJAHR,
            BELNR LIKE BFOD_A-BELNR,
            BUZEI LIKE BFOD_A-BUZEI,
            AUGDT LIKE BFOD_A-AUGDT,
            HKONT LIKE BFOD_A-HKONT,
            BUDAT LIKE BFOD_A-BUDAT,
            SHKZG LIKE BFOD_A-SHKZG,
            DMBTR LIKE BFOD_A-DMBTR,
            DMBE2 LIKE BFOD_A-DMBE2,
          END OF I_BFOD_A.
    DATA: I_SET_VALUES   LIKE SETVALUES OCCURS 0 WITH HEADER LINE,
          I_SORT         TYPE LVC_T_SORT,
          I_ALV_FIELDCAT TYPE LVC_T_FCAT,
          I_PRCTR_COCD   TYPE FCINPCA001 OCCURS 0 WITH HEADER LINE,
          I_BFODA_KUNNR  LIKE I_BFOD_A OCCURS 0 WITH HEADER LINE,
    Begin of changes for DEVK909110
         I_REPORT       TYPE ZFR0ARPR_S1 OCCURS 0 WITH HEADER LINE,
          I_REPORT       TYPE ZPSS_ARBYPC OCCURS 0 WITH HEADER LINE,
    End of changes for DEVK909110
          I_FAEDE        LIKE FAEDE,
          I_TOTAL        TYPE T_TOTAL OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF I_BKPF OCCURS 0,
            BUKRS LIKE BKPF-BUKRS,
            BELNR LIKE BKPF-BELNR,
            GJAHR LIKE BKPF-GJAHR,
            BKTXT LIKE BKPF-BKTXT,
            XBLNR LIKE BKPF-XBLNR,
            HWAER LIKE BKPF-HWAER,
            HWAE2 LIKE BKPF-HWAE2,
          END OF I_BKPF.
    *... combine BSAD and BSID
    DATA: BEGIN OF I_BSYD OCCURS 0,
            KUNNR LIKE BSID-KUNNR,
            BUKRS LIKE BSID-BUKRS,
            GJAHR LIKE BSID-GJAHR,
            BELNR LIKE BSID-BELNR,
            BUZEI LIKE BSID-BUZEI,
            AUGDT LIKE BSID-AUGDT,
            BLDAT LIKE BSID-BLDAT,
            BUDAT LIKE BSID-BUDAT,
            HKONT LIKE BSID-HKONT,
            WAERS LIKE BSID-WAERS,
            ZFBDT LIKE BSID-ZFBDT,
            ZBD1T LIKE BSID-ZBD1T,
            ZBD2T LIKE BSID-ZBD2T,
            ZBD3T LIKE BSID-ZBD3T,
            XBLNR LIKE BSID-XBLNR,
            REBZG LIKE BSID-REBZG,
            SHKZG LIKE BSID-SHKZG,
            DMBTR LIKE BSID-DMBTR,
            WRBTR LIKE BSID-WRBTR,
          END OF I_BSYD.
    DATA: BEGIN OF I_CEPC OCCURS 0,
             PRCTR LIKE CEPC-PRCTR,
             KHINR LIKE CEPC-KHINR,
          END OF I_CEPC.
    DATA: BEGIN OF I_CEPCT OCCURS 0,
             PRCTR LIKE CEPCT-PRCTR,
             MCTXT LIKE CEPCT-MCTXT,
          END OF I_CEPCT.
    DATA: BEGIN OF I_PRCTR OCCURS 0,
            PRCTR LIKE BFOD_A-PRCTR,
          END OF I_PRCTR.
    DATA: BEGIN OF I_KNA1 OCCURS 0,
             KUNNR LIKE KNA1-KUNNR,
             NAME1 LIKE KNA1-NAME1,
          END OF I_KNA1.
    Working Variables Declarations
    *... accumulators
    DATA: V_BFOD_TXNAMT LIKE BSID-WRBTR,    "transaction currency amt
          V_FRCURR      LIKE TCURR-FCURR,   "local currency
          V_TOCURR      LIKE TCURR-FCURR,   "local currency
          V_LCURR       LIKE T001-WAERS,    "local currency
          V_CUSTTOTUSD  LIKE BFOD_A-DMBE2,  "customer total grp curr
          V_TOTAL       LIKE BPPE-WTP03,    "days total grp curr
          V_CURRENT     LIKE BPPE-WTP03,    "days current grp curr
          V_TOTAL_USD   LIKE BPPE-WTP03,    "days total grp curr
          V_TOTAL_ROW   LIKE BPPE-WTP03.    "total of local curr/row
    DATA: V_PRCTR          LIKE CEPC-PRCTR,   "profit center
          V_SUBRC          LIKE SY-SUBRC,
          V_FLAG           TYPE I,
          V_DPAST          TYPE I,     "past due days working
          V_GRAND          TYPE C,
          V_DIFF_COLOR     TYPE C,
          V_MSG(50)        TYPE C,
          V_SAVE_PCFN(128) TYPE C,
          V_EXTENSION(4)   TYPE C,
          V_PREV_PRCTR     LIKE CEPC-PRCTR,
          V_POS            LIKE SY-FDPOS,
          V_SAVE_BUKRS     LIKE BFOD_A-BUKRS,
          V_SAVE_KHINR     LIKE CEPC-KHINR,
          V_PERC           TYPE P DECIMALS 10,
          V_ZBD1T          LIKE BSID-ZBD1T,
          V_ZFBDT          LIKE BSID-ZFBDT,
          V_GROUP_CLASS    LIKE RGSBS-CLASS,
          V_GROUP_NAME     LIKE RGSBS-SETNR,
          V_GROUP_TITLE    LIKE RGSBS-TITLE,
          V_SETID          LIKE SETHIER-SETID,
          V_FILETYPE       LIKE RLGRAP-FILETYPE VALUE 'DAT',
          V_CNT            LIKE SY-TABIX,
          V_PREV_BELNR     LIKE BSID-BELNR,
          V_REPORT1        LIKE I_REPORT,
          V_REPORT         LIKE I_REPORT,
          V_TABIX          LIKE SY-TABIX.
    Constants
    CONSTANTS:
          C_0H(2)     TYPE C VALUE '0H',
          C_0106(4)   TYPE C VALUE '0106',
          C_SPACE(11) TYPE C VALUE '          ',
          C_USD(3)    TYPE C VALUE 'USD',
          C_KBRC      LIKE CEPC-KOKRS VALUE 'KBRC',
          C_TXT(4)    TYPE C VALUE '.txt',
          C_XLS(4)    TYPE C VALUE '.xls',
          C_RTF(4)    TYPE C VALUE '.rtf',
          C_PERIOD(1) TYPE C VALUE '.',
          C_TODATE    LIKE CEPC-DATBI VALUE '99991231'.
    RANGES: R_KUNNR FOR KNA1-KUNNR.         "Customer
    Selection Screen Parameters and Select-options
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS:     P_KHINR LIKE CEPC-KHINR.
    SELECT-OPTIONS: S_PRCTR FOR CEPC-PRCTR,
                    S_KUNNR FOR KNA1-KUNNR,
                    S_BUKRS FOR BKPF-BUKRS,
                    S_HKONT FOR SKB1-SAKNR.
    PARAMETERS:     P_BUDAT LIKE BFOD_A-BUDAT OBLIGATORY.
    SELECTION-SCREEN ULINE.
    SELECT-OPTIONS: S_BELNR FOR BFOD_A-BELNR,
                    S_AUART FOR VBAK-AUART,
                    S_VTWEG FOR VBAK-VTWEG,
                    S_VBTYP FOR VBFA-VBTYP_V.
    SELECTION-SCREEN ULINE.
    PARAMETERS: P_AGEDY TYPE ZZAGEMULT DEFAULT '30' OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME.
    PARAMETERS: P_DSVAR LIKE DISVARIANT-VARIANT.
    SELECTION-SCREEN END OF BLOCK B2.
    class lcl_event_receiver: local class to handle event DOUBLE_CLICK
    Definition:
    CLASS LCL_EVENT_RECEIVER DEFINITION.
      PUBLIC SECTION.
        METHODS:
        MTH_PRINT_TOP_OF_PAGE
            FOR EVENT PRINT_TOP_OF_PAGE OF CL_GUI_ALV_GRID.
        METHODS:
        MTH_PRINT_TOP_OF_LIST
            FOR EVENT PRINT_TOP_OF_LIST OF CL_GUI_ALV_GRID.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    class lcl_event_receiver: local class to handle event DOUBLE_CLICK
    Implementation:
    CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
      METHOD MTH_PRINT_TOP_OF_PAGE.
        CALL FUNCTION 'Z_CA_STD_HEADER'
          EXPORTING
            HEADING    = SY-TITLE
            P_REPID    = SY-CPROG
            LINE_WIDTH = SY-LINSZ.
      ENDMETHOD.                    "MTH_PRINT_TOP_OF_PAGE
      METHOD MTH_PRINT_TOP_OF_LIST.
        CALL FUNCTION 'Z_CA_STD_HEADER'
          EXPORTING
            HEADING    = SY-TITLE
            P_REPID    = SY-CPROG
            LINE_WIDTH = SY-LINSZ.
        CALL FUNCTION 'Z_CA_PRINT_SELECTION_OPTIONS'
          EXPORTING
            P_PGMN  = SY-CPROG
            P_SKIP  = 'X'
            P_NOTOP = 'X'.
        NEW-PAGE.
      ENDMETHOD.                    "MTH_PRINT_TOP_OF_LIST
    ENDCLASS.                    "LCL_EVENT_RECEIVER IMPLEMENTATION
    DATA: REF_EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER.
    Selection Screen Prompt values
      At Selection Screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_DSVAR.
      DATA: LS_DISPLAY_VARIANT TYPE DISVARIANT.
    Get the display variant
      V_DISVARIANT-REPORT  = SY-CPROG.
      V_DISVARIANT-VARIANT = P_DSVAR.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          IS_VARIANT = V_DISVARIANT
          I_SAVE     = 'A'
        IMPORTING
          ES_VARIANT = LS_DISPLAY_VARIANT
        EXCEPTIONS
          OTHERS     = 3.
    Load results to parameter
      IF SY-SUBRC = 0 AND NOT LS_DISPLAY_VARIANT IS INITIAL.
        P_DSVAR = LS_DISPLAY_VARIANT-VARIANT.
      ENDIF.
    *...performed when looking for values in fields
      performs the drop down selection list
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_KHINR.     "Profit center grp
      PERFORM F_GET_S_KHINR.
    Selection Screen validations
    AT SELECTION-SCREEN.
      IF P_KHINR IS INITIAL.
        IF S_PRCTR[] IS INITIAL.
          IF S_BUKRS[] IS INITIAL.
            MESSAGE E000 WITH TEXT-300 TEXT-302.
          ENDIF.
        ENDIF.
      ELSE.
        IF S_PRCTR[] IS INITIAL.
          PERFORM F_VALIDATE_KHINR.
        ELSE.
    *.. Error msg: Please enter either a Profit Center Group or a
                 profit center, but not both
          MESSAGE E000 WITH TEXT-300 TEXT-301.
          EXIT.
        ENDIF.
      ENDIF.
      IF NOT S_AUART[] IS INITIAL.
        MESSAGE E000 WITH TEXT-303.
      ENDIF.
      IF NOT S_VTWEG[] IS INITIAL.
        MESSAGE E000 WITH TEXT-304.
      ENDIF.
       Event AT LINE-SELECTION
    AT LINE-SELECTION.
      CHECK SY-LSIND LE 1.
      CHECK NOT I_REPORT-BELNR IS INITIAL.
      SET PARAMETER ID 'BLN'  FIELD I_REPORT-BELNR.
      SET PARAMETER ID 'BUK'  FIELD I_REPORT-BUKRS.
      SET PARAMETER ID 'GJR'  FIELD I_REPORT-GJAHR.
      CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
      CLEAR: I_REPORT-BELNR, I_REPORT-BUKRS, I_REPORT-GJAHR.
    INITIALIZATION
    INITIALIZATION.
    START OF MAIN PROCESSING
    START-OF-SELECTION.
    Check aging days multiplier
      IF P_AGEDY LE 0.
        MESSAGE S000 WITH 'Aging Days Multiplier must be greater than zero'.
        EXIT.
      ENDIF.
    Populate the s_prctr from a profit center group
      IF NOT I_SET_VALUES[] IS INITIAL.
        PERFORM F_POPULATE_PRCTR_FROM_PRCTRGRP.
      ENDIF.
    Build and validate prctr against cepc table
      IF NOT S_PRCTR[] IS INITIAL.
        PERFORM F_BUILD_I_CEPC_TABLE.      "FILLS THE VALID PROFIT CTR TABLE
      ENDIF.
    Get base selections
      PERFORM F_SELECT_DATA.               "BUILD REF INTERNAL TABLES
    Get additional fields and build reporting structure
      PERFORM F_BUILD_I_REPORT.            "BUILDS INTERNAL REPORTING TABLE
    Generate ALV report
      PERFORM F_WRITE_REPORT.              "WRITES i_report AND RUNS CALCS
    END-OF-SELECTION.
      FREE: I_BFOD_A, I_KNA1, I_CEPC, I_CEPCT, I_REPORT.
          Form  F_DIS_MSG
    FORM F_DIS_MSG USING VALUE(P_PERCENTAGE) VALUE(P_TEXT).
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          PERCENTAGE = P_PERCENTAGE
          TEXT       = P_TEXT
        EXCEPTIONS
          OTHERS     = 1.
    ENDFORM.                               " F_DIS_MSG
          Form  F_GET_S_KHINR
          Get prompt values for Profit Center Group
    FORM F_GET_S_KHINR.
      PERFORM F_DIS_MSG USING 100 'Get prompt values for Profit Ctr Group.'.
      COMMIT WORK.
      CALL FUNCTION 'K_GROUP_SELECT'
        EXPORTING
          BUTTONS            = 'X'
          CLASS              = '0H  '
          CRUSER             = '*'
          FIELD_NAME         = 'RPRCTR'
          SEARCHFLD          = 'KBRC'
          SEARCHFLD_INPUT    = ' '
          SEARCHFLD_REQUIRED = 'X'
          SET                = '*'
          START_COLUMN       = 10
          START_ROW          = 5
          TABLE              = 'GLPCT'
          TYPELIST           = 'BS'
          UPDUSER            = '*'
        IMPORTING
          CLASS_NAME         = V_GROUP_CLASS
          SET_NAME           = V_GROUP_NAME
          SET_TITLE          = V_GROUP_TITLE
        EXCEPTIONS
          NO_SET_PICKED      = 1
          OTHERS             = 2.
      IF SY-SUBRC = 0.
        P_KHINR = V_GROUP_NAME.
      ENDIF.
    ENDFORM.                               " F_GET_S_KHINR
          FORM F_VALIDATE_KHINR                                         *
    FORM F_VALIDATE_KHINR.
      PERFORM F_DIS_MSG USING 100 'Validate Profit Center group.'.
      COMMIT WORK.
      CLEAR I_SET_VALUES.
      REFRESH I_SET_VALUES.
      CONCATENATE C_0106  C_KBRC P_KHINR INTO V_SETID.
      CONDENSE V_SETID.
      CALL FUNCTION 'G_SET_TREE_IMPORT'
        EXPORTING
          CLIENT                    = SY-MANDT
          FIELDNAME                 = 'RPRCTR'
          LANGU                     = SY-LANGU
          SETID                     = V_SETID
          TABNAME                   = 'GLPCT'
          NO_TABLE_BUFFERING        = 'X'
        TABLES
          SET_VALUES                = I_SET_VALUES
        EXCEPTIONS
          SET_NOT_FOUND             = 1
          ILLEGAL_FIELD_REPLACEMENT = 2
          ILLEGAL_TABLE_REPLACEMENT = 3
          OTHERS                    = 4.
      IF SY-SUBRC NE 0.
    E: Unable to find Profit Center Group & - please modify selection
        MESSAGE E000 WITH TEXT-002 P_KHINR.
      ENDIF.
      IF I_SET_VALUES[] IS INITIAL.
        MESSAGE E000 WITH P_KHINR TEXT-039.
      ENDIF.
    ENDFORM.                               " F_VALIDATE_KHINR
          Form  F_SELECT_DATA
    FORM F_SELECT_DATA.
      PERFORM F_DIS_MSG USING 100 'Retrieve info from SAP tables.'.
      COMMIT WORK.
    Build the BFOD_A internal table based on user selections
    f i_cepc table is initial, it means derive all prctr under a co cd
      IF S_PRCTR[] IS INITIAL.
        PERFORM F_RETRIEVE_BFODA_BY_COMPANY.
      ELSE.
        PERFORM F_RETRIEVE_BFODA_BY_PRCTR.
      ENDIF.
      IF I_BFOD_A[] IS INITIAL.
    *... No records fit selection criteria.
        MESSAGE E000 WITH TEXT-H20.
      ENDIF.
    Get the text for profit center
      SELECT SPRAS PRCTR DATBI KOKRS MCTXT FROM CEPCT
                 INTO CORRESPONDING FIELDS OF TABLE I_CEPCT
                  FOR ALL ENTRIES IN I_CEPC
                WHERE SPRAS = SY-LANGU
                  AND PRCTR = I_CEPC-PRCTR.
    Build an internal table of unique bfod keys for bsid and bsad
      I_BFODA_KUNNR[] = I_BFOD_A[].
      SORT I_BFODA_KUNNR BY KUNNR BUKRS GJAHR BELNR BUZEI.
      DELETE ADJACENT DUPLICATES FROM I_BFODA_KUNNR COMPARING
         KUNNR BUKRS GJAHR BELNR BUZEI.
    Build BSID Internal table
      SELECT MANDT BUKRS KUNNR UMSKS UMSKZ AUGDT AUGBL ZUONR GJAHR BELNR
             BUZEI BUDAT HKONT BLDAT WAERS REBZG XBLNR SHKZG DMBTR
             WRBTR ZFBDT ZBD1T ZBD2T ZBD3T
                FROM BSID INTO CORRESPONDING FIELDS OF TABLE I_BSYD
                 FOR ALL ENTRIES IN I_BFODA_KUNNR
               WHERE KUNNR EQ I_BFODA_KUNNR-KUNNR
                 AND BUKRS EQ I_BFODA_KUNNR-BUKRS
                 AND GJAHR EQ I_BFODA_KUNNR-GJAHR
                 AND BELNR EQ I_BFODA_KUNNR-BELNR
                 AND BUZEI EQ I_BFODA_KUNNR-BUZEI.
    Build BSAD internal table
      SELECT MANDT BUKRS KUNNR UMSKS UMSKZ AUGDT AUGBL ZUONR GJAHR BELNR
          BUZEI HKONT BUDAT BLDAT WAERS REBZG XBLNR SHKZG DMBTR WRBTR ZFBDT
          ZBD1T ZBD2T ZBD3T
             FROM BSAD APPENDING CORRESPONDING FIELDS OF TABLE I_BSYD
              FOR ALL ENTRIES IN I_BFODA_KUNNR
            WHERE KUNNR EQ I_BFODA_KUNNR-KUNNR
              AND BUKRS EQ I_BFODA_KUNNR-BUKRS
              AND AUGDT GT P_BUDAT
              AND GJAHR EQ I_BFODA_KUNNR-GJAHR
              AND BELNR EQ I_BFODA_KUNNR-BELNR
              AND BUZEI EQ I_BFODA_KUNNR-BUZEI.
      IF NOT I_BSYD[] IS INITIAL.
    Remove records based on selection criteria
        DELETE I_BSYD WHERE
           NOT BUDAT LE P_BUDAT OR
           NOT HKONT IN S_HKONT.
      ENDIF.
    Acquire document headers
      SELECT BUKRS BELNR GJAHR BKTXT XBLNR HWAER HWAE2 FROM BKPF
                    INTO TABLE I_BKPF
                    FOR ALL ENTRIES IN I_BSYD
                    WHERE BUKRS EQ I_BSYD-BUKRS
                      AND BELNR EQ I_BSYD-BELNR
                      AND GJAHR EQ I_BSYD-GJAHR.
    Sort document lines
      SORT I_BSYD BY KUNNR BUKRS GJAHR BELNR BUZEI ASCENDING.
      SORT I_BKPF BY  BUKRS BELNR GJAHR ASCENDING.
    Create table of unique customers
      SORT I_BFODA_KUNNR BY KUNNR.
      DELETE ADJACENT DUPLICATES FROM I_BFODA_KUNNR COMPARING KUNNR.
    Build customer table
      SELECT KUNNR NAME1 FROM KNA1
                INTO TABLE I_KNA1
                 FOR ALL ENTRIES IN I_BFODA_KUNNR
               WHERE KUNNR EQ I_BFODA_KUNNR-KUNNR.
    Free memory space
      FREE I_BFODA_KUNNR.
    ENDFORM.                               " F_SELECT_DATA
          Form  F_BUILD_I_CEPC_TABLE
          build the i_cepc internal table that would populate the
          valid profit centers to processed.
    FORM F_BUILD_I_CEPC_TABLE.
      PERFORM F_DIS_MSG USING 100 'Build the Profit Center Ref Table.'.
      COMMIT WORK.
    Acquire CEPC table
      IF I_PRCTR[] IS INITIAL.
        SORT S_PRCTR.
        SELECT PRCTR KHINR
          FROM CEPC
          INTO TABLE I_CEPC
          WHERE PRCTR IN S_PRCTR.
    Sort table
        SORT I_CEPC BY PRCTR KHINR.
    Remove duplicate values
        DELETE ADJACENT DUPLICATES FROM I_CEPC COMPARING PRCTR.
        I_PRCTR[] = I_CEPC[].
    Sort table
        SORT I_PRCTR BY PRCTR.
      ELSE.
    Sort table
        SORT I_PRCTR BY PRCTR.
    Acquire CEPC table
        SELECT PRCTR KHINR
          FROM CEPC
          INTO TABLE I_CEPC
          FOR ALL ENTRIES IN I_PRCTR
          WHERE PRCTR = I_PRCTR-PRCTR.
    SOrt table
        SORT I_CEPC BY PRCTR KHINR.
      ENDIF.
      IF I_CEPC[] IS INITIAL.
        MESSAGE E000 WITH TEXT-006.
      ENDIF.
    ENDFORM.                               " F_BUILD_i_CEPC_TABLE
          Form  F_BUILD_I_REPORT
          Build the A/R report internal table from bfod_a, bsid and bsad
          It is necessary to go to BSAD/BSID to get the document currency
          not present in bfod_a.
    FORM F_BUILD_I_REPORT.
      PERFORM F_DIS_MSG USING 100 'Build the report information.'.
      COMMIT WORK.
    Sort all internal tables, this is essential for later processing
      SORT I_BFOD_A BY KUNNR BUKRS GJAHR BELNR BUZEI .
      SORT I_BSYD BY KUNNR BUKRS GJAHR BELNR BUZEI.
      SORT I_CEPC BY PRCTR KHINR.
      LOOP AT I_BFOD_A.
    New customer
        AT NEW KUNNR.
          READ TABLE I_KNA1 WITH KEY KUNNR = I_BFOD_A-KUNNR BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            MOVE I_KNA1-NAME1 TO I_REPORT-NAME1.
          ENDIF.
        ENDAT.
    Acquire header fields
        READ TABLE I_BKPF WITH KEY BUKRS = I_BFOD_A-BUKRS
                                   BELNR = I_BFOD_A-BELNR
                                   GJAHR = I_BFOD_A-GJAHR BINARY SEARCH.
        IF SY-SUBRC NE 0.
          CLEAR I_BKPF.
        ENDIF.
    Build base record
        PERFORM F_MOVE_BASE_TO_REPORT.
    Load profit center data
        IF P_KHINR IS INITIAL.
          IF V_PREV_PRCTR = I_BFOD_A-PRCTR.
            I_REPORT-KHINR = I_CEPC-KHINR.
          ELSE.
            READ TABLE I_CEPC WITH KEY PRCTR = I_BFOD_A-PRCTR BINARY SEARCH.
            IF SY-SUBRC = 0.
              I_REPORT-KHINR = I_CEPC-KHINR.
            ELSE.
              CLEAR I_REPORT-KHINR.
            ENDIF.
            V_PREV_PRCTR = I_BFOD_A-PRCTR.
          ENDIF.
        ELSE.
          I_REPORT-KHINR = P_KHINR.
        ENDIF.
    Reverse signs
        IF I_REPORT-SHKZG = 'H'.
          I_REPORT-DMBTR = I_REPORT-DMBTR * -1.
          I_REPORT-DMBE2 = I_REPORT-DMBE2 * -1.
        ENDIF.
    Additional details
        READ TABLE I_BSYD WITH KEY KUNNR = I_BFOD_A-KUNNR
                                   BUKRS = I_BFOD_A-BUKRS
                                   GJAHR = I_BFOD_A-GJAHR
                                   BELNR = I_BFOD_A-BELNR
                                   BUZEI = I_BFOD_A-BUZEI BINARY SEARCH.
        IF SY-SUBRC = 0.
          PERFORM F_FORMAT_I_REPORT_FR_BSYD.
          APPEND I_REPORT.
        ENDIF.
      ENDLOOP.
    ENDFORM.                               " F_BUILD_I_REPORT
          Form  F_FORMAT_I_REPORT_FR_BSYD
    Retrieve all the information needed for reporting from BSID.
    If a document has a referencing invoice (REBZG), the payment terms
       and the baseline date to be used will come from the referencing
       invoice.
    FORM F_FORMAT_I_REPORT_FR_BSYD.
    *=> get the document currency amount from bsid
      I_REPORT-BLDAT = I_BSYD-BLDAT.
      I_REPORT-WAERS = I_BSYD-WAERS.
    PERFORM F_CONVERT_CURRENCY_FR_2_AMTS USING I_REPORT-HWAER I_BSYD-WAERS
                                                I_BSYD-DMBTR   I_BSYD-WRBTR
                                                             I_BFOD_A-DMBTR
                                                     CHANGING V_BFOD_TXNAMT.
      I_REPORT-WRBTR = V_BFOD_TXNAMT.
      IF I_BSYD-SHKZG = 'H'.
        I_REPORT-WRBTR = I_REPORT-WRBTR * -1.
      ENDIF.
      V_ZBD1T = I_BSYD-ZBD1T.
      V_ZFBDT = I_BSYD-ZFBDT.
    *=> determine reference document (referencing invoice)
      CLEAR I_REPORT-SORT.
      CASE I_BSYD-REBZG.
        WHEN ' '.
          I_REPORT-SORT = I_BFOD_A-BELNR.
        WHEN 'V'.
          I_REPORT-SORT = I_BSYD-XBLNR.
        WHEN OTHERS.
          I_REPORT-SORT = I_BSYD-REBZG.
          PERFORM F_GET_DATEPAYTERM_FR_ORIGDOC.
      ENDCASE.
      CLEAR I_FAEDE.
      I_FAEDE-SHKZG = I_BSYD-SHKZG.
      I_FAEDE-KOART = 'D'.
      I_FAEDE-ZFBDT = I_BSYD-ZFBDT.
      I_FAEDE-ZBD1T = I_BSYD-ZBD1T.
      I_FAEDE-ZBD2T = I_BSYD-ZBD2T.
      I_FAEDE-ZBD3T = I_BSYD-ZBD3T.
      I_FAEDE-REBZG = I_BSYD-REBZG.
      I_FAEDE-BLDAT = I_BSYD-BLDAT.
      CALL FUNCTION 'DETERMINE_DUE_DATE'
        EXPORTING
          I_FAEDE                    = I_FAEDE
        IMPORTING
          E_FAEDE                    = I_FAEDE
        EXCEPTIONS
          ACCOUNT_TYPE_NOT_SUPPORTED = 1
          OTHERS                     = 2.
      V_DPAST = P_BUDAT - I_FAEDE-NETDT.
      IF V_DPAST < 0.
        I_REPORT-DPAST = 0.
      ELSE.
        MOVE V_DPAST TO I_REPORT-DPAST.
      ENDIF.
      I_REPORT-ZBD1T = V_ZBD1T.
      I_REPORT-NETDT = I_FAEDE-NETDT.
    Update totals
      PERFORM F_BUILD_TOTALS.
    ENDFORM.                               " F_FORMAT_I_REPORT_FR_BSYD
          Form  F_GET_DATEPAYTERM_FR_ORIGDOC
    FORM F_GET_DATEPAYTERM_FR_ORIGDOC.
    In order to go back to the original document's payment terms and
    baseline date, we neeed to resort bsid/bsad to a different sort
    order b-coz only these 3 fields logically matched the orig doc
      SORT I_BSYD BY KUNNR BUKRS BELNR.
      READ TABLE I_BSYD WITH KEY KUNNR = I_BFOD_A-KUNNR
                                 BUKRS = I_BFOD_A-BUKRS
                                 BELNR = I_REPORT-SORT BINARY SEARCH.
      IF SY-SUBRC = 0.
        V_ZBD1T = I_BSYD-ZBD1T.            "payment term
        V_ZFBDT = I_BSYD-ZFBDT.            "baseline due date
      ENDIF.
      SORT I_BSYD BY KUNNR BUKRS GJAHR BELNR BUZEI.
    ENDFORM.                               " F_GET_DATEPAYTERM_FR_ORIGDOC
          Form  F_WRITE_REPORT
          Write A/R report summarized by profit center.
          Report will be build by profit center and sum all customers
             then will sum past do for profit center and catagorized
             will also sum by project / wbs element.
    FORM F_WRITE_REPORT.
      SORT I_REPORT BY PRCTR KUNNR SORT BLDAT BELNR DPAST DESCENDING.
      CALL SCREEN 9000.
    ENDFORM.                               " F_WRITE_REPORT
          Form  F_POPULATE_PRCTR_FROM_PRCTRGRP
    FORM F_POPULATE_PRCTR_FROM_PRCTRGRP.
      LOOP AT I_SET_VALUES.
        IF I_SET_VALUES-TO = I_SET_VALUES-FROM.
          I_PRCTR-PRCTR = I_SET_VALUES-TO.
          COLLECT I_PRCTR.
          S_PRCTR-SIGN   = 'I'.
          S_PRCTR-OPTION = 'EQ'.
          S_PRCTR-LOW    = I_SET_VALUES-TO.
          COLLECT S_PRCTR.
        ELSE.
          MESSAGE E000 WITH 'System Error, contact programmer'
                  I_SET_VALUES-TO I_SET_VALUES-FROM.
        ENDIF.
      ENDLOOP.
    ENDFORM.                               " F_POPULATE_PRCTR_FROM_PRCTRGRP
          Form  F_CONVERT_CURRENCY_FR_2_AMTS
          This function module will ensure proper handling of decimals
          and conversion of currency. This will give you the historical
          exchange rate used.
          BFOD_A does not have the trans curr amt so we will get it
           using:  ( bsid trans curr amt / bsid loc curr amt ) *
                   bfod_a loc currency amt
    FORM F_CONVERT_CURRENCY_FR_2_AMTS USING V_FRCURR V_TOCURR
                                            V_OFRAMT V_OTOAMT V_NFRAMT
                                     CHANGING V_NTOAMT.
      CALL FUNCTION 'Z_CONVERT_CURRENCY_FROM_2_AMTS'
        EXPORTING
          FROM_CURRENCY   = V_FRCURR
          TO_CURRENCY     = V_TOCURR
          OLD_FROM_AMOUNT = V_OFRAMT
          OLD_TO_AMOUNT   = V_OTOAMT
          NEW_FROM_AMOUNT = V_NFRAMT
        IMPORTING
          NEW_TO_AMOUNT   = V_NTOAMT
        EXCEPTIONS
          OTHERS          = 1.
      IF SY-SUBRC <> 0.
        MESSAGE E000 WITH TEXT-005.
      ENDIF.
    ENDFORM.                               " F_CONVERT_CURRENCY_FR_2_AMTS
          Form  F_RETRIEVE_BFODA_BY_COMPANY
    FORM F_RETRIEVE_BFODA_BY_COMPANY.
    Acquire BFOD_A table
      SELECT PRCTR KUNNR BUKRS GJAHR BELNR BUZEI AUGDT HKONT BUDAT
             SHKZG DMBTR DMBE2 FROM BFOD_A
         INTO TABLE I_BFOD_A
         WHERE BUKRS IN S_BUKRS.
      IF I_BFOD_A[] IS INITIAL.
        EXIT.
      ELSE.
    Remove records based on selection criteria
        DELETE I_BFOD_A WHERE NOT KUNNR IN S_KUNNR OR
                              NOT BUDAT LE P_BUDAT OR
                              NOT HKONT IN S_HKONT OR
                              NOT BELNR IN S_BELNR OR
                            ( NOT AUGDT IS INITIAL AND
                              NOT AUGDT > P_BUDAT ).
      ENDIF.
    Build selection option
      LOOP AT I_BFOD_A.
        I_PRCTR-PRCTR  = I_BFOD_A-PRCTR.
        COLLECT I_PRCTR.
        S_PRCTR-SIGN   = 'I'.
        S_PRCTR-OPTION = 'EQ'.
        S_PRCTR-LOW    = I_BFOD_A-PRCTR.
        COLLECT S_PRCTR.
      ENDLOOP.
      SORT S_PRCTR.
      SORT I_PRCTR BY PRCTR.
      PERFORM F_BUILD_I_CEPC_TABLE.
    ENDFORM.                    " F_RETRIEVE_BFODA_BY_COMPANY
          Form  F_RETRIEVE_BFODA_BY_PRCTR
    FORM F_RETRIEVE_BFODA_BY_PRCTR.
    Acquire BFOD_A table
      SELECT PRCTR KUNNR BUKRS GJAHR BELNR BUZEI AUGDT HKONT BUDAT
             SHKZG DMBTR DMBE2 FROM BFOD_A
         INTO TABLE I_BFOD_A
         FOR ALL ENTRIES IN I_PRCTR
         WHERE PRCTR = I_PRCTR-PRCTR AND
               KUNNR IN S_KUNNR AND
               BUKRS IN S_BUKRS.
      IF I_BFOD_A[] IS INITIAL.
        EXIT.
      ELSE.
    Remove records based on selection criteria
        DELETE I_BFOD_A WHERE NOT KUNNR IN S_KUNNR OR
                              NOT BUKRS IN S_BUKRS OR
                              NOT BUDAT LE P_BUDAT OR
                              NOT HKONT IN S_HKONT OR
                              NOT BELNR IN S_BELNR OR
                            ( NOT AUGDT IS INITIAL AND
                              NOT AUGDT > P_BUDAT ).
      ENDIF.
    ENDFORM.                    " F_RETRIEVE_BFODA_BY_PRCTR
          Form  F_MOVE_BASE_TO_REPORT
    FORM F_MOVE_BASE_TO_REPORT.
      I_REPORT-PRCTR = I_BFOD_A-PRCTR.
      I_REPORT-KUNNR = I_BFOD_A-KUNNR.
      I_REPORT-BELNR = I_BFOD_A-BELNR.
      I_REPORT-BUKRS = I_BFOD_A-BUKRS.
      I_REPORT-HKONT = I_BFOD_A-HKONT.
      I_REPORT-AUGDT = I_BFOD_A-AUGDT.
      I_REPORT-BUDAT = I_BFOD_A-BUDAT.
      I_REPORT-GJAHR = I_BFOD_A-GJAHR.
      I_REPORT-BUZEI = I_BFOD_A-BUZEI.
      I_REPORT-SHKZG = I_BFOD_A-SHKZG.
      I_REPORT-DMBTR = I_BFOD_A-DMBTR.
      I_REPORT-DMBE2 = I_BFOD_A-DMBE2.
      I_REPORT-HWAER = I_BKPF-HWAER.
      I_REPORT-HWAE2 = I_BKPF-HWAE2.
      I_REPORT-BKTXT = I_BKPF-BKTXT.
      I_REPORT-XBLNR = I_BKPF-XBLNR.
    ENDFORM.                    " F_MOVE_BASE_TO_REPORT
         Module  STATUS_9000  OUTPUT
          text
    MODULE STATUS_9000 OUTPUT.
      SET PF-STATUS '9000'.
      SET TITLEBAR '900'.
    Launch standard ALV grid
      PERFORM F_CREATE_ALV_GRID_CONTROL.
      PERFORM F_LOAD_COLUMN_HEADINGS.
    ENDMODULE.                 " STATUS_9000  OUTPUT
          Module  USER_COMMAND_9000  INPUT
          text
    MODULE USER_COMMAND_9000 INPUT.
      CASE SY-UCOMM.
        WHEN 'EXIT' OR 'CANC' OR 'BACK'.
          CALL METHOD REF_CUSTOM->FREE.
          SET SCREEN 0.
          LEAVE SCREEN.
    Begin of changes for Release 2 by HBE7890 - DEVK909110
        WHEN 'PRIN'.
          PERFORM PRINT_AGING_TOTALS.
    End of changes.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_9000  INPUT
          Form  F_CREATE_ALV_GRID_CONTROL
          text
    FORM F_CREATE_ALV_GRID_CONTROL.
    Set field catalog for ALV
      PERFORM F_SET_FIELDCAT.
      IF REF_CUSTOM IS INITIAL.
      Create ALV container
        CREATE OBJECT REF_CUSTOM
          EXPORTING
            CONTAINER_NAME = 'ZRPT_CONTAINER'.
      Create ALV grid control
        CREATE OBJECT REF_ALV_ZRPT
          EXPORTING
            I_PARENT          = REF_CUSTOM.
    Adjust look and feel
        PERFORM F_CHANGE_SETTINGS.
    Call the ALV Build
        CALL METHOD REF_ALV_ZRPT->SET_TABLE_FOR_FIRST_DISPLAY
          EXPORTING
            IS_LAYOUT       = V_LAYOUT
            IS_VARIANT      = V_VARIANT
            I_SAVE          = V_SAVE
            I_DEFAULT       = V_DEFAULT
          CHANGING
            IT_SORT         = I_SORT
            IT_OUTTAB       = I_REPORT[]
            IT_FIELDCATALOG = I_ALV_FIELDCAT[].
    Create print top of page
        CREATE OBJECT REF_EVENT_RECEIVER.
        SET HANDLER REF_EVENT_RECEIVER->MTH_PRINT_TOP_OF_PAGE
            FOR REF_ALV_ZRPT.
    Create print top of page
        CREATE OBJECT REF_EVENT_RECEIVER.
        SET HANDLER REF_EVENT_RECEIVER->MTH_PRINT_TOP_OF_LIST
            FOR REF_ALV_ZRPT.
      ENDIF.
    ENDFORM.                    " F_CREATE_ALV_GRID_CONTROL
         Form  F_CHANGE_SETTINGS
          text
    FORM F_CHANGE_SETTINGS .
    Set layout parameters
      V_LAYOUT-GRID_TITLE = 'A/R by Profit Center'.
      V_LAYOUT-SEL_MODE   = 'A'.
      V_LAYOUT-INFO_FNAME = 'LINECOLOR'.
      V_LAYOUT-CWIDTH_OPT = 'X'.
      V_LAYOUT-NO_MERGING = 'X'.
      V_LAYOUT-NUMC_TOTAL = 'X'.
      V_DEFAULT           = 'X'.
      V_SAVE              = 'A'.
    Set display variant
      V_VARIANT-REPORT  = SY-REPID.
      IF P_DSVAR NE ''.
        V_VARIANT-VARIANT = P_DSVAR.
      ENDIF.
    ENDFORM.                    " F_CHANGE_SETTINGS
          Form  F_SET_FIELDCAT
          text
    FORM F_SET_FIELDCAT .
    Set field catalog for ALV
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
         I_STRUCTURE_NAME       = 'ZFR0ARPR_S1'  "DEVK909110
          I_STRUCTURE_NAME       = 'ZPSS_ARBYPC'                "DEVK909110
        CHANGING
          CT_FIELDCAT            = I_ALV_FIELDCAT
        EXCEPTIONS
          INCONSISTENT_INTERFACE = 1
          PROGRAM_ERROR          = 2
          OTHERS                 = 3.
    Override any attributes
      LOOP AT I_ALV_FIELDCAT INTO V_ALV_FIELDCAT.
        IF V_ALV_FIELDCAT-FIELDNAME EQ 'NAME1'.
          MOVE 'Customer Name' TO: V_ALV_FIELDCAT-REPTEXT,
                                   V_ALV_FIELDCAT-SCRTEXT_L,
                                   V_ALV_FIELDCAT-SCRTEXT_M,
                                   V_ALV_FIELDCAT-SCRTEXT_S.
        ENDIF.
        IF V_ALV_FIELDCAT-FIELDNAME EQ 'SORT'.
          MOVE 'Documentation' TO: V_ALV_FIELDCAT-REPTEXT,
                                   V_ALV_FIELDCAT-SCRTEXT_L,
                                   V_ALV_FIELDCAT-SCRTEXT_M.
          MOVE 'DocRef' TO         V_ALV_FIELDCAT-SCRTEXT_S.
        ENDIF.
        MODIFY I_ALV_FIELDCAT FROM V_ALV_FIELDCAT.
      ENDLOOP.
    ENDFORM.                    " F_SET_FIELDCAT
          Form  F_BUILD_TOTALS
          text
    FORM F_BUILD_TOTALS .
      DATA: V_DAYS TYPE I,
            V_INDEX(2) TYPE N.
      CLEAR I_TOTAL.
    Build total line
      MOVE I_REPORT-HWAER TO I_TOTAL-WAERS.
      MOVE I_REPORT-DMBTR TO I_TOTAL-TOTAL.
      DO 5 TIMES.
        V_DAYS = ( SY-INDEX - 1 ) * P_AGEDY.
        V_INDEX = SY-INDEX.
        IF I_REPORT-DPAST LE V_DAYS.
          CONCATENATE 'I_TOTAL-DAYS' V_INDEX INTO V_FIELD-NAME.
          ASSIGN (V_FIELD-NAME) TO <COLUMN>.
          <COLUMN> = I_REPORT-DMBTR.
          EXIT.
        ELSEIF SY-INDEX EQ 5.
          CONCATENATE 'I_TOTAL-DAYS' V_INDEX INTO V_FIELD-NAME.
          ASSIGN (V_FIELD-NAME) TO <COLUMN>.
          <COLUMN> = I_REPORT-DMBTR.
          EXIT.
        ENDIF.
      ENDDO.
      COLLECT I_TOTAL.
    ENDFORM.                    " F_BUILD_TOTALS
        

    CO-PA has all the information you need...
    Profitability Analysis is that part of CO where operations will access its performance factors and profitability statements contain margins, standard cost variance, sales information, allocations and other related profit or loss data. This module helps analyze profitability of customers, markets and products at various levels of contribution margins. Profitability is measured down to the SD billing document line and is adjusted periodically against standard costs and other costs.
    It has 2 methods of approach :
    Costing based Profitability Analysis - This is primarily designed to let you analyze profits quickly for the purpose of sales management.
    Account based Profitabilty Analysis - This type of Profitability Analysis enables you to reconcile cost and financial accounting at any time using accounts.
    Guess, the second approach is what you are looking for...

  • Witholding tax at the time of Invoice, payment and advance

    Dear experts,
    I have few questions as below. It would be great if you can help me out in this :
    In vendor master I have two WTH tax codes for invoice and payment and marked as liable.
    Incase of invoice (FB60) posting system is calcu;ating correctly and posting, but while posting no popup for to rectify the WTX code also no base amount is populating in WTH tax tab of invoice posting. Is this correct way??
    While making payment for the same invoice through F-53, system is again calculating on same open item and no popup, until I go to WTH tax tab and delete the tax amount. What is lacking in my customising of WTH tax code (payment type), to restrict WTH tax calcutaing twice ??
    While making advance payment by F-48, system not calculating WTX tax and showing tax code is mandatory, even though tax code (V0-tax exempt) entered, no WTH tax calculation happening. I have checked all Field status of document type and recon account, nothing is mandatory. I dint know why?? Please help in this regard.
    Thanks in advance.
    Regards
    Abhi

    Hi madhu
    Thanks for explaining the process it works.
    Regarding the error I was facing earlier to enter the tax code in F-48 for the tax category was marked as ' * ' in the advance reconciliation GL. I have removed them and now the error is not coming.
    But now for the same or advance payment with F-48, I am not able post the document, though the payment WTX code is showing but not calculating the amount for the same.
    The error is
    "Withholding tax amount exceeds total bank line item amounts."
    Message no. 7Q320
    How to post it. Please help.
    Regards
    Abhi

  • Discount in Outgoing Payment  and Cheque for payment PLD

    Hi,
    Using SBO2007A PL30
    I have tried to find whether there are system variables for amount outstanding and discount which show amounts in foreign and local currency.
    I can't find any references in the .xls document how to use system variables in SBO 2007., and strangely there is no reference in that document to the system variables which already exist in the in- built layouts
    Cheque for Payment
    - total amount paid ( variable 97 )
    Outgoing Payment
    - posting date ( variable 202)
    - Doc Ref ( var 200)
    - Your Ref ( var 201)
    - amount paid ( var 63)
    This leads me to suspect that system variables for outstanding amount and discount may well exist.
    In the meantime I have had to do this using references to database fields Outgoing Payments - Invoices: Discount Amount and Outgoing Payments - Invoices : Amount before Discount with formulae to determin whether the document is in local or foreign currency.
    A further downside to this is that a credit memo is displayed from the latter database field without a negative sign
    Does anyone have any suggestions here?
    Thanks

    Managed to figure out most of it but for the record I have discovered an additional 4 system variables in use for paid document details at line level. Here is the complete list so far:
    outgoing Payment
    PostingDate 202
    our Ref        200
    your Ref      201
    o/S Amt       ?     ( used formula based on db fields instead)
    Discount       ?    (  used formula based on db fields instead)
    Payment       63
    Cheque for Payment
    posting Date  104
    our ref            101
    your ref          100
    O/s amt         96
    Discount           ? ( use formula :difference between 96 and 97)
    Payment        97
    If anyone can supply the missing variables if they exist, I'd be grateful.

  • Tax calculation on down payment

    Hi all,
    At the time of progress billing- there is no tax calculation for down payment for Service Invoice.
    so tax calculation on down payment will be FI step through(F-29).
    For e.g total contract value is 1000 and 10% is down payment..for this tax will be calculated on 900 and for 100 downpaymen the tax calculation will be through FI side.
    Is it possible or correct way t do this otherwise please suggest some other solution.

    Service Tax is NOT Income Tax.  So, you would not calculate Service Tax downpayments.  Service tax is applicable only on Service rendered and does not concern whether it is paid.  (Though, if you want to avail Service tax credit, you'll have to pay for the service, which is mandatory as per the Indian Tax laws).
    So, Service Tax is only calculated from the Invoice.  As long as no invoice is raised, no Service tax is payable / deductable.
    The above is true for India and most countries.  You have not mentioned which country are you working with.  If such a scenario is appropriate in your country, you'll have to consult your country version documentation.
    Ravi.

  • Service Tax On Down Payment and Tax Payment Wizard

    Hi All,
    We would like to make a down payment and apply service tax to it.
    Once i create a AP Down payment invoice with the service tax, make an outgoing payment against it, create AP Invoice and adjust the down payment, now after following this procedure, when i run the tax payment wizard, the service credit available becomes zero.
    It works well in case of partial payment but not 100% advance.  Has anyone faced this issue??
    How can this be resolved?
    Thanks,
    Joseph

    Hi Rahul,
    Exactly! The system doesnt consider the tax on DP when we check through Tax Payment Wizard.
    I guess this is a missing functionality? What do you think? Because there may be a chance that the service tax may get deducted at down payment! What is your take on this?
    Looking for valuable responses from other experts too!
    Thanks,
    Joseph

  • Discount cal by looking at 'Terms of Payment' and 'Baseline date'

    Hi,
    We have activated check box (Max. cash discount) in FBZP tcode for company code CUSA. As a result, when we run F110 (Vendor payment transaction), system is just looking at 'Terms of payment' and not 'Baseline date' and calculating discount FOR ALL VENDORS if the payment terms allow. However, there are some vendors where we need to look at both 'Terms of Payment' and 'Baseline date' and calculate discount.
    How we can do this ? I checked up in F110 if there are any user exits so that we can put our own code for certain vendors, but I did not find any.
    Any other solution for above.
    Pl let us know.
    Niranjan

    Hi Sridhar,
    Thanks for the help, but that will not help us. What you recommend is Alternative Baseline date. We cannot use that as we cannot ask users to enter all the terms of payment details while posting invoice. It is a waste of time. We want something that involves less time in entering data in SAP AND that will solve our current problem. I am looking for better solution.
    Niranjan

  • Interest calculation on due date and not on invoice

    Hello,
    Pls can some one let me how to start interest calculation on due date and not invoice date.
    In the interest calculation, T code FINT, the system calculates interest from invoice date till clearing date and not from due date till clearing date.
    BR,
    Zulfikar

    Hello,
    We have selected the Always calculate interest from net due date check box. but now when i run FINT transaction for a customer it is calculation interest from invoice date and not on due date. the item is already cleared.
    The scenarion is
    the net due date of the docuemnt is 30.07.2008 so the interest calculation should stard from 31.07.2008 till clearing date. but the interest calcualtion is starting from 01..07.2008 which is the invocie date.
    BR,
    Zulfikar

  • My MacBook Pro was stolen last night. I need the serial number. It is not showing up on my devices list. My iPads and iPhones are. I have used it to to sync my phones and pads as well having it registered with apple. Any thoughts? Thanks

    My MacBook Pro was stolen last night. I need the serial number. It is not showing up on my devices list. My iPads and iPhones are. I have used it to to sync my phones and pads as well having it registered with apple. Any thoughts? Thanks

    Click here: https://supportprofile.apple.com/MySupportProfile.do
    SIgn in with your Apple ID, the same one you used to access this support forum.
    Hopefully, you will see a list of all the devices you registered with your Apple ID, including their serial numbers. Let me know how this works out.
    Edit to add: If you enabled "find my imac" on your Pro, you ought to be able to remotely lock it, or even wipe its memory. Click http://www.icloud.com/ sign in with your Apple ID and click the big green "find my iPhone" icon (nevermind the name, it will find all your devices provided they're running Lion or iOS 5).
    Then file a police report and nail the b*****d.

  • Rolling back of Quick Pay Pre-payment and Quick Pay in case of void cheque

    Hi All
    I am facing an issue if you can help me out of if
    Here is a scenario
    a payroll manager runs the following processes.
    1. Payroll run
    2. Pre-Payments
    3. Payroll Archiver
    4. Payment Output file
    After running all these process payroll manager finds that he also has to make an adhoc payment on account of car loan of AED 150,000.
    So he runs following processes
    1. Quick pay for Car loan
    2. Quick pay pre-payments (payment made through check)
    3. payroll archiver
    4. Cheque Writer.
    Now due to some technical fault, alignment on printing of cheque becomes disturbed there for cheque misprinted.
    Payroll manager runs Void Cheque process to cancel the cheque.
    After all these processes which has run successfully, order comes from upper management to rollback quickpay for adhoc payment of loan.
    Now question is how it can be achieved.
    I tried different things as follows
    On Assignment Process results screen i queried the assignment which all the processes in descending order.
    I tried to start roll back from cheque writer but system didn't allowed to do this because of check Void process.
    I tried to start rollback from Magnetic report, system allowed to roll it back.
    Then i tried to rollback Quick-pay prepayment, system did not allow me be do it. There fore i couldn't run rollback for Quick-pay.
    There is an another thing i tried.
    On "Assignment Process Result" screen i queried assignment. Then i delete the first entry of Void cheque by using delete option from menu bar on top and saved the record. then i delete cheque writer entry and saved the record. Then i run rollback for quick pay pre-payments and ran it successfully and then lastly i ran rollback for quick pay run.
    One thing cautioned me that if I delete the void cheque entry then its history may be lost or have lost and on the other hand with out deleting void cheque i cannot proceed to rollback quick pay.
    Kindly tell me the best way to run rollback for quick pay in this situation.
    Regards
    Majid

    Bt do not provide broadband only so you need existing account holder to add broadband to phone account and then you can pay back the account holder - probably not what you want
    the 12 months advance applies to the line rental not the broadband - as I said BT do not sell broadband only you buy a package which includes phone
    If you like a post, or want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side of the post.
    If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • Display Totally paid items(cleared items), partial payments and residual pa

    Hi Experts,
    I am working on one requirement,
    Requirement: Display Totally paid items(cleared items), partial payments and residual payments.
    I am fetching data from BSAD table for Totally paid items, but I want to understand what are the fields to check when fetching data.
    Partial payments: Please let me know the logic to get data for partial payments from BSID table.
    Residual payments: what are the tables to check for residual payments and the logic.
    What are the fields that i have check and what are the fields that I have to check and get.?
    Please let me know what ever you know about this.
    Regards,
    Dileep,

    Hi,
    All types of Payments  either Totally paid items(cleared items) or  partial payments and residual payments the Document Number serious will b same.   Try to  extract by  Filtering Assignment Field .
    Thanks
    Goutam

Maybe you are looking for

  • Problem Installing iTunes on Windows XP   -  Please Help!

    Hey guys, I'm not exactly the best with computers and i finally downloaded the setup for iTunes 9 after many failed attempts. I tried to open the setup file but nothing happened. So obviously i tried again, still nothing happened. It's not responding

  • JEditorPane/HTML image loading delay

    I am using a JEditorPane to render HTML to a graphics buffer which I then write as an image file. Since HTML loading is asynchronous I wait for the "page" property change event after calling setPage() before using print() to capture the rendered HTML

  • IPhoto crash

    Hi, I was recently updating my Macbook pro with latest software updates. It showed a red mark (exclamation in a red circle) in the updates section. I continued updating other softwares and unmarked iPhoto for the time being because of the warning. La

  • Signal drops in Jersey City

    I have a Galaxy S4 and suddenly the signal keeps dropping. Been happening for 2 weeks. I usually notice it at night. This very same thing happened when I had a droid razr maxx. Been happening now for 45min. I can make calls, but no data. Some techs n

  • Are magnetic cases safe to use with iPhone?

    Are magnetic cases safe to use with the iPhone? I've seen a few 3G cases that have magnetic flaps that look awesome, but I've heard arguments both for and against using them.