hi,
before rectification I need to highlight the coding performance.
1.use Into table in select Query do not use select ...endselect
2.Try to use For All Entries instead of select inside loop.
3.Use Field Symbol <> to avoid modify of internal Table.