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: 

deep table infinite loop

Former Member
0 Kudos

Hello experts,

I met an error of infinite loop when populating a deep table. Can any one help me correct the code?

Thanx.

LOOP AT ZGT_ITM INTO ZGS_ITM.

   CONCATENATE ZGS_ITM-VBELN ZGS_ITM-POSNR

               INTO TXTNAME.

   LV_EXTQTY = ( ZGS_ITM-FKIMG + ZGS_ITM-SPR_QTY ) MOD ZGV_CMSTPCS.

   LV_FULQTY = ( ZGS_ITM-FKIMG + ZGS_ITM-SPR_QTY ) - LV_EXTQTY.

CLEAR: LANGVAL, LT_LINE[].

DATA: LV_FMTXT TYPE TDLINE,

       LV_TOTXT TYPE TDLINE.

DATA: LV_FMVAL TYPE P,

       LV_TOVAL TYPE P.

PERFORM GET_LANGU USING 'VBBP' TXTNAME 'Z801'

                   CHANGING LANGVAL.

PERFORM GET_ITM_TXT TABLES LT_LINE

                     USING 'Z801' LANGVAL TXTNAME 'VBBP'.

LOOP AT LT_LINE.

   LS_TXTS-IDX_VAL = SY-TABIX.

   LS_TXTS-CARTXT  = LT_LINE-TDLINE.

   IF SY-TABIX = 1.

     SPLIT LS_TXTS-CARTXT AT '-' INTO LV_FMTXT LV_TOTXT.

     PERFORM CONV_TXT_TO_NUM USING LV_FMTXT

                             CHANGING LV_FMVAL.

     PERFORM CONV_TXT_TO_NUM USING LV_TOTXT

                             CHANGING LV_TOVAL.

     LS_TXTS-SQTY    = ZGS_ITM-SPR_QTY.

     LS_TXTS-CTNQTY  = ( ZGS_ITM-FKIMG + ZGS_ITM-SPR_QTY ) DIV ZGV_CMSTPCS.

     LS_TXTS-PERCTN  = ZGV_CMSTPCS.

     LS_TXTS-QTY_VAL = LV_FULQTY.

   ENDIF.

   IF SY-TABIX = 2.

     LS_TXTS-SQTY    = 0.

     LS_TXTS-PERCTN  = LV_EXTQTY.

     LS_TXTS-QTY_VAL = LV_EXTQTY.

     FIND LC_PATT IN LS_TXTS-CARTXT IGNORING CASE.

       IF SY-SUBRC = 0.

         SPLIT LS_TXTS-CARTXT AT 'INCLUDED' INTO LV_FMTXT LV_TOTXT.

         PERFORM CONV_TXT_TO_NUM USING LV_FMTXT

                                 CHANGING LV_FMVAL.

          LS_TXTS-INLFLG = 'X'.

          LS_TXTS-CTNQTY = 0.

       ELSE.

         PERFORM CONV_TXT_TO_NUM USING LS_TXTS-CARTXT

                                 CHANGING LV_FMVAL.       

          LS_TXTS-INLFLG = '-'.

          LS_TXTS-CTNQTY = 1.

       ENDIF.

     LV_TOVAL = LV_FMVAL.

   ENDIF.

   LS_TXTS-FM_VAL = LV_FMVAL.

   LS_TXTS-TO_VAL = LV_TOVAL.

   APPEND LS_TXTS TO ZGS_CART_ITM-LONGTXT.

ENDLOOP.

   MOVE-CORRESPONDING ZGS_ITM TO ZGS_CART_ITM.

   APPEND ZGS_CART_ITM TO ZGT_CART_ITM.

   CLEAR: ZGS_CART_ITM, ZGS_ITM.

ENDLOOP.

7 REPLIES 7

Former Member
0 Kudos

Hi t s,

you should provide more information about what table is producing an "infinite loop".

Your code contains a loop inside another loop and performs inside these loops and perhaps these performs contains insturcitions like "append internal_table" in...

In my opinion it is not an efficient code... you could debug and having a look at all instructions "append interna_tables" and checking if some of them is growing up in some bucle.

Regards and good luck!

Alberto.

0 Kudos

Hi ts,

on the level of provided code, there's no reason for an infinite loop.

Like Alberto suggested, you'll have to take a look at your forms.

Besides: why do you have a DATA statement within the loop???

Regards

Jörg

0 Kudos

Hello Alberto,

I upload an attachment to explain my intention. Would you mind telling me how to construct the code efficiently?

Thanx.

Regards,

ts

juan_vasquez2
Active Participant
0 Kudos

Hi

Try with debug

may be you can follow sy-index, maybe it is returning to first position

take care of table size, it is posible that instructions instert new rows

using en debug table_name[]  with [] at the end shows you number of rows for table

if an iteration inserts new row, it is an infinite loop

Former Member
0 Kudos

0 Kudos

If you don't know what internal table induce an infinite loop you could try to put a watchpoint like that:

It could give you some track.

Regards,

Alberto.

0 Kudos

Thanx.