Application Development 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: 

field-symbol error: cannot be converted to type c.

aris_hidalgo
Contributor
0 Kudos

Hello experts,

I am presently experementing with field-symbols as my work area. Now, I did someything like this:

tables: spfli.

data: it_spfli type standard table of spfli with

header line.

field-symbols: <fs_spfli> like line of it_spfli.

start-of-selection.

select * from spfli

into table it_spfli.

end-of-selection.

if not it_spfli[] is initial.

loop at it_spfli assigning <fs_spfli>.

write: / <fs_spfli>.

endloop.

endif.

The error says that <fs_spfli> cannot be converted to a type c or something like that.

My understanding of this is that the field-symbol acts just like a header line/work area.

Again, thank you guys and have a nice day!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

i dont think we can conclude that the field-symbol here will act as header/workarea mainly because there is no data being transported here, if you use workarea/header within a loop the entry of the body will be transported to the workarea and it can be accessed there so the change in the contents of the workarea is not going to get reflected inside the table but if u use <FS> then the data is not transported from body to <fs> becuase <fs> is just an alias for the entry of the body.

So cannot conclude that <fs> in this case and an workarea/header is same.

10 REPLIES 10

Former Member
0 Kudos

Hi Viray,

Try this piece of code.

types: begin of ttab,

field1(10) type c,

field2(10) type c,

field3(10) type c,

field4(10) type c,

field5(10) type c,

end of ttab.

data: itab type table of ttab,

wa_tab like line of itab.

field-symbols: <fs_tab> type table.

field-symbols: <fs> type ttab.

wa_tab-field1 = 'Viray'.

wa_tab-field2 = 'Viray'.

wa_tab-field3 = 'Viray'.

wa_tab-field4 = 'Viray'.

wa_tab-field5 = 'Viray'.

append wa_tap to itab.

start-of-selection.

loop at itab assigning <fs>.

write:/ <fs>-field1, <fs>-field2, <fs>-field3.

endloop.

Thanks & Regards,

YJR.

0 Kudos

Hi,

So my understanding is that you need to manually write all fields in the write statement?

0 Kudos

Yes you have write the fields individually.

Former Member
0 Kudos

if SPLFI contains only character based fields then it is possible to use - write: / <fs_spfli>.

Since this is not the case error is being shown, use a normal work area instead of field-symbol say -

data: wa_splfi like line of it_splfi.

loop at it_spfli into wa_splfi.

write: / wa_splfi.

endloop.

ABOVE statement will give you the same error.

Former Member
0 Kudos

tables: spfli.

data: it_spfli type standard table of spfli with

header line.

field-symbols: <fs_spfli> like line of it_spfli.

ASSIGN it_spfli TO <fs_spfli>.

start-of-selection.

select * from spfli

into table it_spfli.

end-of-selection.

if not it_spfli[] is initial.

loop at it_spfli assigning <fs_spfli>.

<b> write: / <fs_spfli>-carrid. </b>

endloop.

endif.

Rgds,

Jothi.

0 Kudos

This is not a syntax error in my 46c system, but is a warning in my was 7.0. This leads me to believe that this is a unicode thing. In this case, you must specificly name the fields when writing them out.



report zrich_0006.

tables: spfli.

data: it_spfli type standard table of spfli with
header line.

field-symbols: <fs_spfli> like line of it_spfli.

start-of-selection.

  select * from spfli
  into table it_spfli.

end-of-selection.

  if not it_spfli[] is initial.
    loop at it_spfli assigning <fs_spfli>.
<b>      write: / <fs_spfli>-carrid, <fs_spfli>-connid.</b>
    endloop..
   
  endif.

Regards,

Rich Heilman

0 Kudos

Hi guys,

Thanks for the replies. I guess I have no choice but to write down each and every field in write statement:)

Former Member
0 Kudos

i dont think we can conclude that the field-symbol here will act as header/workarea mainly because there is no data being transported here, if you use workarea/header within a loop the entry of the body will be transported to the workarea and it can be accessed there so the change in the contents of the workarea is not going to get reflected inside the table but if u use <FS> then the data is not transported from body to <fs> becuase <fs> is just an alias for the entry of the body.

So cannot conclude that <fs> in this case and an workarea/header is same.

Former Member
0 Kudos

Hi,

You could try the code below.

I would just like to raise a point in the programming.

If you will be using Header Line, you no longer need to use a work area or a field symbol when you loop at your internal table.

tables: spfli.

data: it_spfli type standard table of spfli with

header line.

field-symbols: <fs_spfli> type spfli.

start-of-selection.

select * from spfli

into table it_spfli.

end-of-selection.

if not it_spfli[] is initial.

loop at it_spfli assigning <fs_spfli>.

write: / <fs_spfli>-cityfrom

endloop.

endif.

  • yes you still have to call the fields

0 Kudos

Hi again guys,

Thanks for useful replies. I was wrong to say that I am trying to use that as a work area/header line since it points directly to the current index of my itab.

Again, thank you all and have a nice day!