‎2010 Dec 28 2:23 PM
HI ALL ,
assume i have field like 99.999.99 or fields like 99,99 or fileds
like 99.99,99 or 99,99.99 ,how can i know that the fields
are with symbols (, or .) and separate between them and filed like 9999 that
dont have any symbol on it .
I try with FIND REGEX `(.)(,)` IN lv_val. but
it dont fetch fiels like 99.999.99 .
Regards
Alex
‎2010 Dec 29 6:53 AM
Is this what you are looking for ?
REPORT z_test LINE-SIZE 255.
DATA: num(30) VALUE '999.999.999,999'.
DATA: v_strlen TYPE i,
v_index TYPE i VALUE 0,
v_temp TYPE c VALUE '',
output TYPE string VALUE ''.
v_strlen = STRLEN( num ).
DO v_strlen TIMES.
CASE num+v_index(1).
WHEN '1'. v_temp = 'X'.
WHEN '2'. v_temp = 'X'.
WHEN '3'. v_temp = 'X'.
WHEN '4'. v_temp = 'X'.
WHEN '5'. v_temp = 'X'.
WHEN '6'. v_temp = 'X'.
WHEN '7'. v_temp = 'X'.
WHEN '8'. v_temp = 'X'.
WHEN '9'. v_temp = 'X'.
WHEN '0'. v_temp = 'X'.
WHEN OTHERS.
IF v_temp = 'X'.
CONCATENATE output '-' INTO output.
CLEAR v_temp.
ENDIF.
CONCATENATE output num+v_index(1) INTO output.
ENDCASE.
v_index = v_index + 1.
ENDDO.
WRITE : / output.
‎2010 Dec 28 2:28 PM
‎2010 Dec 28 2:32 PM
You can use Replace all occurances with space and then condense.
Thanks,
Anmol.
‎2010 Dec 28 2:47 PM
‎2010 Dec 28 2:32 PM
Hi,
If its always numeric then you can go like this. Seperate the string where non numeric characters are found. In your case comma and dot are always non numeric. Also could you please explain it bit more clear. Is your requirement to find if there is a separator or what is the separator ?
‎2010 Dec 28 2:45 PM
HI Keshav ,
The fields can come as dec or quan
and i need to know if the field contain the follwing template .
(.-.) 99.99.99
(,-,) 99,99,99
(,-.) 99,99.99
(.-,) 99.99,99
(,-,-.) 99,99,99.00
(.-.-,) 99.99.99,00
what is the best way to do that ?
Regards
Alex
‎2010 Dec 28 2:48 PM
OK then put the value into a string and check if
w_string CP '999999*'
‎2010 Dec 28 3:10 PM
HI François Henrotte
The string can be diffrent now it 999.999 and it can be also any nubmer like 11,11 etc
i need to find if tstring lv_val contain the following patterns
(.-.) 99.99.99
(,-,) 99,99,99
(,-.) 99,99.99
(.-,) 99.99,99
(,-,-.) 99,99,99.00
(.-.-,) 99.99.99,00Regards
Alex
‎2010 Dec 28 3:19 PM
I am not sure whenthere this is what you meant
data:str type string.
data:temp type string.
str = '99,99,99.00'.
replace all occurrences of regex '[:\d:]' in str with ` `.
replace all occurrences of ` ` in str with '-'.
condense str.
write str.
or spli it into internal table then concatenate the symbols with -.
‎2010 Dec 28 3:27 PM
Hi Alex,
Please try inputting single validations for the REGEX. Instead of checking for "," & '.' at the same time, take a multi step approach. Use IF conditions; like if the the field does not have commas then check if it has dots. Also, if you can use constants in your code, you can make good enough use of the syntax. Declare constants for the values "," & "." .
Example:
CONSTANTS: C_COMMA TYPE C VALUE ',' ,
C_DOT TYPE C VALUE '.' .
DATA: result_tab TYPE match_result_tab.
Use the constants in the code as shown below.
FIND ALL OCCURRENCES OF REGEX C_COMMA IN "FIELDNAME" RESULTS result_tab.
FIND ALL OCCURRENCES OF REGEX C_COMMA IN "FIELDNAME" RESULTS result_tab.Please try as aforesaid and post back if you need help.
Best Regards,
Chaitanya
Edited by: cn chaitanya on Dec 28, 2010 8:58 PM
‎2010 Dec 29 5:47 AM
if you're looking for patterns, you could try something like this:
parameters: lv_val type string.
if lv_val CP '*.*.*'.
if lv_val CP '*.*.*,*'.
write /: `Contains pattern '*.*.*,*'`.
else.
write /: `Contains pattern '*.*.*'`.
endif.
ELSEIF lv_val CP '*.*,*'.
write /: `Contains pattern '*.*,*'`.
endif.
if lv_val CP '*,*,*'.
if lv_val CP '*,*,*.*'.
write /: `Contains pattern '*,*,*.*'`.
else.
write /: `Contains pattern '*,*,*'`.
endif.
ELSEIF lv_val CP '*,*.*'.
write /: `Contains pattern '*,*.*'`.
endif.
‎2010 Dec 29 6:21 AM
Hi,
You can do like this way.
data: w1(10) value '99,999.99',
w2(10) value '9999',
s(2) value '.,'.
if w1 ca s .
write 'found'.
else.
write: 'not found'.
endif.
‎2010 Dec 28 2:49 PM
You need not go for any regex pattern for this. This is determined by the decimal notation in user profile.
You can get it from table USR01, field DCPFM passing the username to field BNAME.
Possible values are X,Y , SPACE.
If its blank then thousand separator is dot and decimal separator is comma
if its X then thousand separator is comma and decimal separator is dot
‎2010 Dec 28 3:00 PM
HI Keshav.T
Yes i know how to do it like that but i need to do it with coding
assume the field value is type string and i want to find if it contain one of the pattern in my previos post
Thanks
Alex
‎2010 Dec 28 3:02 PM
What do you mean by coding ?
Is it like the string might comtain the pattern opposite to the values maintained in the user profile ?
‎2010 Dec 29 6:53 AM
Is this what you are looking for ?
REPORT z_test LINE-SIZE 255.
DATA: num(30) VALUE '999.999.999,999'.
DATA: v_strlen TYPE i,
v_index TYPE i VALUE 0,
v_temp TYPE c VALUE '',
output TYPE string VALUE ''.
v_strlen = STRLEN( num ).
DO v_strlen TIMES.
CASE num+v_index(1).
WHEN '1'. v_temp = 'X'.
WHEN '2'. v_temp = 'X'.
WHEN '3'. v_temp = 'X'.
WHEN '4'. v_temp = 'X'.
WHEN '5'. v_temp = 'X'.
WHEN '6'. v_temp = 'X'.
WHEN '7'. v_temp = 'X'.
WHEN '8'. v_temp = 'X'.
WHEN '9'. v_temp = 'X'.
WHEN '0'. v_temp = 'X'.
WHEN OTHERS.
IF v_temp = 'X'.
CONCATENATE output '-' INTO output.
CLEAR v_temp.
ENDIF.
CONCATENATE output num+v_index(1) INTO output.
ENDCASE.
v_index = v_index + 1.
ENDDO.
WRITE : / output.
‎2010 Dec 29 8:07 AM
You can use the SEARCH
Constants : c_minus(1) type c value '-'.
Eg:- SEARCH text FOR c_minus