2013 Aug 01 7:44 AM
Hello Gurus,
We are having one custome table and am fetching the values into one itab in that there is alphanumeric field. The values of that field are
AB0002
LO0987
CMR3002345
CMR3007890
CMR3009008
CMR1000901
CMR1000906
from the above values i want to pick the values starting with CMR30 and pass the highest value in that values to variable.
Please light me on this issue.
Thanks and Regards,
Muralikrishna P
Hello Gurus,
We are having one custome table and am fetching the values into one itab in that there is alphanumeric field. The values of that field are
AB0002
LO0987
CMR3002345
CMR3007890
CMR3009008
CMR1000901
CMR1000906
from the above values i want to pick the values starting with CMR30 and pass the highest value in that values to variable.
Please light me on this issue.
Thanks and Regards,
Muralikrishna P
2013 Aug 01 1:41 PM
Hello Murali.
As your itab is having alpha numeric values and you want to pick the values starting with CMR30.
1)Declare itab1 of type itab.
2)Loop itab and check workarea+0(5) = 'CMR30'.3) if yes,move all the values containing CMR30 to itab1.4)And on itab1, do necessary operations as you required.ThanksKatrice2013 Aug 01 1:51 PM
Hi Murali,
you can do this way....
select <fld>
into itab-fld
from <tbnam>
where fld like 'CMR30%'.
sort itab by fld descending.
read itab index 1.
data: var(8) type c.
var = itab-fld+3(7).
Many Thanks / Himanshu Gupta
2013 Aug 01 2:53 PM
Hi Murali,
Here is the answer to your requirement.
Try this code.
types:begin of stru,
field1(12) type c,
field2(20) type c,
end of stru.
data:itab type table of stru ,
itab2 type table of stru ,
wa type stru,
wa1 type stru,
wa3 type stru,
line_no type i.
wa-field1 = 'CMR301234'.
wa-field2 = 'second value'.
append wa to itab.
wa-field1 = 'CMR300034'.
wa-field2 = 'first value'.
append wa to itab.
wa-field1 = 'CMR303234'.
wa-field2 = 'third value'.
append wa to itab.
wa-field1 = 'CMP300034'.
wa-field2 = 'first value'.
append wa to itab.
sort itab.
loop at itab into wa1 WHERE field1+0(5) = 'CMR30'.
append wa1 to itab2.
endloop.
sort itab2 BY field1 ASCENDING.
describe table itab2 LINES line_no.
read table itab2 into wa3 index line_no.
write:wa3-field1.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |