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

Sorting Internal table by Color Code

Former Member
0 Likes
665

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
Read only

naimesh_patel
Active Contributor
0 Likes
544

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
Read only

naimesh_patel
Active Contributor
0 Likes
545

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

Read only

0 Likes
544

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

Read only

Former Member
0 Likes
544

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