2009 Feb 05 4:27 PM
Hi All,
I have a string with the following values:
B1;;2009/11 Claim: 007324;SA;20081006;20091101;I004;;1032000MAR;;750;31;500481;Michael O`Leary
I want to find the 'i001' with in this string.I can't hard find this value becuase it will come from file.It does contain any value other than this with in that postion.
I want to find it through Find Rgex.
Can anybody please help.
2009 Feb 05 4:41 PM
Hi,
Do as below,
p = 'B1;;2009/11 Claim:i001:uuiiooiji001'.
FIND 'i001' IN p.
IF sy-subrc = 0.
your code
ENDIF.What exactly you wan to do if it is found that value?
Regards
Bala Krishna
2009 Feb 05 4:53 PM
Try something like this way
data: v_str type string ,
t_result type match_result_tab ,
wa_result like line of t_result,
lt_result type match_result_tab.
v_str = 'B1;;2009/11 Claim: 007324;SA;20081006;20091101;I004;;1032000MAR;;750;31;500481;Michael O`Leary
'.
data matcher type ref to cl_abap_matcher.
matcher = cl_abap_matcher=>create(
pattern = `^.* (i001) .*$`
ignore_case = 'X'
text = v_str ).
lt_result = matcher->find_all( ).
a®
2009 Feb 05 5:07 PM
Check this:
DATA:
w_string TYPE string VALUE 'B1;;2009/11 Claim: 007324;SA;20081006;20091101;I004;;1032000MAR;;750;31;500481;Michael O`Leary',
w_sub_string(4) TYPE c VALUE 'I004',
w_lenght1 TYPE i,
w_lenght2 TYPE i,
w_offset TYPE i,
w_result TYPE string.
w_lenght1 = STRLEN( w_string ).
w_lenght2 = STRLEN( w_sub_string ).
IF w_string CS w_sub_string.
w_offset = sy-fdpos.
w_result = w_string+w_offset(w_lenght2).
WRITE: w_result.
ENDIF.
2009 Feb 06 5:12 AM
hi tarangini,
chk if this helps...
data:
w_str1 type string value 'B1;;2009/11Claim:007324;SA;20081006;20091101;I004;;1032000MAR;;750;31;500481;Michael O`Leary ',
w_str2 type string value 'I004'.
search w_str1 for w_str2.
if sy-subrc = 0.
write: sy-fdpos. " position of w_str2 in w_str1.
endif.
Regards,
Mdi Deeba Najam
2009 Feb 06 5:24 AM
Hi,
Take 'i004' into one character variable.
Take the string into a string variable .
search string for 'i004' .
if sy-subrc eq 0.
write 😕 'Found ',sy-fdpos.---> position of the string
endif.
Else use abbreviated option with the above search
search string for 'i4' abbreviated .
This searches for i4 where ever it is in the string
2009 Feb 06 6:27 AM
Hi,
Hope may be helpful,
data:
w_string type string,
w_char(10) type c.
w_string = 'B1;;2009/11 Claim:007324;SA;20081006;20091101;I004;;1032000MAR;;750;31;500481;Michael O`Leary '.
w_char = 'i001'.
search w_string for w_char.
if sy-subrc = 0.
write: / sy-fdpos.
endif.
2009 Feb 06 8:55 AM
Hi All,
As i specified in my question is should not hard code the the value 'i004'. i want to get this based on the Postion.I want to find the I004'.In the file in that postion it may conatin I004 or anythin else.
I dont want to hard code the value.
Thanks,
2009 Feb 06 9:57 AM
Hey,
One-way is to use SubString function to find the string for the specified position, for this u've to use Native Sql.
check this code:
DATA:
v_word TYPE string VALUE
'B1;;2009/11 Claim: 007324;SA;20081006;20091101;I004;;1032000MAR;;750;31;500481'.
DATA: v_string type string.
parameters: pos type i,
len type i.
exec sql.
select substr(:v_word, :pos,:len) from dual into :v_string
endexec.
write:/ v_string.thanks\
Mahesh