2005 Nov 26 5:41 AM
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.
2005 Nov 26 5:50 AM
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.
2005 Nov 26 5:50 AM
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.
2005 Nov 26 5:53 AM
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
2005 Nov 26 6:38 AM
Muralidaran,
I think SPLIT is a better option.
Regards,
Amey
2005 Nov 26 7:03 AM
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