URGENT - Query to get employes with multiple cost center

Hello,
The sample data for my requirement is:
create table a
(year     number(4),
month      number(2),
empno number(5),
cost_center number(3)
insert into a values(2003, 10, 1034, 102);
insert into a values(2003, 10, 1034, 102);
insert into a values(2003, 10, 1034, 102);
insert into a values(2003, 10, 1034, 103);
insert into a values(2003, 10, 1034, 103);
insert into a values(2003, 10, 1039, 102);
insert into a values(2003, 10, 1039, 102);
insert into a values(2003, 10, 1070, 102);
insert into a values(2003, 10, 1070, 103);
commit;
In the above sample data, empno 1034 & 1070 has two different cost centers (102 & 103) whereas empno 1039 has one only cost center i.e. (102).
Now I want a query that returns empno, cost_center with employees having more than one cost center. Considering the above sample data, the query should return empno 1034 & 1070. Empno 1039 should not appear in the query output as it has only cost center.
The output should be something like...
Empno cost_center
1034 102
1034 103
1070 102
1070 103
I'll b grateful for an urgent reply.
HASAN.

select distinct empno, cost_center
from a a1
where exists (select 1 from a a2
where a2.empno = a1.empno
having count(distinct cost_center) > 1)
/

Similar Messages

  • Query to get invoice with multiple sales order

    Hi
    Our requirement is to customize the invoice report as per new requirement. For this customization we need to get the invoice which has multiple sales order with it. Please help to me get the invoice number from database which has multiple sales order with it.
    Thanks and regards,
    Sundar

    Sunder,
    interface_line_attribute6 in ra_customer_trx_all is nothing but the sales order line id. And sales_order in ra_customer_trx_lines_all is the sales order number.
    You can use the following 2 conditions to fetch your requirement.
    sales_order = TO_CHAR (order_number)
    interface_line_attribute6 = TO_CHAR (line_id)
    Please let me know if you are still facing any issue.
    Regards,
    Jyoti

  • Creation of multiple cost center for one emplyee

    HI All,
    I have requirement . one emplyee is working two projects so need create two cost centers for one employee.
    please tell me how create multiple cost center for one employee.
    Thanks&Regards
    ramesh

    hai.
    if he works half the time... u can give 50%.. or just get it confirmed from core team member..
    manu

  • Employes with Multiple Assignments

    Hi all
    can you please let me know how can i get list of employees with multiple assignments.
    Thanks in advance

    This has now been resolved, closing this post.
    thanks

  • Multiple Cost Center Change Batch Upload

    Hi,
      I need to update the data of multiple cost centers. I have tried using BDC/ transaction KS02 and BAPI_COSTCENTER_CHANGEMULTIPLE. However, I encounter problems with cost centers with different validity periods when changing the heirarchy of cost centers. Your input will be highly appreciated.

    Hi Christian,
    Updating cost centers with single validity period say, 10/25/05-12/31/9999, isn't a problem. However, when changing the heirarchy area, CSKS-KHINR, of cost centers with multiple validity periods, meaning with intervals, i.e. 08/01/2005-09/30/2005 and 11/01/2005 - 12/31/9999, neither BDC nor BAPI works. With BAPI, even the gap where the cost center does not exist is updated while in the BDC of tcode KS02, it gets stuck.
    I hope I made the problem clear to you. Hoping you could help.

  • Cost assosiated with the cost center

    Hi,
    How do I know the cost associated with a particular cost center. Also I would like to distribute the cost in a particular center to all the active cost centers. Please let me know how can this be achieved.
    Thanks.

    Hi Lakshmi,
                    Time sheets are filled for employees and subcontrators and that data will be stored in CATSDB table. So from the CATSDB you can get the cost center, activity type passing the company code,Fiscal year, Fiscal period and the controlling area as inputs.
    For each cost center and activity type combination, you can get the OBJNR from table CSSL passing SKOSTL and LSTAR.
    call the Function module
        CALL FUNCTION 'BKK_GL_FI_PERIOD_DETERMINE'
          EXPORTING
            I_BUKRS = '1010'  "Pass the Company Code
            I_BUDAT = l_budat
          IMPORTING
            E_MONAT = l_monat
            E_GJAHR = l_gjahr
            E_RC    = l_rc.
    Pass on the l_budat = t_catsdb-workdate and bukrs as "Specific to ur company"
    Get the cost rate from table cost passing the objnr and l_gjahr(Through above function module).
    Get the cost rate from table COST passing the objnr and l_gjahr.
    The exact cost is determined by the field cost-tkgoxx where the ‘XX’ is obtained by
    the exporting parameter(l_monat) of BKK_GL_FI_PERIOD_DETERMINE.
    if l_monat is 10 then,
    Select tkg010 from COST table passing objnr and l_gjahr.
    This program was done for posting the document for Full time employees. I dont know if it works for you.
    Thanks,
    Vamsi.
    sample code
    *--This is done inside the loop after extrating data from CSSL table and catsdb.
    READ TABLE ITAB_CSSL WITH KEY KOSTL = ITAB_CATSDB-SKOSTL
                                   LSTAR = ITAB_CATSDB-LSTAR
                                            BINARY SEARCH.
              IF SY-SUBRC = 0.                 "3
    *This function is used for picking fiscal period
                CALL FUNCTION 'BKK_GL_FI_PERIOD_DETERMINE'
                  EXPORTING
                    I_BUKRS = P_BUKRS
                    I_BUDAT = ITAB_CATSDB-WORKDATE
                  IMPORTING
                    E_MONAT = L_MONAT
                    E_GJAHR = L_GJAHR
                    E_RC    = L_RC.
    *determination of exact cost (GV_Ecost) by concatinating the field cost-tkgo
    with exporting parameter(l_monat)
                CLEAR : GV_ECOST.
                CONCATENATE 'TKG0' L_MONAT INTO GV_ECOST.
    *getting single value of exact cost into a variable GV_cost from table cost where
    Object Number is equal to ITab_CSSL Object number & fiscal year is equal to year derived.
                SELECT SINGLE (GV_ECOST) INTO GV_COST
                                    FROM COST
                                    WHERE OBJNR = ITAB_CSSL-OBJNR
                                     AND  GJAHR = L_GJAHR.

  • Cost center Group associated with a Cost center

    Hi Experts ,
    I have a requirement , where I need to find the cost center group of given cost center.
    Is there any FM to do the same?
    I have Cost center in the Input and should get Cost Center group associated with it.
    Thanks !!

    BAPI_COSTCENTER_GETDETAIL

  • Assets Captalised with wrong cost center

    Hi,
    I am facing one problem while capitalizing the asset it get capitalized with the wrong cost center and the depreciation is also get posted for two month. Now my problem is how to correct this entry as this is posted to wrong profit center.
    Is there is any way to correct the posted entries in FI.
    Thanks in advance
    Regards
    Rajesh Kumar

    Hi Rajesh,
    Transfer the asset to a receiving asset with the correct cost center using T code ABUMN.  Make sure that the asset value date is the same as the capialization date of the sending asset (unless is was capitalized in a prior-year, then use 01/01/CY).  When depreciation is ran for the month using T code AFAB, the depreciation in the wrong cost center will be reversed and reposted to the correct cost center.
    Hope this helps.
    Thanks,
    Chad

  • Cost Distribution - Sender to be selected with Real Cost Center / Stats IO

    hi CO allocation gurus,
    our company has a unique requirement. we want to identify cost by Cost Center/stats IO combination. We have a scenario wherein one cost center will have multiple Stats IO combination and these Stats IO can be used across multiple cost centers.
    The reason is that the Stats IO are cost portions identifiers and they are repetitive across cost centers. So instead of creating multiple cost centers, we create a combination in the coding block.
    During cost allocation we want to move cost based on a particular cost combination. As Stats IO are not cost allocatble, the system completely ignores the combination and total cost for the cost center/cost element combination is selected.
    The stats IO information is stored in COEP as OBJNR_N1 field. However this is not available in the Tcode KCIV ( maintain Sender / receiver combination ). 
    Has anybody come across this scenario and did some enhancement, are there any speciific userexits  to address this ?
    any help would be appreciated...
    regards,

    hi CO allocation gurus,
    our company has a unique requirement. we want to identify cost by Cost Center/stats IO combination. We have a scenario wherein one cost center will have multiple Stats IO combination and these Stats IO can be used across multiple cost centers.
    The reason is that the Stats IO are cost portions identifiers and they are repetitive across cost centers. So instead of creating multiple cost centers, we create a combination in the coding block.
    During cost allocation we want to move cost based on a particular cost combination. As Stats IO are not cost allocatble, the system completely ignores the combination and total cost for the cost center/cost element combination is selected.
    The stats IO information is stored in COEP as OBJNR_N1 field. However this is not available in the Tcode KCIV ( maintain Sender / receiver combination ). 
    Has anybody come across this scenario and did some enhancement, are there any speciific userexits  to address this ?
    Can i do this with costing substitution rule, if so what user exit ?
    any help would be appreciated...
    regards,

  • How to get Function Area (or Cost Center) from COSP ?

    Dear experts,
    I am new to FICO and here is one question need your help:
    Now I have table COSP, can anybody let me know how can I get Function Area through joining some other table?
    Or how to get the cost center from COSP, since I know then I can go to CSKS to find the function area.
    Any post would be appreciated and thank you all in advance!
    Tim
    Edited by: ctsiszidane on Feb 12, 2011 4:07 AM

    Ajay,
    Thanks for your reply.
    Actually this is a requirement for our BW system. I checked all the records to find their OBJNR start with "OR", but we need to get the function area information. Do you know how can I get that?
    The link below listed all the fields we have on BW side, actually it has function area, but it returns blank, we tried to apply one OSS note in the source ECC system, but still no value returned for this field. So we have to find another way to get the function area.
    http://help.sap.com/saphelp_em70/helpdata/en/29/5f4cf98c9141488cda37e173549834/content.htm
    Point has been assigned to you and thanks for your time in advance!
    Tim
    Edited by: ctsiszidane on Feb 12, 2011 6:39 AM

  • Multiple cost center for one cogs account

    Hi Gurus,
    We have created cogs account as cost element so that system picks relevant cost center at PGI.
    Appreciate if you can tell how can system know which cost center should be entered in cogs line if there are multiple cost centers?????
    Thank you

    Hi  Mohit,
    You can specify in OKB9 on what basis different cost centers need to be picked.
    Regards
    Ajith

  • Get Name for CO Cost Center Group and BGD Processing

    Hi,
    I use these function modules to get the cost center group nodes in the CO hierarchy.
    If I pass it a value that is in two controlling areas
    if prompts another screen to pick which controlling area we want to look in.  My problem is when I try to run this report in the background it gets hung up on this screen waiting for input. any ideas on how to get around this.
    here is the reference code.
    thanks
    Please note that the following logic is parts of SAP example report
    RGSEX001.
    Get the internal Set-ID from the external name of the set
    Selection of sets can be restricted to a specific set class or
    to sets matching a specific table field.
    See documentation of function module G_SET_GET_ID_FROM_NAME
    If the set class, subclass and setname is known, function module
    G_SET_ENCRYPT_SETID should be used alternatively (see RGSEX020)
        CALL FUNCTION 'G_SET_GET_ID_FROM_NAME'
             EXPORTING
                  shortname = w_set
                  old_setid = w_setid
             IMPORTING
                  new_setid = w_setid.
    Read the complete hierarchy (set and all subsets)
        CALL FUNCTION 'G_SET_TREE_IMPORT'
             EXPORTING
                  setid              = w_setid  "Set-ID, not the Setname!!!
                  no_table_buffering = ' '
             TABLES
                  set_hierarchy      = it_hierarchy
                  set_values         = it_values.

    Hi!
    For reading cost center hierarchy you can try K_HIERARCHY_TABLES_READ.
    It returns near the same info as one you've mentioned, works well for single controlling area and I hope in case of ambiguity it will raise one of exceptions provided. Give it try.
    Regards,
    Maxim.

  • Can I get  Vendor Account Group & Cost center from PAYEXT Message Type?

    Hi Everybody,
    I am getting all the IDOC's of message type "PAYEXT" fro EDIDC & EDID4 tables. But will these IDOC's will contain Vendor Account Group & Cost Center ? If so could you please let me know the Segment & corresponding fields.
    Thanks & Regards,
    Nagaraju Maddi

    Hi
    You can find the all related IDOC fields in the SDATA field of EDID4 table
    Yhis is a 1000 CHAR field which stores all the Segments data by concatenating into a string
    have to search for the required field by looking into the related segment..
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • Ad-Hoc Query for OU's and their Cost Center

    Cost Centers are often inherited from parent OU's. If I try to make an Ad-Hoc query, select some OU's and show the Cost Centers via the relationship A11, the fields are empty unless the Cost Center is hardcoded for the OU.
    Is there a way to create an Ad-Hoc query that shows the Cost Centers even if they are inherited? I can't make any changes to system tables or other customizing.
    Thanks in advance!

    Unfortunately I'm not authorized to use SE16.
    This is my selection:
    Object ID: xxx (Selection)
    Object Type: O (Selection)
    Plan Version: 01 (Selection)
    Relationship Between Objects: 011 (IT1001)
    Relationship Specification: A (IT1001)
    Type of Related Object: K (IT1001)
    Output:
    Object ID (IT1000)
    Object Abbreviation (IT1000)
    Object Name (IT1000)
    ID of Related Object (IT1001)
    Any other way?

  • Get fuctional location from cost center

    Hi,
    I need help to write this algorithm in ABAP
    1) cost center value is given to CC variable
    2) get Fuctional location value according to the diven Cost center
    3) return 'Yes' if this fuctional location is Active, else return NO
    Thx,

    You can start by asking your functional consultant on which master data screen the relationship exists.
    Rob

Maybe you are looking for