12-03-2007 12:57 AM
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..
12-03-2007 1:36 AM
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
12-03-2007 1:36 AM
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
12-03-2007 3:58 AM
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
12-03-2007 5:10 AM
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