10-23-2007 2:59 PM
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.
10-23-2007 3:04 PM
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.
10-23-2007 3:04 PM
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.
10-23-2007 3:07 PM
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.
10-23-2007 3:10 PM
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.
a®
10-23-2007 3:10 PM
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
10-23-2007 3:12 PM
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.
10-23-2007 3:08 PM
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
10-23-2007 3:09 PM
Hi,
LOOP AT UPLOAD_ITAB.
....
APPEND UPLOAD_ITAB. " Use some other internal table say upload_itab_tmp
ENDLOOP.
Enjoy SAP.
Pankaj Singh