06-29-2006 6:54 PM
Hello
Just wondering how can we terminate a program or return to the orginal screen from an if loop. I know there is this thing called EXIT, but it seems only quite the inner most loop, what should I do for quitting multiple loops?
Also, how to make an error message appear in like the pop-up instead of showing on the status bar at the bottom? thanks a lot!
Regards,
Anyi
06-29-2006 8:21 PM
err...is there such a structure like raise exception kind of thing in ABAP, I know there was one in JAVA. Thanks!
Anyi
06-29-2006 6:54 PM
Hi,
Use <b>STOP</b> Statement. Stop statement will make you to come out of a program where as an EXIT statement will make you to just come out of a loop.
Regards,
Santosh
06-29-2006 6:55 PM
stop. would bring you to the start of end of selection event.
exit. (inside an event, would terminate the program.
may be you can trigger multiple exits till you come out of the outermost of loops.
alternatively,
issue an error message
message e000(zz0.
regards,
ravi
06-29-2006 6:59 PM
hi anyi,
what should I do for quitting multiple loops?
use--EXIT.
how to make an error message appear in like the pop-up instead of showing on the status bar at the bottom
message e001(zz).
zz- message class
06-29-2006 7:09 PM
If error message and stopping the program are related
try issuing message type A to get popup screen and exit the program.
message A001(zz).
Regards
Sridhar
06-29-2006 8:06 PM
Err...a question following this thread. What if the error message is not standard? Say for example, the error message is "Anyi is too fat" and I want the process to continue? Thanks!
Anyi
06-29-2006 8:10 PM
Hi Anyi,
Error messages does not allow you to continue the process. If you need to continue your process just specify the message type as I (INFORMATION). This will let you to continue process and this also pop-ups as ERROR MESSAGE.
<b>MESSAGE I000(ZZ) WITH 'ANYI IS TOO FAT'.</b>
Thanks,
Vinay
06-29-2006 8:14 PM
hi Anyi,
Use Information Message in this regards as error message stops you from proceeding
<b>MESSAGE I100(ZI) WITH 'ANYI IS TOO FAT'.</b>
06-29-2006 8:21 PM
err...is there such a structure like raise exception kind of thing in ABAP, I know there was one in JAVA. Thanks!
Anyi
06-29-2006 8:23 PM
Hi Anyi,
You had RAISE statement in ABAP. But it only make sense with conjuction of Function modules only.
You can handle exceptions based SY-SUBRC value returned for your Function module.
Thanks,
Vinay
06-29-2006 8:30 PM
From Help. Only used in conjunction with function modules.
<i>
<b>
Raising Exceptions</b>
There are two ABAP statements for raising exceptions. They can only be used in function modules:
<b>RAISE <except>.
and
MESSAGE..... RAISING <except>.</b>
The effect of these statements depends on whether the calling program handles the exception or not. If the name <except> of the exception or OTHERS occurs in the EXCEPTIONS addition of the CALL FUNCTION statement, the exception is handled by the calling program.
If the calling program does not handle the exception
The RAISE statement terminates the program and switches to debugging mode.
The MESSAGE ..... RAISING statement display the specified message. How the processing continues depends on the message type.
If the calling program handles the exception, both statements return control to the program. No values are transferred. The MESSAGE ..... RAISING statement does not display a message. Instead, it fills the system fields SY-MSGID, SY-MSGTY, SY-MSGNO, and SY-MSGV1 to SY-MSGV4.
Source Code of READ_SPFLI_INTO_TABLE
The entire source code of READ_SPFLI_INTO_TABLE looks like this:
FUNCTION READ_SPFLI_INTO_TABLE.
*"------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(ID) LIKE SPFLI-CARRID DEFAULT 'LH '
*" EXPORTING
*" VALUE(ITAB) TYPE SPFLI_TAB
*" EXCEPTIONS
*" NOT_FOUND
*"------------------------------------------------------------
SELECT * FROM SPFLI INTO TABLE ITAB WHERE CARRID = ID.
IF SY-SUBRC NE 0.
MESSAGE E007(AT) RAISING NOT_FOUND.
ENDIF.
ENDFUNCTION.
The function module reads all of the data from the database table SPFLI where the key field CARRID is equal to the import parameter ID and places the entries that it finds into the internal table SPFLI_TAB. If it cannot find any entries, the exception NOT_FOUND is triggered using MESSAGE...RAISING. Otherwise, the table is passed to the caller as an exporting parameter.
</i>
Regards,
Rich Heilman
06-29-2006 8:37 PM
first clarify that are you using IF or LOOP.
IF is not a LOOP.its a conditional statement.
if you want to skip the processing from the START-OF-SELECTION event, use STOP command, which will go directly to END OF SELECTION if you write STOP in START-OF-SELECTION event.
check POP_UP* function modules in SE37, which will help you to display text in popup window.
whenever any error, call that function module instead of MESSAGE.
regards
srikanth.