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: 

Internal table

Former Member
0 Kudos

Hi,

I am having internal table with some values..I

Ex :

No Name age lines

1 arun 12 1

1 arun 12 2

2 ram 13 1

2 ram 13 2

2 ram 13 3

3 manu 14 1

4 kam 17 1

5 chin 16 1

If i want to select the minimum of lines field for Ram..

1 ACCEPTED SOLUTION

amit_khare
Active Contributor
0 Kudos

Try this -

SORT itabt BY NAME LINES.

Read table itab with key Name = ' Ram'.

This will give the firat fiedl with RAM and Lines value minimum as table is sorted in ascending order.

Regards,

Amit

7 REPLIES 7

Former Member
0 Kudos

can u explain clearly what u want say the expected o/p

amit_khare
Active Contributor
0 Kudos

Try this -

SORT itabt BY NAME LINES.

Read table itab with key Name = ' Ram'.

This will give the firat fiedl with RAM and Lines value minimum as table is sorted in ascending order.

Regards,

Amit

ravishankar_reddy2
Active Participant
0 Kudos

Hi Mahesh,

can u please explain it clearly,

regards,

ravi shankar reddy

Former Member
0 Kudos

Hi,

You can achieve that that by using following steps on the internal table...

1) delete table int_tabl where name <> 'ram'

2) short int_tabl by lines ascending

3) read table int_table index 1.

you will get minium lines for ram.

hope this helps.

Rajesh

Former Member
0 Kudos

Hi,

You can try like this:

data : wa like line of itab,

c.

clear c.

loop at itab where Name = 'Ram'.

if sy-tabix = 0.

move corresponding itab to wa.

c = itab-lines.

else.

if itab-lines < c .

move corresponding itab to wa.

c = itab-lines.

endif.

endif.

endloop.

regards,

Himanshu

Former Member
0 Kudos

Hello,

Do like this.


DATA: BEGIN OF ITAB OCCURS 0,
        NO(3),
        NAME(10),
        AGE(3),
        LINE(3),
        END OF ITAB.
ITAB-NO = 1.
ITAB-NAME = 'arun'.
ITAB-AGE = 12.
ITAB-LINE = 1.
APPEND ITAB.

ITAB-NO = 1.
ITAB-NAME = 'arun'.
ITAB-AGE = 12.
ITAB-LINE = 2.
APPEND ITAB.

ITAB-NO = 2.
ITAB-NAME = 'ram'.
ITAB-AGE = 13.
ITAB-LINE = 1.
APPEND ITAB.

ITAB-NO = 2.
ITAB-NAME = 'ram'.
ITAB-AGE = 13.
ITAB-LINE = 2.
APPEND ITAB.

ITAB-NO = 2.
ITAB-NAME = 'ram'.
ITAB-AGE = 13.
ITAB-LINE = 3.
APPEND ITAB.

ITAB-NO = 3.
ITAB-NAME = 'manu'.
ITAB-AGE = 14.
ITAB-LINE = 1.
APPEND ITAB.

SORT ITAB." BY LINE." DESCENDING.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING NO.

LOOP AT ITAB.
  WRITE:/ ITAB-NO,ITAB-NAME,ITAB-AGE,ITAB-LINE.
ENDLOOP.

Vasanth

Former Member
0 Kudos

Thanks