‎2006 Jan 26 6:52 PM
Hi friends,
I got a small problem with internal table....
i have an internal table <b>i_data</b>,
it has been declared as :
begin of i_data occurs 0,
delimiter,
rec like rec_type,
vendor like mara-mfrnr,
-
-
end of i_data.
constants:
rec_type(2) value 'SD'.
-
-
then i'm searching for '"' mark in that internal table..
<b>search i_data for '"'.
if sy-subrc = 0.
replace '"' with ' ' into i_data.
endif.</b>
but it is giving a syntax error saying that <b>{"i_data" must be a character data object(data type C,N,D,T, or STRING). field string)}.</b>
can anybody plz tell me, wt does it means? and how can i correct this?
thnks much,
Dev
‎2006 Jan 26 7:42 PM
‎2006 Jan 26 6:57 PM
Hi Dev,
You have to search that in the field of the internla table i_data rather than the internal table i_data.
‎2006 Jan 26 7:01 PM
‎2006 Jan 26 7:03 PM
‎2006 Jan 26 7:42 PM
‎2006 Jan 26 8:28 PM
Hi all,
The rec and rec_type is nothing to do with that ' " ' in fact.
The thing is there is another constant defined as
constants: delimiter_quote as ' " '.
is this causing that syntax problem?
plz let me know....
thnx
begin of i_data,
‎2006 Jan 26 8:29 PM
‎2006 Jan 26 8:33 PM
The problem is that I_DATA probably has one or more currency or type p or i fields (IE - non-character). Since you are searching the entire record, it won't let you. Instead of searching the entire record, you have to change it so that you are only looking at character fields.
Rob
‎2006 Jan 26 8:34 PM
Hi Dev,
There is no Syntax error for me.Give the code & let us know where are you facing the problem.
‎2006 Jan 26 8:42 PM
Friends,
let me give u the whole thing under one context.
the constants are defined as:
<b>constants: rec_type(2) value 'SD',
delimiter_quote value ' " '.</b>
the internal table is something like this:
<b>data: begin of i_data occurs 0,
delimiter,
rec like rec_type,
vendor like mara-mfrnr,
.....................
end of i_data</b>.
.....................
....................
now here i'm searching for the double quotation mark....and want to replace it with a space
the code is like this:
<b> search i_data for ' " '.
if sy-subrc = 0.
replace ' " ' with ' ' into i_data.
endif.</b>
<b>i_Data-delimiter = delimiter_quote.</b>
and when i check this program, is giving that error.
i think now the scenario is clear for u...
let me know, if anything is ambiguous.
thnx,
‎2006 Jan 26 8:45 PM
‎2006 Jan 26 8:47 PM
Even if I add a non-character field to the I_DATA internal table, still I get no syntax error.
report zrich_0002.
constants: rec_type(2) value 'SD',
delimiter_quote value ' " '.
data: begin of i_data occurs 0,
delimiter,
rec like rec_type,
vendor like mara-mfrnr,
<b> p(10) type p decimals 2,</b>
end of i_data.
search i_data for ' " '.
if sy-subrc = 0.
replace ' " ' with ' ' into i_data.
endif.
i_data-delimiter = delimiter_quote.
Regards,
Rich Heilman
‎2006 Jan 26 8:48 PM
yes rob,
i have one more field " <b>rate like konp-kbetr</b>" in the <b>i_data</b>.
so wt do u want me to???
‎2006 Jan 26 8:49 PM
‎2006 Jan 26 8:51 PM
‎2006 Jan 26 8:53 PM
i made it sure that the error is caused by the field,
" <b>rate like konp-kbetr</b>" only. when i delete this from the <b>i_data</b>, i'm not getting the syntax error.
plz tell me how to overcome this.
i must have that field in the i_data as it is.
thnx
‎2006 Jan 26 8:54 PM
In order to get rid of the warning, you must change the types of the fields to character or just search a character field of i_data. Where are you expecting to find the '"'.
report zrich_0002.
constants: rec_type(2) value 'SD',
delimiter_quote value ' " '.
data: begin of i_data occurs 0,
delimiter,
rec like rec_type,
vendor like mara-mfrnr,
<b> rate(13) type c,</b>
end of i_data.
search i_data for ' " '.
if sy-subrc = 0.
replace ' " ' with ' ' into i_data.
endif.
i_data-delimiter = delimiter_quote.
Again, in my system, it is a warning message. It will allow you to continue.
Regards,
Rich Heilman
‎2006 Jan 26 8:56 PM
You have to do what I said earlier:
Instead of searching the entire record, you have to change it so that you are only looking at character fields.
You could examine each field (except rate). You could also examine i_data(n) and i_data+i(j), so that you are skipping rate.
There may also be a solution using field-symbols.
Rob
‎2006 Jan 26 8:59 PM
but rich,
as it is a currency field, i cant do like that.
when i tried to declare it as:
<b>rate type p decimals 2.</b> , it is giving me the same warning message...
is ther any other way to overcome that?
thnx
‎2006 Jan 26 9:12 PM
thnks guyz...
i have just took out that <b>rate</b> field out that i_data and kept in a separate new internal table....it solved...
thnx
‎2006 Jan 26 8:58 PM
You might be able to get away with something like this. I am concerned about the packed field though. Not sure that it will show correctly in the string.
report zrich_0002.
constants: rec_type(2) value 'SD',
delimiter_quote value ' " '.
<b>data: string type string.</b>
data: begin of i_data occurs 0,
delimiter,
rec like rec_type,
vendor like mara-mfrnr,
<b> rate like konp-kbetr,</b>
end of i_data.
<b>string = i_data.</b>
<b>search string for ' " '.</b>
if sy-subrc = 0.
replace ' " ' with ' ' into <b>string.</b>
endif.
<b>i_data = string.</b>
i_data-delimiter = delimiter_quote.
REgards,
Rich Heilman