07-12-2006 6:12 PM
Hi,
I have few values in SGTXT field in BSIS.
Ex :
1) 123456 Some Description.
2) Some Text 678343.
In this I need to store only numeric values into a variable.
Like in 1st case it is started with numeric and some text
and second it is started with some text and then numeric.
I need the variable should have only the first six numberic characters only. Ex. First case.
I need to check whether the first six are numeric or not, if it is numeric store it in variable otherwise leave blank.
Can u please let me know any methos or function module or anyother code to do it?
Thanks,
Pavan.
Message was edited by: Pavan Panduru
07-12-2006 6:17 PM
Will it always be 6 numerics? Will there always be a space in between? Assuming these assumptions are true, you can do something like this.
report zrich_0001.
data: begin of itab occurs 0,
sgtxt type bsis-sgtxt,
end of itab.
data: begin of itab2 occurs 0,
value(10) type c,
end of itab2.
data: isplit type table of string with header line.
itab-sgtxt = '123456 Some Description'. append itab.
itab-sgtxt = 'Some Text 678343'. append itab.
loop at itab.
split itab at ' ' into table isplit.
loop at isplit.
if isplit co '1234567890'.
exit.
endif.
endloop.
itab2-value = isplit.
append itab2.
endloop.
loop at itab2.
write:/ itab2-value.
endloop.
Regards,
Rich Heilman
07-12-2006 6:17 PM
Will it always be 6 numerics? Will there always be a space in between? Assuming these assumptions are true, you can do something like this.
report zrich_0001.
data: begin of itab occurs 0,
sgtxt type bsis-sgtxt,
end of itab.
data: begin of itab2 occurs 0,
value(10) type c,
end of itab2.
data: isplit type table of string with header line.
itab-sgtxt = '123456 Some Description'. append itab.
itab-sgtxt = 'Some Text 678343'. append itab.
loop at itab.
split itab at ' ' into table isplit.
loop at isplit.
if isplit co '1234567890'.
exit.
endif.
endloop.
itab2-value = isplit.
append itab2.
endloop.
loop at itab2.
write:/ itab2-value.
endloop.
Regards,
Rich Heilman
07-12-2006 6:18 PM
translate v_sgtxt using 'A B C D E F G H I ..Z a b c d e f g.. z '.
condense v_sgtxt.
now sgtxt will only have the numeric part of the text.
Regards,
ravi
07-12-2006 6:21 PM
Hi,
Check this :
data x_text(100) type c,
x_text_1(100) type c,
x_pattern(10) type c,
x_val(6) type n.
x_text_1 = x_text+0(5).
x_pattern = '0123456789'.
if x_text_1 CA x_pattern
move x_text_1 to x_val.
else.
clear : x_val.
endif.
Regards
Appana
07-12-2006 6:33 PM
hi
if txt = 123456 Some Description
req = txt + 0(6).
if req co '0123456789'.
---
endif.
07-12-2006 6:52 PM
test = '12345abcde'.
TRANSLATE test TO UPPER CASE.
MOVE test TO test2.
strl1 = STRLEN( test ).
SHIFT test LEFT DELETING LEADING '0123456789'.
strl2 = STRLEN( test ).
res = strl1 - strl2.
IF strl1 = strl2.
SHIFT test LEFT DELETING LEADING sy-abcde.
ELSE.
MOVE test2(res) TO test.
ENDIF.
WRITE test.
Regards, Felipe Cunha.