Percentage Profit workings?

Hi,
I am using this formula to evaluate the percentage profit on a product :-
=(M464-D464)/(M464*100)
In this case
M464=0.12
D464=0.08
The answer to my formula is 33%
This evaluates the percentage profit between the two prices but what I would like to do is create a formula that calculates this price (M464) from (D464)?
I am struggling with getting htis to work & all the formulas that I have tried come up with different numbers?
Can anyone help me to solve this please?

Thanks for the replies, its better that I expalin all to clear this up
Here is an extract from the table
I am working out retail prices & wholesale prices from the cost prices of an item, a mini truck in this case.
Row 4 is the old system that I had.
D4, has no sum, this is filled by me
E4  has no sum, this is filled by me
F4 =(E4-D4)/(E4*100)
G4, has no sum, this is filled by me
H4 =(G4-D4)/(G4*100)
I4 =(E4-G4)/(E4*100)
Previously I have been filling in e4 & g4 then just playing with the numbers until f4, h4 & i4 display the correct profit %.
F4 should be around 50%
H4 & I4 should be 30%
This can take a bit of time so, on updating the table I figured there should be a sum that can do this for me.  I am just struggling with it.
I need to work out the costs in this way as it continues the ongoing system & effects how prices are discounted later on, outside of Numbers

Similar Messages

  • Percentage Calculation in Query

    Hi Gurus,
      Hope you are all doing good! I have an issue in my query. I have calculated the summation of Profit for 05 and 06 . In the properties these are the specification i have given :
    1.Scaling Factor : 1,000,000
    2.Number of Decimal Place : 0.0
    3.Calculate Result As : Summation
        I get the summation for both 05 and 06 correctly. I computed the percentage for
    both and seems to be fine.
    Formula used for computing percentage : ' / Profit 06' / ' / Profit 05' * 100
    My issue being the Over all percentage seems to be high.
    Any idea Gurus?
    Points would be surely assigned.
    Regards,
    Sunitha.R

    Hi Norris Silva,
    As per your scenario total questions = 11
    persons (c1, c2, c3, c4, c5) = 5
    c1 answered questions = 5
    c2  "          "      = 5
    c3  "          "      = 1
    here to calculate the percentage of answered questions
    for each person. This can be calculated as below with use of
    calculated key figure
    c1's % ---> ci1 answered questions/total questions * 100
             5/(551)*100= 45.45%
    like write formula in calculated key figure for each person.
    Hope it helps you...
    Regards,
    Ramki.

  • CONFUSE

    Hello,
    i am having big confusion about the mandatory fields of fico tables, i asked the question regarding the same in expert somebody told me that mandatory fields are already clikmark in the filed of key/intial there i am having doubt that ok some fileds are already cliked in the field and rest of the fields are uncliked i can understood that the cliked fields are already in the master table and rest of the user have to enter that field then how to know the which fields are mandatory i mean uncliked fields i.e. key/initial.
    also sending the screenshort for one table there the key/intial fields are cliked in top of the two coloums i can understood that are already loaded in the master table again user not necessary to enter that, i want to know rest of the fileds which are mandatory that i want to know, please help me soon and oblige.
    TABLE: LFA1 (Vendor Master (General Section)                              
    FIELD     Key     Initial     DATAELEMENT     DTYPE     LENGTH
    MANDT     √     √     MANDT     CLNT     3     Client
    LIFNR     √     √     LIFNR     CHAR     10     Account Number of Vendor or Creditor
    LAND1               LAND1_GP     CHAR     3     Country Key
    NAME1               NAME1_GP     CHAR     35     Name 1
    NAME2               NAME2_GP     CHAR     35     Name 2
    NAME3               NAME3_GP     CHAR     35     Name 3
    NAME4               NAME4_GP     CHAR     35     Name 4
    ORT01               ORT01_GP     CHAR     35     City
    ORT02               ORT02_GP     CHAR     35     District
    PFACH               PFACH     CHAR     10     PO Box
    PSTL2               PSTL2     CHAR     10     P.O. Box Postal Code
    PSTLZ               PSTLZ     CHAR     10     Postal Code
    REGIO               REGIO     CHAR     3     Region (State, Province, County)
    SORTL               SORTL     CHAR     10     Sort field
    STRAS               STRAS_GP     CHAR     35     House number and street
    ADRNR               ADRNR     CHAR     10     Address
    MCOD1               MCDK1     CHAR     25     Search term for matchcode search
    MCOD2               MCDK2     CHAR     25     Search term for matchcode search
    MCOD3               MCDK3     CHAR     25     Search term for matchcode search
    .INCLUDE               SI_LFA1     STRU     0     Vendor Master (General Section)
    ANRED               ANRED     CHAR     15     Title
    BAHNS               BAHNS     CHAR     25     Train station
    BBBNR               BBBNR     NUMC     7     International location number  (part 1)
    BBSNR               BBSNR     NUMC     5     International location number (Part 2)
    BEGRU               BEGRU     CHAR     4     Authorization Group
    BRSCH               BRSCH     CHAR     4     Industry key
    BUBKZ               BUBKZ     NUMC     1     Check digit for the international location number
    DATLT               DATLT     CHAR     14     Data communication line no.
    DTAMS               DTAMS     CHAR     1     Report key for data medium exchange
    DTAWS               DTAWS     CHAR     2     Instruction key for data medium exchange
    ERDAT               ERDAT_RF     DATS     8     Date on which the Record Was Created
    ERNAM               ERNAM_RF     CHAR     12     Name of Person who Created the Object
    ESRNR               ESRNR     CHAR     11     POR subscriber number
    KONZS               KONZS     CHAR     10     Group key
    KTOKK               KTOKK     CHAR     4     Vendor account group
    KUNNR               KUNNR     CHAR     10     Customer Number 1
    LNRZA               LNRZA     CHAR     10     Account Number of the Alternative Payee
    LOEVM               LOEVM_X     CHAR     1     Central Deletion Flag for Master Record
    SPERR               SPERB_X     CHAR     1     Central posting block
    SPERM               SPERM_X     CHAR     1     Centrally imposed purchasing block
    SPRAS               SPRAS     LANG     1     Language Key
    STCD1               STCD1     CHAR     16     Tax Number 1
    STCD2               STCD2     CHAR     11     Tax Number 2
    STKZA               STKZA     CHAR     1     Indicator: Business Partner Subject to Equalization Tax?
    STKZU               STKZU     CHAR     1     Liable for VAT
    TELBX               TELBX     CHAR     15     Telebox number
    TELF1               TELF1     CHAR     16     First telephone number
    TELF2               TELF2     CHAR     16     Second telephone number
    TELFX               TELFX     CHAR     31     Fax Number
    TELTX               TELTX     CHAR     30     Teletex number
    TELX1               TELX1     CHAR     30     Telex number
    XCPDK               XCPDK     CHAR     1     Indicator: Is the account a one-time account?
    XZEMP               XZEMP     CHAR     1     Indicator: Alternative payee in document allowed ?
    VBUND               RASSC     CHAR     6     Company ID of Trading Partner
    FISKN               FISKN_K     CHAR     10     Account number of the master record with fiscal address
    STCEG               STCEG     CHAR     20     VAT registration number
    STKZN               STKZN     CHAR     1     Natural Person
    SPERQ               QSPERRFKT     CHAR     2     Function That Will Be Blocked
    GBORT               GBORT_Q     CHAR     25     Place of birth of the person subject to withholding tax
    GBDAT               GBDAT_Q     DATS     8     Date of birth of the person subject to withholding tax
    SEXKZ               SEXKZ     CHAR     1     Key for the *** of the Person Subject to Withholding Tax
    KRAUS               KRAUS_CM     CHAR     11     Credit information number
    REVDB               REVDB_CM     DATS     8     Last review (external)
    QSSYS               QSSYS_IST     CHAR     4     Vendor's QM system
    KTOCK               KTOCK     CHAR     4     Reference Account Group for One-Time Account (Vendor)
    PFORT               PFORT_GP     CHAR     35     PO Box city
    WERKS               WERKS_EXT     CHAR     4     Plant (Own or External)
    LTSNA               LTSNA     CHAR     1     Indicator: vendor sub-range relevant
    WERKR               WERKR     CHAR     1     Indicator: plant level relevant
    PLKAL               FABKL     CHAR     2     Factory calendar key
    DUEFL               DUEFL_BKPF     CHAR     1     Status of Data Transfer into Subsequent Release
    TXJCD               TXJCD     CHAR     15     Jurisdiction for Tax Calculation - Tax Jurisdiction Code
    SPERZ               SPERZ     CHAR     1     Payment Block
    SCACD               SCACD     CHAR     4     Standard carrier access code
    SFRGR               SFRGR     CHAR     4     Forwarding agent freight group
    LZONE               LZONE     CHAR     10     Transportation zone to or from which the goods are delivered
    XLFZA               XLFZA     CHAR     1     Indicator: Alternative payee using account number
    DLGRP               DLGRP     CHAR     4     Service agent procedure group
    FITYP               J_1AFITP_D     CHAR     2     Tax type
    STCDT               J_1ATOID     CHAR     2     Tax Number Type
    REGSS               J_1AREGSS     CHAR     1     Registered for Social Insurance
    ACTSS               J_1AACTSS     CHAR     3     Activity Code for Social Insurance
    STCD3               STCD3     CHAR     18     Tax Number 3
    STCD4               STCD4     CHAR     18     Tax Number 4
    IPISP               J_1BINDEQU     CHAR     1     Tax Split
    TAXBS               TAXBS     NUMC     1     Tax Base in Percentage
    PROFS               PROFS     CHAR     30     Profession
    STGDL               STGDL     CHAR     2     Shipment: statistics group, transportation service agent
    EMNFR               EMNFR     CHAR     10     External manufacturer code name or number
    LFURL               URL     CHAR     132     Uniform resource locator
    J_1KFREPRE               REPRES     CHAR     10     Name of Representative
    J_1KFTBUS               GESTYP     CHAR     30     Type of Business
    J_1KFTIND               INDTYP     CHAR     30     Type of Industry
    CONFS               CONFS_X     CHAR     1     Status of Change Authorization (Central)
    UPDAT               UPDAT_RF     DATS     8     Date on Which the Changes Were Confirmed
    UPTIM               UPTIM_RF     TIMS     6     Time of Last Change Confirmation
    NODEL               NODEL_X     CHAR     1     Central deletion block for master record
    QSSYSDAT               QQSSYSDAT     DATS     8     Validity date of certification
    PODKZB               PODKZB     CHAR     1     Vendor indicator relevant for proof of delivery
    FISKU               FISKU     CHAR     10     Account Number of Master Record of Tax Office Responsible
    STENR               STENR     CHAR     18     Tax Number at Responsible Tax Authority
    .APPEND               ALFA1_PSO     STRU     0     Local Authority Additional Fields (Address)
    PSOFG               PSOFG     CHAR     10     Processor group
    PSOIS               PSOIS     CHAR     20     Subledger acct preprocessing procedure
    .INCLUDE               IADDR_PSO     STRU     0     Local Authority Additional Fields (Address)
    PSON1               NAME1_GP     CHAR     35     Name 1
    PSON2               NAME2_GP     CHAR     35     Name 2
    PSON3               NAME3_GP     CHAR     35     Name 3
    PSOVN               PSOVN     CHAR     35     First name
    PSOTL               PSOTL     CHAR     20     Title
    PSOHS               PSOHS     CHAR     6     House number: is no longer used from Release 4.6B
    PSOST               PSOST     CHAR     28     Street: No longer used from Release 4.6B

    hi
    u click on the entry help/check
    after that some table name r there,just click on the tables that r appeared so theat fileds is key fields for another table,so u may use that as key mandatory fields..in u r program..
    not  all fields according to u r requirement u sue that fields

  • Result Analysis - Profit Percentage based on Revenue

    Deare Gurus,
    While executing Result Analysis, we see profit percentage on the right side as percentage onthe basis of costs. We would like to view such detail as a percentage of revenue
    eg: standard
    Revenue - 100
    Costs - 80
    Profit - 20
    Profit percentage = 20/80 = 25%
    We want it to be 20/100 = 20%.
    Please help!!!!

    Hi Babu,
    I think your example is not totally clear. From what I understand, you need to calculate a result in percentage based on the result of two other columns. What you can do is to use the first result (from the two columns) as a CKF. And then, to this CKF, use the result calcultation options of the query desinger for percentage.
    Hope this helps.
    Regards,
    Diego

  • Profit and Loss Percentage Challenge

    We control our Gross Margins and Costs by expressing every Profit and Loss item as a percentage of the Total Sales. So our Total Sales is 100%. So everything is divided by the 100% to calculate a Percentage. So for example a Gross margin is 45% (Of the 100%). Advertising Cost is 15% of Total Sales. Net Profit may be 4% etc. My question is if anybody knows if such report exisits in SAP b1. as a Standard or how can I achieve this?
    EG
    SALES                          $10,000    100%
    COST OF GOODS          $  5,500     55%
    Gross Profit                    $  4,500     45%
    Advertising Cost                $  1500     15%
    Telephone                         $    200       2%
    Admin                               $  1600     16%
    Overheads                         $    800       8%
    Net Profit                           $     400        4%  
    Thanks
    Robert

    Hi Robert,
    I had the exact same question as you did in regards to adding a percentage to the P&L Statement.  I found using the XL Reporter to be fairly simple and straight-forward.  Below is a link to the SAP documentation on how to create a P&L using the XL Reporter.  From there I just modified it a bit to add a column with the corresponding percentages.
    https://websmp110.sap-ag.de/~sapidb/011000358700001160462006E.pdf
    Hopefully, this helps anybody else that's looking to add percentages to the P&L.
    Thanks,
    Amanda

  • Approval Template by Gross profit Percentage for entire Document

    I'm trying to figure out how to create an approval template that would require an approval if the entire Sales order falls below a minimum gross profit percentage. I did find a built in function that I can require approval if any single line items drop below minimum, but I haven't been able to find a way to either select the gross profit percentage or access the needed fields to calculate the GPP.
    Thanks in advanced

    Hi Nick
    You can give an approval template of the gross profit percentage at the document level in the sales order but not at the row level, it will suit if the condition one to one relationship exists. Thought on the queries and formatted searches might help.
    HTH
    Thanks & Regards
    baskar

  • Creating a Profit Margin Percentage column in Numbers '09

    I searched around the forums and could not find anything on this topic.
    Basically I am making a spreadsheet for the company I work for and want a column that has our profit margin percentage for a couple of items we sell.
    Problem is, I only have basic knowledge of spreadsheet formulas
    Can anyone help? Thanks!

    plan9
    Hi welcome to the forum.
    The spreadsheets in Pages follow the formating and formulae in Numbers.
    Download the Formulaand_FunctionsUserGuide.pdf from under the Help menu in Numbers.
    Peter

  • Crosstab Profit Margin Percentages

    In Crystal 9 or Crystal Xi I need a crosstab as shown below.
    Each cell containts Sales, Profit, and Profit as a Percent of Sales
    _____________Month____
    _________1____2_____3
    Huey ___120__150__200
    ________10___ 20___15
    ________8%__13%__8%
    Dewey__300__250__350
    ________-30___40___25
    _______-10%__16%__7%
    Please note that the Profit percentages are calculated for each month.
    I am not looking for each month's profit as a percentage of the total profit.
    The main report contains all the necessary groupings and calculations.
    How can I get the crosstab to show the Profit percentages?
    Thanks,
    Art
    Edited by: Art Schwalge on Nov 30, 2009 4:29 PM

    I Art
    I have two fields last year costs and last year sales.
    I created a formula field in which I wrote the below formula
    product.last year sales - product.last year cost
    I opened the cross tab expert and I put this formula field in summarized fields. I clicked on change summary and checked that by default "calculate this summary" is a sum.
    I checked the options for "Show as percentage of".Click on Ok.
    Please let me know if you could get the desired output after trying a similar way like above.
    Regards
    Sourashree

  • Sales Analysis - Gross Profit Percentage

    Hello,
    This is a very basic question that hopefully somebody can help me with.
    I ran the Sales Analysis by Customers --> Orders --> for a specific customer.  When I look at the detailed report of the Sales Analysis for this particular customer there are two orders.  I'm confused by how SAP is calculating the gross profit percentage.
    For example, one of the invoices has a sales amount of $76,160.00 and a gross profit of $22,580.00.  The gross profit percentage on the analysis is 42.143. 
    Shouldn't the GP % really be 29.648%?  I used the following formula to calculate this:  (Gross Profit/Sales Amount)*100. 
    What formula is SAP using? 
    Thank you,
    Amanda

    I get it.  It's calculating, however, it's setup on that tab.
    I've been able to calculate both percentages now.
    Thank you so much for your help.  I knew it had to be basic!
    Thanks!
    Amanda

  • How much profit is Apple making off of Apple Pay?  What is their percentage cut?

    How much profit is Apple making off of Apple Pay?  What is their percentage cut per transaction?

    .15% from banks not the merchant

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

  • Allocation of cost  from one profit center group to various profit centr gr

    Hi Experts,
    Here we  created one profit center as group function having various cost centers like common function Admin,Accounts,Legal,HR etc. Now we want to allocate the the cost from group function to various profit center group.
    Kindly give your valuable solution.
    J.Francis

    Hi,
    The allocation can be done through Distribution either in a fixed value or in percentages.  You can define a planning
    cycle for a sender profit center group and define the amount to be allocated to receiver profit center group.
    Define Actual cycle in the same way.  In periodic processing which may be every month/quarterly/half yearly,
    you can distribute the values from one group to the other.
    Best Regards,
    Sadashivan

  • Calculating Profit of COGS - different ways of calculating

    I found that in SAP B1 the profit calculation varies and it depends on where you look and the different settings allowed. For instance:
    I am talking about the calculation method of COGS:
    1. In System Initialisation/Document Setting one can set the workings of Profit on say Last Calculated Price
    2. In individual (say Item Code ABC) Item Master Data one can set the calculation method on FIFO
    3. In another Item Master Data (say Item code FGH) can be set on Average Cost method
    So now we have 3 ways of calculating COGS in the same system - so how can one achieve consitency?
    My understanding is that setting 1 is not taken into account when the system charges COGS, so does anybody know what is the purpose of this setting?
    Thank you
    Robert
    I am trying to debate this in order to confirm my understanding

    Robert--
    The basic rule to understand in B1 is that specific settings take precedence over general settings.  The company-wide default settings that you find in the System Initialization screens set the general parameters for the system.  But they may be overridden on specific records - like the Item Master or BP Master.  On these, company policy may determine that certain items or business partners do not fit the general rules and should be treated differently in some regard.  So an authorized user may change the default settings for these records, either during the initial entry of the record or afterwards (if changes to the specific fields are permitted).  Similarly, users may change some settings on specific documents if they represent an exception situation that should not be forced to follow the usual rules.
    The other consideration - which should make accountants happy - is that settings that affect journal postings generally cannot be changed once they have been used.  So for example, a customer's AR control account number cannot be changed once there are any transactions for that customer. An item's valuation method cannot be changed while there are quantities in the warehouse or open documents that may have caused journal postings.  These rules may not represent consistency, as you wish for, but they do enforce an integrity in the accounting process.
    The place where these restrictions cause problems is if records are imported from a legacy system without regard to the system defaults.  Since these records are brought in and saved in a single process, they can have whatever settings are specified in the import process, which may or may not be the same as the system defualts you wanted.  Once these records are created and then used in transactions, it is very difficult to make them conform to what you wanted.  Changing the system defaults will never cause retroactive changes to existing records.
    If you are having continuing problems with settings on new records, I would consider restricting authorization for adding or editing new records to those people who understand what the ramifications are.  Additional training for your personnel may also be helpful, now that you have a better understanding of how the system works.

  • What is Indirect Allocation in Profit Center Report?

    Hi Experts
    Can Anybody tell me What it show in Indirect allocation Column. I checked it all  the transaction it shows in Direct allocation. 
    Thanks
    Regards
    Gorge

    Hi,
    For a profit center created, a default distribution rule is created which is mapped to direct expenses.
    If you want to show any expense under indirect expense, create a new distribution rule under
    Financials->Cost Accounting->Distribution Rules
    1.Give distribution code and name
    2.In the total field put 100
    3.Now map the cost centers with repective percentage where you need to book the expense as indirect expense
    4.Dont check the direct debit, if this is checked all the entries will be shown in direct expenses
    Map this distribution rule in the chart of account.
    Now book an expense for that account, this will be shown under indirect expense column in the profit center report.
    Hope this is helpful.

  • STO - Profit center report

    Dear Experts,   I have one scenerio  Please help guide, 
    When we do STO for two plants, sending plant(1001) receiving plant (1002), scenario need to be configured,  Profit center wise Report should happen in both pant.
    Cost Of Goods Manufactured at plant 1001       Rs: 950
    Admin expense(Cost with markup fixed value)   RS:  50
    (Admin charge, it may be percentage or fixed price wise for one month putting manually)
    1) Now the point is when they send material through STO process below scenario should happen as per my requirement
    Receiving Plant 1002 (COGM)      Dr    950
    Admin charges(expense)             Dr      50 (Profit center 5001)
    To Sending Plant 1001(COGM)     Cr    950-
    To Admin charge(income)             Cr     50- (Profit Center 5002)
    2) Profit center accounting activated, when I see profit center wise report for Individual and consolidation report should show as bellow I mentioned
    Individual wise   Profit center           Profit center
                        5002                   5001
              Admin charge Income Dr 50      Admin charge(income) Cr 50-
                  Total     =   50                Total  =      50-
    Consolidation Profit center (5001+5002)
    50 Dr         50 Cr       Total = 0
    If I want to go for above scenario How can I do at configuration level...
    Regards
    Chandu

    Hi,
    Configure the transfer pricing between the profit centers. This enables u track internal movement of goods and internal profit...
    Regards
    Sudhakar Reddy

Maybe you are looking for

  • JSF Design Time View Not working correctly for ADF/JSF components

    My project is not using any external tag libraries. It is based purely on ADF core/html and JSF core/html components. The design time view does not show the appropriate presentation, everything is shown as nexted frame containers (I suppose how you w

  • The number of details is not matching with the total count.

    Hi all, again stuck with the code. There is a form where i have to populate all the details of few tables in excel & there is a report where i have to make count of all these details. The problem here is the number of details that is populated in exc

  • Help with the event log in the type B hub

    I have  probs with broadband slowing down and also with link going down a number of times again (it recovers quickly) I just wanted to confirm that the message in trhe event log in the type B hub:- (134558.700000) RTNL: Received ERROR reply 'No such

  • I need to download firefox 4.0 to file my FASA

    How do I download firefox 4.0 on my Mac, so I can get into a government web site to file my FASA for college?f''' '''

  • Exceptions while generating reports

    Hi, We are facing a problem while exporting the reports in PDF/RTF format. find below the errors messages displayed Error   Can't connect to CRXI window server using 'WNCSUSHCLIN0110.ncsbe.eu.jnj.com:0.0 as the value of the DISPLAY variable' and for