How to Extract top most position in any given Org Unit

Hi Experts,
I have  a requirement to extract the highest position(or root position) in any given OrgUnit.  See the below example for more info.
Eg: org1
       -- position1
    Org2
         -- position2   
    Org3
       --Org3A
          -- position3
       --Org3B
          -- position4
As shown in the above structure, I need to extract the top most position in each Orgunit structure like postion1, position2, position3 and position4.  Note that Org3 does not have a immediate position or chief position so we are reading position3 and 4 instead for org3.
Thanks in Advance,
Vijay

The best way is to search until there is no more, in order to create the hierarchy.
To get all the B002 relationships for a respective Org. use parameter ACT_TDEPTH = 99 (i guess it won't go that deep) for the top Org.
The output table RESULT_STRUC will have a hierarchy structure, with all organizational units below the top one. Use the fields LEVEL and PDOWN (or PUP) to construct the hierarchy. Then for each ORG. just search for the manager position (B012).
Just a small look-in to what the fields in that table mean :
LEVEL - Level of the Org.
SEQNR - Index of ORG.
PDOWN - SEQNR of ORG below.
VCOUNT - Number of "brothers" (Orgs at the same level)
PNEXT - Brother to the RIGHT
PUP - Father
PPREV - Brother to the Left
Here is a sample program i made to insert this into a table that will later be used for creating an ALVTREE as an F4 for a field.
REPORT  YHR00101UPDPG.
* TABELAS
TABLES: HRP1000, HRP1001.
* VARIAVEIS AUXILIARES
DATA: T_STRUC TYPE TABLE OF STRUC,
      WA_STRUC TYPE STRUC,
      WA_YTHR00035 TYPE YTHR00035.
DATA: W_PLVAR type OBJEC-PLVAR.
DATA: W_OBJID TYPE HRP1000-OBJID.
* ECRAN DE SELECCAO
SELECTION-SCREEN : BEGIN OF BLOCK bloco1 WITH FRAME TITLE text-001.
PARAMETERS : P_objid type hrp1000-objid MATCHCODE OBJECT PLOMA,
             P_begda type hrp1000-begda DEFAULT sy-datum.
SELECTION-SCREEN END OF BLOCK bloco1.
START-OF-SELECTION.
* Get plan variant
  call function 'RH_GET_ACTIVE_WF_PLVAR'
       importing
            act_plvar = w_plvar
       exceptions
            others    = 1.
  CALL FUNCTION 'RH_STRUC_GET'
    EXPORTING
      ACT_OTYPE              = 'O'
      ACT_OBJID              = p_objid
      ACT_WEGID              = 'B002'
      ACT_PLVAR              = w_plvar
      ACT_BEGDA              = p_begda
      ACT_ENDDA              = p_begda
      ACT_TDEPTH             = 99
      ACT_TFLAG              = 'X'
      ACT_VFLAG              = 'X'
      AUTHORITY_CHECK        = 'X'
    TABLES
      RESULT_STRUC           = T_STRUC
    EXCEPTIONS
      NO_PLVAR_FOUND         = 1
      NO_ENTRY_FOUND         = 2
      OTHERS                 = 3.
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  if not t_struc[] is initial.
    delete from YTHR00035.
  endif.
* Agora temos a estrutura vamos criar a tabela YTHR00035
  LOOP AT T_STRUC INTO WA_STRUC.
    clear WA_YTHR00035.
    WA_YTHR00035-NIVEL          = WA_STRUC-LEVEL.
    WA_YTHR00035-SEQNR          = WA_STRUC-SEQNR.
    WA_YTHR00035-ORGID          = WA_STRUC-OBJID+0(8).
    WA_YTHR00035-FILHO          = WA_STRUC-PDOWN.
    WA_YTHR00035-NR_IRMAOS      = WA_STRUC-VCOUNT.
    WA_YTHR00035-IRMAO_DIREITA  = WA_STRUC-PNEXT.
    WA_YTHR00035-PAI            = WA_STRUC-PUP.
    WA_YTHR00035-IRMAO_ESQUERDA = WA_STRUC-PPREV.
* Primeiro vamos buscar a descrição da Unidade Organizacional
    select single MC_STEXT into WA_YTHR00035-NMORG from HRP1000 where
      PLVAR = w_plvar and
      OTYPE = 'O' and
      OBJID = WA_YTHR00035-ORGID and
      BEGDA <= p_begda and
      endda >= p_begda.
    clear hrp1001.
* Aqui verificamos se a Un. Organizacional tem uma posição de chefia associada
    select single * from HRP1001 where
      plvar = w_plvar and
      OTYPE = 'O' and
      ISTAT = '1' and
      OBJID = WA_YTHR00035-ORGID and
      RSIGN = 'B' and
      RELAT = '012' and
      BEGDA <= p_begda and
      endda >= p_begda.
    if sy-subrc = 0.
* Encontramos uma ligação com uma posição de chefia
      WA_YTHR00035-POSID = HRP1001-SOBID+0(8).
* Primeiro vamos buscar a descrição da Unidade Organizacional
      select single MC_STEXT into WA_YTHR00035-NMPOS from HRP1000 where
        PLVAR = w_plvar and
        OTYPE = 'S' and
        OBJID = WA_YTHR00035-POSID and
        BEGDA <= p_begda and
        endda >= p_begda.
    endif.
    INSERT YTHR00035 FROM WA_YTHR00035.
  ENDLOOP.
  commit work.
END-OF-SELECTION.
Hope this helps.
Edited by: Pedro Guarita on Dec 16, 2010 2:30 PM

Similar Messages

  • How to get subordinate org units for a given org unit within specific dates

    hi,
    How to get subordinate org units for a given org unit within specific dates

    Use the following Func module ..
    HRWPC_RFC_STRUCTURE_GET
    *--Get the sub org.unts for the given selection.
        CALL FUNCTION 'HRWPC_RFC_STRUCTURE_GET'
          EXPORTING
            ROOT           = root_org   <-- Give the Org unit 
            EVPATH         = 'O-O_DOWN'
            BEGDA          = s_date-low
            ENDDA          = s_date-high
          TABLES
            T_OBJEC        = t_objec
            T_STRUC        = t_struc
          EXCEPTIONS
            NOTHING_FOUND  = 1
            INTERNAL_ERROR = 2
            OTHERS         = 3.
        IF SY-SUBRC <> 0.
          MESSAGE i000 WITH 'No Sub Orgunits for ' s_objid-low.
        else.
    *--Prepare final sub org.units tabl.
          loop at t_objec.
            if t_objec-objid ne s_objid-low.
              it_orgunit = t_objec-objid.
              it_orgunit-begda   = t_objec-begda.
              it_orgunit-endda   = t_objec-endda.
              APPEND it_orgunit.
            endif.
          endloop.
        endif.

  • How many cost centers can we assign to a org unit

    can anyone pls tell me tht How many cost centers can we assign to a org unit ??
    thanks
    waiting for reply asap

    Hi,
    As mentioned above the common is to assign one cost center. You will see it in IT0001. But in case you need mor cost center to be assign to one employee you have the option to go to IT0027 and in there you may assign more cost centers base on different percentage.
    Hope it helps.
    Kind Regards,
    Edoardo

  • How to get Top most Manager in Org. Structure

    Hi Experts,
          I have an Organization Structure like the following:
                      [0]  MAIN ORG. UNIT
                               MANAGER9           
                              [1]  SUB ORG. UNIT1
                                     Manager1
                                     [1.1] Department1
                                               Manager2
                                               Manager3
                                               Supervisor1
                                               Supervisor2
                              [2]  SUB ORG. UNIT2
                                     Manager6
                                     [2.1] Department2
                                              Manager4
                                              Manager5
                                              Supervisor3
                                              Supervisor4
    1. I want to get the top most manager in the org. structure by looping the org. structure in workflow.
                            Here MANAGER9!!
    2. How can i get Manager1 by using the same.
    Waiting for your valuable Answer
    Thanks
    Regards
    Nizamudeen SM
    Edited by: Nizamudeen SM on Aug 26, 2008 4:08 PM

    These are the paramters to pass ..
    CALL FUNCTION 'RH_STRUC_GET'
            EXPORTING
              act_otype      = c_o
              act_objid       = w_orgunitid
              act_wegid      = 'ORGCHART'
              act_plvar        = '01'
              act_begda      = sy-datum
              act_endda      = '99991231'
            TABLES
              result_tab     = t_restab
              result_objec   = t_resobj
              result_struc   = t_reslt
            EXCEPTIONS
              no_plvar_found = 1
              no_entry_found = 2
              OTHERS         = 3.
          IF sy-subrc NE 0.
          ENDIF.
    It is not the orgunit id should be passed hear in your case it is manin orgunit ..so that it picksup the managers of child Orgunit as well.

  • How to get Top most parent Taskflow Id at runtime?

    Hi,
    I am working on a portal site and I need to get the parent Id of the current taskflow at runtime.
    Following is the code through which I get the current taskflow Id.
    ControllerContext cctx = ControllerContext.getInstance();
    ViewPortContext currentViewPort = cctx.getCurrentViewPort();
    TaskFlowContext taskFlowCtx = currentViewPort.getTaskFlowContext();
    TaskFlowId taskFlowId = taskFlowCtx.getTaskFlowId();
    String taskFlowName = taskFlowId.getFullyQualifiedName();
    But How can I get the parent Id if this taskflow is embedded within some taskflow(s). I want to get the top most parent Id.
    Your help is appreciated.
    Thanks,
    Jaykishan

    Hi, i tried this code but i'am getting ClassCastException.
    ControllerContext cctx = ControllerContext.getInstance();
    ViewPortContext currentViewPort = cctx.getCurrentViewPort();
    ChildViewPortContextImpl c = (ChildViewPortContextImpl)currentViewPort; (get error here oracle.adfinternal.controller.state.RootViewPortContextImpl cannot be cast to oracle.adfinternal.controller.state.ChildViewPortContextImpl)
    Object pViewPort = c.getParentViewPort();
    ViewPortContext parentViewPort = (ViewPortContext)pViewPort;
    String parentTaskFlowId = parentViewPort.getTaskFlowContext().getTaskFlowId().toString();
    how did you manage to make work ?

  • How to group employees together belonging to a particular org. unit togethe

    Hi,
    I am developing a report. In that report after retrieving the relevant data(Employees belonging to a particular org. unit together irrespective of position say employee, chief etc.) it is required to display the output in a such a manner that all employees belonging to a particular org. unit will be grouped together.
    Which one would be a better grouping criteria?
    1. Grouping by personnel area(P0001-WERKS)
    2. Grouping by org. unit(P0001-ORGEH)
    What is the impact of both of them?
    In case if there is a grouping criteria other than both mentioned above, then please guide me for the same.
    The objective of the report is to show the result in the form of employees belonging to a particular department together irrespective of their position in the department.
    Thanks,

    Cost Center Can be inherited Via
    OU - Current or Any OU above inthe Hierarchy
    Position Hierarchy
    IT - Account Assignment for OU or Position
    Or IT-27 directly..
    Ensure Cost center ref is removed from all these sources if you dont want a Cost Center.

  • How do we assign mass BP's to an ORG UNIT

    Hi Experts,
    I need to assign a more than 500 BP's to a Position.Could you please tell me that how do we do this mass assignment of Bp's to a position?What will be the impact if assign many bp's to an orgunit.
    Thanks in advance,
    Regards,
    Kishore

    Hello
    PPOMA is a transaction in which org data assignment must be done manually. Anyway, you can create a report using FM RH_INSERT_INFTY_EXP, but this FM is not released by SAP so be careful with the BP load.
    Another option would be running report CRMC_R3_ORG_GENERATE in order to replicate partners from ERP to CRM.
    The impact of 500 BPs to a single org unit is clear: Everytime you load the WebUI, all the structure is loaded, so you will possibly notice an impact in performance when loading WebUI. My recommendation is performing stress tests before passing the org structure to your production system.
    Hope it helps
    Joaquin

  • 1 position belonging to 2 org units

    hello all,
                 i want a positon reporting to 2 org units
    how is this possible . i know that its possible through matrix structure
    but what are the steps to be followed kindly provide ur inputs............its bit urgent
    points are assured
    regards
    vikram

    Hi,
    First of all. you try to create the Diff matrix types(i.e define matrix types, which specify how the matrix organization will appear according to the selection of object types in the two dimensions) eg: Functional, technical etc as per your req.
    <b>Path:-SPRO settings in Org Mgmt matrix types</b>Secondly go to easy access- <b>HROMMatrixchange</b>, here you select the type of matrix you have created, here you specify the various Obj ID for your positions * the view you want to see & execute
    It displays the matrix structure, as per your req
    If you are still not clear then go through SAP HELP
    Hope this helps!!
    reward points if useful!!
    regds,
    nithi

  • Delimiting positions assigned to a Org Unit

    Hi Everyone,
    HAPPY NEW YEAR!
    I have delimited a organisational unit through PPOME. Now I want to delimit all the positions ( vacant as well as filled positions) associated with that particular org unit.
    Is there any T-Code or program where I can delimit all the positions together or I have to delimit all the positions manually. Please let me know.

    Hi
    As far as i know you cannot delimit a position created.
    We need to close the position status from open to close for the position to be delimited automatically.
    If we try to delimit the position by entering a date the system will overwrite the previous one and create a new position from the next date of the delimited date.
    Ravee
    +91.99206.33669

  • How to Restrict Creation of Infotype Record for Certain Org Units?

    Dear All,
    Requirement:
    Org Unit 1 does not have overtime. Even the employee works overtime, they will not get overtime compensation.
    One of the option is to disallow the creation of IT2005's record for all the employees in Org Unit 1.
    Is it possible to do this through standard SAP?
    Thanks a lot.

    Hi,
    The best way to control this will be with Authorizations so that people belonging to one Org.unit should not have IT2005 mantainence.
    Let me know if u have any concerns on this.
    Thanks
    Swati

  • How get to top or bottom of (any kind of) page without scrolling in Fusion?

    When on any kind of page (TextEdit, Pages, Safari) in Mac, I can press Cmd+PageUp to get immediately back to the top (or Cmd+PageDown to get to the bottom).
    When I launch VMWare Fusion (using spaces), Cmd+Left/Right arrow keys move me from Mac to Windows environments. When in Windows, Cmd+PageUp makes the screen maximixed and Cmd+PageDown restores the size.
    How can I get to top/bottom of pages in Fusion with one combination of key presses?
    Thanks.

    Please post Fusion questions on the VMWare forums, as Apple discussions only provide support for Apple products:
    http://communities.vmware.com/community/vmtn/desktop/fusion

  • How to Extract data using Query or any data fucntion in Excel.

    Dear Users,
     i want to ask one question about excel..............
    i have a parts list sheet, it contains part-number , price, name........ in columns. now my question is this that for example  part names are as under ,
    fix contactor
    moveable contactor
    half contactor
    contactor gm
    contactor skf
    as you saw in the names of parts contactor is the same in all the column. i want such a query that extract all the entries which contain contactor and make a new column or highlight them in the same column. my requirement is very similar to dos command when
    i want to see the list of all files which have exe extension ...dir *.exe.
    Best Regards
    Tahir Mehmood

    =IFERROR(IF(FIND( "contactor" ,LOWER(A1))>0,TRUE,FALSE), FALSE)
    This formula checks cell A1 and will flag TRUE if it matches the requirements of the specified text.  Have wrapped a lower function around the cell to mitigate for different upper or lower case mismatches.
    Alternativey you can use conditional formatting > "Use a formula to determine which cells to format" and use the following formula  =FIND("contactor", LOWER(A1)) >0.  Change the format to colour in the cell and copy the
    format down to all corresponding cells.  This will now highlight those that match the text value.
    Regards

  • How get to top or bottom of (any kind of) page without scrolling?

    On a Windows PC, I could press Ctrl+Home to immediately go to the top of a page (text document, Word document, web page, etc)... Ctrl+End to go to the bottom.
    Im Mac, there are no Home/End keys. The best I have found is Ctrl+UpArrow but I have to press it several times to get to the top of a long scroll.
    Please, please.. isn't there a way to get to the top/bottom of pages with one set of keystrokes?
    Thanks.

    BobHarris wrote:
    On a laptop (and some keyboards that also have an fn key)
    fn+left arrow - top of page
    fn+right arrow - bottom of page
    fn+up arrow - page up
    fn+down arrow - page down
    The reason those work is because adding the Fn key turns those keys into Home, End, Page Up, and Page Down. On extended keyboards, you can get to top of page by pressing just the Home key, and the bottom of a page by pressing End.

  • How to get top most rows col into a vriable.

    hi,
    i want to get the smallest
    "Tid" greater than v_Id1
    into v_b
    which method i should use both are working.
    1)
    SELECT *
    INTO v_b
    FROM ( SELECT TId
    FROM tt_T
    WHERE TId > v_Id1
    ORDER BY TId )
    WHERE ROWNUM <= 1;
    2)
    SELECT *
    INTO v_b
    FROM (SELECT Tid
    FROM ( SELECT TId
    FROM tt_T
    WHERE TId > v_Id1
    ORDER BY TId )
    WHERE ROWNUM <= 1);
    yours sinicerely
    Edited by: 944768 on Apr 28, 2013 9:35 AM

    Hi,
    944768 wrote:
    i wanted to know about the correctness of my sql.
    so please tel me which one is correct . or both are correct.You said both give the results you want, so both are correct.
    The ways Solomon posted are also correct, and they are better, because they are faster and/or easier to maintain.
    and specially about one extra bracket which i have in my 2) stmt.What do you see as the advantages and disadvantages of the 2 ways you posted?
    If 2) is better than 1), wouldn't this be even better han 2)?
    SELECT  *
    INTO      v_b
    FROM      (
             SELECT  TId
             FROM    (
                          SELECT    TId
                   FROM       (
                              SELECT  TId
                              FROM    (
                                             SELECT    TId
                                    FROM         tt_T
                                    WHERE         TId > v_Id1
                                    ORDER BY  TId
                                  WHERE   ROWNUM <= 1
    ;Why stop at 4 sub-queries?

  • How to find top level object on a given layer?

    I need to assign it to a var...
    var topLevelObj = app.activeDocument.layers.name("foo")... whatever is on top of that stack...
    ...this is probably not correct but you know what I mean

    Jump_Over wrote:
    Hi,
    top level object is the first in a collection:
    var fooLayerTopObj = app.activeDocument.layers.item("foo").pageItems[0]
    Jarek
    I'm not very good in ID-scripting, but I think this isn't good enough to find topmost item of a layer.
    Why?
    - create a new document
    create a polygon
    create a rectangle
    create an ellipse
    create a line
    Run this script snippet:
    var pI = app.activeDocument.layers.item(0).pageItems;
    for (i=0; i<=pI.length-1; i++) {
    pI[i].select();
    alert (i);
    pI[i].locked = true;
    Do you see, which element pageItems[0] is?

Maybe you are looking for

  • Generic Extractor on cdpos & CDHDR - severe performance issues in productio

    Hello friends, Can you take a look at my code? I have used a view in cdhdr table for extractor.code executes okay in dev and QA, but had to cancel job after running 48 hours. Any help is appreciated. This is my code in CMOD... FORM Zpurchasing_exit 

  • How do I delete a partition that was created in Bootcamp?

    I installed XP on my MBP using Bootcamp a while ago, and recently erased all the data on the partitioned drive. I have the second partition doing nothing and would just rather delete it. I have been told that I need to use Bootcamp to delete the part

  • Finding lost files

    After recently moving the Lightroom folder to an external hard drive, Lightroom shows thumbnails of images, but can't locate the files. We've chosen the new folder location in preferences, but after restarting the computer and the program, the list o

  • About vz messages and mypicmessages

    I am the one that pays the bill for the 4 cellphonez on my account. The phone in question is a lucid 2, it is receiving and sending from both of these pages. the my pic starts with a cellphone number then mypicmessages.com. From what I have read both

  • Bootcamp MUP.sys windows xp issue

    I have been running my imac with snow leapard and bootcamp with a bootcamp partition running windows xp pro. This has been stable for a few months with no problems. I have my business accounts on this as the accounts package wont work under a mac os.