How to find latest child for a given parent in same table?

More details:
Here I am giving an example -
Orig_ID     Chg_to_ID
A     B
B     C
C     D
D     Null
From source I use to get Orig_ID values, using Orig_ID value have to find latest Child(Chg_to_ID) to that at any level.
Latest child identify by Null value in the column "Chg_to_ID".
If I get B --> need to replace B with D. I may get any value A or B or C or D -- but at an end I have to replace those values with 'D', since it is latest for any of those parents.
I tried to use "Connect By Prior", but it is tooo slow ofcourse query not returned after 10min also. Plz advise.

First time every employee will be assingend an ID and may changed/merged to another ID basing on some other conditins. So, any time first assigned ID may changed to new ID and will be updated to another column "Chg_to_ID" as winner ID and at the same time one more records will be created with new ID as ID and Null in "Chg_to_ID".
In my first post, given an example, here pasting again:
Orig_ID     Chg_to_ID
A-------------->B
B-------------->C
C-------------->D
D-------------->Null
In detail: One employee first assigned ID as "A" after wards changed to "B". At that time data would be like below
Orig_ID     Chg_to_ID
A-------------->B
B-------------->Null
After that B change to C, now it looks like this:
Orig_ID     Chg_to_ID
A-------------->B
B-------------->C
C-------------> Null
For each change one record will be inserted.
My requirement is -- Orig_ID may get A or B or C, but I need to replace those with "C", since it is latest child. For latest child "Chg_to_ID" is NULL.
Plz let me know for any clarifications.

Similar Messages

  • How to find the Datasources for the given table names ?

    Hi All,
    I have an urgent requirement where I ned to find the names of BW Datasources, created for the given table names.
    Both the tables and Datasources are in BW system only. I can see the table in SE11 but I am unable to find its associated Datasources in the 'Where Used List'.
    Is there any method ?
    Will assign points to satisfactory answers.
    Regards,
    Srinivas

    Hi,
    Check this thread on how to find the DS.
    I have the field name, please help me find the data source.
    Once you identify your DS you find which all Data targets are fed by trying to see the " Show data flow" in RSA1 for this data source.
    Hope this helps.
    Thanks,
    JituK
    Edited by: Jitu Krishna on Apr 30, 2008 11:52 AM

  • How to find Handling unit for a given Sales order...

    From which table can we find the Handling unit for a given Sales order?

    hi this will help u.
    SALES AND DISTRIBUTION TABLES
    KONV Conditions for Transaction Data
    KONP Conditions for Items
    LIKP Delivery Header Data
    LIPS Delivery: Item data
    VBAK Sales Document: Header Data
    VBAP Sales Document: Item Data
    VBBE Sales Requirements: Individual Records
    VBEH Schedule line history
    VBEP Sales Document: Schedule Line Data
    VBFA Sales Document Flow
    VBLB Sales document: Release order data
    VBLK SD Document: Delivery Note Header
    VBPA Sales Document: Partner
    VBRK Billing: Header Data
    VBRP Billing: Item Data
    VBUK Sales Document: Header Status and Administrative Data
    VBUP Sales Document: Item Status
    VEKP Handling Unit - Header Table
    VEPO Packing: Handling Unit Item (Contents)
    VEPVG Delivery Due Index
    with regards,
    Hema Sundara,
    pls reward if u find it helpful.

  • How to find Assembly Numbers for a given Equipment Number

    Hi all,
    Can anyone pls help me out in finding the assembly numbers for a given equipment number??
    Thkz in advance.
    Harpreet.

    Hi
    Try a code like this:
    DATA: BEGIN OF MCHA_KEY,
           MATNR TYPE MATNR,
           WERKS TYPE WERKS_D,
           CHARG TYPE CHARG_D,
          END   OF MCHA_KEY.
    DATA: BATCHCLASS LIKE BAPI_CLASS_KEY-CLASSTYPE VALUE '022'.
    DATA: OBJECT_CLASSIFICATION LIKE  BAPI_OBJECT_VALUES
                                                  OCCURS 0 WITH HEADER LINE,
          CLASS_OBJECTS LIKE  BAPI_CLASS_OBJECTS  OCCURS 0 WITH HEADER LINE.
    DATA: _CLASSNUM LIKE BAPI_CLASS_KEY-CLASSNUM.
        BAPIFLAG = 'X'.
        CALL FUNCTION 'BAPI_CLASS_GET_CLASSIFICATIONS'
             EXPORTING
                  CLASSTYPE              = '022'
                  CLASSNUM               = _CLASSNUM
                  CHARACTS_OF_CLASS_ONLY = BAPIFLAG
             TABLES
                  OBJECT_CLASSIFICATION  = OBJECT_CLASSIFICATION
                  CLASS_OBJECTS          = CLASS_OBJECTS
             EXCEPTIONS
                  OTHERS                 = 1.
    Max

  • BOM: Finding Children Nodes For a Given Parent Node

    Hi,
    I am trying to find the longest path for a particular BOM material. I am using the FM CS_BOM_EXPL_MAT_V2 to explode the BOM to get the materials (including children nodes etc.). I think, in this scenario, a recursive function would be the best way to go. The problem is to find the children nodes for a node in a particular level. Looking at the structure STPOX and the fields STUFE (Level), WGEXX (path) , TTIDX (index) and VWGEX (path, multi-level), I cannot find a logical way to link the children nodes to a parent node although visually I can see how things are connected when the FM returns the STB table..
    For example: TBL_STB returns from FM:
    STUFE     WEGXX     BMTYP     TTIDX     VWEGX     OJTXB
    1     1     M     1     0     MATXX1
    2     1     M     2     1     MATXX2
    3(a)     1     M     3     1              MATXX3     
    4(c)     1     M     4     1              MATXX4               
    4(d)     2     M     4     1              MATXX5     
    3(b)     2     M     3     1              MATXX6     
    4(e)     3     M     5     2              MATXX7     
    4(f)     4     M     5     2              MATXX8     
    Visually, we can tell that  Level 2 has one item 2, level 3 has 2 items, 3(a) and 3(b), Level 4 has 4 items where 4c and 4d are connected to 3a and 4e and 4f are connected to 3b.
    Going through STPOX structure itself, how can we find out that 4c and 4d belongs to assembly 3a but 4e and 4f belong to 3b??  If someone can explain the uses of the differnet indicators in STPOX (or other) where I can find out the children from the parent, it would be greatly helpful to write the recursive function..
    Thanks in advance..
    P.S. I will give points out immediately for any useful answers..
    Edited by: Shuvo Datta on Sep 10, 2008 6:17 PM

    Figured it out myself

  • How to find Last Child (Node) of a parent

    Hi All
    I have following data:
    PARENT CHILD
    1 2
    2 3
    3 4
    4 5
    100 101
    101 102
    200 201
    300 301
    301 302
    302 303
    303 304
    Now I need the output as below:
    Parent Final Child
    1 5
    100 102
    200 201
    300 304
    Which means, for the parent, it should start with immediate child and traverse through all subsequent parent-child relation ship and should find at ending with the last child for that group.
    When the parent child relation is as below: i need to output 1 (first parent in the group) & 5 (last child in the group)
    1 - 2 - 3 - 4 - 5
    Quick solution could be helpful.
    Thanks in advance,
    Ram.

    It seem that you asked for leafs from all roots.
    If so try this
    Processing ...
    with Test_Data as (
      select 1 as parent, 2 as child from dual union all
      select 2, 3 from dual union all
      select 3, 4 from dual union all
      select 4, 5 from dual union all
      select 4, 6 from dual union all
      select 100, 101 from dual union all
      select 101, 102 from dual union all
      select 200, 201 from dual union all
      select 300, 301 from dual union all
      select 301, 302 from dual union all
      select 302, 303 from dual union all
      select 303, 304 from dual
    Levels as (
      select child, level as lvl, connect_by_root parent as root
      from test_data td
      start with parent not in (select child from Test_Data)
      connect by parent = prior child
    ), paths as (
         select child,root,lvl,
              max(lvl) over (partition by root) max_lvl
         from Levels
    select root,child
    from paths
    where lvl= max_lvl
    Query finished, retrieving results...
                     ROOT                                   CHILD                
                                         1                                      5
                                         1                                      6
                                       100                                    102
                                       200                                    201
                                       300                                    304
    5 row(s) retrievedBye Alessandro
    Edited by: Alessandro Rossi on 1-set-2008 12.41
    I've never imagined that a simple copy and past would do that!
    I won't leave it so the new forum supporters ( if any exist ) could see what the cr4p we are using now

  • Find The Transaction for the given EXIT Name

    Hi Friends,
                    This is my doubt,pls dont think in the other sense
    I know how to find the EXIT for a given Transaction. My question is that IS THERE IS ANY WAY TO FIND THE TRANSACTION FOR A GIVEN EXIT NAME.Could any one help me out on this.My fuctional guys are giving me the EXIT names and asking me to find for which transaction the exit triggers.
    Thanks & Regards
    Vijaya Lakshmi

    hi lakshmi,
    try the following steps.
    1. give the exit name in SMOD.(J45A0007) go to display mode
    2. click component and take the exit name.(EXIT_SAPMJ45A_009)
    3. here SAPMJ45A is the progam name, so that in SE38 give the progame name click the Where used button and select the transaction and deselect other checkbox.
    4. you will get the transaction code.
    Reward if found helpful.
    Regards,
    Boobalan Suburaj

  • How to find system status for production orders?

    How to find system status for production orders?
    looked into table AUFK, AFKO and AFVC but none of these tables, carry
    system status as part of the fields(STTXT)
    I tried to filter in COOIS, but not much help
    Able to find system status information in COHV,Is there any other way where
    I can find system status information for production orders
    Kindly guide

    Hi,
    Look into table, JEST, JSTO, AFPO & AFKO. CAUFV filed OBJNR, TJ02T filed ISTAT.
    But, it is very difficult to combine the details like Order and System status.
    Take the help of your ABAPer to generate Report for you.
    Regards,
    Siva

  • EHSM - Create Vendor - error: 'Could not find a document for the given key'

    Dear all,
    In the Chemical Approval Process I have attached a SDS document to the Approval Request. You can assign a Vendor to the SDS. As there are no (EHSM) Vendors currently available in the system I would like to create a new (EHSM) Vendor by clicking on 'Create Vendor'.
    This will lead me to the following Webdynpro Application: Edit Vendor (EHFND_UI_VENDOR_OVP).
    Only one field is shown in the Webdynpro named: 'Name of the Vendor'. After typing a name e.g. 'test', the following error message appears; 'Could not find a document for the given key'. See also attached document. This issue looks like a missing number range, however I could not find a EHSM number range for Vendors.
    How to solve this issue?
    More information:
    Software Component: SAP EHS Management (EHSM) Support Package: 3
    Process: Chemical Approval
    Webdynpro application: EHFND_UI_VENDOR_OVP
    Thank you.
    Kind regards,
    Roy

    Hi
    babooraj
    This might be a problem with Windows Power Shell.
    The solution is to copy the folder: "PSWorkflow" from "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\"
    to "C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules"
    Than everything works fine.
    Ps.: @Microsoft, please fix this problem in future versions.
    Thomas van Veen

  • FindChildIndex cannot find the child with the given itemName

    Hi,
    I am getting error " findChildIndex cannot find the child with the given itemName" when runs the page from jdeveloper.
    I didnt use findChildIndex in my CO or AM.
    Please help me to resolve it.
    Thanks
    Amit Jaitly

    Amit
    Check old threads
    Re: how to call concurrent programs from oaf page
    http://forums.oracle.com/forums/search.jspa?threadID=&q=findChildIndex+cannot+find+the+child+with+the+given+itemName&objID=f210&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks
    AJ

  • How to find CUSTOMER EXIT for a Standard SAP program

    How to find CUSTOMER EXIT for a Standard SAP program

    Hi
    To introduce the techniques of enhancement in standard SAP system. SAP creates customer exits for specific programs, screens, and menus within standard R/3 applications. These exits do not contain any functionality. Instead, the customer exits act as hooks. You can hang your own add-on functionality onto these hooks.
    They do not affect standard SAP source code.
    When you add new functionality to your SAP System using SAP’s exits, you do not alter the source code of standard SAP programs in any way. The code and screens you create are encapsulated as separate objects. These customer objects are linked to standard applications, but exist separately from SAP’s standard software package.
    They do not affect software updates.
    When you add new functionality to your SAP System using SAP’s exits, your objects (called customer objects) must adhere to strict naming conventions. When it comes time to upgrade a to a new software release, customer objects’ names ensure that they will not be affected by any changes or new additions to the standard software package.
    Customer exits are not available for all programs and screens found in the SAP System.
    Any change made to an SAP object in a customer system is called a modification. Customers usually modify their systems for one of two reasons. Either they make changes to the SAP standard in order to adjust the R/3 System to their specific business needs (actual modifications), or they alter individual SAP objects in order to correct an error (as recommended in an SAP error note).
    You should only modify the SAP standard if the modifications you want to make are absolutely necessary for optimizing work flow in your company. Be aware that good background knowledge of application structure and flow are important prerequisites for deciding what kind of modifications to make and how these modifications should be designed.
    SAP application programmers create SAP enhancements in transaction SMOD using function module exits, menu exits, and screen exits.
    Customers are given a catalog containing an overview of existing SAP enhancements. They can then combine the SAP enhancements they want into an enhancement project using transaction CMOD.
    SAP enhancements are made up of component parts. These components include function module exits, menu exits, and screen exits. A specific component may be used only once in a single SAP enhancement (this guarantees the uniqueness of SAP enhancements).
    Customer enhancement projects consist of SAP enhancements. Each individual SAP enhancement may be used only once in a single customer enhancement program (this guarantees the uniqueness of a customer project).
    SAP application programmers preplan function module exits, menu exits, and screen exits for their applications and combine them to create useful enhancements for the R/3 System.
    Customers create their own enhancement projects for their systems using SAP enhancements. You can customize the individual components of an enhancement project by creating your own include programs (for function module exits), texts (for menu exits), and subscreens (for screen exits).

  • How to find Info objects for particular filed??

    Hi
    I hav doubt Can anyone tel me???
    My Query s <b>How to find Info objects for particular filed??</b>
    For example i hav some table fileds, how to find Info objects for that fields??
    Pls explain me detaily
    Points wil be given for all answers.
    Thanks
    Senthil

    Hi Senthil ,
    You have your field description along with your Field right.
    For example:MATNR - Material Number
    Now take this description and go to your BW side Tcode:RSA1
    1)Search in Modelling >> Infoobjects >> Material Number
    Then you get few hits (matches)  which have description matched.
    For Example: 0material  - Material Number
    Check for the Length and type match.
    You will understand once you get those hits as to which is related to yours.
    2)Go to BI content and search in the infoobjects this has all active and inactive objects but this takes a little time (not much  though).
    3) You have meta data search / simple search also where you can search for the objects with field description as matching criteria.
    Hope your doubt is cleared atleast to some extent.
    Assign Points if helpful.
    Thanks,
    Priyanka

  • How to find Opening Balance for Cash Book

    Hello Friends,
    I am Creating one Report for Cash Book.(Means : For Perticuler GL Account)
    I have no idea how to find Opening Balance for some Perticuler Date.
    Ex.
         Current date: 07/06/2007
        and i want to find Opening Balance on 26/05/2007
    i have Function for Calculating Opening Balance,                                                                               
    Group No: 3006             Business Object General Ledger Account  
    BAPI_GL_ACC_EXISTENCECHECK     Check existence of G/L account                  
    BAPI_GL_ACC_GETBALANCE     Closing balance of G/L account for chosen year  
    BAPI_GL_ACC_GETCURRENTBALANCE  Closing balance of G/L acc for curr year
    BAPI_GL_ACC_GETPERIODBALANCES  Posting period balances for each G/L account    
    but they show current opening balance, and i want for perticulaer Date..
             How to find Opening Balance for Cash Book
    please Help me out
    Thanks
    Gaurav Tripathi

    Hi Maruthi,
       Opening balance for a cutomer for a given period, u need to first find closing balance of that customer in the previous period. For eg. Suppose u want to find opening balance for customer 'A' for month of Nov'06, then U have to find wot was his closing balance in at end of Oct'06. Hope this solves u r problem

  • How to find serial Number for BCC Plugin?

    Hi,
    How to find serial number for Bcc plugin on FCP?
    I need format my Mac so before that I to find the serial number?
    Please anyone can help me....

    The serial number has the format like E-111-aaa-222-bbb-333-ccc-444-ddd-5ee-ffff, it can be found on a piece of paper which has 3 stickers with it inside the box.

  • How to find function code for buttons on toolbar in oops alv

    Hi experts,
    I want to remove some buttons from toolbar in oops alv, i know the procedure like get function code and pass the value in a table and pass that table to IT_TOOLBAR_EXCLUDING of
    method set_table_for_first_display but I WANT TO KNOW HOW TO FIND FUNCTION CODE FOR BUTTONS ON TOOLBAR IN OOPS ALV

    Hi Prakash,
    -->First you have to set the pf status in your alv program by,
    {FORM pf_status USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'FIRST'.
    ENDFORM.                    "PF_STATUS}
    -->Pass this Subroutine name in the Function module, Reuse_alv_grid_display's parameters i.e,
          i_callback_pf_status_set          = 'PF_STATUS'}
    *-->Then doble click on that pf status,
    From the menu bar, select Extras->Adjust Template->List Viewer,
    This will give you the existing statndard gui status of the program*
    ->Then catch that function codes in the User command Parameter of the Function module Reuse.. i.e,
          i_callback_user_command           = 'COMM'
    And make a subroutine of the name 'COMM'i.e,
    FORM comm USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
      DATA: okcode TYPE sy-ucomm.
      okcode = ucomm.
      CASE okcode.
        WHEN 'REF'.
        CALL FUNCTION 'POPUP_TO_INFORM'
          EXPORTING
            titel         = 'MANSI'
            txt1          = 'CREATED BY'
            txt2          = SY-UNAME
          TXT3          = ' '
          TXT4          = ' '
    endcase.
    Hope it helps you
    Regrds
    Mansi

Maybe you are looking for

  • Window 8.1 single language window store

    i upgrade my window 8 to window 8.1 single language. now after upgrading, my laptop can't open the window store app and my window music disappear. how to solve this problem. please help me. thank you.

  • Problems connecting from Forms 6i to Personal Oracle

    I have loaded Oracle 8i Personal Edition in the following directory c:\Oracle\Oar81 and Forms 6i in c:\Orawin95 on my local PC. I'm running windows 98 OS. I have been able to use SQL*Plus to query the customer and sales_order demo databases sucessful

  • Error 10000 Date format issue

    Hi all, Has anyone seen the following error please or has a troubleshooting hint: - "[NT AUTHORITY\SYSTEM (15/10/2012 18:35:12) - Service request cancelled due to an error. Error Code: 10000 Error Description: Failed to create lease requisition. Faul

  • How to Root Lenovo S939? And how to install VIBEUI_V1.5_1417_2_DEV_S939_NK_W_B215_MultiLang_GAPPS_

    I bought a Lenovo S939 with a multilanguage ROM and GAPPS (aNDROID 4.2.2  -  S939_S124_131211). After the system update to the 4.4.2 ( VIBEUI_V2.0_1434_2_ST_S939) all the system (including Apps) have appeared in Chinese (I could choose English as sys

  • Match Sequence Settings

    Has anyone figured out how to export from PPro/AME with settings from an specific sequence?  Meaning, if my sequence is DVCPROHD 1080p and it has 10 mono audio tracks in it,  I could export a QT in DVCPROHD with all those 10 mono tracks embeded witho