cancel
Showing results for 
Search instead for 
Did you mean: 

sort of type c field

Former Member
0 Kudos

I am making a report for qm module. In report while I sort a field of type c (but having numbers) I face a problem. I describe briefly as this.

The contents of field are like this as

10, 12, 10, 8, 10, 12, 14, 8, 13.

When I sort it ascending it should be

8, 8, 10, 10, 12, 12, 13, 14 like this.

But result is coming 10, 10, 12, 12, 13, 14, 8, 8 as this. I think the problem occurred when it detects only 8 , because when the field kept different contents for different operation it sort correctly.

Here is my code.

Loop at itab.

…..

….

….

SORT COMP_TAB BY FINAL_VAL ASCENDING.

LOOP AT COMP_TAB.

READ TABLE COMP_TAB INDEX 1 INTO MIN.

ENDLOOP.

…..

…..

Clear COMP_TAB.

Refresh COMP_TAB.

Endloop.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member195698
Active Contributor
0 Kudos

Try changing the field from C to N.

Since its a character field and sap takes 1 as a lower number than 8 ... that is why the sorting is coming in that way

if your data is stored as

10, 12, 10, <b>08</b>, 10, 12, 14, <b>08</b>, 13 then i think the sort will be proper.

Former Member
0 Kudos

Hi,

Remove this statement

Refresh COMP_TAB

Why are you reading the same table inside the same table loop?

LOOP AT COMP_TAB.

READ TABLE COMP_TAB INDEX 1 INTO MIN.

ENDLOOP.

Regards,

Satish

Message was edited by:

Satish Panakala