‎2007 Jun 07 2:44 PM
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
‎2007 Jun 07 2:48 PM
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
‎2007 Jun 07 2:48 PM
<b>APPEND IS_zsft_terr_code TO IT_zsft_terr_code.</b>
u are appending entries to the same table in the loop.
‎2007 Jun 07 2:48 PM
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
‎2007 Jun 07 2:54 PM
‎2007 Jun 07 2:56 PM
‎2007 Jun 07 2:59 PM
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
‎2007 Jun 07 3:08 PM
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