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

move stat problem

Former Member
0 Likes
879

Hi friends,

I have one problem in move statement. sample coding is

data: begin of f_string,

f1 like kna1-kunnr,

f2 like kna1-name1,

f3 like kna1-ort01,

end of f_string.

data: ls_string type f_string,

lt_string type table of f_string.

select f1 f2 f3 from kna1 into table lt_string where f1 = kna1-kunnr.

loop at lt_string to ls_string.

move ls_string-f1 to lt_string-f1.

move ls_string-f2 to lt_string-f2.

append ls_string to lt_string.

endloop.

In the above code I m getting error that lt_string is a table without a header line & therefore has no component called f1.

My object is to fetch the data. & move the data fetched to the internal table.

Will u tell me how to solve this error.

7 REPLIES 7
Read only

naimesh_patel
Active Contributor
0 Likes
845

Hello,

data: begin of f_string,

f1 like kna1-kunnr,

f2 like kna1-name1,

f3 like kna1-ort01,

end of f_string.

data: ls_string type f_string,

lt_string type table of f_string.

select f1 f2 f3 from kna1 into table lt_string where f1 = kna1-kunnr.

After this statment you get the data into the table lt_string.

No, need of the other logic....

Regards,

Naimesh

Read only

andreas_mann3
Active Contributor
0 Likes
845

hi,

loop at lt_string to ls_string.

<u>move ls_string-f1 to lt_string-f1.

move ls_string-f2 to lt_string-f2.</u>

append ls_string to lt_string.

endloop.

ulined code is useless

A.

Message was edited by: Andreas Mann

Read only

Former Member
0 Likes
845

<b>lt_string type table of f_string.</b>

this creates an Internal table without HEADER LINE. you have to use EXPLICIT work area to manipulate the data of this internal table.

<b>lt_string type table of f_string WITH HEADER LINE.</b>

This will creates an internal table WITH HEADER LINE,so you can use LT_STRING as a workarea to hold a single record.

i believe you got the point.

coming to your code,

<b>loop at lt_string to ls_string.
move ls_string-f1 to lt_string-f1.
move ls_string-f2 to lt_string-f2.
append ls_string to lt_string.
endloop.</b>

what is your intenstion here ? because you got data from KNA1 table to LT_STRING. again you are LOOPING the same LT_STRING again adding the SAME record to that table. this becomes an infinite loop,as you keep on adding the records.

the code between LOOP and ENDLOOP is meaningless.

so think again what you need and then code it.

Regards

srikanth

Message was edited by: Srikanth Kidambi

Read only

Former Member
0 Likes
845

couple of points ---

First as even others have pointed out that you dont need the loop part as you already have the particular data in lt_string.

Second, you can define your internal table with header line...in that case you would not see the below error.

Please check the available variations for DATA statement.

Read only

Former Member
0 Likes
845

Create internal table with header line. Change data decleration for lt_string as below:

data: ls_string type f_string,

lt_string type table of f_string with header line.

*This will resolve ur problem.

Regards,

Vishal

Reward if helpful

Read only

Former Member
0 Likes
845

Hello,

Types: begin of f_string,

f1 like kna1-kunnr,

f2 like kna1-name1,

f3 like kna1-ort01,

end of f_string.

data: ls_string type f_string,

lt_string type table of f_st with header line.

select kunnr name1 ort01 from kna1 into table lt_string.

Reward points if useful.

Thanks

Senthil

Read only

Former Member
0 Likes
845

One more thing you should write as

loop at itab <b>into</b> wa. "it should be into and not to

loop at lt_string into ls_string.

move ls_string-f1 to ls_string2-f1. "this should be another structure

move ls_string-f2 to ls_string2-f2.

append ls_string2 to lt_string2. "this table is another one with same structure as ls_string2

endloop.

Regards,

ravi