2010 Jan 29 10:25 AM
Hello ,
MY requirement is to find how many spaces in a string ..is there any function module plz advise.
thanks.
2010 Jan 29 10:27 AM
Hi!
Use the SEARCH command for this. In higher SAP versions (ECC6) you can use the FIND as well.
Regards
Tamá
Hi!
Use the SEARCH command for this. In higher SAP versions (ECC6) you can use the FIND as well.
Regards
Tamá
2010 Jan 29 10:27 AM
Hi!
Use the SEARCH command for this. In higher SAP versions (ECC6) you can use the FIND as well.
Regards
Tamá
2010 Jan 29 10:51 AM
hello there ,
thanks for your reply. I am getting an runtime error saying endless loop..any help?
Thanks
2010 Jan 29 11:12 AM
Hello,
DATA: v_str TYPE string,
v_len_ini TYPE i,
v_len_fin TYPE i,
v_spaces TYPE i.
v_str = `Welcome to SDN ABAP Forums `.
v_len_ini = STRLEN( v_str ).
WRITE / v_str.
CONDENSE v_str NO-GAPS.
v_len_fin = STRLEN( v_str ).
WRITE / v_str.
v_spaces = v_len_ini - v_len_fin.
IF v_spaces > 0.
WRITE: / 'No of spaces:', 20 v_spaces.
ENDIF.Does this solve your req ?
BR,
Suhas
2010 Jan 29 11:17 AM
2010 Jan 29 11:24 AM
Hi,
May be there are many ways. But one way is using split:
data: itab type table of string,
count type i.
split v_string at c_space into table itab.
describe table itab lines count.
count = count - 1.
Now count contains the number os spaces in the string.
@Keshav,
Sorry,ended up by posting same solution as I didnt checked your suggestion before posting
Regards,
Swarna Munukoti.
Edited by: Swarna Munukoti on Jan 29, 2010 12:26 PM
2010 Jan 29 11:08 AM
hi,
u can try this..
PARAMETER dat TYPE string.
DATA count TYPE i.
DATA: len TYPE i,
var TYPE c.
len = strlen( dat ).
do len TIMES.
len = len - 1.
var = dat+len(1).
if var = ' '.
count = count + 1.
ENDIF.
enddo.
WRITE / count.
2010 Jan 29 11:11 AM
PARAMETER dat TYPE string.Is STRING data type allowed?
Manas M.
2010 Jan 29 11:15 AM
You can check the f1 help of find and search.
But what comes to my mind now is
Split lv_string at space into table itab."make sure that the syntax is correct
describe table itab lines lv_lines.
lv_lines = lv_lines - 1.
write:'Spaces-',lv_lines.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |