‎2009 Jan 27 8:08 PM
hie guys
i am looping at two internal tables and want to exit through an if statement when a condition specified is not met however the code exits both loops.
loop at itab1.
loop at itab2.
if itab2-value eq 0.
exit.
else.
process.
endif.
endloop.
endloop.
however its not behaving as such..i have tryed to use return statement but it still wont work. i have verified my entries and the conditions exist to be true for some entries ie itab2-value ne 0 but the program exists. please assist.
regards.
Isaac Prince
‎2009 Jan 27 8:13 PM
Hi,
Instead of EXIT statement you can move it to the where clause of the loop statement..
loop at itab1.
loop at itab2 WHERE value NE 0.
process.
endloop.
endloop.Thanks
Naren
‎2009 Jan 27 8:27 PM
hie Naren,
i also have some events during the loop like:
loop at itab1.
loop at itab2.
at new value.
process.
endat.
at last value.
add value to total_value.
endat.
endloop.
if total_value eq 0.
exit.
esle.
write values on screen.
endif.
endloop.
could the events be the cause??
‎2009 Jan 27 8:44 PM
Hello,
Since you have EXIT in the outer loop, control is coming out of both the loops.
loop at itab1.
loop at itab2.
at new value.
process.
endat.
at last value.
add value to total_value.
endat.
endloop.
if total_value eq 0.
exit. <----
Exit in outer loop
esle.
write values on screen.
endif.
endloop.
‎2009 Jan 27 8:37 PM
Hi,
If you have events..then you cannot use WHERE...
but in your last post...if you have mentioned the EXIT statement after the inner loop...that is the reason why it is exiting out of both the loops..
Thanks
Naren
‎2009 Jan 27 9:03 PM
YOU CAN USE IT
BUT THE SECOND TABLA MUS BE SORTED
LOOP AT T_DOCTOS_WORK.
T_DOCTOS_FINAL-BELNR_PAGO = T_DOCTOS_WORK-BELNR.
T_DOCTOS_FINAL-BUDAT_CONCILIA = T_DOCTOS_WORK-AUGDT.
T_DOCTOS_FINAL-BUDAT_PAGO = T_DOCTOS_WORK-BUDAT.
**********************************************************************
Se tratan las partidad del proveedor
**********************************************************************
READ TABLE T_DOC_BSIK_BSAK WITH KEY
AUGGJ = T_DOCTOS_WORK-GJAHR
AUGBL = T_DOCTOS_WORK-BELNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
INDEXK = SY-TABIX.
DO .
READ TABLE T_DOC_BSIK_BSAK INDEX INDEXK.
IF T_DOC_BSIK_BSAK-AUGGJ NE T_DOCTOS_WORK-GJAHR OR
T_DOC_BSIK_BSAK-AUGBL NE T_DOCTOS_WORK-BELNR OR
SY-SUBRC NE 0.
EXIT.
ELSE.
INDEXK = INDEXK + 1.
*MAKE YOUR CODE
ENDIF.
ENDDO.
ENDIF.
ENDLOOP
‎2009 Jan 27 9:27 PM
hi
thnx all you guys for yo contributions..Nareen i owe u..i would have to try yo suggestions wen in office 2mrw..points have been awarded..