Application Development and Automation 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: 
Read only

Sort table like other table

Former Member
0 Likes
834

Hi,

i have 2 tables itab1 and itab2

and i wont to sort itab1 like itab2 but i dont have the field that i sort by him (NODE_ID ).

there is a way to do it without add field nodid to iatb1 ?

Regards

ITAB 1 
          
                NODE_NAME 
1              10OLDS-1000
2              10HEADQTR
3              10PST
4                10AS
5               10ZY03
6               10VENT

ITAB2
       NODE_ID       NODE_NAME 
1	00000096	  10ZY03
2	00000097	   10AS
3	00000154	  10HEADQTR
4	00000328	  10PST
5	00000684	  10VENT
6	00000712	  10OLDS-1000

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
798

Code ur own logic to sort the table it cud be like

loop at itab2

loop at itab1.

then search for node_name in itab1 when found swap it then it ll come at same position as in itab2.

this is a rough logic if u've understood it u can refine it to get a better performing code.

regards,

kartik

Hi,

i have 2 tables itab1 and itab2

and i wont to sort itab1 like itab2 but i dont have the field that i sort by him (NODE_ID ).

there is a way to do it without add field nodid to iatb1 ?

Regards

ITAB 1 
          
                NODE_NAME 
1              10OLDS-1000
2              10HEADQTR
3              10PST
4                10AS
5               10ZY03
6               10VENT

ITAB2
       NODE_ID       NODE_NAME 
1	00000096	  10ZY03
2	00000097	   10AS
3	00000154	  10HEADQTR
4	00000328	  10PST
5	00000684	  10VENT
6	00000712	  10OLDS-1000

5 REPLIES 5
Read only

Former Member
0 Likes
798

if both the tables consists of the same number of records then Scrap the ITAB1.

what is the need of Another internal table...?

Read only

0 Likes
798

hI Vijay Babu Dudla ,

Thanks but in itab1 i have a lot data (more columns ) i just put the relevant ,

the 2 table have different data i put just the data that is relevant.

Regards

Read only

0 Likes
798

Hi

you can introduce the column node_id in to the itab1 if it is feasible

Else you need to go for the third table to avoid the complex logic...

Read only

Former Member
0 Likes
798

Hi,

Take a new table say itab3 with the two fields node_id and node_name...

You need to fetch the corresponding node_id's to this tab and use this table furter in your program..

Loop at itab1.

Read itab2 where node_name =itab1-node_name.

wa_itab3-node_name = itab1-node_name.

wa_itab3-node_id = itab2-node_id

append wa_itab3 to itab3.

endloop.

Now you can

sort itab3 by node_id.

Thank you

Read only

Former Member
0 Likes
799

Code ur own logic to sort the table it cud be like

loop at itab2

loop at itab1.

then search for node_name in itab1 when found swap it then it ll come at same position as in itab2.

this is a rough logic if u've understood it u can refine it to get a better performing code.

regards,

kartik