Profit Center Aging

Dear All,
Is there any way I can get an aging report from SAP by giving the Profit Center? If not, can someone help me with the logic of writing my own report.
Thanks
Reza

Hi Gordon,
We have 4 departments (PG, SV, SM & OH) and we are using the Profit Center functionality to differentiate between these four departments. On the Invoice, I make sure that the profit center is automatically populated on the line level, which in turn, ends up on the Journal Entry row level. Basically, i need to see the aging for each department separately.
Thanks
Reza

Similar Messages

  • Profit Center wise & customer and vendor ageing balance

    HI,
      If anyone has developed the profit center ageing report for customer & vendor open items, then plz provide me the logic used. I need the same to implement for my customer.
    Standard reports ( FBL1N/FBL5N or new GL reports) are not solving my purpose
    Thanks:
    Gaurav

    PCA wise Customer Aging: - Development
    I also developed the same report with following logic and It is working till now.
    1. Copy the Standard customer aging report S_ALR_87012176 and pass the same documents into FAGLFLEXTA and get the Profit Center.
    PCA wise Open Items:  - Standard
    1. GO to FAGLL03 Report
    2. Give all customer reconciliation accounts in GL Account Field in selection (including Spl GL Recon Accounts)
    3. and Execute report, call Customer Code, and Profit Center Field in Layout (in standard layout, Customer Code available, name is not viable).
    4. Short PCA and Customer wise, we will get PCA wise Open Items.
    use the same logic for Vendor also.
    Please check and revert if you need more clarity.
    Regards,
    Ganesh Lokam

  • Vendor Ageing Report Business Area and Profit Center wise

    Dear Experts,
    I have a requirement where user wants a Report for Vendor Ageing Business Area and Profit Center wise.I checked Standard T Codes but the same were Business Area wise but i could'nt find Profit Center wise Report.If their is any standard functionality then please advice.
    We are using SAP ECC 6.0 Classic GL with Spl Purpose Ledger active.Can someone please advice can i derive such a report through Report Painter.If possible please advice in details.
    Your Valuable inputs shall be appreciated....
    Regards
    Rahul

    Hi Durga,
    Can you please elaborate further on the same how you are determining the Report in FBL1N.What are the prerequisited to be taken care of and some further details on the same.
    My Bus Area is not as same as Profit Center eg
    BA          PC
    FXRT     RT0001 / 2 / 3
    TMMG   TM0001/ 2 / 3
    LTOB     LO0001/ 2 / 3
    I checked in my system but we do not have the Program for the following T Codes
    S_PCO_36000218 - Segment Receivables
    S_PCO_36000219 - Segment Payables
    S_AC0_52000887 - Profit Center Receivables
    S_AC0_52000888 - Profit Center Payables
    Regards
    Rahul

  • 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[].

  • Stock ageing report by profit center

    hi I am new to abap, please kindly send the code for the stock ageing report by profit center in MM module

    hi,
    for getting stock ageing report in  profit center in MM
    use the tcode :
    S_ALR_87013348
    from this u can get the necessary data.
    rewards points if useful.
    regards
    sandhya

  • AR Aging by profit center

    My business group has a need to incorporate profit center into our Customer Aging report.
    We have a customer z version of S_ALR_87012176.
    Has anyone been successful doing an aging report with profit center under SAP 6.0 using classic GL.
    We use IKEK to breakdown the AR balance by profit center in PCA but the PCA data doesn't contain the necessary information to generate an aging report.
    Thank you.

    HI
    Go through the links below
    http://forums.sdn.sap.com/thread.jspa?threadID=1746520
    http://forums.sdn.sap.com/thread.jspa?messageID=10758465#10758465
    http://forums.sdn.sap.com/thread.jspa?messageID=6822369#6822369
    http://forums.sdn.sap.com/thread.jspa?messageID=9345468#9345468
    Reg
    Vishnu

  • Profit Center Customer Age Analysis

    Team
    Is there any standard report available to extract subject age analysis by the profit center? In FDI1 am able to see BA and also tried evaluations but to no avail.
    Cheers
    Kartik

    Try using standard report S_ALR_87012078 - Due Date Analysis for Open Items Profit center wise in ECC6.
    If the standard report do not suffice your requirement, you can do the following:
    (Note that if you are classical GL, the profit center is not updated on vendor line item.)
    Go to transaction code FDI4
    Select Form Type RFFRRD20 Line item analysis
    Give your form name and description
    Structure (Two axis) - as defaulted
    Click on Create
    You will have lead column
    Delete the rows 2, 3 and 4
    Double click on column 1
    Enter the customer numbers from 1 to 999999
    First column double click (A)
    Slelect following values
    Due date analysis 1
    Days for net due date 0 to 30
    Give the short name, medium name and long text for the column.
    Repeat this step in next columns like 31 to 60, 61 to 90, 91 to 120 and 121 to 99999 days etc in other columns and select due date analysis 1. (B,C,D,E)
    Create one more column by way of formula. To create a new column you need to double click on blue line. Put formula add all five columns you have created above. (F = ABCDE)
    You prepare one more column with
    Due date analysis 2 (G)
    Now you prepare one more column add (F+G) = This will be total open items = over due and not due.
    Now go to FDI1 and prepare a report - assign the form created in FDI4 to the report.
    Characteristics you need to select are
    Account Type (Select Account Type as D for customers)
    Currency
    Customer
    Document Type
    Special G/L Ind
    Company Code
    Change the output types and options according to your requirement.
    Refer FDI2 and FDI3 for other standard reports created.
    Refer FDI5 and FDI6 for other standard forms created.
    Save your report and execute.
    Regards,
    Gaurav

  • Vendor aging report profit center vise

    Hi,
    The requirement is client wants to have profit center vise due date analyses (0-30,31-60,...).I tried standard reports S_ALR_87013344 profit center payables.But 'no records' message is coming.In Table BSIK field for profit center is not getting updated.
    Any suggestions??
    Thanks,
    Anitha

    Hi
    From NEW GL onwards the reports to view open items asper Profit centre should be seen from the following:
    S_AC0_52000887 - Receivables: Profit Center
    S_AC0_52000888 - Payables: Profit Center
    You can use the same logic used in the above programs for the report:
    S_ALR_87012085 - Vendor Payment History with OI Sorted List .
    Otherwise, you can develop a standalone report using the tables BSIK and FAGLFLEXA by linking these two tables with a common parameter of Document number and the fiscal year. Once you get the details of the document number and fiscal year into FAGLFLEXA, then you can search for the offsetting entry of the vendor line item and fetch profit centre.
    And after getting profit centre, i think you can fetch up the data from BSIK.
    I suggest to try to see how best you can modify the standard report with the same logic as given in the start.
    Reg
    Bharathi

  • 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...

  • Account Recievables Extractor and Profit Center

    Hi Gurus,
    I have a requirement of creating an Aging report ( which i am planning will be based on AR DataSource , 0fi_ar_4).
    Now , i have a requirement to show the Profit Center data in this report.
    I am not sure how to go ahead with this. If anybody has any suggestions please pass it on. 
    Regards,
    Dennis

    Dennis we are going to need some more info on this
    Have you got ECC6 segment ledgers set up for AR and does those post the AR side of the posting to the individual profit centres
    IF you are not using segment ledgers then because of the way FI documents are posted you CANNOT add profit centre to the report
    This is the reason why
    Example FI journal
    dr Customer  117.50
    cr VAT        17.50 default profit centre
    cr revenue    50.00 profit centre A
    cr revenue    50.00 profit centre B
    Now all you have in the AR4 extractor is the 117.50
    The way R3 handles this is that you have a special job which posts via 1KEK or 1KES (I forget which) at month end into the PCA ledger the net balance but not aged per profit centre for the AR sub ledger
    (this month end job is one of the reasons that PCA is being replaced by segment ledgers in ECC6 - 30 days is too late to produce a "segmented" balance sheet as per the IAS 14 and SoX regulations) anyway....
    Unless your process says - there is a 1:1 mapping between each debtor posting and a revenue posting and that revenue posting cannot to be more than 1 profit centre (HIGHLY unlikely)..
    then unfortunately you cannot produce the report
    Somebody has seriously messed up the FICO config andd esign if they request this at the end of the project and haven't designed segment ledgers to handle this...
    (you could have a look at the 0EC_PCA_1 extractors for the PRC4 activity type for the month end postings - but i seriously dount whether the month end PCA jobs are posting document by document - 99% of the time they post by total customer balance and that is not aged)
    Sorry!
    (note: I have had a similar requirement in one of my past projects - the way I did it was to allocate a customer to a "profit centre" - this I did by utisling one of the user defined fields on the customer master and allocating that customer to that "grouping" - ie not physically a profit centre but some sort of grouping that resembled a profit centre - this of course can only happen if logically you can do this irrsptive of the revenue postings to other "profit centres")

  • S_AC0_52000888 - Payables: Profit Center

    Dear All
    Can someone tell me how to add due date or other fields in report S_AC0_52000888 - Payables: Profit Center . Further, how to create vendor or customer aging reports based on document splitting.
    Thanks and Best Regards
    Farhan Qaiser

    This is not a aging report. It just gives you the payables by profit center. I don't think there is a standard report to display the ageing details by profit center. We have developed a custom report for ageing receivables by profit center. At this client, they do not care agieng payables by profit center.

  • Relation between Account Recievables and Profit center

    Hi ,
    Can you pls help me with the relation between the account recievables & Profit center.
    Thanks

    Hi,
    Accounts Receivables records all account postings generated as a result of Customer sales activity.
    These postings are automatically updated in the General Ledger. It is within the Accounts
    Receivables Module that you can monitor aging of the receivables and generate customer analysis. The Accounts Receivable Module also integrates with the General ledger, Sales and Distribution, and Cash Management Modules.
    Profit Center Accounting provides visibility of an organizationu2019s profit and losses by profit center. The methods which can be utilized for EC-PCA (Profit Center Accounting) are period accounting or by the cost-of-sales approach. Profit Centers can be set-up to identify product lines, divisions, geographical regions, offices, production sites or by functions. Profit Centers are used for Internal Control purposes enabling management the ability to review areas of responsibility within their organization. The difference between a Cost Center and a Profit Center is that the Cost Center represents individual costs incurred during a given period and Profit Centers contain the balances of costs and revenues.
    Hope this helps.
    regards,
    mahesh

  • Shall we have internal transactions in profit center

    hi experts,
    in my client we have two divisions (processes), shall i treated as two business areas or profit centers, i want totally individual financial statements like PL statement, balance sheet as well as consolidated balance sheet for one co. code(legel entity), shall we post transaction inbetween profit centers/business areas, what will the impact of that.
    thanks & regards,

    Hi friend,...
    my advice is to you to create two profit centers for each products insted of Business areas.
    Any how u can create P & L Account, B/S at Profit center level and also u can get a consolidated at Cocde level.
    all the reports like vendors, creditors (including aging and etc.,) asset reports etc... can also available at Profit center level.
    And in 6th version Business area concept is given least preference and insted of that using Profit center concept.
    All the best

  • GR/IR account not shown in profit center report

    Dear all
    I have created GR/IR accont, when there is transaction use these account the profit center is appear, but why when i run profit center line item report there is no posting from GR/IR and in S_ALR_87009722 report .there is no posting from GR/IR  new Account but the old account is appear?
    in old GR/IR account i dont thick the open item management, but ini new account i have thick open item management.
    Regards
    Adit

    Hi Aditya
    Your question is not clear...
    1. Did you assign new GR/IR account in OBYC - WRX?
    2. Which PCA you use . New GL PCA or Classical PCA?
    3. If you use Classical PCA, then GR/IR line item wont appear in PCA reports.. You need to run T codes 1KE* at period end
    Regards
    Ajay M

  • How to look at a report for Profit Center ?

    Dear All ,
    Good Morning ,
                                   I need a report which can show a details of posting for all types  of doc. types for ex. ---> " DZ " = Payment from customer , " AB " = Adjustment .Here User's requirement is to see the posting made for these different doc types in a profit center.Is there ne t. code for this ?
    regards
    sap11
    Edited by: sap11 on Jun 26, 2008 10:40 AM

    Hello,
    I think there is no standard report in SAP as per your req.
    You have to make some modification in SAP with the help of ABAP team .
    Your requirement is like to FBO3 to display the documents,you have to add the one selection criteria in  general section in T code FB03 the extra selection criteria would be profit center as per your requirement.
    Hope it will helps you.
    Regards
    Ravi

Maybe you are looking for