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

perofrmance

Former Member
0 Likes
730

Hi all,

Why below code is going to continous loop it is never coming back...

LOOP AT it_zsft_terr_code INTO IS_zsft_terr_code.

LV_STRLEN = STRLEN( IS_zsft_terr_code-ZZTERCD ).

MOVE IS_zsft_terr_code-ZZTERCD+1(3) TO LV_ZZTERCD.

MOVE LV_ZZTERCD TO IS_zsft_terr_code-ZZTERCD.

APPEND IS_zsft_terr_code TO IT_zsft_terr_code.

IF LV_STRLEN = 4.

DELETE IT_zsft_terr_code.

ENDIF.

ENDLOOP.

Pls help

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
709

Hi Srikanth ,

The reason is that in the loop you are using the statement

<b>APPEND IS_zsft_terr_code TO IT_zsft_terr_code.</b>

which appends a new line to the internal table , thus the loop becomes an infinite loop because when you process the last record you add one more record , so this process goes on.

Regards

Arun

6 REPLIES 6
Read only

Former Member
0 Likes
709

<b>APPEND IS_zsft_terr_code TO IT_zsft_terr_code.</b>

u are appending entries to the same table in the loop.

Read only

Former Member
0 Likes
710

Hi Srikanth ,

The reason is that in the loop you are using the statement

<b>APPEND IS_zsft_terr_code TO IT_zsft_terr_code.</b>

which appends a new line to the internal table , thus the loop becomes an infinite loop because when you process the last record you add one more record , so this process goes on.

Regards

Arun

Read only

0 Likes
709

so..how can i write now...

Read only

0 Likes
709

Use modify itab index sy-tabix.

Message was edited by:

Swathi

Read only

0 Likes
709

Hi ,

Your code will look like this

LOOP AT it_zsft_terr_code INTO IS_zsft_terr_code.
LV_STRLEN = STRLEN( IS_zsft_terr_code-ZZTERCD ).
IF LV_STRLEN = 4.
*" If length is 4 delete the entry
DELETE table T_zsft_terr_code from IS_zsft_terr_code.
else.
*"Get the string starting from 4'th Char
MOVE IS_zsft_terr_code-ZZTERCD+1(3) TO LV_ZZTERCD.

MOVE LV_ZZTERCD TO IS_zsft_terr_code-ZZTERCD.

MODIFY IT_zsft_terr_code from IS_zsft_terr_code transporting ZZTERCD

ENDIF.

ENDLOOP.

Hope this helps , reward points if reply is helpful.

Regards

Arun

Read only

0 Likes
709

Hi KOta,

Try this...simple code..

LOOP AT it_zsft_terr_code INTO IS_zsft_terr_code.

SHIFT IS_ZSFT_TERR_CODE-ZZTERCD.

MODIFY IT_ZSFT_TERR_CODE FROM IS_ZSFT_TERR_CODE .

ENDLOOP.

Cheers