Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

grouping records based on a condition...

Hello experts,

I am currently having a problem on how to go about this. What I need to do is to group equipments with their respective subordinates. Just like a parent-child relationship and display that using ALV. Now here is my problem, when I loop through the itab it looks like this:


000000000000002448 |

000000000000900599 |

000000000000000164 | 000000000000000168

000000000000000165 |

000000000000000166 |

000000000000000167 |

000000000000000168 |

Now, if an equipment(equnr) has a value in HEQUI, it means that it is a child equipment of the value found in HEQUI. In my example, equipment 000000000000000164 is a child equipment of equipment 000000000000000168. Now, how can I display this using ALV in a format similar to this:



000000000000000164 000000000000000168

Help would be greatly appreciated as well points being rewarded.Thanks again guys!

Message was edited by: viraylab

Message was edited by: viraylab

Former Member
Former Member replied

create 2 more itabs.

Data: itab1 like itab0, (ur current)

itab2 like itab0.

itab1[] = itab0[]

loop at itab0.

if not itab0-hequi is initial.

read table itab1 with table key itab1-equinr = itab0-hequi.

if sy-subrc = 0.

itab2-equnr = itab1-equnr.

itab2-hequi = itab1-hequi.

append itab2.


itab2-equnr = itab0-equnr.

itab2-hequi = itab0-hequi.

append itab2.


In the end display itab2.

Hope this helps


Dont forget about points.

0 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question