11-20-2007 8:04 PM
Hi All,
I am working on the module pool porgram.In module pool programming i have LOOP-ENDLOOP in PAI section, I have to exit from this loop with condition.
can anyone suggest any options in apab to do this.??
Quick response is appreciated.
Thanks ,
Sridhar
11-20-2007 8:08 PM
You can use the EXIT:
LOOP AT ITAB.
IF ITAB-MATNR IS INITIAL.
EXIT. " << to exit from loop
ENDIF.
ENDLOOP.
Regards,
Naimesh Patel
11-20-2007 8:28 PM
Hi Naimesh,
In PAI section of the module pool(In ECC6.0) IF ...ENDIF and Exit are not defined.so i will egt a message like "Statement "IF" is not defined. Check your spelling. spelling. spelling.".
this will not work.
Kindly let me know if any other options..!
Thanks,
Sridhar
11-20-2007 8:40 PM
I believe he meant you to put it in a module called from the PAI.
Rob
11-20-2007 8:50 PM
Hi rob,
I tried that also, but the code inside the module of PAI, it exit from the module in PAI only,not exit the loop.
still loop is running for all other records.
my requirement is to come out of the loop once the condition fails.
which is not happening in both the cases suggested.
Thanks,
Sridhar
11-20-2007 9:11 PM
OK - then put it in a form called from the module. I'm doing this in a program and it does work OK.
Rob
11-21-2007 6:39 AM
Are you talking of a LOOP / ENDLOOP in the flow logic (e.g. one around a table control), or one in the module pool around an internal table? If the former, then it will always loop as many times are there are lines showing in the table control on the screen, but you can prevent any logic being executed for lines after an exception is found by setting a global flag field e.g. something along the following idea:
" PBO
process before output.
module d9999_initialise.
" PAI flow logic for screen 9999.
process after input.
loop with control tc_9999.
module d9999_tc_pai.
endloop.
& then
module d9999_initialise output.
clear: g_hit_empty_line. "reset the bad data flag
endmodule.
module d9999_tc_pai input.
if g_hit_empty_line = 'X'.
exit. "perform no checks until next PBO
endif.
if some condition I want to test for is true.
g_hit_empty_line = 'X'. "process no more TC rows this PAI
exit.
endif.
* logic here for good lines until a bad one found
endmodule.
Jonathan
p.s. btw I wouldn't normally put any code in the modules except "performs" - I reckon it's a lot tidier having all your code in subroutines, not the modules.
11-21-2007 10:13 AM
hai,
try this
u need to write like this
loop at itab where......[condition]
......
endloop