F-04 Profit center blocked

HI All,
I am trying to clear all opens items in F-04. but in the end i am getting "profit center is blocked for the XXX/1234567".
Please assist me how to pass this entry.
ASAP

Hi venkat,
Please unblock the profit center(t-code - KE52) which you got the error.
and then try to clear.
- Sudhir Krishna Kumar Singh

Similar Messages

  • Profit Center blocked error in depreciation run

    We are upgrading SAP system from 4.6 to 6.0. It was noticed that Profit Center blocked error is being captured in depreciation run test run in the upgraded version. In 4.6, this error is not being captured. Is this an enhancement in the upgraded version?

    I have not search information about it. I found this change only positive. Now you have direct to solve the error (wrong profit center) and not later with the retirement. It is only when they block profit centers or assign an other profit center to a cost center that they have to contact asset accounting for changing the asset. In the old version the values on the profit center where wrong, now you have to correct them. I see this more as a bug in the old version that is solved now.
    When you don't want this have a look to the error message and turn it of when that is possible, but then you accept that the vallues in profit center accounting are wrong

  • Exit or BADI for Profit Center Block in Tcode KE51 , KE52

    Dear all,
    Is there any BADI or User Exit available to block Profit Center  during create or change.
    Thnaks in advance.

    You can go for implicit enhancements.In case no badi or exit is avaiable.
    Regards,
    Nabheet Madan

  • Profit center blocked report

    Hi,
    I need to pull a report to display the list of profit centers blocked and the date / period on which it was blocked.
    Please advise any Table / report to get this list.
    Thanks a lot.
    Rgds,
    Pavan.

    Hi,
    I guess, you will have to look at CDHDR/CDPOS tables for this information. Go to CDHDR with object class 'PRCTR' and object = controlling area + profit centre (mind leading zeros, if profit centre starts with digit). Get the change document number + info you need (who changed and when) and check in CDPOS what change was that, if it was for the blocking indicator.
    Regards,
    Eli

  • Deletion of Dummy profit center or Blocking of the same

    Dear Sir/Madam
    We were using dummy profit center in classic GL, Now we have migrated to new gl and we want to delete the dummy profit center or block the same. We are not able to do so. Kindly suggest an alternative solution where we can delete or block the dummy profit center.
    Regards
    Prashant Zinge

    Hi
    Refer to SAP Note 702854 for deletion of dummy profit center
    Regards
    Sanil

  • Blocking Profit Center field in MM02 (making it display only)

    Hi,
    I have a query, We have blocked via authorizations all views in MM02 except for the "Sales: General/Plant" view, so now we need to know how to make the Profit Center field a display only so that we can assign a role for people who will change the Serial Number Profile field only using MM02.
    If MARC-PRCTR in OMS9 is set as display only for MM02 can it be possible to for the master data team to still have change access to for the Profit Center field.
    Your assistance is appreciated.
    Rendani

    Thanks Sarita for your input, my problem is nearly next to the solution state.
    Could you please tell me how I can make the field lock relevant, I don't have a lot of SAP experience so a detailed response will be welcome. Whether it also involves authorizations as well.
    Many thanks.
    Regards,
    Rendani

  • Stored Procedure to block cost center or profit center to present in JE

    Hi ...
    I have a case where i need to block if either one of the cost center or the Profit Center is not present in the manual journal entry.
    Below is my Stored Procedure which i have written....My Problem is that this block allows me to update only if both the Cost Center and the Profit Center is Present and does not allow if any one is present.
    IF @object_type='30' AND (@transaction_type='A' or @transaction_type='U')
    BEGIN
      if(Select Count(*) from OJDT T0  INNER JOIN JDT1 T1 ON T0.TransId=T1.TransId
      INNER JOIN OACT T2 ON T2.AcctCode=T1.Account
      where  T2.ExportCode LIKE '1%' And (isnull(T1.ProfitCode,0)='0'  OR ISNULL(T1.OcrCode2,'')='')  and
       T0.TransId=@list_of_cols_val_tab_del)>0
      begin
      SET @error = 0201
         SET @error_message= 'R1'
    end
    end
    What could be the problem...?

    Hi Gopi
    Try This
    IF @transaction_type IN ('A','U') and @Object_type = 30
    BEGIN
    IF EXISTS (SELECT T0.TransId FROM dbo.JDT1 T0
    WHERE ((T0.ProfitCode ='' OR T0.ProfitCode IS NULL) and (T0.[OcrCode2]='' OR T0.[OcrCode2] IS NULL) and (T0.[OcrCode3]='' OR T0.[OcrCode3] IS NULL) and
    (T0.[OcrCode4]='' OR T0.[OcrCode4] IS NULL) and (T0.[OcrCode5]='' OR T0.[OcrCode5] IS NULL)) AND T0.TransId = @list_of_cols_val_tab_del)
    Begin
    SET @Error = 1111
    SET @error_message = 'At least one cost center is mandatory!'
    End
    End
    With Regards
    Balaji Sampath

  • Block Postings to specific account/profit center combinations

    How do I set rules or controls to prohibit manual postings to specific account/profit center combinations?  I want to emphasize that I am not not just interested in blocking postings to an account, it has to be the unique combination of account and profit center which is prohibited.
    Thank you,
    Mark Galla

    Hi,
    Use OB28...
    Set the prerequisite as BKPF-Tcode : FB01...( any transaction used for manual posting)
    and BSEG-BUKRS <> the company code
    Then in the Check button
    BSEG-PRCTR = prctr ( first create a set id using GS01 with this name there give all the profit center which you want to block.
    Third is as usual give the message type as Error.
    Thats it...
    Hope this helps
    Regards,
    Velumani

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

  • Profit Center Substitution Not getting reflected in FI document duirng MIGO

    Hello friends,
    I have implemented a substition exit for profit center replacement. The rule has been created with this exit. But when I do a MIGO, i see the FI documents getting created with original profit center, not with the profit center that we have manipulated in the substitution. Even though i see in the debugging mode that the profit center is being replaced within the code, when the accounting document is generated, I see the old profit center only in FB03. There is no other substitution exit that is overwriting the profit center. What else could impact this / any inputs would be of great help.
    Thanks,
    Mayank

    Are you using Accounting document substitution (Tcode OBBH)? Try using Controlling substitution (Tcode OKC9), this will substitute the coding block (COBL) of accounting doc where profit center (COBL-PRCTR) is found.

  • 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

  • Profit Center was not maintained during order n billing creation.

    Dear, Gurus
    I'm facing a problem of Profit Center. User created a service material, maintenance contract. They created a Billing Document as it is order related billing. Accounting document was not generated when saving invoice. When I got to the bottom of this I realized no costing tabs were ever maintained for material type services. (Henceforth no Profit Center in Sales Order n Invoice).
    I have done the necessary config n assignments but question now is what should I do as in billing doc  the field is greyed out it will not allow me to assign Pr Center now. I am thinking that this may work if I cancel the billing document and then go back to sales order and try and changing the field, then re-create the invoice. I'm trying to avoid canceling. Is there any program, bapi, user exit I may use to re assign or make system re check the MM while saving invoice to allow accounting document to be created?  This is one scenario.
    2nd scenario is similar but in the case of this contract everything was made. Accounting document was cleared even but with some dummy weird Profit Center. (No proft center in Order nor invoice.) Whole problem at first in this scenario is User saying everything is complete so status in doc flow should show maintenance contract as complete but wasn't. it showed being processed. I discovered no completion rule was maintained. I maintained E Full target value referenced but status still has not changed any idea guys? (New config not showing on old existing data only show on new document, concept?) Is there a program or anything to make system update status doc flow? aside from this Profit center  incompletion log is coming in Contract. Not maintained in order or invoice.

    In one of my earlier projects, a similar requirement was putforth by users and we had developed a zee tcode to change the profit center in billing document via SM30 which can be done only by FI authorised users.
    I am reproducing the said program as under:-
    REPORT  "ZPROFIT_CHG"
    TABLES : VBRP.
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME.
    SELECT-OPTIONS : SO_VBELN FOR VBRP-VBELN OBLIGATORY.
    PARAMETERS:      P_PRO LIKE VBRP-PRCTR OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1.
    DATA : BEGIN OF IT_VBRP OCCURS 0,
            VBELN LIKE VBRP-VBELN,
            POSNR LIKE VBRP-POSNR,
            PRCTR LIKE VBRP-PRCTR,
          END OF IT_VBRP.
    DATA COUNT(3).
    DATA W_MESSAGE(30).
    START-OF-SELECTION.
      LOOP AT SO_VBELN.
           IF SO_VBELN-LOW CA '~`!@#$%^&*()_+|\=-><,.;":' OR SO_VBELN-HIGH CA '~`!@#$%^&*()_+|\=-><,.;":'.
               MESSAGE 'Special character not allowed' type 'S'.
               LEAVE LIST-PROCESSING.
               STOP.
           ENDIF.
      ENDLOOP.
      IF P_PRO CA '~`!@#$%^&*()_+|\=-><,.;":'.
               MESSAGE 'Special character not allowed' type 'S'.
               LEAVE LIST-PROCESSING.
               STOP.
      ENDIF.
      SELECT B~VBELN B~POSNR B~PRCTR FROM VBRK AS A  INNER JOIN VBRP AS B ON A~VBELN EQ B~VBELN INTO CORRESPONDING FIELDS OF TABLE IT_VBRP
                                WHERE A~VBELN IN SO_VBELN
                                AND   A~FKART EQ 'ZFF2'
                                AND   A~FKSTO NE 'X'.
      IF SY-DBCNT EQ 0.
          MESSAGE 'NO DATA FOUND' TYPE 'S'.
          LEAVE LIST-PROCESSING.
      ENDIF.
      SORT IT_VBRP BY VBELN.
      DELETE ADJACENT DUPLICATES FROM IT_VBRP COMPARING VBELN.
      CLEAR COUNT.
      IF IT_VBRP[] IS NOT INITIAL AND P_PRO IS NOT INITIAL..
          LOOP AT IT_VBRP.
              UPDATE VBRP SET PRCTR = P_PRO  WHERE VBELN = IT_VBRP-VBELN AND POSNR = IT_VBRP-POSNR.
              IF SY-SUBRC = 0.
                 COUNT = COUNT + 1.
              ENDIF.
              COMMIT WORK.
              CLEAR IT_VBRP.
          ENDLOOP.
    ENDIF.
    IF COUNT IS NOT INITIAL.
        CONCATENATE 'No Of Records Updated Is - ' COUNT INTO W_MESSAGE.
        MESSAGE I000(ZSFL) WITH W_MESSAGE.
    ELSE.
        MESSAGE 'No Records Updated' TYPE 'S'.
    ENDIF.
    Since I am so weak in ABAP coding, not sure whether the above coding is correct.  You need to check with your ABAPers and develop this logic.  This should work.
    thanks
    G. Lakshmipathi

  • Profit Center not getting uploaded through BAPI for MM01. Pls help

    Hello all,
                  I am getting an errror while uploading a file through BAPI for MM01 , The error says
    Error:
    Profit center 1000/sslcommon does not exist
    for material: AC2
    *& Report  ZBAPI_DUMMY
    REPORT  ZBAPI_MM01.
    *& Report  ZBAPI2
    TABLES
    FLAGS *
    DATA: F_STOP. " Flag used to stop processing
    DATA DECLARATIONS *
    DATA : V_EMPTY TYPE I, " No. of empty records
    V_TOTAL TYPE I. " Total no. of records.
    STRUCTURES & INTERNAL TABLES
    *--- BAPI structures
    DATA: BAPI_HEAD LIKE BAPIMATHEAD,  " Header Segment with Control
    BAPI_MAKT LIKE BAPI_MAKT, " Material Description
    BAPI_MARA1 LIKE BAPI_MARA, " Client Data
    BAPI_MARAX LIKE BAPI_MARAX, " Checkbox Structure for BAPI_MARA
    BAPI_MARC1 LIKE BAPI_MARC, " Plant View
    BAPI_MARCX LIKE BAPI_MARCX, " Checkbox Structure for BAPI_MARC
    BAPI_MBEW1 LIKE BAPI_MBEW, " Accounting View
    BAPI_MBEWX LIKE BAPI_MBEWX, " Checkbox Structure for BAPI_MBEW
    BAPI_RETURN LIKE BAPIRET2, " Return Parameter
    BAPI_MARDL LIKE BAPI_MARD,
    BAPI_MARDX LIKE BAPI_MARDX.
    *--- Internal table to hold excel file data
    DATA: IT_INTERN TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
    *--- Internal table to hold Matetrial descriptions
    DATA: BEGIN OF IT_MAKT OCCURS 100.
            INCLUDE STRUCTURE BAPI_MAKT.
    DATA: END OF IT_MAKT.
    *--- Internal to hold the records in the text file
    DATA : BEGIN OF IT_DATA OCCURS 100,
    WERKS(4), " Plant
    MTART(4), " Material type
    MATNR(18), " Material number
    MATKL(9) , " Material group
    MBRSH(1), " Industry sector
    MEINS(3), " Base unit of measure
    SPART(2), " Division
    EKGRP(3), " Purchasing group
    PRCTR(10), " Profit Center
    VPRSV(1), " Price control indicator
    BKLAS(4), "Valuation Class
    *stprs(12), " Standard price
    PEINH(3), " Price unit
    SPRAS(2), " Language key
    MAKTX(40), " Material description
    LGORT(4) , " storage location
    DISMM(2) , "MRP TYPE
    VERPR(23), " Moving Average Price
    MTVFP(2) , " Availability Check
    DISLS(2) , "Lot Size
    DISPO(3) , "MRP Controller
    BESKZ(1) , "Procurment Type
    FHORI(3) , "SCHEDMARGIN KEY
    PERKZ(1) , "Period Indicator
    END OF IT_DATA.
    SELECTION SCREEN. *
    SELECTION-SCREEN BEGIN OF BLOCK SCR1 WITH FRAME TITLE TEXT-111.
    PARAMETER : P_FILE TYPE RLGRAP-FILENAME OBLIGATORY  " Input File
    PARAMETER : P_MAX(4) OBLIGATORY DEFAULT '100'. " no.of recs in a session
    PARAMETERS: P_HEADER TYPE I DEFAULT 0. " Header Lines
    PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,
    P_BEGROW TYPE I DEFAULT 2 NO-DISPLAY,
    P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,
    P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.
    SELECTION-SCREEN END OF BLOCK SCR1.
    AT SELECTION-SCREEN *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
    *--- Validating file
      PERFORM VALIDATE_FILE USING P_FILE.
    START-OF-SELECTION
    START-OF-SELECTION.
    *--- Perform to convert the Excel data into an internal table
      PERFORM CONVERT_XLS_ITAB.
      IF NOT IT_DATA[] IS INITIAL.
    *--- Perform to delete Header lines
        PERFORM DELETE_HEADER_EMPTY_RECS.
      ENDIF.
    END OF SELECTION. *
    END-OF-SELECTION.
    *--- Perform to upload Material Master data
      PERFORM UPLOAD_MATMAS.
    Form : validate_input_file
    Description : To provide F4 help for file if read from PC
    FORM VALIDATE_FILE USING F_FILE TYPE RLGRAP-FILENAME.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        CHANGING
          FILE_NAME     = F_FILE
        EXCEPTIONS
          MASK_TOO_LONG = 1
          OTHERS        = 2.
      IF SY-SUBRC <> 0.
        MESSAGE S010(ZLKPL_MSGCLASS). " 'Error in getting filename'.
      ENDIF.
    ENDFORM. " validate_input_file
    *& Form CONVER_XLS_ITAB
    text
    FORM CONVERT_XLS_ITAB.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          FILENAME    = P_FILE
          I_BEGIN_COL = P_BEGCOL
          I_BEGIN_ROW = P_BEGROW
          I_END_COL   = P_ENDCOL
          I_END_ROW   = P_ENDROW
        TABLES
          INTERN      = IT_INTERN.
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *--- Perform to move the data into an internal data
      PERFORM MOVE_DATA.
    ENDFORM. " CONVERT_XLS_ITAB
    *& Form MOVE_DATA
    text
    FORM MOVE_DATA.
      DATA : LV_INDEX TYPE I.
      FIELD-SYMBOLS <FS>  .
    *--- Sorting the internal table
      SORT IT_INTERN BY ROW COL.
      CLEAR IT_INTERN.
      LOOP AT IT_INTERN.
        MOVE IT_INTERN-COL TO LV_INDEX.
    *--- Assigning the each record to an internal table row
        ASSIGN COMPONENT LV_INDEX OF STRUCTURE IT_DATA TO <FS> .
    *--- Asigning the field value to a field symbol
        MOVE IT_INTERN-VALUE TO <FS> .
        AT END OF ROW.
          APPEND IT_DATA.
          CLEAR IT_DATA.
        ENDAT.
      ENDLOOP.
    ENDFORM. " MOVE_DATA
    *& Form DELETE_HEADER_EMPTY_RECS
    To delete the Header and empty records
    FORM DELETE_HEADER_EMPTY_RECS.
      DATA: LV_TABIX LIKE SY-TABIX.
      IF NOT P_HEADER IS INITIAL.
        LOOP AT IT_DATA.
          IF P_HEADER > 0 AND NOT IT_DATA IS INITIAL.
            DELETE IT_DATA FROM 1 TO P_HEADER.
    P_HEADER = 0.
            EXIT.
          ENDIF.
        ENDLOOP.
      ENDIF.
      CLEAR IT_DATA.
    *--- To delete the empty lines from internal table
      LOOP AT IT_DATA.
        LV_TABIX = SY-TABIX.
        IF IT_DATA IS INITIAL.
          V_EMPTY = V_EMPTY + 1.
          DELETE IT_DATA INDEX LV_TABIX..
        ENDIF.
      ENDLOOP.
      CLEAR IT_DATA.
    *--- Total no of recs in file
      DESCRIBE TABLE IT_DATA LINES V_TOTAL.
      IF V_TOTAL = 0.
        MESSAGE I013(ZLKPL_MSGCLASS). " No records in the file
        F_STOP = 'X'.
        STOP.
      ENDIF.
    ENDFORM. " DELETE_HEADER_EMPTY_RECS
    *& Form UPLOAD_MATMAS
    to upload Material Master data
    FORM UPLOAD_MATMAS .
      LOOP AT IT_DATA.
    Header
        BAPI_HEAD-MATERIAL = IT_DATA-MATNR.
        BAPI_HEAD-IND_SECTOR = IT_DATA-MBRSH.
        BAPI_HEAD-MATL_TYPE = IT_DATA-MTART.
        BAPI_HEAD-BASIC_VIEW = 'X'.
        BAPI_HEAD-PURCHASE_VIEW = 'X'.
        BAPI_HEAD-ACCOUNT_VIEW = 'X'.
        BAPI_HEAD-storage_view ='X'.
        bapi_head-mrp_view = 'X'.
        bapi_head-COST_view ='X'.
    Material Description
        REFRESH IT_MAKT.
        IT_MAKT-LANGU = IT_DATA-SPRAS.
        IT_MAKT-MATL_DESC = IT_DATA-MAKTX.
        APPEND IT_MAKT.
    Client Data - Basic
        BAPI_MARA1-MATL_GROUP = IT_DATA-MATKL.
        BAPI_MARA1-BASE_UOM = IT_DATA-MEINS.
       bapi_mara1-unit_of_wt = it_data-gewei.
        BAPI_MARA1-DIVISION = IT_DATA-SPART.
        BAPI_MARAX-MATL_GROUP = 'X'.
        BAPI_MARAX-BASE_UOM = 'X'.
        BAPI_MARAX-UNIT_OF_WT = 'X'.
        BAPI_MARAX-DIVISION = 'X'.
    Plant - Purchasing
        BAPI_MARC1-PLANT = IT_DATA-WERKS.
        BAPI_MARC1-PUR_GROUP = IT_DATA-EKGRP.
        BAPI_MARC1-PROFIT_CTR = IT_DATA-PRCTR.
        BAPI_MARC1-MRP_TYPE = IT_DATA-DISMM.
        BAPI_MARC1-AVAILCHECK = IT_DATA-MTVFP.
        BAPI_MARC1-LOTSIZEKEY = IT_DATA-DISLS.
        BAPI_MARC1-MRP_CTRLER = IT_DATA-DISPO.
        BAPI_MARC1-PROC_TYPE = IT_DATA-BESKZ.
        BAPI_MARC1-SM_KEY = IT_DATA-FHORI.
        BAPI_MARC1-PERIOD_IND = IT_DATA-PERKZ.
        BAPI_MARCX-PLANT = IT_DATA-WERKS.
        BAPI_MARCX-PUR_GROUP = 'X'.
        BAPI_MARCX-AVAILCHECK = 'X'.
        BAPI_MARCX-PROFIT_CTR = 'X'.
        BAPI_MARCX-MRP_TYPE = 'X'.
        BAPI_MARCX-MRP_CTRLER = 'X'.
        BAPI_MARCX-SM_KEY = 'X'.
        BAPI_MARCX-LOTSIZEKEY = 'X'.
       Storage Location.
        BAPI_MARDL-PLANT     = IT_DATA-WERKS.
        BAPI_MARDL-STGE_LOC = IT_DATA-LGORT.
        BAPI_MARDX-PLANT    = IT_DATA-WERKS.
        BAPI_MARDX-STGE_LOC = IT_DATA-LGORT.
    Accounting
        BAPI_MBEW1-VAL_AREA = IT_DATA-WERKS.
        BAPI_MBEW1-PRICE_CTRL = IT_DATA-VPRSV.
        BAPI_MBEW1-VAL_CLASS = IT_DATA-BKLAS.
        BAPI_MBEW1-MOVING_PR = IT_DATA-VERPR.
       bapi_mbew1-std_price = it_data-stprs.
        BAPI_MBEW1-PRICE_UNIT = IT_DATA-PEINH.
        BAPI_MBEWX-VAL_AREA = IT_DATA-WERKS.
        BAPI_MBEWX-PRICE_CTRL = 'X'.
        BAPI_MBEWX-STD_PRICE = 'X'.
        BAPI_MBEWX-PRICE_UNIT = 'X'.
        BAPI_MBEWX-MOVING_PR = 'X'.
    *--- BAPI to create material
        CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
        EXPORTING
        HEADDATA = BAPI_HEAD
        CLIENTDATA = BAPI_MARA1
        CLIENTDATAX = BAPI_MARAX
        PLANTDATA = BAPI_MARC1
        PLANTDATAX = BAPI_MARCX
    FORECASTPARAMETERS =
    FORECASTPARAMETERSX =
    PLANNINGDATA =
    PLANNINGDATAX =
    STORAGELOCATIONDATA = BAPI_MARDL
    STORAGELOCATIONDATAX = BAPI_MARDX
    VALUATIONDATA = BAPI_MBEW1
    VALUATIONDATAX = BAPI_MBEWX
    WAREHOUSENUMBERDATA =
    WAREHOUSENUMBERDATAX =
    SALESDATA = BAPI_MVKE1
    SALESDATAX = BAPI_MVKEX
    STORAGETYPEDATA =
    STORAGETYPEDATAX =
        IMPORTING
        RETURN = BAPI_RETURN
        TABLES
        MATERIALDESCRIPTION = IT_MAKT
    UNITSOFMEASURE =
    UNITSOFMEASUREX =
    INTERNATIONALARTNOS =
    MATERIALLONGTEXT =
    TAXCLASSIFICATIONS =
    RETURNMESSAGES =
    PRTDATA =
    PRTDATAX =
    EXTENSIONIN =
    EXTENSIONINX =
        IF BAPI_RETURN-TYPE = 'E'.
          WRITE:/ 'Error:' ,BAPI_RETURN-MESSAGE ,'for material:' ,
    IT_DATA-MATNR.
        ELSEIF BAPI_RETURN-TYPE = 'S'.
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          WAIT          =
         IMPORTING
           RETURN        = BAPI_RETURN
          WRITE: 'Successfully created material' ,IT_DATA-MATNR.
        ENDIF.
       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          WAIT          =
        IMPORTING
          RETURN        = BAPI_RETURN
      ENDLOOP.
    ENDFORM. " UPLOAD_MATMAS

    the Profit center 1000/sslcommon  not created. first create the profit center and then upload your data.check tcode KE52 for created profit centers...

  • Profit Center Accounting

    Hi,
    We have several Cost Centers and Profit Centers.
    Upon creating the master data for Cost center I left the Profit Center assignment a "blank" as one cost center could service several profit centers and I need to capture the data at the initial recording.
    Now when I pass the JE thru FB50, the system overwrites the Profit Center I assign in the line item with the "Dummy" profit center...as I have not mentioned any profit center in the Cost center master data.
    Is there a work around via substitution or something else?
    How can I override this coding block  and yet retain the functionality of Dummy PC to post to entries that are not posted with a PC.
    Any help would be appreciated.
    Thanks G.Iyer

    Hi,
    You can go for Validations and substitutions.
    Else you can have derivations for profit Centers.
    Best Regards
    Surya

Maybe you are looking for