Copy tree structure to another tree structure

I have a tree, but I want to copy this structure to another structure.
say I got a tree model:
1
2 3
4 5 6
2,3 are the children of 1;
4 is the child of 2; 5,6 are the children of 3.
after I have got this structure, I want to build a tree structure in this way:
object1
object1.add(2),object1.add(3)
object2.add(4)
object3.add(5),object3.add(6);
I want to build a dynamic tree, so i cann't do this, I need a way to build a tree from any tree model into such a tree structure.
thanks!

Hi jiangyubao!
To copy a tree to another tree, each node (obejct) in the tree needs to have a method that can return the children of that node, all the objects one level below this node in the tree. Then you can copy the tree using a loop that looks a little bit like this:
public void copyTree(newTree, oldTree){
TreeNode children[] = oldTree.children();
for(int i=0; i<children.length; i++){
newTree.add(copyNode(children);
public TreeNode copyNode(TreeNode oldNode){
//the call to the constructor of the TreeNode should
// copy the data from the TreeNode passed as argument
TreeNode newNode = new TreeNode(OldNode);
TreeNode children[] = oldNode.children();
for(int i=0; i<children.length; i++){
//call this method again recursively to get down through
// all levels of the tree.
newNode.add(copyNode(children[i]);
And that should be it. Any questions, just fire :-)

Similar Messages

  • Copy the structure of a table to another with another table name.

    how to copy the structure of a table to another with another table name.
    ie. i want a emp table with same values/structure to be copied to another table called my_employee.
    how can this be done?

    create table my_emp as select * from emp;
    If you do not want the data to be copied then do the following:
    create table my_emp as select * from emp
    where 1=2;
    Avanti.

  • Copy the structures in a query

    hi,
      Can we copy the structure of one query to another query ?
       If so, please let me know how to do it.
    Thanks in advance.

    Hi,
    If the queries in question are on the same Infoprovider, then you can save the structure as a global structure and use it in both the queries.
    If the queries will be on different InfoProviders, then you would need to copy at the query level using RSZC.
    Hope this helps...

  • Short Dump while copying Org structure from ERP to CRM

    Hello Experts:
    We are trying to copy the Org structure from ECC to CRM.
    We have a standard transaction 'CRMC_R3_ORG_GENERATE' to copy the the org structure from ECC or the IMG path:
    SPRO->CRM->Master Data->Organization Management->Data Transfer->Coppy ECC Sales Structure
    We have a multiple assignment scenario where each sales groups are assigned to multiple sales offices and likewise,each sales office is assigned to multiple sales org unit in ECC.
    This can be achieved by turning on the enhanced version.
    In our current business,even though the sales offices and groups are created,but are not having relavance in the business,hence while running in the sandbox system, we ran the program to copy the structures in the standard mode(default) and we could copy it without issues and create the org units for every entity in CRM based on how the number ranges are defined.
    What happens when enhanced version switch is turned on ::
    While we turn the mode to enhanced version, The system automatically::
    - enhances the Function tab page in the ppoma_crm  transaction to include a grid table, in which you maintain multiple assignments of organizational units
    - generates an extra dialog box to the Organization tab page in business transactions for you to select the relevant assignment path for the organizational unit
    - adapts the consistency check in business transactions to take into account organizational units that have been multiple assigned
    Risk factor :
    Once you have switched to the enhanced backend integration version of the organizational model you cannot return to the standard backend integration version. The system will also automatically make changes to the organizational model version in CRM Mobile Sales.
    Also this structure will happen across all the clients in the system,so unfortunately cannot try in a sandbox client also of the new environment.
    We are building our development box,so while running the above step in standard mode,the program gives a short dump due to long execution time even though we have the same amount of data as in our prototype system.
    Also, we increased the idle time value to a very high value.
    When I approached SAP OSS,I was told that it is due to the multiple assignment scenario,hence we need to switch to enhanced version in CRM before we run the copy program ( CRMC_ORG_R3_GENERATE )
    I am not quite sure if the mismatch of the scenarios between CRM and ECC could be causing this short dump as we could run it in standard mode in our prototype/sandbox environment without issues even  with the same data volume as in the new development system .
    I am looking for help from all the experts if they have come across similar issue and your recommendations/feedback if this can be corrected.
    Appreciate your guidance/recommendation on this issue.
    thanks!!

    In CRM Best Practices Building block C05 is the step by step description how to replicate Org. structure and some of employee's master data.
    Follow link - http://help.sap.com/bp_crmv12007/CRM_DE/BBLibrary/html/C05_EN_DE.htm

  • How to copy a structure with a very long name

    I would like to copy a structure with a very long name (YAM_INBOX_DISPLAY) . How to do that?
    Thank you in advance

    Hi,
    Copying a structure is very simple. In the initial screen on se11 you have an option of copying a structure. Type in the structure name in the DATA TYPE and click on copy. It will suggest you a name which you can always rename and copy it. Max number of characters the structure can be named is 30.
    Reward points if useful

  • Copying Folder Structure

    I have a folder structure of Months (01-January, 02-February, etc.) setup under each year folder.
    Is there a way in Aperture to create a folder structure template and copy that structure to a new folder, as the new years need to be setup?

    You can do this for Projects by setting up you Folder and Album structure in an empty Project, exporting it, and then importing it again each time you need a new copy, but not for Folder structures outside of Projects.
    But if you download the Aperture-InDesign integration examples from http://www.apple.com/applescript/aperture/indesign/ there are a couple of example scripts for creating organisational structures that you might be able to tweak.
    Ian

  • Copying standard structure

    Hi experts,
    when i tried to copy standard structure. Not all the fields are copying. The structure im trying to copy is VBKPF_ALV. In this first 3 fields are getting copied. when i tried to convert that in to change mode only first 3 fields are getting displayed. But when i see in display mode all fields are visible.
    thank you
    regards
    vijay.

    thank you Jose
    but my problem is i want to add two more fields for this custom structure but it is asking for reference table and refrence field.  The field i added is wrbtr. when i entered ref. table as bseg and ref. field as wrbtr it is not accepting this combination.
    please help me in this.
    thank you
    vijay

  • PM: Copy functional location to another

    Hi,
    Is there any function module or BAPI which can copy one functional location to another functional location. Thanks

    Ya I know about the table IFLOT. But my requirement is that I need to give a functional location as the input and execute to see the hierarchical structure of this functional location. I should also have a button on this output screen to enable the user to copy this functional location and its subordinates to other functional locations. And once this is done, I need to see the newly copied FL structure in the output also. Is this possible?

  • How to copy one schema into another

    I need to copy one schema into another. That means, all the tables, views, constraints, etc, and all the data as well.
    I have a dmp file of source-schema (created daily with expdp by our backup schedule).
    Can I use impdp to import this dmp file into dest-schema? I'm thinking about something like this:
    The dmp file was created with:
    expdp source-schema/pwd DIRECTORY=dmpdir DUMPFILE=myproject.dmp
    Create the copy on dest-schema with:
    impdp dest-schema/pwd DIRECTORY=dmpdir DUMPFILE=myproject.dmp
    (dest-schema is an existing schema on the same machine. I'll drop all the tables before executing the command. Is there anything else I should do first?)
    If this approach is not feasible, kindly suggest me an alternative.
    Thank you.
    Edited by: mgro on Apr 16, 2010 3:22 AM (changed 2nd command: expdp to impdp)

    Thank you both. Dean, I've made a note of your proposed command. May use it next time.
    In the end I used the following command and it worked for me. I added TABLE_EXISTS_ACTION=REPLACE since the destination was not empty.
    First I ran these command logged in as SYS
    GRANT Import Full Database TO dest-schema;
    GRANT Create Any Directory TO dest-schema;
    GRANT Unlimited Tablespace TO dest-schema;
    impdp
    dest-schema/pwd
    DIRECTORY=dmpdir
    DUMPFILE=myproject.dmp
    REMAP_SCHEMA=source-schema:dest-schema
    TABLE_EXISTS_ACTION=REPLACE
    LOGFILE=implog.log
    There were some errors though. The import process complained about constraints referencing non-existent primary keys.
    It turns out that the source schema has some constraints that are marked with status DISABLED. These constraints either:
    - are not part of the DUMP file
    or
    - are in the DUMP file but skipped during import
    Don't know if this is a bug or by design behavior.

  • Error while copying Z program to another enviroment

    Hi, experts
    I have a Z program into one client's enviroment, which works fine. I tried copying this program into another client's enviroment, and i get the following error message, while syntax check:
    "RC_IN1 must be a byte-type field. (Typ X or XSTRING)."
    And this error is on the following form:
    form xor using rc_in1 type c rc_in2 type c rc_out type c.
      data:
        li_abit type i,
        li_bbit type i.
      rc_out = space.
      if rc_in1 <> space.
        do 8 times.
          get bit sy-index of rc_in1 into li_abit.
          get bit sy-index of rc_in2 into li_bbit.
          if li_abit <> li_bbit.
            set bit sy-index of rc_out to 1.
          else.
            set bit sy-index of rc_out to 0.
          endif.
        enddo.
        if rc_out = space.
          rc_out = rc_in1.
        endif.
      endif.
    endform.
    When I check into one client's enviroment, it does not gives error. Only in THAT client.
    Why is this happening?
    Thanks in advance,
    Brian Gonsales

    Hi,
    are the both client environments hav same version (ECC 6).
    In ECC 6 version type X is not allowed.
    To avoid this problem,
    you need to declare the field of TYPE C.
    you need to get the value from Cl_ABAP_CHAR_UTILITIES.
    Regards
    Sandeep Reddy

  • HT1727 My old computer died on me with no warning signs. I didn't know or need to copy my music to another computer. I would like to know how to get the music that I bought onto my new computer without having to buy it all again.

    My old computer died on me with no warning signs. I didn't know or need to copy my music to another computer. I would like to know how to get the music that I bought onto my new computer without having to buy it all again. I just want to be able to get all of my music that I bought on itunes onto my computer. Right now the money ive spent is just gone and I have no music to show for it.

    Go to the iTunes Store and select "Purchased" from the Quick Links side bar on the right. Go through all the tabs to download again for free

  • How to copy report properties into another report?

    I have created one updated list report and I wanted to create another updated list report with same report properties of first one but with different data objects so I don't have to redo properties settings.
    I copied first report to another name and I tried to change data objects but It didn't allow me to choose different data object. It says "Data object must contain at least the same fields as in the Original Data object".
    Do I have to create another report from scratch?

    You could edit the report xml.

  • How to copy a database to another location in sqlserver 2008 express edition

    Hi,
    Please help for to copy a database to another location in sqlserver 2008 express edition
    With many thanks
    Pol
    polachan

    if you are using SQL Server 2008 express edition
    you are NOT able to use Copy database wizard so the only option you have is to try as mentioned above 
    a) Backup /Restore
    Create a new DB to where you want the copy should go and
    Make a Full Backup with .BAK of your original database and Restore the backup on other system and Right click on the the new DB you created and Restore by navigate to your .BAK and make sure MDF and LDF file match the new.
    http://msdn.microsoft.com/en-us/library/ms190436.aspx
    b) Detach/Attach
    Detach the database and copy the database files to other system; and attach these database files.
    I hope this is more informative for you and Good-luck
    Please remember to click “Mark as Answer” on the post that has answered your question as it is very relevant to other community members dealing with same problem in seeking the right answer

  • How do I copy one image onto another image?

    How do I copy one image onto another image?

    Lots of ways;  Use the Place command to place a file in another.  Open two files and drag one to the other's window tab, drag an image from bridge onto an open file.  Open an image, press ctrl/cmd-A to select all, the ctrl/com-C to copy the image, the ctrl/cmd-V to paste it into another image.

  • Wich rights must a user have to copy a table to another user?

    Wich rights must a user have to copy a table to another user? If I try it while using SQLDeveloper I become a message wich says that the user has not enough rights.
    Thanks a lot
    Torsten

    If you are trying to create a table in a schema other than your own, you must have the CREATE ANY TABLE system privilege.

Maybe you are looking for

  • Select which fields to copy of fields during creation of new version

    Hi Gurus- Is it possible to set config in a manner that will copy the authorization group value when creating a new version?  Thanks! -J Edited by: Jennifer Kramer on Mar 14, 2011 6:18 PM

  • How to Install Oracle 10g in Windows 7 Home premium 64bit operating system

    Hi, I am using Windows 7 Home premium 64bit operating system. While i was installing oracle 10g i got error and not able to install. How to install the Oracle 10g databse on this operating system. Is there any patch to install this or i have to use o

  • Cannot Access Dimension Library from Workspace - Hyp 9.3.1

    Dear All, I've got error message when trying to access dimension library from workspace with information : (0)null (org.apache.axis.AxisFault) below is the more detail : Trace: com.hyperion.awb.web.common.BaseService.openSession(BaseService.java:112)

  • Unable to create content area item for RDF-report

    According to white paper "Security tips in Oracle Reports Services (release 6i with Portal 3.0)" I'm trying to integrate an Oracle Reports 6i RDF-module in my portal. All goes well including running the report from de reports definition file. However

  • Can't import using MP3, but AAC works fine

    I have tried importing music using MP3 to no avail. Error correction is off. AAC works great though. Here is my CD diagnostic info. Software is up to date as well as drivers and firmware for DVD drives. Doug Microsoft Windows XP Professional Service