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: 

String Processing

Murali_Shanmu
Active Contributor
0 Kudos

Hi

I have a string which starts with a number and ends with some other Unit of Measurement. Now i am not sure what are all the possible UOM symbols that may appear in the string. Can anyone suggest me a method to remove the UOM and just obtain the number alone.

Good answers would definetly be rewarded.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Muralidaran,

1 Assumption :

The string is like

562323 MTR

ie. there is atleast one space between number and uom.

2 Use abap statement SPLIT.

3 Sample program (just copy paste)

REPORT ac.

*----


DATA : str(50) TYPE c.

DATA : BEGIN OF itab OCCURS 0,

f1(10) TYPE c,

END OF itab.

str = '234234 MTR'.

SPLIT str AT ' ' INTO TABLE itab.

read table itab index 1.

write itab-f1.

Hope the above helps.

Regards,

Amit M.

4 REPLIES 4

Former Member
0 Kudos

Hi Muralidaran,

1 Assumption :

The string is like

562323 MTR

ie. there is atleast one space between number and uom.

2 Use abap statement SPLIT.

3 Sample program (just copy paste)

REPORT ac.

*----


DATA : str(50) TYPE c.

DATA : BEGIN OF itab OCCURS 0,

f1(10) TYPE c,

END OF itab.

str = '234234 MTR'.

SPLIT str AT ' ' INTO TABLE itab.

read table itab index 1.

write itab-f1.

Hope the above helps.

Regards,

Amit M.

Former Member
0 Kudos

Murali,

You need to have some kind of delimiter to do this, it could be space or something else. Other options is to have fixed length either from the begining or from back of the string.

Regards,

Ravi

Former Member
0 Kudos

Muralidaran,

I think SPLIT is a better option.

Regards,

Amey

Former Member
0 Kudos

Hi,

SPLIT cannot serve the purpose as there is no delimiter between quantity and UOM. I am giving you the sample code for this. It definitely works.

d_int = 0.

while d_int >= 0 .

if textl+d_int(1) ca 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.

fdpos = d_int.

exit.

else.

d_int = d_int + 1.

continue.

endif.

endwhile.

lentextl = strlen( textl ).

xqty = textl+0(fdpos).

lenxqty = strlen( xqty ).

aunitlen = lentextl - lenxqty.

aunit = textl+fdpos(aunitlen).

Here :

If for eg:

textl = 250kg

then xqty = 250

and aunit = kg.

Regards

Lakshmi.S