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

Logic required

Hi all,

I have the following scenerio.

I have an internal table with data.I have to check each entry in it in the

database table say zsuku with fields either (field1 or field2) and I have to append all related records to it.

Fo ex :

In zsuku it may contain like this:

ZSUKU --->table.

field1 fild2 ---> fields

123 xyz

xyz 456

456 abc

....so on

so for ex in itab if it contains 123 i have to get all related records like xyz,456,abc.

same case if itab contains abc i should get all related records 123,456,xyz like that.

I hope it is clear.

Any help will be appreciated.

Thanks

Sukumar.

Message was edited by:

Sukumar G

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 10:19 PM

    I would suggest you create two tables called parent and child.

    Structure for parent

    Parent , Child.

    Structure for child

    Child, value.

    So for the example you have given the parent table will have the values

    123 xyz

    123 456

    xyz 456

    456 abc

    (Basically listign out all parents directly or indirectly)

    and the child table will have the entries

    123 xyz

    xyz 456

    456 abc

    (Basically listing all childs here)

    Now for the record 123, if you need the related records then you go to the parant table and collect all teh parants which is 123 itself, xyz and 456. For these parants you get the childs which is xyz and 456 as you desired. This is the best and efficient way to do it.

    - Guru

    Reward points for helpful answers

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 10:21 PM

    If record matches, where do you want to append rows? In another internal table? If so, refer below:

    DATA: IT_DATA TYPE ZSUKU OCCURS 0. "New itab

    CHECK NOT ITAB[] IS INITIAL.. "Your itab which contains data

    SELECT FIELD1 FIELD2

    FROM ZSUKU

    INTO TABLE IT_DATA

    FOR ALL ENTRIES IN ITAB

    WHERE FIELD1 EQ ITAB-FIELD1

    OR FIELD2 EQ ITAB-FIELD2.

    Hope this helps.

    Thanks,

    Santosh

    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.