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

SEPARATING STING AND NUMERIC

Former Member
0 Likes
847

HI ALL,

I HAVE AN STATEMENT LIKE THIS "12.5% VAT TAX OR VAT IS 12.5%'

I WANT THIS 12.5 ALONE TO FILTERED FROM THE TEXT AND DISPLAY IT.

PLEASE HELP ME .

THANKS IN ADVANCE.

POINTS WILL REWARDED.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
817

hi,

this code will solve your problem:

data len type i.

data itab type table of string with header line.

data: zstr type string value 'the tax is 4% of total amount',

zstr1 type string,zstr2 type string.

data int type i.

split zstr at space into table itab.

loop at itab.

if itab CO '0123456789%'.

zstr1 = itab.

replace '%' with ' ' into zstr1.

endif.

endloop.

write zstr1.

here the output is 4.

do reward points if it helps.rgds

Message was edited by:

abaper s

9 REPLIES 9
Read only

former_member188827
Active Contributor
0 Likes
817

use split statement...

str = '12.5%'

split str at '%' into str1 str2.

str1 'll contain 12.5

Read only

0 Likes
817

but it can be any where say 4% in the middle or starting or at the last of the statement.

Read only

Former Member
0 Likes
817

Hi,

write like this.

data:str(40) value '12.5% VAT TAX'.

data:num(5) type n.

num = str.

write:/ num.

<b>reward if helpful</b>

rgds,

bharat.

Read only

0 Likes
817

i have given you an example '12.5% vat' or vat 12.5%' .it can be like this also 'vat 4% of total'

Read only

0 Likes
817

u can also use da following:

replace '%' in str with space.

Read only

0 Likes
817

HI,

it will like that only.

see my previous post.

rgds,

bharat.

Read only

0 Likes
817

BELOW ARE THE EXAMPLES OF THE STATEMANTS.

FROM THE BELOW STATEMANTS I WANT ONLY THE NUMERIC VALUES

Zero% output tax

16% eED + 2% ECESS + 4%VAT

4%

16% eED + 2% ECESS + 4%VAT

16% ED + 2% ECESS

10% LST - No Excise

Test Taxcode - Sandeep

16% ED + 2% ECESS + 12.5% CST

16% ED + 2% ECESS + 12.5% CST

16% ED + 2% ECESS + 4% CST

'Test Taxcode - Sandeep

Zero % input tax assets

Zero% output tax --assets

Zero % input tax

16% bed

4% CST

Input ED 16% and Cess for Depot

input tax 16% bed

Excise16 %, Ecess 2 %,AED 4%

12.5 % VAT DEDUCT

12.5 % VAT'

Read only

Former Member
0 Likes
818

hi,

this code will solve your problem:

data len type i.

data itab type table of string with header line.

data: zstr type string value 'the tax is 4% of total amount',

zstr1 type string,zstr2 type string.

data int type i.

split zstr at space into table itab.

loop at itab.

if itab CO '0123456789%'.

zstr1 = itab.

replace '%' with ' ' into zstr1.

endif.

endloop.

write zstr1.

here the output is 4.

do reward points if it helps.rgds

Message was edited by:

abaper s

Read only

hongyan_shao
Product and Topic Expert
Product and Topic Expert
0 Likes
817

Very good thread for programming learning.

Just think that maybe the sentence

if itab CO '0123456789%'.

should be

if itab CO '0123456789%.'.

which would be better to consider the decimal point also.