Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

internal table error

Former Member
0 Likes
1,637

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,572

Hi Dev

Is REC_TYPE a flat structure?

Reagrds

Santosh

20 REPLIES 20
Read only

Former Member
0 Likes
1,572

Hi Dev,

You have to search that in the field of the internla table i_data rather than the internal table i_data.

Read only

0 Likes
1,572

Do you really mean to search i_data-rec?

search <b>i_data-rec</b> for '"'.
if sy-subrc = 0.
replace '"' with ' ' into i_data.
endif.

Regards,

Rich Heilman

Read only

0 Likes
1,572

How is rec_type defined? This is passing syntax check.



report zrich_0002.

data:
   begin of i_data occurs 0,
      delimiter,
  <b>    rec(1000) type c,</b>
      vendor like mara-mfrnr,
   end of i_data.


search i_data for '"'.
if sy-subrc = 0.
  replace '"' with ' ' into i_data.
endif.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,573

Hi Dev

Is REC_TYPE a flat structure?

Reagrds

Santosh

Read only

0 Likes
1,572

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,

Read only

0 Likes
1,572

I'm not getting a syntax error. Please post the entire code of the program. Thanks.

Regards,

Rich Heilman

Read only

0 Likes
1,572

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

Read only

0 Likes
1,572

Hi Dev,

There is no Syntax error for me.Give the code & let us know where are you facing the problem.

Read only

0 Likes
1,572

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,

Read only

0 Likes
1,572

Again, I'm not getting any syntax error. Post the code as it is in your editor from the REPORT statement to the end of the program.

Regards,

Rich HEilman

Read only

0 Likes
1,572

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

Read only

0 Likes
1,572

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???

Read only

0 Likes
1,572

Hi Dev,

I am not getting any syntax error.

Read only

0 Likes
1,572

Its coming as a warning message. This will not stop you from running the program.

Regards,

Rich HEilman

Read only

0 Likes
1,572

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

Read only

0 Likes
1,572

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

Read only

0 Likes
1,572

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

Read only

0 Likes
1,572

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

Read only

0 Likes
1,572

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

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,572

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