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

Problem with Write Statement

Former Member
0 Likes
2,047

Hi Friends,

Select * from ekko into table i_ekko up to 100 rows.

loop at i_ekko into w_ekko.

write : w_ekko.

endloop.

when i write the above code i am getting an error "cannot be converted in to charater type".

but i want to display the all the coloums and rows from the DB table in the report.

regards

kumar m

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,014

hi,

you need to specify the fields in the write statement as your work area which contains a single row of your internal table , can not be converted into a single character string.

so u have to specify lilke this inside a loop statement:

write 😕 w_ekko-fld1 , w_ekko-fld2 , .......

16 REPLIES 16
Read only

Former Member
0 Likes
2,014

Either you have to specify each and every column like w_ekko-field1, w_ekko-field2

or you have to dynamically assign field-symbols to do the job if number of fields are very high

Read only

0 Likes
2,014

my issue was.

List all the rows from the table LAGP(Storage Bins) in a report

Read only

GauthamV
Active Contributor
0 Likes
2,014

hi,

w_ekko is workarea so u cannot get data into that,u have to define all the fileds in order to get them in output.

Read only

Former Member
0 Likes
2,014

hi,

loop at i_ekko into w_ekko

Here w_ekko is considered as the field string which cannot be written with name with reference of the field name.

You shold try this

loop at i_ekko into w_ekko.
write : w_ekko-filed1.

endloop

.

This will work.

Regards

Sumit Agarwal

Read only

Former Member
0 Likes
2,014

Hi Mukesh,

Here you are writing the field string at once. It considers the field string as a completer character type. But it contains fields other than character type. So, they cannot be converted into character type.

Instead you try to write each field individually as

wa_ekko-field1 etc.

Regards,

Chandra Sekhar

Edited by: Chandrasekhar Gandla on Jul 10, 2008 9:08 AM

Read only

Former Member
0 Likes
2,014

Hi,

Use

Loop at itab into wa .

write: wa-field.

Endloop.

Regards,

Sujit

Edited by: Sujit Pal on Jul 10, 2008 9:10 AM

Read only

bpawanchand
Active Contributor
0 Likes
2,014

Hi

W_EKKO is only a work area which is like the line type of your internal table so you haveto explicitly write all teh column names

like

write :

/ W-EKKO-<name of the column>.

Regards

Pavan

Read only

Former Member
0 Likes
2,014

HI mukesh,

When you loop at a internal table without a header line,that time while retrieving/printing the data , you should deal at field level & not work area level.

So instaed of writing the complete work area,try to write field one by one.

eg,

write : workarea-field 1,
         workarea-field 2,

The code which you have writeen would work for table with header line..

Good luck

Bhumika

Read only

Former Member
0 Likes
2,015

hi,

you need to specify the fields in the write statement as your work area which contains a single row of your internal table , can not be converted into a single character string.

so u have to specify lilke this inside a loop statement:

write 😕 w_ekko-fld1 , w_ekko-fld2 , .......

Read only

Former Member
0 Likes
2,014

But LAGP contains 50 fields,,

ok if Any table contain 250 fields

i should write

wa-<tab>-field1 ....... to wa_<tab>-field250. ?

Read only

0 Likes
2,014

Hi,

yes on that time declare the field symbol like <fs> type any.

aassign internal table to this field symbol.

finally.

write:/ <fs>.

regards.

sriram.

Read only

0 Likes
2,014

Hi,

in yoour code try like this,

FIELD-SYMBOLS: <FS>.

Select * from ekko into table i_ekko up to 100 rows.

loop at i_ekko into w_ekko.

assign lw_ekko to <FS>.

write : <FS>.

endloop.

regards.

sriram.

Read only

Former Member
0 Likes
2,014

I think structure of i_ekko and wai_ekko not same as ekko DB table. You have define them.

Syed Tayab shah

Read only

Former Member
0 Likes
2,014

Hi,

U cannot call the Itab directil into the write statement. Instead u have to specify whatever fields you want in the output that u have to give.

For eg.

loop at itab into w_itab.

write:/ w_itab-field1,

w_itab-field2,

w_itab-field3,

w_itab-field4.

endloop.

Hope this helps you.

Reward points if helpfull.

Thanks & Regards,

Y.R.Prem Kumar.

Read only

Former Member
0 Likes
2,014

Hi Mukesh,

Actually you can do like this because each record is taken into the work area w_ekko . But probably you have some fields which cannot be converted into character types. and this character type can be of type C , N , D or T. And I also think that you might have observed some special characters also which appear. So it is always advisable to write the fields individually.

Regards,

Swapna.

Read only

Former Member
0 Likes
2,014

Try this it may work.

data : iekko like ekko occurs 0.

data : wekko like ekko.
field-symbols : <fs> type any.

select * from ekko into table iekko up to 100 rows.

loop at iekko into wekko.
do 100 times.
assign component sy-index of structure wekko to <fs>.
if sy-subrc = 0.

write :  <fs>.
else.
exit.
endif.
unassign <fs>.

enddo.
write : /.
endloop.