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

Read itab without header

former_member254358
Participant
0 Likes
5,084

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.

1 ACCEPTED SOLUTION
Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
2,079

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

6 REPLIES 6
Read only

SharathYaralkattimath
Contributor
0 Likes
2,079

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.

Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
2,080

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

Read only

Former Member
0 Likes
2,079

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

Read only

Former Member
0 Likes
2,079

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.

Read only

Former Member
0 Likes
2,079

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.

Read only

VenkatRamesh_V
Active Contributor
0 Likes
2,079

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.