‎2007 Jan 09 10:07 PM
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
‎2007 Jan 09 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
‎2007 Jan 09 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