ā2014 Jun 13 10:21 AM
Hi,
I'm moving in an internal table (without header) using a loop and I need to read the lines.
With the read line (saving data in a wa) sentence it can be done but it returns me an error because the itab hasn't header.
Can anybody tell me the correct syntax to achieve this?
Thanks in advance.
Regards.
ā2014 Jun 13 10:30 AM
Hello David,
define work area of same type as of ITAB.
Example :
DATA : ITAB type standard table of KNA1 ,"Table without header line.
wa_itab type kna1. "work area for ITAB.
READ ITAB INTO WA_ITAB and wa_itab will have some values if sy-subrc = 0 after read statement.
Thanks
ā2014 Jun 13 10:30 AM
Hi David,
the syntax is ,
DATA: itab type table of ztable,
wa LIKE LINE OF itab.
LOOP AT itab into wa.
.....
..........
ENDLOOP.
another option is ,
FIELD-SYMBOLS: <fs_wa> type ztable.
LOOP AT itab assigning <fs_wa>.
.........
ENDLOOP.
ā2014 Jun 13 10:30 AM
Hello David,
define work area of same type as of ITAB.
Example :
DATA : ITAB type standard table of KNA1 ,"Table without header line.
wa_itab type kna1. "work area for ITAB.
READ ITAB INTO WA_ITAB and wa_itab will have some values if sy-subrc = 0 after read statement.
Thanks
ā2014 Jun 13 10:31 AM
Hi David,
You would need to either:-
1. Define a work area to read the internal table contents inside a loop
OR
2. Define the table with header line
-Regards,
Ragavan
ā2014 Jun 13 10:32 AM
hi David,
Please press an F1 on the keyword to find the syntaxes.
Below is what you should be doing.
DATA: ITAB type table of MARA, "internal table
ITAB_WA type MARA. "Work Area
READ TABLE itab INTO itab_wa WITH KEY FIELD = VAR. "Read data from table to work area.
Regards,
DN.
ā2014 Jun 13 11:03 AM
Hi David,
To read a record from internal table to work area. You have to follow at least one of the following:
1) Declare internal table with header line.
2) Declare internal table and work area separately.
3) you must declare a field-symbols.
ā2014 Jun 13 11:14 AM
Hi David,
If you delcare Internal table with headerline, system automatically assign headerline,
but
if you delcare Internal table without header line, you should delcare workarea or field symbols.
Syntex.
Data: itab type table of mara,
wa like line of itab.
read table itab into wa with key fieldname = fieldname.
with Header line.
data: itab type table of mara with headerline initial size 0.
read table itab with key matnr = matnr.
Regards,
Venkat.