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: 

error in loop at itab in ECC 6.0

Former Member
0 Kudos
1,562

hi,

in ECC 6.0, in an abap proxy class i have a loop statement as follows:

LOOP AT tablename.

sdfsdf

sfsfsf

s

fsf

ENDLOOP.

and i get the error, At "Loop At itab" one of the additions into/assigning or transporting no fields is required in OO context !! what does that mean ? in my abap proxy class can't i use the loop at statement's simplest form ?

whats the solution ?

1 ACCEPTED SOLUTION

JozsefSzikszai
Active Contributor
0 Kudos
450

hi,

in OO conetxt you cannot use internal table with header line, so you have to LOOP through the table INTO a work area or you have to ASSIGN a field symbol.

LOOP AT itab INTO wa .

...

ENDLOOP.

hope this helps

ec

8 REPLIES 8

Former Member
0 Kudos
450

use a workarea

JozsefSzikszai
Active Contributor
0 Kudos
451

hi,

in OO conetxt you cannot use internal table with header line, so you have to LOOP through the table INTO a work area or you have to ASSIGN a field symbol.

LOOP AT itab INTO wa .

...

ENDLOOP.

hope this helps

ec

valter_oliveira
Active Contributor
0 Kudos
450

Hello.

Is that tablename an input structure of the proxy?

You must create a work area for it, and then use:


LOOP AT tablename INTO wa.
...
ENDLOOP.

Best regards.

Valter Oliveira.

naimesh_patel
Active Contributor
0 Kudos
450

YOu can't use the normal internal table declared with OCCURS 0 extention in OO programming

You need to have the internal tables declared with type and you have to explicitally take the current row into the workarea.

Like:


types: begin of ty_tab,
field1 type vbeln,
end  of ty_tab.

data: tablename type standard table of ty_tab,
wa_tab type ty_tab.

LOOP AT tablename into wa_tab.
wa_tab-vbeln = 'XXXX'.

ENDLOOP.

Regards,

Naimesh Patel

Former Member
0 Kudos
450

Hi,

In the OO concept we should not modify or process an internal table direcly.

A work area must be used for this purpose. The error will be thrown if WA is not used.

regards,

teja.

Former Member
0 Kudos
450

Hi

It means it can only use an internal table without header line, so it needs to create a workarea in order to see the data of a record of the table:

DATA: WA TYPE TABLENAME.

LOOP AT tablename INTO WA.
ENDLOOP.

Max

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
450

Sure you can, you just have to use an explicit workarea and use the INTO.

Types: begin of ttab,
            fld1 type c,
           fld2 type c,
          end of ttab.


data: itab type table of ttab.
data: wa like line of itab.

Loop at itab INTO wa.

* Now the row is stord in WA, do what you need to here.

endloop.

YOu can NOT use internal tables with header lines in the OO context.

Regards,

Rich Heilman

former_member188685
Active Contributor
0 Kudos
450

You need to use work area when you are working with Object Oriented environment. I hope you are using the loop inside class or BSP or WDA or some BADI

LOOP AT ITAB INTO WA. use work area for all internal table processing.