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 Internal table by Color Code

Former Member
0 Kudos

Hi Friends

I need a help in sorting the internal table by color_code.

I have an Internal Table with the field Color_code.

The Color_code Contains HTML Color values, like

1.'#FF0000' - Red

2.'#FFFF00' - Yellow

3.'#008000' - Green

I need to sort the color code by red,yellow than green

*Sort I_PARTS by color_code (red, yellow then green boxes)

Pls let me know how to do this.

Regards

karthik

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

hello,

Take one field sort in itab.

Modify itab like,

itab-sort = 1 where color = '#FF0000'

itab-sort = 2 where color = '#FFFF00'

itab-sort = 3 where color = '#008000'

Sort Itab.

Regards,

Naimesh

3 REPLIES 3

naimesh_patel
Active Contributor
0 Kudos

hello,

Take one field sort in itab.

Modify itab like,

itab-sort = 1 where color = '#FF0000'

itab-sort = 2 where color = '#FFFF00'

itab-sort = 3 where color = '#008000'

Sort Itab.

Regards,

Naimesh

0 Kudos

You will need to use a special sort field here. Have a field in your internal to hold the sequence that you desire.

case itab-color .
when '#FF00000'.
itab-sortseq = 1.
 

when '#FFFF000'.
itab-sortseq = 2.
 

when '#008000'.
itab-sortseq = 3.
 
endcase.

modify itab.

.....

sort itab ascending by sortseq.

Regards,

RIch Heilman

Former Member
0 Kudos

As the color code values will NOT help you SORTING the way you want, have an additional field and assign appropriate values and SORT by that field.

Regards,

Ravi

Note : Please mark the helpful answers