04-18-2014 7:22 AM
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.
04-18-2014 11:25 PM
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
04-18-2014 7:59 AM
Hi,
Declare your internal with header line.
data itab1 type itab WITH HEADER LINE.
04-18-2014 3:53 PM
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.
04-18-2014 8:05 PM
04-18-2014 11:25 PM
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
04-19-2014 6:23 AM
04-23-2014 5:40 AM
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