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

sort it_table

Former Member
0 Likes
812

i have table itab

lgort matnr count

10 2 5

10 3 7

10 6 8

20 1 4

20 2 6

20 3 1

i want to get:

the low and high count acording <b>lgort-matnr</b> the low and high count acording <b>matnr</b>

how i made it ?

9 REPLIES 9
Read only

ferry_lianto
Active Contributor
0 Likes
776

Hi Liat,

You can code something like this.


SORT ITAB BY LGORT ASCENDING
             MANTR ASCENDING.

For more information, please chcek this link.

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3800358411d1829f0000e829fbfe/content.htm

Hope this will help.

Regards,

Ferry Lianto

Read only

0 Likes
776

thank ferry.

i did not find how i can make select by matnr for min or max

Read only

Former Member
0 Likes
776

In your example can you tell what you want to achieve?

Read only

0 Likes
776

the <b>min</b> and the <b>max</b> count of matnr in lgort

Read only

0 Likes
776

once in lgort and once not only the matnr and his count min and max

Read only

0 Likes
776

So what will be the answer for your example?

Read only

0 Likes
776

give me only 1 answer

how you cna tell me the min and max count per matnr

just it PLS

Read only

0 Likes
776

Hi,

SORT ITAB by LGORT ASCENDING MATNR ASCENDING.

LOOP AT ITAB.

AT NEW LGORT.

WRITE 😕 ITAB-LGORT, ITAB-MATNR.

ENDAT.

AT END OF LGORT.

WRITE 😕 ITAB-LGORT, ITAB-MATNR.

ENDAT.

ENDLOOP.

This should give you the output of

lgort matnr

10 6 8

10 2 5

20 3 1

20 1 4

Regards,

Ravi

Note :Please mark the helpful answers

Read only

former_member186741
Active Contributor
0 Likes
776

Hi Liat,

I think you would have got better and quicker answers if you had laid out your question better. It's not exactly clear what you want. People are unsure if you mean max and min of matnr within lgort or something else. When they asked for more details they really wanted you to give your exact expected results for your example.

I'm assuming you mean max/min count at matnr regardless of lgort. If this is correct you want an answer of:

Matnr Min Max

1 4 4

2 5 6

3 1 7

6 8 8

Try this:

data itab2 like itab.

field-symbols <entry> like line of itab.

itab2[] = itab[].

loop at itab2 assigning <entry>.

clear <entry>-lgort.

endloop.

sort itab2 by matnr count.

loop at itab2 assigning <entry>.

at new matnr.

write:/ 'min',<entry>-matnr,<entry>-count.

endat.

at end of matnr.

write:/ 'max',<entry>-matnr,<entry>-count.

endat.

endloop.