Profit center in FI-module

Hi All,
Is there any field named as parent profit center?
I know "parter profit center" related to profit center accounting.
But never heard and seen about parent profit center.
Please let me know exactly.
Thanks and regards,

hi sarau,
  ya ur right Profit center is the field anme generally on that profit centre only u have to do analysis of profit/loss .
but in some cases i.e if it having hierarchy in that "parter profit centers" also having analysis.
Thanks
kiran.
assign the points if it helpfull**

Similar Messages

  • Profit center conversion Function Module

    Hi,
    Is there Any Function Module to  Convert Profit Center from 4 digit into 10 digit.
    Regards,
    Dhanush.S.T

    Try using FM CONVERSION_EXIT_ALPHA_INPUT.
    data: lv_prctr type prctr value '1234'.
    CALL 'CONVERSION_EXIT_ALPHA_INPUT'
      exporting input = lv_prctr
      importing output = lv_prctr.
    "After this call lv_prctr will have values '0000001234'.
    Hope this helps.
    Thanks,
    Balaji

  • How to User Profit Center Fucntionality in ISH Module

    Hi,
    In ISH Module, i dont find an option To User Profit Center Accounting fucntionality as i am able to see only Cost Center & Internal Order.
    Kindly Proivde me some inputs how to use Profit Center in ISH module and How to get the P&L Reports profit center wise.
    Thanks

    Hi
    IS-H uses cost centers for revenue accounting, you must deactivate the flag that blocks revenue accountig in cost center master data. The revenues are then posted to profit center assigned to the cost center. There is no place to configure profit center accounting in IS-H.
    With best regards
    Matías

  • Profit Center Report doesn't show data

    Dear Experts,
    I've posted some data thru FB50 in FI, with different cost center assignment 1201 and 1202.  Both cost centers are assigned to profit centers, YB110 and YB120 respectively in master data.
    Then, I tried to run a profit center report, S_ALR_87013326 from Profit Center Accounting (PCA) module but doesn't show any data.
    Do I need to do any period-end processing in order to get the data out from PCA report?
    By the way, the selection required for plan version, I just keyed in '0'.  Not sure of the number, where to find the plan version as I didn't create any plan before this.
    regards,
    Abraham

    Hi
    If you see the screen shot I attached, it has the text "(new)" against the Folder name...
    All new gl reports are under such a folder to differentiate... You cant deactivate any reports from the Standard Menu... You can just control it by authrization....
    You can also ask your BASIS guy to display only the authorized trans on the user screen so that they are not able to see the std set of transactions
    Br, Ajay M

  • Function module to find the top node in the Profit Center standard hierarch

    Hi,
    Please let me know the function modules/Tables to do the following.
    1. To find the Top node in the Profit center standard hierarchy which is displayed via KCH6N Transaction.
    2. To read/retrieve standard hierarchy displayed in KCH6N Transaction.
    Thanks in Advance,
    Madhuri.

    Hi Madhuri ,
    have a look @<b>SETLEAF</b> or SET* in se11 , u can get the Top Node by putting the Logic like this
    ex: i am searching for Top Node of A3
    <b>select setname from setleaf where  valfrom eq 'A3'.</b>and for that selected setname u have to do one more
    loop.
    <b>select setname from setleaf where  valfrom eq 'A2'.</b>
    then only u will net Node A1.
    this is a sample code only , dont check F2.
    let me know if u want more inputs of Set Ids.
    regards
    prabhu
    [email protected]
    NjoySAP

  • Get Profit Center Function Module

    is there any Get Profit Center Function Module..
    what for is it used ? how way is it related to profit center.
    What are the transaction codes of MR1M,OKB9.
    What is the significance of using these ?
    Could any body please explain.
    THANKS IN ADVANCE...

    All the profit center are stored in CEPC - Profit Center Master Data Table, so u get the profit center details from this table.
    Check the below link for the transaction:
    http://help.sap.com/saphelp_utilities472/helpdata//EN/08/513e4243b511d182b30000e829fbfe/frameset.htm
    Regards,
    Prakash.

  • Function module for Profit Center group and Cost Center group changes

    All,
    The requirement is to change the profit center group and cost center group from one node to another. Please remember it is trying to simulate the transactions KCH5 and OKEO programatically.
    I would like to know if somebody had this requirement previously and had made use of some function module or some other technique which will help in changing the standard hierarchy nodes.
    Help is much appreciated.
    Regards,
    Hari

    All,
    The requirement is to change the profit center group and cost center group from one node to another. Please remember it is trying to simulate the transactions KCH5 and OKEO programatically.
    I would like to know if somebody had this requirement previously and had made use of some function module or some other technique which will help in changing the standard hierarchy nodes.
    Help is much appreciated.
    Regards,
    Hari

  • Function Module to Update the Profit Center in Profit Segment of SO?

    Hi,
           I am updating the profit center with help of user exit in the sales order at the time of saving it. But my problem is it doesnt appear in the Profit Segment in the Account Assignment.
           So if i go to the change mode of a Sales Order do some change and save it, the profit center get determined automatically. Now if one goes into the display mode of the same order and goes into Account Assignment of a particular item we can see that the Profit Center in the Profit Segment pop-up is not updated.
          My question here is, is there a function module to derive/update the profit segment so all the details get updated in the user exit used to update the profit center?

    Hi Deepika,
    Did you find any way to update the discount pricing in camapign.
    Thanks,
    Satya

  • Print Sort Code in Profit Center Report

    Hi,
    i'd like to print the field Sort Code in the 'Profit Center Report by Linked Accounts', from Profit Centre Report, but i'm not able to do.
    I can see Profit Centre field, and Name field, but not the Sort Code.
    There is a way?
    Thank you very much.
    Regards
    Marco

    Hi,
    You will still get the answer from ERP financials. SAP Business 1 is simply a preconfigured SAP R3 system with the same modules etc. and this question is very definitely a financial module problem.
    I am sure that you will get the answer there.
    Good luck
    Steve B

  • A material document was posted to a Profit Center that didn't exist yet

    Material document 4900876825 posted to profit center
    P102925892 on 1/26/07.  According to the master data record it wasn't created
    until 1/31/07.  This caused an FDM issue.
    How is this possible?
    There is an  include program in FI_DOCUMENT_PROJECT which calls the  function module  Z_GET_PDC_PLANT. Apparently,  this function module does not contain any logic for checking if whether the "formulated" profit center is valid or not (or the FM did not use function KE_PROFIT_CENTER_CHECK to validate profit center).

    Good luck, Apple tends to treat suggestions as their own property, though

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

  • Hi Profit center descriptions

    Hi Experts,
         For this design only profit centers under the following level 4 nodes will need to be extracted and sent to PROS SOI7CR0326 , SOI7FU0763 , SOI7FU0764 , SOI7FU0765.  All profit centers under these nodes will need to be sent although only level 4, level 6, and level 7 descriptions should be sent for each profit center.  I used transaction KCH3 to view the hierarchy below.
         I need descriptions for all the profit centers for the above mentioned nodes,  please see the code and give me some solution.
        5  SOI_STREAM      Downstream                                                                               
    4  SOI4000011      DOWNSTREAM (OIL)                                                       
            4  SOI5000001      DOWNSTREAM REFINING 1 PEER GRP                                         
            4  SOI5000002      DOWNSTREAM REFINING 2 PEER GRP                                         
            4  SOI5000003      DOWNSTREAM COMMERCIAL PEER GRP                                         
            5  SOI5000004      DOWNSTREAM RETAIL PEER GROUP                                                                               
    4  SOI6AC0001      ACCELERATOR BUSINESS UNIT                                          
                4  SOI6CR0001      US CONVENIENCE OPERATIONS                                          
                5  SOI6FU0001      US FUELS OPERATING UNIT                                                                               
    5  SOI7FU0692      SECONDARY TRANS / PIPELINE                                     
                    5  SOI7FU0762      RESTRUCTURING HIERARCHY                                        
                    5 <b> SOI7FU0763</b>      US FUELS MARKETING - EAST/GULF COAST         <--           Level 4 Description                                                                               
    5  SOI7FU0766      EGC FUELS SUPPLY GEOGRAPHY                                                                               
    5  SOI7FU0017      NORTHEAST GEOGRAPHY                                     <--          Level 6 Description
                                                                                    18026650   EAST S&H OPPORTUNITY PROJECTS EXPENSE       <--          Level 7 Description                                                                               
    5  SOI7FU0033      NEW YORK HARBOR - SUPPLY ENVELOPE                                                                               
    5  SOI7FU0034      TERMINALS&SUPPLYPLANTS -NEW YORK HARBOR                                                                               
    5  SOI7FU0174      GASOLINE - NEW YORK HARBOR                                                                               
    18000063   MA FIELD DISTRIBUTION                          
                                            18000070   WASHINGTON DC-20003 (LPOB)                     
                                            18000361   WILMINGTON DE-19801 (LPOB)                     
                                            18000371   CORAOPOLIS PA-15108 (LPOB)                     
                                            18000396   PHILADELPHIA PA-EXXON (LTOZ)                   
                                            18004753   BROOKLYN TERMINAL
    * This program can be used to export profit center hierarchies or other groups in a level table (format used by RGSIMPH1)
    * To actively use this program:
    *   - copy it to a local object
    *   - adapt DATA_TAB to the data structure in your foreign system
    *     (change positions, length of fields, remove TOVALUE if
    *      hierarchies contain single values only, ...)
    *   - write an export routine for DATA_TAB if you don't want to
    *     download it to the presentation server
    * Example hierarchy that will be exported by this program
    *    HIER-TOP                      Top node
    *      |
    *      |---- HIER-010              Node 10
    *      |       |
    *      |       |---- HIER-011      Node 11
    *      |       |       - CC 1      Profit center 1
    *      |       |       - CC 2      Profit center 2
    *      |       |
    *      |        ---- HIER-012      Node 12
    *      |               - CC 3      Profit center 3
    *      |               - CC 4      Profit center 4
    *      |
    *       ---- HIER-020              Node 20
    *              - CC 5              Profit center 5
    * The level table  DATA_TAB will look like this:
    *    Level  Groupname    Fromvalue  Tovalue           Descript
    *    0001   HIER-TOP                                  Top node
    *    0002   HIER-010                                  Node 10
    *    0003   HIER-011                                  Node 11
    *    0004                CC 1       CC 1
    *    0004                CC 2       CC 2
    *    0003   HIER-012                                  Node 12
    *    0004                CC 3       CC 3
    *    0004                CC 4       CC 4
    *    0002   HIER-020                                  Node 20
    *    0003                CC 5       CC 5
    *  Standard Architecture Data Structures
    INCLUDE: zbiod001,
             zbiud002,
             zbiud007.
    DATA: c_text_write(5) TYPE c VALUE 'Write'.
    TABLES: CEPC,
            CEPCT.
    *------------------------ Data ---------------------------------*
    DATA: I_CEPCT  LIKE CEPCT OCCURS 0 WITH HEADER LINE,
          WA_CEPCT LIKE CEPCT,
          I_CEPC   LIKE CEPC OCCURS 0 WITH HEADER LINE,
          WA_CEPC  LIKE CEPC.
    DATA: W_OBJECTID LIKE CDHDR-OBJECTID,
          W_LEVEL_CODE(30) TYPE C,
          W_LEVEL_NAME(50) TYPE C,
          W_LEVEL_CODE1(30) TYPE C,
          W_LEVEL_NAME1(50) TYPE C.
    DATA: BEGIN OF I_PROFIT OCCURS 10,
      ID(15)                TYPE C,
      CODE(10)                 TYPE C,
      NAME(20)                 TYPE C,
      DESC(40)                 TYPE C,
      HIER_LVL1_CODE(30)       TYPE C,
      HIER_LVL1_NAME(50)       TYPE C,
      HIER_LVL2_CODE(30)       TYPE C,
      HIER_LVL2_NAME(50)       TYPE C,
      HIER_LVL3_CODE(30)       TYPE C,
      HIER_LVL3_NAME(50)       TYPE C,
      HIER_LVL4_CODE(30)       TYPE C,
      HIER_LVL4_NAME(50)       TYPE C,
      HIER_LVL5_CODE(30)       TYPE C,
      HIER_LVL5_NAME(50)       TYPE C,
      HIER_LVL6_CODE(30)       TYPE C,
      HIER_LVL6_NAME(50)       TYPE C,
      HIER_LVL7_CODE(30)       TYPE C,
      HIER_LVL7_NAME(50)       TYPE C,
      HIER_LVL8_CODE(30)       TYPE C,
      HIER_LVL8_NAME(50)       TYPE C,
      HIER_LVL9_CODE(30)       TYPE C,
      HIER_LVL9_NAME(50)       TYPE C,
      HIER_LVL10_CODE(30)      TYPE C,
      HIER_LVL10_NAME(50)      TYPE C,
      HIER_LVL11_CODE(30)      TYPE C,
      HIER_LVL11_NAME(50)      TYPE C,
      CREATED_BY(15)                         TYPE C,
      CREATED_DATE(10)                       TYPE C,
      LAST_UPDATED_BY(15)                    TYPE C,
      LAST_UPDATED_DATE(10)                  TYPE C,
      BATCH_ID(15)                           TYPE C,
      STAGE2_DIM_ID(15)        TYPE C,
      SOURCE_SYSTEM_ID(20)                   TYPE C,
      ALT_ACCOUNT_SET_HIERARCHY_IND(1)       TYPE C,
    END OF I_PROFIT.
    *Structure required by Essbase. Str_PC1.TXT
    DATA: BEGIN OF I_STR_PC1 OCCURS 10,
      HIER_LVL1_CODE(30)       TYPE C,
      FILLER1(1)                TYPE C VALUE '|',
      HIER_LVL1_NAME(50)       TYPE C,
      FILLER2(1)                TYPE C VALUE '|',
      HIER_LVL2_CODE(30)       TYPE C,
      FILLER3(1)                TYPE C VALUE '|',
      HIER_LVL2_NAME(50)       TYPE C,
      FILLER4(1)                TYPE C VALUE '|',
      HIER_LVL3_CODE(30)       TYPE C,
      FILLER5(1)                TYPE C VALUE '|',
      HIER_LVL3_NAME(50)       TYPE C,
      FILLER6(1)                TYPE C VALUE '|',
      HIER_LVL4_CODE(30)       TYPE C,
      FILLER7(1)                TYPE C VALUE '|',
      HIER_LVL4_NAME(50)       TYPE C,
      FILLER8(1)                TYPE C VALUE '|',
      HIER_LVL5_CODE(30)       TYPE C,
      FILLER9(1)                TYPE C VALUE '|',
      HIER_LVL5_NAME(50)       TYPE C,
      FILLER10(1)                TYPE C VALUE '|',
      HIER_LVL6_CODE(30)       TYPE C,
      FILLER11(1)                TYPE C VALUE '|',
      HIER_LVL6_NAME(50)       TYPE C,
      FILLER12(1)                TYPE C VALUE '|',
      HIER_LVL7_CODE(30)       TYPE C,
      FILLER13(1)                TYPE C VALUE '|',
      HIER_LVL7_NAME(50)       TYPE C,
      FILLER14(1)                TYPE C VALUE '|',
      HIER_LVL8_CODE(30)       TYPE C,
      FILLER15(1)                TYPE C VALUE '|',
      HIER_LVL8_NAME(50)       TYPE C,
      FILLER16(1)                TYPE C VALUE '|',
      HIER_LVL9_CODE(30)       TYPE C,
      FILLER17(1)                TYPE C VALUE '|',
      HIER_LVL9_NAME(50)       TYPE C,
      FILLER18(1)                TYPE C VALUE '|',
      HIER_LVL10_CODE(30)      TYPE C,
      FILLER19(1)                TYPE C VALUE '|',
      HIER_LVL10_NAME(50)      TYPE C,
      FILLER20(1)                TYPE C VALUE '|',
      HIER_LVL11_CODE(30)      TYPE C,
      FILLER21(1)                TYPE C VALUE '|',
      HIER_LVL11_NAME(50)      TYPE C,
      FILLER22(1)                TYPE C VALUE '|',
      CODE(10)                 TYPE C,
      FILLER23(1)                TYPE C VALUE '|',
      DESC(40)                 TYPE C,
      FILLER24(1)                TYPE C VALUE '|',
      NAME(20)                 TYPE C,
      FILLER25(1)                TYPE C VALUE '|',
    END OF I_STR_PC1.
    *Variable declaration
    DATA: CTR(2) TYPE C,
          INC TYPE I,
          W_CTR1(2) TYPE C,
          W_INC1 TYPE I.
    DATA: w_file_prft LIKE w_prc_files.
    *Field symbols.
      FIELD-SYMBOLS: <CD1>,
                     <NM1>.
    * External level table will be using the following structure
    DATA: BEGIN OF data_tab OCCURS 0,
            level(4)      TYPE n,          "level in hierarchy
            groupname     LIKE grpdynp-name_coall, "name of node
            fromvalue     LIKE setvalues-from,  "From-Value of interval
            tovalue       LIKE setvalues-to,    "To-Value of interval
            descript      LIKE sethier-descript,"description of this entry
          END OF data_tab.
    *Constants
    CONSTANTS: c_setclass LIKE sethier-setclass VALUE '01++'.
    *------------------------ SelectionScreen--------------------------*
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    * Parameters
    PARAMETERS: g_setid   LIKE sethier-setid OBLIGATORY MEMORY ID gse.
    SELECTION-SCREEN END OF BLOCK B1.
    * Tables to read sets
    DATA: sethier   LIKE sethier OCCURS 0 WITH HEADER LINE,  "hierar. nodes
          setvalues LIKE setvalues OCCURS 0 WITH HEADER LINE, "hier. values
          g_setval_index LIKE sy-tabix,    "index for setvalues,
          g_int     TYPE i,
          g_rc      TYPE c,
          g_old_file LIKE lgrwo-exp_file.
    *------------------------ AT Selection screen----------------------*
    AT SELECTION-SCREEN.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR g_setid.
    * Value request for group name
      CALL FUNCTION 'G_RW_SET_SELECT'
           EXPORTING
                class           = c_setclass
                set             = g_setid
                typelist        = 'BS'
                show_field_name = ' '
                show_table_name = ' '
           IMPORTING
                setid           = g_setid
                set_name        = g_setid.
    *peform to read profit center hierarchy
    PERFORM READ_SETHIER.
    *perform to change the output format to flat file format
    PERFORM PROFIT_CENTER_HIER.
    *Fill remaining details from profit center master tables
    PERFORM FILL_PRCTR_DETAILS.
    *perform to download the details
    PERFORM F_WRITE_TO_FILE.
    FORM READ_SETHIER.
    * Preparations: check authority to read sets
        CALL FUNCTION 'G_SET_OR_GROUP_AUTHORITY'
             EXPORTING
                  i_setid = g_setid
                  i_actvt = '03'.
    * Read set
      REFRESH: sethier, setvalues.
      CALL FUNCTION 'G_SET_TREE_IMPORT'
           EXPORTING
                no_rw_info    = 'X'
                setid         = g_setid
           TABLES
                set_hierarchy = sethier
                set_values    = setvalues.
    * Copy set into DATA_TAB
      REFRESH data_tab.
      g_setval_index = 1.
      LOOP AT sethier.
        CLEAR data_tab.
        data_tab-level = sethier-level.
        data_tab-groupname = sethier-shortname.
        data_tab-descript = sethier-descript.
        APPEND data_tab.
        CHECK sethier-vcount > 0.
        CLEAR data_tab.
        data_tab-level = sethier-level + 1.
        g_int = g_setval_index + sethier-vcount - 1.
        LOOP AT setvalues FROM g_setval_index TO g_int.
          data_tab-fromvalue = setvalues-from.
          data_tab-tovalue = setvalues-to.
          data_tab-descript = setvalues-descript.
          APPEND data_tab.
        ENDLOOP.
        g_setval_index = g_int + 1.
      ENDLOOP.
    ENDFORM.
    FORM PROFIT_CENTER_HIER.
    * Use DATA_TAB table here to get to the heirarchies.
    LOOP AT DATA_TAB.
         W_INC1 = DATA_TAB-LEVEL.
         W_CTR1 = W_INC1.
         IF DATA_TAB-LEVEL = '0000' .
            CONTINUE.
         ENDIF.
        IF NOT DATA_TAB-GROUPNAME IS INITIAL.
          CONCATENATE 'I_PROFIT-HIER_LVL' W_CTR1 '_CODE' INTO W_LEVEL_CODE1.
          ASSIGN  (W_LEVEL_CODE1) TO <CD1>.
          <CD1> = DATA_TAB-GROUPNAME.
          CONCATENATE 'I_PROFIT-HIER_LVL' W_CTR1 '_NAME' INTO W_LEVEL_NAME1.
          ASSIGN (W_LEVEL_NAME1) TO <NM1>.
          <NM1> = DATA_TAB-DESCRIPT.
         ELSEIF NOT ( DATA_TAB-FROMVALUE IS INITIAL OR
                           DATA_TAB-TOVALUE IS INITIAL ) AND
                            DATA_TAB-LEVEL NE '0001' .
              MOVE DATA_TAB-FROMVALUE TO I_PROFIT-CODE.
              PERFORM CLEAR_ABOVE_LEVEL USING W_CTR1.
              APPEND I_PROFIT.
              CONTINUE.
         ENDIF.
    ENDLOOP.
    ENDFORM.
    *       FORM GET_FILE_NAME                                            *
    *       Value help for export/import file name                        *
    FORM get_file_name CHANGING p_outfile LIKE lgrwo-exp_file.
      DATA: path             LIKE lgrwo-exp_file,
            len              TYPE i,
            separator(1)     TYPE c,
            window_system(4) TYPE c.
      FIELD-SYMBOLS <last_char>.
    * get presentation server operating system for file name separator
      CALL FUNCTION 'WS_QUERY'
           EXPORTING
                query  = 'WS'
           IMPORTING
                return = window_system.
      IF window_system = 'MC'.             "Mac OS
        separator = ':'.
      ELSE.                                "Windoze
        separator = ''.
      ENDIF.
    * get path name
      path = p_outfile.
      SHIFT path RIGHT DELETING TRAILING space.
      DESCRIBE FIELD path LENGTH len.
      len = len - 1.
      ASSIGN path+len(1) TO <last_char>.
      WHILE <last_char> <> separator AND
            path <> space.
        SHIFT path RIGHT.
      ENDWHILE.
      SHIFT path LEFT DELETING LEADING space.
    * get file name
      WHILE p_outfile CS separator.
        SHIFT p_outfile UP TO separator.
        SHIFT p_outfile.
      ENDWHILE.
    * get file name
      CALL FUNCTION 'WS_FILENAME_GET'
           EXPORTING
                def_filename = p_outfile
                def_path     = path
                mask         = ',*.*,*.*.'
                mode         = 'S'
           IMPORTING
                filename     = p_outfile
           EXCEPTIONS
                OTHERS       = 0.
    ENDFORM.
    *&      Form  CLEAR_ABOVE_LEVEL
    FORM CLEAR_ABOVE_LEVEL USING   P_LEVEL.
    *Field symbols.
      FIELD-SYMBOLS: <CD>,
                     <NM>.
    *Clear code and name from upper level hierarchies when profit center
    * is found in the lower level hierarchies.
        WHILE P_LEVEL <= 10.
         CONCATENATE 'I_PROFIT-HIER_LVL' P_LEVEL '_CODE' INTO W_LEVEL_CODE.
          ASSIGN  (W_LEVEL_CODE) TO <CD>.
          CLEAR <CD>.
         CONCATENATE 'I_PROFIT-HIER_LVL' P_LEVEL '_NAME' INTO W_LEVEL_NAME.
          ASSIGN  (W_LEVEL_NAME) TO <NM>.
          CLEAR <NM>.
          P_LEVEL = P_LEVEL + 1.
        ENDWHILE.
        CLEAR: P_LEVEL,
               W_LEVEL_CODE,
               W_LEVEL_NAME.
    ENDFORM.                    " CLEAR_ABOVE_LEVEL
    *&      Form  FILL_PRCTR_DETAILS
    FORM FILL_PRCTR_DETAILS.
    DATA: CTR TYPE I.
    *Select description from CEPCT table
      SELECT * FROM CEPCT INTO TABLE I_CEPCT WHERE SPRAS EQ 'EN'.
      SELECT * FROM CEPC INTO  TABLE I_CEPC.
       SORT I_CEPC DESCENDING BY PRCTR DATBI.
       DELETE ADJACENT DUPLICATES FROM I_CEPC COMPARING PRCTR.
       SORT I_CEPC.
       SORT I_PROFIT BY CODE.
    LOOP AT I_PROFIT.
       CLEAR: WA_CEPC,
              WA_CEPCT,
              W_OBJECTID.
       CTR = CTR + 1.
         READ TABLE I_CEPC INTO WA_CEPC WITH KEY PRCTR = I_PROFIT-CODE.
         READ TABLE I_CEPCT INTO WA_CEPCT WITH KEY PRCTR = WA_CEPC-PRCTR
                                                   DATBI = WA_CEPC-DATBI.
              MOVE: CTR             TO I_PROFIT-ID,
                    WA_CEPCT-KTEXT  TO I_PROFIT-NAME,
                    WA_CEPCT-LTEXT  TO I_PROFIT-DESC.
        CONCATENATE '0002' I_PROFIT-CODE INTO W_OBJECTID.
           MOVE-CORRESPONDING I_PROFIT TO I_STR_PC1.
           APPEND I_STR_PC1.
    ENDLOOP.
    FREE I_PROFIT.
    ENDFORM.                    " FILL_PRCTR_DETAILS
    *&      Form  F_DOWNLOAD
    FORM F_DOWNLOAD.
    ENDFORM.
    *&      Form  F_WRITE_TO_FILE
    FORM F_WRITE_TO_FILE.
    LOOP AT I_STR_PC1.
        PERFORM WRITE_FILE USING I_STR_PC1
                                       w_file_prft-PRC_FILE..
    ENDLOOP.
    ENDFORM.                    " F_WRITE_TO_FILE
    FORM WRITE_FILE USING W_RECORD W_PRC_FILE.
      DATA: W_RECORD_LEN TYPE I.
    *  Retreive the actual length of the record to be written
      DESCRIBE FIELD W_RECORD LENGTH W_RECORD_LEN.
      TRANSFER W_RECORD TO W_PRC_FILE LENGTH W_RECORD_LEN.
      IF SY-SUBRC NE 0.
        MESSAGE ID 'ZZ' TYPE 'A' NUMBER '001'
             WITH C_TEXT_WRITE  W_PRC_FILE.
      ENDIF.
      CLEAR W_RECORD.
    ENDFORM.
    Thanks & Regards,
    Poorna.

    hi all,
              here is the solution:
    **------------------------ Data ---------------------------------*
    DATA: i_cepct  LIKE cepct OCCURS 0 WITH HEADER LINE,
          wa_cepct LIKE cepct,
          i_cepc   LIKE cepc OCCURS 0 WITH HEADER LINE,
          wa_cepc  LIKE cepc.
    *Variable declaration
    DATA: w_ctr1(2) TYPE c,
          w_inc1 TYPE i.
    DATA: w_level_code(30) TYPE c,
          w_level_name(50) TYPE c,
          w_level_code1(30) TYPE c,
          w_level_name1(50) TYPE c.
    *Field symbols.
    FIELD-SYMBOLS: <cd1>,
                   <nm1>.
    * External level table will be using the following structure
    DATA: BEGIN OF data_tab OCCURS 0,
            level(4)      TYPE n,          "level in hierarchy
            groupname     LIKE grpdynp-name_coall, "name of node
            fromvalue     LIKE setvalues-from,  "From-Value of interval
            tovalue       LIKE setvalues-to,    "To-Value of interval
            descript      LIKE sethier-descript,"description of this entry
          END OF data_tab.
    * Tables to read sets
    DATA: sethier   LIKE sethier OCCURS 0 WITH HEADER LINE, "hier-nodes
          setvalues LIKE setvalues OCCURS 0 WITH HEADER LINE, "hier-values
          g_setval_index LIKE sy-tabix,    "index for setvalues,
          g_int     TYPE i.
    DATA: BEGIN OF i_profit OCCURS 10,
      id(15)                TYPE c,
      code(10)                 TYPE c,
      name(20)                 TYPE c,
      desc(40)                 TYPE c,
      hier_lvl1_code(30)       TYPE c,
      hier_lvl1_name(50)       TYPE c,
      hier_lvl2_code(30)       TYPE c,
      hier_lvl2_name(50)       TYPE c,
      hier_lvl3_code(30)       TYPE c,
      hier_lvl3_name(50)       TYPE c,
      hier_lvl4_code(30)       TYPE c,
      hier_lvl4_name(50)       TYPE c,
      hier_lvl5_code(30)       TYPE c,
      hier_lvl5_name(50)       TYPE c,
      hier_lvl6_code(30)       TYPE c,
      hier_lvl6_name(50)       TYPE c,
      hier_lvl7_code(30)       TYPE c,
      hier_lvl7_name(50)       TYPE c,
      hier_lvl8_code(30)       TYPE c,
      hier_lvl8_name(50)       TYPE c,
      hier_lvl9_code(30)       TYPE c,
      hier_lvl9_name(50)       TYPE c,
      hier_lvl10_code(30)      TYPE c,
      hier_lvl10_name(50)      TYPE c,
      hier_lvl11_code(30)      TYPE c,
      hier_lvl11_name(50)      TYPE c,
      created_by(15)                         TYPE c,
      created_date(10)                       TYPE c,
      last_updated_by(15)                    TYPE c,
      last_updated_date(10)                  TYPE c,
      batch_id(15)                           TYPE c,
      stage2_dim_id(15)        TYPE c,
      source_system_id(20)                   TYPE c,
      alt_account_set_hierarchy_ind(1)       TYPE c,
    END OF i_profit.
    DATA: BEGIN OF i_str_pc2 OCCURS 10,
            code(10)                 TYPE c,
            desc(50)                 TYPE c,
            hier_lvl1_name(50)       TYPE c,
            hier_lvl3_name(50)       TYPE c,
            hier_lvl4_name(50)       TYPE c,
            extradatetime(20)        TYPE c,
          END OF i_str_pc2,
          BEGIN OF i_setid OCCURS 4,
            g_setid   LIKE sethier-setid,
            v_kokrs LIKE sethier-kokrs,
          END OF i_setid.
    DATA : wa_str_pc2 LIKE i_str_pc2,
           wa_setid LIKE i_setid,
           v_datetim(20) TYPE c,
           v_tim(8) TYPE c,
           v_level_dec(50) TYPE c,
           v_profit_desc(50) TYPE c.
    *"*"Local interface:
    *"  TABLES
    *"      IPROFIT STRUCTURE  ZPCT
    * Append all the major nodes to I_setid
    * SOI7CR0326 – Profit Center node1( under this Hier will be available, and the end you will have profit centers),
    * SOI7FU0763 – Profit Center node2,
    * SOI7FU0764 – Profit Center node3,
    * SOI7FU0765 – Profit Center node4.
      wa_setid-g_setid = text-009.
      wa_setid-v_kokrs = text-004.
      APPEND wa_setid TO i_setid.
      wa_setid-g_setid = text-010.
      wa_setid-v_kokrs = text-004.
      APPEND wa_setid TO i_setid.
      wa_setid-g_setid = text-011.
      wa_setid-v_kokrs = text-004.
      APPEND wa_setid TO i_setid.
      wa_setid-g_setid = text-012.
      wa_setid-v_kokrs = text-004.
      APPEND wa_setid TO i_setid.
    * Loop at earch major nodes from i_setid.
      LOOP AT i_setid INTO wa_setid.
        REFRESH: i_profit.
    * Preparations: check authority to read sets
        CALL FUNCTION 'G_SET_OR_GROUP_AUTHORITY'
             EXPORTING
                  i_setid = wa_setid-g_setid
                  i_actvt = '03'.
    * Funtion module to import the set hierarchy and nodes values.
        REFRESH: sethier, setvalues.
        CALL FUNCTION 'G_SET_TREE_IMPORT'
             EXPORTING
                  no_rw_info    = 'X'
                  setid         = wa_setid-g_setid
             TABLES
                  set_hierarchy = sethier
                  set_values    = setvalues.
    * Copy set into DATA_TAB
        REFRESH data_tab.
        g_setval_index = 1.
        LOOP AT sethier.
          CLEAR data_tab.
          data_tab-level = sethier-level.
          data_tab-groupname = sethier-shortname.
          data_tab-descript = sethier-descript.
          APPEND data_tab.
          CHECK sethier-vcount > 0.
          CLEAR data_tab.
          data_tab-level = sethier-level + 1.
          g_int = g_setval_index + sethier-vcount - 1.
          LOOP AT setvalues FROM g_setval_index TO g_int.
            data_tab-fromvalue = setvalues-from.
            data_tab-tovalue = setvalues-to.
            data_tab-descript = setvalues-descript.
            APPEND data_tab.
          ENDLOOP.
          g_setval_index = g_int + 1.
        ENDLOOP.
    * Loop at the data_tab to move all the Profit center nodes to i_profit.
        LOOP AT data_tab.
          w_inc1 = data_tab-level.
          w_ctr1 = w_inc1.
          IF data_tab-level = text-002 .
            v_level_dec = data_tab-descript.  "Description of level 4 node
            CONTINUE.
          ENDIF.
          IF NOT data_tab-groupname IS INITIAL.
            CONCATENATE text-001 w_ctr1 text-007 INTO w_level_code1.
            ASSIGN  (w_level_code1) TO <cd1>.
            <cd1> = data_tab-groupname.
            CONCATENATE text-001 w_ctr1 text-008 INTO w_level_name1.
            ASSIGN (w_level_name1) TO <nm1>.
            <nm1> = data_tab-descript.
          ELSEIF NOT ( data_tab-fromvalue IS INITIAL OR
                            data_tab-tovalue IS INITIAL ) AND
                             data_tab-level NE text-003 .
            MOVE data_tab-fromvalue TO i_profit-code.
            PERFORM clear_above_level USING w_ctr1.
            APPEND i_profit.
            CONTINUE.
          ENDIF.
        ENDLOOP.
    *Select description from CEPCT table
        SELECT * FROM cepct
                 INTO TABLE i_cepct
                 WHERE spras EQ text-006.
        SELECT * FROM cepc
                 INTO  TABLE i_cepc.
        SORT i_cepc DESCENDING BY prctr datbi.
        DELETE ADJACENT DUPLICATES FROM i_cepc COMPARING prctr.
        SORT i_cepc.
        SORT i_profit BY code.
    * Date and Times for each record.
        CONCATENATE sy-uzeit+0(2) text-005 sy-uzeit+2(2) text-005
          sy-uzeit+4(2) INTO v_tim.
        CONCATENATE sy-datum v_tim INTO v_datetim SEPARATED BY space.
        LOOP AT i_profit .
          CLEAR: wa_cepc,
                 wa_cepct.
          IF   ( i_profit-code <> space
            AND i_profit-hier_lvl2_name <> space
            AND i_profit-hier_lvl3_name <> space ).
            READ TABLE i_cepc INTO wa_cepc WITH KEY prctr = i_profit-code.
            IF sy-subrc = 0.
            READ TABLE i_cepct INTO wa_cepct WITH KEY prctr = wa_cepc-prctr
                                                      datbi = wa_cepc-datbi.
              IF sy-subrc = 0.
    *v_level_dec               ( Description of level 4 node )
    *i_profit-hier_lvl2_name   ( Descri Level 6 )
    *i_profit-hier_lvl3_name   ( Descri Level 6 )
    *i_profit-code             ( Profit Center code )
    *v_profit_desc             ( Profit Center description )
       CONCATENATE wa_cepct-ltext text-013 i_profit-code INTO v_profit_desc.
                wa_str_pc2-hier_lvl1_name = v_level_dec.
                wa_str_pc2-hier_lvl3_name = i_profit-hier_lvl2_name.
                wa_str_pc2-hier_lvl4_name = i_profit-hier_lvl3_name.
                wa_str_pc2-code           = i_profit-code.
                wa_str_pc2-desc           = v_profit_desc.
                wa_str_pc2-extradatetime  = v_datetim.
                APPEND wa_str_pc2 TO iprofit.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDLOOP.
        CLEAR: v_level_dec.
      ENDLOOP.
      CLEAR: wa_setid.
    ENDFUNCTION.

  • Tbb1 - changing profit center in FI document account

    Dear all,
    i need to change the profit center and the movement type when i create the document account with transaction TBB1.
    movement type: I CHANGED THE METHOD  ACCIT_RMVCT_EXIT IN INTERFACE IF_EX_TPM_ACCIF_TRAC And it is ok.
    prctr : I created a new method in interface class but for changing interface i need a development key; is there something that i can do to change prctr or i need to change standard sap ?
    thanks a lot
    Elena

    Hi Elena,
    Probably the class is doing its job OK but FI is not accepting the document because some field is missing. In most  SAP implementations I have seen, the profit center is not informed directly. Instead, you inform the cost center and the system determines the profit center automatically. Can you check if the cost center field is filled in the ACCIT structure when itu2019s sent to FI? Iu2019m thinking some information needed by the CO module in order to post to a profit center is missing.
    Regards,
    Daniel
    Edited by: dmfdmf77 on Mar 30, 2011 12:43 PM

  • Update the correct profit center in tables BSEG / BSAS / BSIS / BSIK / BSAK

    Hi FI Gurus,
    I am looking after a Support Project in SAP IS-Retail. I am from the FI functional and possess very limited knowledge in FI.
    My client has done the sales posting in SAP using IDOC's. During the postings, it was found that wrong Profit Centers were assigned. Due to this, the sales reports based on Profit Center are coming wrong. It was suggested to the client to reverse the IDOCs, do necessary changes in Profit Centers and re-post the IDOCs. The client wanted a short method to get the reports right. A senior consultant (Non FI) in the Company and the Management are forcing me to write a ABAP program to update certain (not all) FI tables. According to me, it will have some negative impact on the system for which reason I am not ready to take the call as a Project Manager. The management wants me to do the following (I am quoting the same mail which I received from the consultant ) :
    We need to update the correct profit center in tables BSEG / BSAS / BSIS / BSIK / BSAK / BSID / BSAD, wherever the records exists against billing document numbers provided.
    BAPI for updating profit center in Accounting documents: BAPI_ACC_DOCUMENT_POST
    Function Module : 'BAPI_DOCUMENT_CHANGE'
    Also look at SAP Note: Note 966428 - FB02: Functional area (FKBER) can be changed on coding block
    Based on the above, the ABAPer has written the program, the program will update the tables BSEG, BSIS, BSIK, according to the selection criteria of document number, company code and line item number with the new profit centers.
    Please clarify me about the following :
    1. This program is updating profit center in just the FI tables (BSEG, BSIS, BSIK etc.), but the New GL tables (faglflexa and faglflext) which have approx. 65 lakh entries in PRD do not get updated with the correct profit center.
    2. The Controlling tables also do not get updated with this program yet. Also since the previoius updation of Profit centers did not happen correctly, most of the times the controlling document has not been generated at all. Since we will be updating the profit center in just the FI tables, the controlling document will not be created still. Though there are SAP notes suggesting re-creation of the Controlling documents, which is still an option you can choose. Please confirm.
    3. The Special GL also does not get updated because of this.
    This is a very critical and hot issue. My job is at Stake as the Management has threatened me of sacking if I do not follow their directives as they are only concerned with their money.
    Is the consultant who suggested this change RIGHT ?
    Your early replies will help me take the decision.
    Regards

    Hi,
    There is no standard program or BAPI that would update profit centre in a posted document. You should either develop your own process for it,which is not recommended, but sometimes is essential, or reverse the existing documents and post them with the correct profit centre.
    Regards,
    Eli

  • BADI/Exit to automatically populate Profit Center in MM41/42 for DC/Store

    Hi All,
    In MM41/MM42, when u creating/changing an article, system should enter automatically the Profit Center as below:
    1. Profit Center related to DC on Logistic DC page
    2. Profit Center related to store on Logistic store page
    I have tried the BADI MGW_SITE_DATA but it not useful as it is can be implemented only by SAP-internally.
    I also tried implementing the SAP note 335267 - Proposal of profit center in logistics data (MARC) but it gave an warning ''Corrections incompletely copied' for the object LMGWLF1J'.
    Please help me in providing a solution.
    Thanks in advance.

    Hi,
    Use the user exit PPCO0007 ,function module EXIT_SAPLCOZV_001
    HEADER_EXP-PRCTR
    Thanks,
    Shailaja Ainala.

Maybe you are looking for

  • How To Mark Content In adobe Reader

    Hi Experts, I hope you guys are doing well. At work I have to read lots of PDF document and I want to mark or color few things so that I don't have to search Important points again and again. FYI I using adobe reader 11 on Centos 6. Any help would be

  • Macbook pro monitor

    hello, I would like to connect my macbook pro to an imac (white - the old kind) to use it as a second monitor. how do I do this? thanks a lot

  • I'm shopping for the Apple Mac Pro

    I'm shopping for the Apple Mac Pro Desktop 2.66GHz Intel Core 2 Quad, 3GB RAM Mfr. Part # MB871LL/A When I put that in the Apple website, (just MB871LL/A ) or Google on the Web, it shows results) which on the Web is : 2300$ at PC connection, J&R and

  • Calling Java code from Webdynpro Abap UI

    Hi All, Can anybody tell me, How to make calls to java code on a button click from webdynpro ABAP UI ? Thanks in Advance. Jenish .V. Joy

  • How to launch Java WebDynpro From ABAP?

    I have a requirement to launch a Java WebDynpro from ABAP code. Has anyone done this? If so, does anyone know of documentation/sample code or at least an ABAP class/function group I could look at? Thanks in advance.