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

Facing sorting probleam in my program

Former Member
0 Likes
1,021

Hi,

I am sorting a int. table gt_marm like this in my program

SORT gt_marm BY meinh DESCENDING.

SORT gt_marm BY meinh AS TEXT .

SORT gt_marm BY umrez .

After sorting i am getting like this

000000000000001006|LAB | 1 | 1 |

000000000000001006|PC | 1 | 1 |

00000000000001006|021 | 11 | 1

My probleam is I want PC (2nd row as always in as first record) but here it is occuping as 2nd record.

CAN somebody help me how to do it? or how to interchange the position of first row as second row and second row as first row.

Please i am in trouble...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
911

Assign as sort sequence as a numeric field in your internal table....increment the value as your process the screen content...sort by that value ascending...then you will see the data as it came from the screen.

8 REPLIES 8
Read only

Former Member
0 Likes
911

Write all 3 sorts under one sort statement. Read help on Sort

Read only

0 Likes
911

Hi,

In mm02 screen the values populated this order.So i want exactly the same order in my int. table also

Whatever sorting i maintaned its working some extent and the order is in my int. table

MM02 scree:::::::::::::::

1 PC Piece <=> 1

1 020 1.4980 Roh <=> 1

1 LAB Label Qty <=> 1

1 021 1.4401 <=> 11

1 BOX Box <=> 11

1 110 1.4370 <=> 15

1 029 1.4404 T <=> 34

1 097 1.4405 T <=> 34

1 003 HOUR <=> 70

int, table after sorting

1 000000000000001006|020 | 1 | 1 |

2 000000000000001006|LAB | 1 | 1 |

3 000000000000001006|PC | 1 | 1 |

4 000000000000001006|021 | 11 | 1 |

000000000000001006|BOX | 11 | 1 |

000000000000001006|110 | 15 | 1 |

000000000000001006|029 | 34 | 1 |

000000000000001006|097 | 34 | 1 |

000000000000001006 |003

That mens PC 020 LAB only changing the wrong order...

Please help me.

Read only

Former Member
0 Likes
911

Hi,

Use this logic.

SORT gt_marm BY meinh TEXT umrez descending.

Regards,

Preetham

Read only

Former Member
0 Likes
912

Assign as sort sequence as a numeric field in your internal table....increment the value as your process the screen content...sort by that value ascending...then you will see the data as it came from the screen.

Read only

0 Likes
911

Hi,

Thanks

can u explain little bit more.

I did like this ..

SORT gt_marm BY meinh DESCENDING.

SORT gt_marm BY meinh AS TEXT .

SORT gt_marm BY umrez .

How to do??

Read only

0 Likes
911

Hi..

The way this sort is written, the table will first be sort in the following steps:

1. MEINH in descending order.

2. Sorting again in MEINH as text.

3. Then again on UMREZ ascending.

So in the process, the initial sorting is lost.

So you need to decide which should be the important key for sorting, so it can be written as:

SORT gt_marm BY meinh AS TEXT DESCENDING umrez.

Regards,

Karthik

Read only

0 Likes
911
SORT gt_marm BY meinh DESCENDING.

SORT gt_marm BY meinh AS TEXT .
SORT gt_marm BY umrez .

Wouldn't you want that last statement to be a SORT....STABLE....to retain the original row order before rearranging by UMREZ?

Read only

Former Member
0 Likes
911

SORT gt_marm BY meinh DESCENDING.

you will get PC (2nd row as always in as first record)

zashok