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: 

seperating number -- urgent

Former Member
0 Kudos

hi,

there is a filed lv_var1 which has value '9,999 PC' it can have vlause in this manner also '3,333,333 PC'

so my requirement if to pick up the numbers from the filed ie 9999 in first case and 3333333 in second case ..

how can i do it..?

thnx..

Message was edited by:

neha gupta

7 REPLIES 7

Lakshmant1
Active Contributor
0 Kudos

Hi Neha,

Use SPLIT command or Check demo program DEMO_MOD_TECH_FB_STRING_SPLIT .

Thanks

Lakshman

Former Member
0 Kudos

data : text(40) type c value '152as1an',

num(20),

chr(20),

pos type i,

len type i,

v_ch.

compute len = strlen( text ).

do len times.

v_ch = text+pos(1).

if v_ch ca '0123456789'.

concatenate num v_ch into num.

condense num no-gaps.

else .

concatenate chr v_ch into chr.

condense chr no-gaps.

endif.

pos = pos + 1.

enddo.

write : / num,20 chr.

Former Member
0 Kudos

Hi

U can use search command and find that string and split the text into another field. Then u will remain with only numbers.

Regards

Haritha.

Former Member
0 Kudos

Hi

You can use the belowing code if lv_var1 is a character variable...

replace all occurences of 'pc' in lv_var1 with space .

Former Member
0 Kudos

hi,

first split iv_var1 on space character to value and the rest.

second split value to start and end on comma.

repeat second step until end is blank concatenating end to start.

DATA: i(40),

start(40),

end(40),

value(40),

rest(40),

right(40).

START-OF-SELECTION.

i = '3,333,333,333,333,333 PC'.

SPLIT i AT ' ' INTO value rest.

WRITE:/ 'i =', i.

WRITE:/ 'value =', value.

WRITE:/ 'rest =', rest.

DO.

REPLACE ',' WITH '' INTO value.

IF sy-subrc NE 0.

EXIT.

ENDIF.

SKIP 1.

WRITE:/ 'value =', value.

ENDDO.

CONDENSE value NO-GAPS.

SKIP 1.

WRITE:/ 'value =', value.

WRITE value TO right RIGHT-JUSTIFIED.

WRITE:/ 'right =', right.

Former Member
0 Kudos

hi neha,

use split command to seperate a string.

ex: data: v_var(20) type c,

v_var2(10) type c,

v_var3(2) type c.

v_var = '3,333,333 PC'.

split v_var at space into v_var2 v_var3.

<b><i>Reward points if useful</i></b>

Chandra

Former Member
0 Kudos

len = strlen (lv_var1).

len = len - 2.

lv_var1 = lv_var1+0(len).

now lv_var1 will hav wat u want..

Hope this solves ur doubt

Reward points if useful