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: 

Inifinite looping of internal table?

Former Member
0 Kudos

Hi.

I have a piece of codes that loops through an internal table.

There isn't any syntax nor run-time errors, but my program seems to be hanging, even though there is only ONE record in my internal table!!

********************************************

DATA: UPLOAD_ITAB TYPE TABLE OF ZTA_S_CCA WITH HEADER LINE.

......

LOOP AT UPLOAD_ITAB.

....

APPEND UPLOAD_ITAB.

ENDLOOP.

********************************************

Is it because of the WITH HEADER LINE? But when i tried to remove it, I got a run-time error. Could anyone advise? Thanks.

1 ACCEPTED SOLUTION

Sougata
Active Contributor
0 Kudos

That is because you are adding lines to the same table you are looping at! On every loop pass a line is aaded to the same internal table as a result it goes into an infinite loop. Use another internal table when adding rows.

7 REPLIES 7

Sougata
Active Contributor
0 Kudos

That is because you are adding lines to the same table you are looping at! On every loop pass a line is aaded to the same internal table as a result it goes into an infinite loop. Use another internal table when adding rows.

Former Member
0 Kudos

Oh, I see.. Thanks a lot... Points given.

Actually, I wasn't trying to add new lines to the internal table.

I was actually trying to loop through the internal tables and make changes to the values in the internal table. Somehow the values don't get updated. Any idea why that is so?

********************************************

DATA: UPLOAD_ITAB TYPE TABLE OF ZTA_S_CCA WITH HEADER LINE.

......

LOOP AT UPLOAD_ITAB.

UPLOAD_ITAB-LAST_CHGED_BY = SY-UNAME. ==> the value is not updated!!!

ENDLOOP.

0 Kudos

Hi,


DATA: UPLOAD_ITAB TYPE TABLE OF ZTA_S_CCA WITH HEADER LINE.
......
LOOP AT UPLOAD_ITAB.

UPLOAD_ITAB-LAST_CHGED_BY = SY-UNAME. 

modify UPLOAD_ITAB index sy-tabix. "<<<<<<<

ENDLOOP.

Former Member
0 Kudos

Then:

********************************************
DATA: upload_itab TYPE TABLE OF zta_s_cca WITH HEADER LINE.
......
LOOP AT upload_itab.

  upload_itab-last_chged_by = sy-uname. ==> the value is not updated!!!

  modify upload_itab transporting last_chged_by.

ENDLOOP.
********************************************

Rob

0 Kudos


DATA: 
  UPLOAD_ITAB TYPE TABLE OF ZTA_S_CCA.

FIELD_SYMBOLS:
  <p> TYPE ZTA_S_CCA.


LOOP AT UPLOAD_ITAB assigning <p>.

<p>-LAST_CHGED_BY = SY-UNAME.
ENDLOOP.



Former Member
0 Kudos

Try something like this:

********************************************
DATA: upload_itab TYPE TABLE OF zta_s_cca WITH HEADER LINE,
      temp_itab   TYPE TABLE OF zta_s_cca WITH HEADER LINE.
......
LOOP AT upload_itab.
  ....
  APPEND temp_itab.
ENDLOOP.

APPEND LINES OF temp_itab TO upload_itab.

********************************************

Rob

messier31
Active Contributor
0 Kudos

Hi,

LOOP AT UPLOAD_ITAB.

....

APPEND UPLOAD_ITAB. " Use some other internal table say upload_itab_tmp

ENDLOOP.

Enjoy SAP.

Pankaj Singh