Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8852

Re: AT Statement in Nested Loops

$
0
0

Hi,

 

The other alternative is that you loop at VBUP as you need to put 'AT LAST' statement for this loop and read the table for VBUK as below:

 

DATA: itab_vbuk TYPE STANDARD TABLE OF vbuk ,

          wa_vbuk   TYPE vbuk,

          itab_vbup TYPE  STANDARD TABLE OF VBUP,

          wa_vbup TYPE vbup.

 

DATA: counter TYPE i.

 

 

START-OF-SELCTION.

 

SELECT * FROM VBUK INTO TABLE  itab_vbuk.

if sy-subrc eq 0.

sort itab_vbuk STABLE BY vbeln.

endif.

SELECT * FROM VBUP INTO TABLE  itab_vbup.

if sy-subrc eq 0.

sort itab_vbup STABLE BY vbeln posnr.

endif.

 

LOOP AT itab_vbup into wa_vbup where wbsta = 'C'.

     READ TABLE itab_vbuk into wa_vbuk WHERE VBELN = itab_vbup-vbeln

                                                                         BINARY SEARCH.

     IF SY-SUBRC EQ 0.

         counter = counter + 1.

     ENDIF.

     AT END OF vbeln.

          WRITE counter.

          CLEAR counter.

     ENDAT.

CLEAR : WA_VBUP, WA_VBUK.

ENDLOOP.

 

Let me know if you need any more details.


Viewing all articles
Browse latest Browse all 8852

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>