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: 

sorting techinque without using sort statement /Comparing table fields.

rejish_balakrishnan
Contributor
0 Kudos

Hi,

How to achieve sorting techinque without using sort statement in tables.

Also how to compare fields of 2 custom tables and check their compatability without using code ?

3 REPLIES 3

rejish_balakrishnan
Contributor
0 Kudos

self answered

Former Member
0 Kudos

Hi,

Can you tell me any of these sorting techniqes..

I am stuk up at one point with sort statment with internal table.

-Maharshi

0 Kudos

Hi,

Refer the below program, it will be helpful.

types: begin of t_int,
         int type i,
        end of t_int.
data: it_int type standard table of t_int,
       wa_int type t_int,
       wa_int1 type t_int.

wa_int-int = 70.
append wa_int to it_int.
clear wa_int.


wa_int-int = 50.
append wa_int to it_int.
clear wa_int.


wa_int-int = 20.
append wa_int to it_int.
clear wa_int.

wa_int-int = 30.
append wa_int to it_int.
clear wa_int.

wa_int-int = 23.
append wa_int to it_int.
clear wa_int.

wa_int-int = 23.
append wa_int to it_int.
clear wa_int.

wa_int-int = 32.
append wa_int to it_int.
clear wa_int.

wa_int-int = 77.
append wa_int to it_int.
clear wa_int.

wa_int-int = 99.
append wa_int to it_int.
clear wa_int.

wa_int-int = 1.
append wa_int to it_int.
clear wa_int.

wa_int-int = 11.
append wa_int to it_int.
clear wa_int.

wa_int-int = 90.
append wa_int to it_int.
clear wa_int.

wa_int-int = 40.
append wa_int to it_int.
clear wa_int.

data: wk_line type i.
data: cnt type i.
data: cnt1 type i.

describe table it_int lines wk_line.
clear: cnt,cnt1.

data wk_flag type c.
   clear wk_flag.
while wk_line gt cnt1.
   cnt = cnt + 1.
   read table it_int into wa_int index cnt.
   cnt1 = cnt + 1.
   read table it_int into wa_int1 index cnt1.

   if wa_int-int lt wa_int1-int.
     modify it_int from wa_int index cnt1.
     modify it_int from wa_int1 index cnt.
     wk_flag = 'X'.
   endif.
   if cnt1 eq wk_line.
     clear: cnt, cnt1.
     if wk_flag eq 'X'.
     clear wk_flag.
     continue.
     else.
       exit.
     endif.
   endif.
endwhile.

loop at it_int into wa_int.
   write: / wa_int-int.
endloop.