Skip to Content
author's profile photo Former Member
Former Member

Parent child relationship in ABAP tables

Hello experts,

I have created a table as

Next what i want to do is

Now its like:

  • ProductA
  • ProductB
  • ProductC

But it needs to be

  • Product_1
    • Child A
    • Child B
  • Product_2

How it can be done? If anybody have any idea please share it with me.

Thanks,

Avadhut

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Feb 11, 2014 at 12:06 PM

    Hi Avadhut Mulay,

    If you want parent and child relationship then you should refer Tree concept.

    For Ex:

    Output will be

    E001 - Manager 1

    E002 - Employee1

    E003 - Employee2

    E004 - Manager2

    E005 - Employee3.

    Thanks and Regards,

    Ragavendra BR


    DB.png (3.2 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 11, 2014 at 12:30 PM

    Have one more field for parent in your table and maintain this value for child nodes

    Nabheet

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 11, 2014 at 11:53 AM

    Hi Avadhut,

    If you are thinking of using two tables and relating them with parent-child approach then with the help of foreign keys you can achieve it. It's called header and item table in ABAP terms ie,

    it has one to many relationship,

    for examples check out these combination of parent child tables,VBAK (header) VBAP(item) or EKKO & EKPO table

    If you are thinking of only one table then you can make a field of the table to be of type table so that it can hold further values in it.

    to explain further tables have fields and usually we mark these fields to type some data element like in you case

    MANDT type SY-MANDT

    PRODUCT type PRODUCT_TABLE

    Where PRODUCT is a field in table which is of type table of PRODUCT_TABLE.

    Hope this helps!

    Happy Coding,

    Santhosh Yadav


    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 11, 2014 at 11:40 AM

    you can take a concept of ekko-ekpo table.

    you can treat purchase document number as product (ekko)

    and items as childs (ekpo)

    -Avirat

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 11, 2014 at 12:41 PM

    Hi ,

    you can create the View.

    For this you have to create the 2 tables. One is for parent and another one is for child.

    in the View you can join the 2 tables in the Table/Join Condition tab.

    and in the VIew Fields tab you can select the Field to view.

    Thanks,

    Dhina..

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.