04-09-2009 9:36 AM
Hi,
I have a requirement where i need to delete all the characters up to teh first numeric value.
Ex: "POBOX123A" is the requirement and it shuld retain "123A".
Please do the need ful
Thanks,
Shiva shekar
04-09-2009 9:44 AM
Data: w_char(20) value 'POBOX123A'.
DO.
if w_char+0(1) co '0123456789'.
exit.
elseif w_char+0(1) is initial.
Exit.
else.
w_char = w_char+1.
ENDIF.
ENDDO.
write : w_char.
These codes works.
regards,
gurpreet
Edited by: Gurpreet Singh on Apr 9, 2009 11:05 AM
04-09-2009 10:01 AM
Hi Shiva,
Here is the code for your requirement:
DATA: w_char(20) VALUE 'POBOX123A',
w_num(1) TYPE c,
count TYPE i,
len TYPE i,
w_out TYPE dd01v-datatype.
count = 0.
DO.
w_num = w_char+count(1).
CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
string_in = w_num
IMPORTING
STRING_OUT =
htype = w_out
.
len = STRLEN( w_char ).
IF w_out = 'NUMC'.
len = len - count.
w_char = w_char+count(len).
EXIT.
ENDIF.
count = count + 1.
ENDDO.
WRITE w_char.
Regards,
Nitin.
04-09-2009 10:02 AM
hi,
calculate the length of the string first.
v_val = 'POBOX123A'.
v_length = strlen(v_val).
v_next = 0.
v_last = v_next + 1.
do v_length times.
if v_val+v_next(v_last) CA 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
**delete it from v_val.
else.
exit.
endif.
v_next = v_next + 1.
v_last = v_last + 1.
enddo.
v_val will hve the new value now.
04-09-2009 10:03 AM
Try this code.
REPORT ztest.
DATA: s(20) TYPE c VALUE 'POBOX123A',
l TYPE i,
i TYPE i VALUE 0,
ch TYPE c,
ch1(20) TYPE c.
l = STRLEN( s ).
DO l TIMES.
ch = s+i(1).
IF ch NA '1234567890'.
i = i + 1.
IF sy-index = l.
CONCATENATE ch1 ch INTO ch1.
ELSE.
CONTINUE.
ENDIF.
ELSE.
i = i + 1.
CONCATENATE ch1 ch INTO ch1.
ENDIF.
ENDDO.
04-09-2009 10:07 AM
Just check these codes are tested and working.
Data: w_char(20) value 'POBOX123A'.
DO.
if w_char+0(1) co '0123456789'.
exit.
elseif w_char+0(1) is initial.
Exit.
else.
w_char = w_char+1.
ENDIF.
ENDDO.
write : w_char.
OR.
USE:
Data: w_char(20) value 'POBOX123A'.
if w_char cN sy-abcde.
write :sy-fdpos.
w_char = w_char+sy-fdpos.
ENDIF.
write : w_char.
Regards,
Gurpreet
04-09-2009 10:28 AM
Hey,
Please look at following code
data: l(20) VALUE 'POBOX123A',
len type i.
len = strlen( l ).
do.
if sy-index = len.
exit.
endif.
if l+0(1) cn '0123456789' .
shift l LEFT .
else.
exit.
endif.
enddo.
write: l.
-RJ