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: 

How to copy data to Internal table

Former Member
0 Kudos

Hi ABAP gurus,

I am new to ABAP programming. I am trying the copy data from a database Z table to an internal table. For the purpose I wrote the following code.

types: begin of t1,       "declaring the type of line.
employee
like zemployees_src-employee,
surname
like zemployees_src-surname,
forename
like zemployees_src-forename,
title like zemployees_src-title,
dob
like zemployees_src-dob,
end of t1.

types itab type standard table of t1.     "declaring the internal table type

data itab1 type itab.   "declaring the actual internal table
data wa_itab1 type t1.  "declaring the work area

select employee surname forename title dob from zemployees_src into wa_itab1.   "puting data into internal table through work area
append wa_itab1 to itab1.
endselect.

loop at itab1.
write / itab1.
endloop.


It is throwing the following error.


Please help me to resolve the problem and where I am making the mistake.

1 ACCEPTED SOLUTION

former_member223873
Participant
0 Kudos

Hi

change



loop at itab1.
write / itab1.
endloop.


to

loop at itab1 into wa_itab1.  " store every line of the table to the work area
write / wa_itab1. " you can't write whole table, only line by line
endloop.


Br

Bohuslav

6 REPLIES 6

Former Member
0 Kudos

Hi,

Declare  your internal with header line.

data itab1 type itab WITH HEADER LINE.



Former Member
0 Kudos

Declare your internal table itab1 like this,

DATA itab1 TYPE STANDRAD TABLE OF t1.

This creates an internal table with a header line. No need of creating itab in this case.

Former Member
0 Kudos

Still throwing the same error. Please help.

former_member223873
Participant
0 Kudos

Hi

change



loop at itab1.
write / itab1.
endloop.


to

loop at itab1 into wa_itab1.  " store every line of the table to the work area
write / wa_itab1. " you can't write whole table, only line by line
endloop.


Br

Bohuslav

Former Member
0 Kudos

Thanks a lot BR. the solution worked. Thank you again.

vamsilakshman_pendurti
Active Participant
0 Kudos

Hi ...

U declare two Types one is for structure(t1) and one is for table(itab)....

these two structures are used as data object like as follows

data itab1 type itab.    "declaring the actual internal table with out header line
data wa_itab1 type t1.  "declaring the work area


so in ur program u separate the objects without includes the header line in the internal table..


so at last u want to display the content of  internal table itab1.

in ur program itab1 is only body of internal table without header line...

so if u want to display content of internal table u need to take support of work area ....

other wise u need to take field symbol support...sooooo


U need to change ur program in the loop at statement as follows..


loop at itab1 to wa_itab1.

write : /02 wa_itab1-employee,

          10 wa_itab1-surname,

          20 wa_itab1-forename,

          30 wa_itab1-title,

          40 wa_itab1-dob.

endloop.




Hope this will be helpful to ur query

check it onceeeee




Regards

vamsilakshman.p