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

Fetching alpha numeric values and display highest value among them

former_member267445
Participant
0 Likes
810

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

3 REPLIES 3
Read only

Former Member
0 Likes
725

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.
Thanks
Katrice
Read only

himanshu_gupta13
Product and Topic Expert
Product and Topic Expert
0 Likes
725

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


Read only

Former Member
0 Likes
725

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.