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: 

Help..

Former Member
0 Kudos

Masters!!

I have two fields in one internal table..namely field1 and field2..each field has a corresponding value..my problem is I want to get their last value..example:

field1

1

2

3

field2

1

2

3

4

since field1 has its last value of 3 and field2 has its value of 4..

I need to get those value..

field1 = 3 and field2 = 4.

Could you help me to compose my logic and my coding..please help me..

1 ACCEPTED SOLUTION

Former Member
0 Kudos

There are many ways to do this, but you can try:


SORT itab BY field1 DESCENDING.
READ TABLE itab index 1.                      "Last value of field1.

SORT itab BY field2 DESCENDING.
READ TABLE itab index 1.                     "Last value of field2.

Rob

Message was edited by:

Rob Burbank

3 REPLIES 3

Former Member
0 Kudos

There are many ways to do this, but you can try:


SORT itab BY field1 DESCENDING.
READ TABLE itab index 1.                      "Last value of field1.

SORT itab BY field2 DESCENDING.
READ TABLE itab index 1.                     "Last value of field2.

Rob

Message was edited by:

Rob Burbank

Former Member
0 Kudos

Hi Salma,

I want o ask one thing in this .

Suppose

field1

1

3

2

field1

2

3

1

If this is the case then you want 2 in field1 and 1 in field 2.

If it is not the case , Then you just sort these two fields in decending order and get the topmost value.

here is the code:-

sort itab1 by field1 descending.

move: itab1-field1 to wa_field1.

sort itab2 by field2 descending.

move: itab2-field2 to wa_field2.

Now use these variables for your further logic.

Thanks & Regards,

Mamta

Former Member
0 Kudos

Hi Salma..

suppose you want the perticular value you can go for the below code:

SORT itab BY field1 DESCENDING.

READ TABLE itab where field1 eq 3 .

SORT itab BY field2 DESCENDING.

READ TABLE itab where field2 eq 4.

otherwise if want only the last values,then as others told,you can code in your program.

reward if helpful.

Thanks