Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Endless Loop

Hi I'm trying to output a routing report.

It all goes well until I process my internal tables to an alv.The code is getting stuck in a loop and I can't work out why.

Problem code below. Any ideas? Thanks in advance.

loop at gt_routing_hdr into ls_routing_hdr.

       clear ls_display_op.

       move-corresponding ls_routing_hdr to ls_display_op.

       loop at gt_routing_item into ls_routing_item where plnnr = ls_routing_hdr-plnnr.

*                                                     and plnal = ls_routing_hdr-plnal.

         move-corresponding ls_routing_item to ls_display_op.

* Get BOM information ignoring alternative BOMs

         read table gt_mast into ls_mast with key matnr = ls_display_op-matnr.

         if sy-subrc = 0.

           ls_display_op-stlnr = ls_mast-stlnr.

           ls_display_op-bmeng = ls_mast-bmeng.

           ls_display_op-bmein = ls_mast-bmein.

         endif.

* Get Production version data

         read table gt_mkal into ls_mkal with key matnr = ls_display_op-matnr

                                                  werks = ls_display_op-werks

                                                  plnnr = ls_display_op-plnnr

                                                  alnal = ls_display_op-plnal.

         if sy-subrc = 0.

           ls_display_op-stlal = ls_mkal-stlal.

           ls_display_op-verid = ls_mkal-verid.

           ls_display_op-mdv01 = ls_mkal-mdv01.

         endif.

* Get the costing lot size and planned future prices

         read table gt_marc into ls_marc

         with key matnr = ls_display_op-matnr

                  werks = ls_display_op-werks.

         ls_display_op-mtart = ls_marc-mtart.

         ls_display_op-losgr = ls_marc-losgr.

         ls_display_op-zplp1 = ls_marc-zplp1.

         ls_display_op-zplp2 = ls_marc-zplp2.

         ls_display_op-zkprs = ls_marc-zkprs.

         append ls_display_op to gt_display_op.

       endloop.

     endloop.

     sort gt_display_op by matnr plnnr plnal plnkn.

Not what you were looking for? View more on this topic or Ask a question