Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Sort Internal table based on another internal table

0 Kudos

Hello All,

My Requirement is :

I have two internal tables itab1 and itab2. itab1 has partner_number along with some more fields/columns. Based on the partner_numbers of the itab1 i write a query to get the values for partner_last_name and central_block_flag from the table but000 and i fill these values into a new itab2.

Sort itab2 by partner_last_name and central_block.

Now how do I sort itab1 based on the sorted itab2-partner_number. I need to have itab1 sorted similar to the order in the itab2.

How do i do this?

Please let me know if you need more details.Looking forward for your support.

Regards,

Harish P M

1 ACCEPTED SOLUTION

Sm1tje
Active Contributor
0 Kudos

Beside the fact that this is just not possible, I'm trying to imagine why you would want to do this, but I can't think of anything.

So why this requirement? When sorting itab2 all business partner numbers will be randomly 'sorted' in this itab2 and you can't just randomly sort another internal table (itab1) based on this.

What you can do is create another internal table itab3. Loop at itab2, read line from itab1 and append it to itab3.

2 REPLIES 2

Sm1tje
Active Contributor
0 Kudos

Beside the fact that this is just not possible, I'm trying to imagine why you would want to do this, but I can't think of anything.

So why this requirement? When sorting itab2 all business partner numbers will be randomly 'sorted' in this itab2 and you can't just randomly sort another internal table (itab1) based on this.

What you can do is create another internal table itab3. Loop at itab2, read line from itab1 and append it to itab3.

0 Kudos

Hello Micky,

Thank you for your early reply.

I have this scenario wherein i need to sort a existing internal table itab1 of type 'bapibus1006_relations' based on the 'Partner last name ' and 'Inactive/Active Flag'. These two fields are not available in this itab1 and so i need to create itab2 after a query on table but000.

Sorting itab2 is , first sort itab2 based on the 'Active flag' and then sort this itab2 again by 'Partner last name'(ascending order).

Finally when i get my sorted itab2 i would have to ensure that my objective of sorting itab1 is obtained.

I guess i sound better now.

Would be helpful if you could reply.

Regards,

Harish P M