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

Loop statement processing will be terminated

vijay_kumar134
Participant
0 Likes
1,133

Hi,

Please help me to solve the issue from Code inspector - like Loop statement processing will be terminated.

Thanks.

Viji.

5 REPLIES 5
Read only

former_member491621
Contributor
0 Likes
1,082

Hi Vijay,

Why are you using where with from and to additions in the loop?

the from and to additions already define a range to read(you are getting the indexes already)

Hope this helps

Read only

former_member16322
Participant
0 Likes
1,082

This appears to be caused by the combination of a limited loop (WHERE or FROM TO) and the usage of AT statements.

May we see the loop? Additionally, may we see the declaration of the table being looped through and any sorting done to the table?

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,082

As specified in the message, usage of a LOOP AT with a WHERE clause and of AT/ENDAT statements in the loop can give unpredictable results (or not)

To ensure that control level processing is carried out properly, the following rules must be observed:

  • A table key specified for LOOP in cond must be chosen so that it produces the required sort order of the imported rows.

  • A restricting condition specified for LOOP in cond must select a contiguous block of rows from the internal table. Otherwise the behavior of the control level processing is undefined.

  • The internal table cannot be modified within the LOOP loop.

  • A work area wa specified in the LOOP statement after the addition INTO must be compatible with the row type of the table.

  • A field symbol <fs> specified in the statement LOOP after the addition ASSIGNING must be typed with the row type of the table.

  • The content of a work area wa specified in the statement LOOP after the addition INTO cannot be modified.

(From AT - itab documentation)

Regards,

Raymond

Read only

0 Likes
1,082

Hi ,

Please find the below code for the issue we discussed about:

            AT END OF wempf.
              READ TABLE git_mseg INTO gwa_mseg INDEX l_tabix.

              IF gwa_mseg-wempf IS NOT INITIAL AND l_mtart = 'ZFES'.
                l_sent_quantity = l_sent_quantity - 1.
                gwa_final-bdmng = 1.
              ELSE.
                CLEAR : l_sent_quantity, gwa_mseg-wempf.
                gwa_final-bdmng = gwa_resb_sum-bdmng.
              ENDIF.


---------------

AT LAST.
              IF l_sent_quantity GT 0.

                gwa_final-wempf = space.
                gwa_final-bdmng = l_sent_quantity.
                l_sentqty = l_541 - l_542.

                gwa_final-l_sentqty = l_sentqty.   "Sent Qty

                l_recqty = l_942 - l_941.
                gwa_final-l_recqty = l_recqty.   "rec Qty


                IF gwa_final-l_sentqty IS INITIAL.
                  gwa_final-budat = space.
                ENDIF.

                IF gwa_final-l_recqty IS INITIAL.
                  gwa_final-recvdate = space.
                ENDIF.

----------------

              AT END OF bwart.
                READ TABLE git_lead INTO gwa_lead INDEX l_tabix.
                l_sent_date = gwa_lead-budat.
              ENDAT.
            ENDIF.

            IF gwa_lead-bwart = c_942.
              l_942_sum = gwa_lead-menge.
              IF l_sent_quantity IS NOT INITIAL.
                l_sent_quantity = l_sent_quantity - l_942_sum.
                CLEAR : l_942_sum.
                IF l_sent_quantity LE 0.
                  l_recv_date = gwa_lead-budat.
                  EXIT.
                ENDIF.
              ENDIF.
            ENDIF.
            CLEAR : gwa_lead.
          ENDLOOP.


Thanks.

Viji.

Read only

0 Likes
1,082

Hi Vijay,

Try using either from-to or where addition with the loop.

In my program, i have used the from-to addition with LOOP and it is not showing the error in code inspector.

Hope this helps