2006 Dec 06 9:10 AM
Hallow Im doing a batch input from file csv (comma dilmeted) In the file I have company that ok and company name with before and after the company name word <b>''</b> how can I get rid of from that . just<b> ''</b> before and after the company name .
*--
LOOP AT itab1.
SPLIT itab1 AT ',' INTO:
itab-osek_morsh
<b>itab-company_name</b>
itab-company_code.
APPEND itab.
ENDLOOP.
2006 Dec 06 9:12 AM
Use the REPLACe command
Constants c_comma type c value '"'.
REPLACE c_comma in itab-company_name with space.
CONDENSE itab-company_name no-gaps.
Hallow Im doing a batch input from file csv (comma dilmeted) In the file I have company that ok and company name with before and after the company name word <b>''</b> how can I get rid of from that . just<b> ''</b> before and after the company name .
*--
LOOP AT itab1.
SPLIT itab1 AT ',' INTO:
itab-osek_morsh
<b>itab-company_name</b>
itab-company_code.
APPEND itab.
ENDLOOP.
2006 Dec 06 9:12 AM
Use the REPLACe command
Constants c_comma type c value '"'.
REPLACE c_comma in itab-company_name with space.
CONDENSE itab-company_name no-gaps.
2006 Dec 06 9:14 AM
Hi Antonio,
Use the following after making small correction.
constants: c_comma type char01 value ','.
LOOP AT itab1.
SPLIT itab1 AT c_comma INTO:
itab-osek_morsh
itab-company_name
itab-company_code.
APPEND itab.
ENDLOOP.
Please check above code will work.
Regards
Bhupal reddy
2006 Dec 06 9:16 AM
You can just replace " by nothing ... like this - replace all occurrences of '"' in text with ''.
Try this ....hope it works for u.
2006 Dec 06 9:18 AM
Hi Antonio ,
You can use the following commands
REPLACE ALL OCCURRENCES of ' " ' in itab_company_name with sapce.
condense intab-company-name.
Regards
Arun
2006 Dec 06 9:19 AM
Hi Antonio
As you were saying that you will have double quotes before and after company name, a small modification in Dominic's Code.
Use the REPLACe command
Constants c_comma type c value '"'.
*REPLACE c_comma in itab-company_name with space.
<b>REPLACE ALL OCCURENCES OF c_comma in itab-company_name with space.</b>
CONDENSE itab-company_name no-gaps.
Hope Dominic wouldnt mind.
Kind Regards
Eswar
2006 Dec 06 9:28 AM
No problem at Eswar
All suggestions are welcome. No 'mind' at all
2006 Dec 06 9:48 AM
2006 Dec 06 9:54 AM
Hi,
LOOP AT itab1.
SPLIT itab1 AT ',' INTO:
itab-osek_morsh
itab-company_name
itab-company_code.
REPLACE ALL OCCURENCES OF '''' in itab-company_name with ''.
APPEND itab.
ENDLOOP.
2006 Dec 06 9:59 AM
Hi Antonio
Please check this code:
Constants c_comma type c value '"'.
LOOP AT itab1.
SPLIT itab1 AT ',' INTO:
itab-osek_morsh
itab-company_name
itab-company_code.
REPLACE ALL OCCURENCES OF c_comma IN itab-company_name with ' '.
CONDENSE itab-company_name NO-GAPS.
APPEND itab.
ENDLOOP.
Hope this helps you.
Kind Regards
Eswar
2006 Dec 06 9:25 AM
loop at itab.
len = strlen(itab-company_name).
len = len - 1.
itab-company_name = itab-company_name+1(len).
modify itab index sy-tabix transporting company_name.
endloop
2006 Dec 06 9:58 AM
hi chandrasekhar your answer is good but just forthe first occurse ex. if i have a company name like that <b>"</b>microsoft<b>"</b> and i wont to remove both what can i do thankes for your time
2006 Dec 06 10:01 AM
Hi Antonio ,
Why dont you loop and in that use the <b>replace</b> command.
Hope this help , if not i shall send you the code
Regards
Arun
2006 Dec 06 10:03 AM
Hi,
My code works fine for that "microsoft"
itab-company_name = itab-company_name+1(len).
the above statement will remove the first and the last characters from the string
the numbering starts from 0 and i had subtracted 1 from len
so 1(len) will start from second character and to length - 1 character
Pls let me know if u need any more clarification
2006 Dec 06 10:52 AM
hi chandrasekhar jagarlamudi how can i use it in my loop regards
2006 Dec 06 11:30 AM
Hi antonio,
U can check my previous post , that works perfectly , posting the same here
loop at itab.
len = strlen(itab-company_name).
len = len - 1.
itab-company_name = itab-company_name+1(len).
modify itab index sy-tabix transporting company_name.
endloop
2006 Dec 06 12:51 PM
Hallow everybody my problem is a little bit difficult
I use your suggestion with REPLACE ALL OCCURRENCES OF and it work well but if I have a company name like "<b>abcef"ghi</b>" (one word) and between f and g I wont the comma to stay its problem .and when I use <b>strlen</b> like the suggestion it omitting the first letter of the word (because not all the company have coma before and after. Did some one have any idea how to solve this problem regardes
2006 Dec 06 11:11 AM
Hi Antonio ,
If you want to use the strlen option the here is the code
-
<b>Data : v_strlen type i.</b>
LOOP AT itab1.
Clear v_strlen.
SPLIT itab1 AT ',' INTO:
itab-osek_morsh
itab-company_name
itab-company_code.
v<b>_strlen = strlen(itab-company_name).
v_strlen = v_sterlen - 1.
itab-company_name = itab-company_name+0(v_strlen ).</b>
APPEND itab.
ENDLOOP.
-
Regards
Arun
2006 Dec 06 11:15 AM
Hi Antonio ,
Just a small correction in one of the statments , insted of
<i>itab-company_name = itab-company_name+0(v_strlen ).</i>
use
<b>itab-company_name = itab-company_name+1(v_strlen).</b>
Reagrds
Arun
2006 Dec 06 1:00 PM
Hallow everybody my problem is a little bit difficult
I use your suggestion with REPLACE ALL <b>OCCURRENCES</b> OF and it work well but if I have a company name like "<b>abcef"ghi</b>" (one word) and between f and g I wont the comma to stay its problem .and when I use<b> strlen</b> like the suggestion it omitting the first letter of the word (because not all the company have coma before and after. Did some one have any idea how to solve this problem <b>regardes</b>
2006 Dec 06 2:09 PM
hallow antonio your problem is diffcult logic i try to solve it but i cant you have to ask some one with more experience and in this form you have a lot sorry and regardes
2006 Dec 07 4:34 AM
Hi Antonio ,
Now what i understand is that some companies may have " at begining , some may have at end , some may have both and some none .
So your requirement is that if there is a " as the first char or last then we need remove it , for all other cases it is not required.
If my understanding is correct , here is the code which gives the desired result
* Selection Screen
parameters : p_string type string .
start-of-selection.
DATA : t_result type MATCH_RESULT_TAB. " Internal table
data : v_string type i .
v_string = strlen( p_string ). " Get the lenght of string
* get the offset of all occurances of " in your string
FIND ALL OCCURRENCES OF '"' IN P_STRING RESULTS T_RESULT.
v_string = v_string - 1. " Here the offset start with zero
* Check if last char is "
read table t_result with key OFFSET = v_string transporting NO FIELDS .
if sy-subrc = 0.
" If yes remove if from string
p_string = p_string+0(v_string).
endif.
*Check if the first char is "
read table t_result with key OFFSET = '0' transporting NO FIELDS .
if sy-subrc = 0.
* if yes replace with space
replace '"' in p_string with ' '
endif.Check if this serves your purpose , if not please tell what is the concern you have.
Thanks
Arun
2006 Dec 07 4:46 AM