Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

EXIT FROM THE PROGRAM

Former Member
0 Kudos

HI,

I am checking one condition inside the loop

like

if v_filedata ne v_lines .... that means here i am comparing the number of records in the file and the number of records read... if those are not equal then i have stop processing by giving some error message i have to come out of the program

can anyone guide me how to do that?

SRI

7 REPLIES 7

Former Member
0 Kudos

if v_filedata ne v_lines.

Message '<your mesage here>' TYPE 'E'.

ENDIF.

Regards,

Sudhir Atluru

0 Kudos

SUDHIR,

does it stop the further processing of the program.....

without any exit statement....

0 Kudos

Sri,

You can use <b>EXIT</b> command to exit from the loop...

Chandra.

0 Kudos

I have to stop the program completly from the further processing......

0 Kudos

Yes issuing an error message will stop further processing of the program. But remember that a message is typically intended for online execution. But if the same program is executed in the background, then the background job will go to a cancelled status when you issue an error message. You will see the message itself in job log. WRITE statements will go to the spool but MESSAGE statements will be seen in job logs.

But in both cases, any further processing will be stopped immediately. If you want to write message to the spool and still achieve the same result, you can always keep a flag to inform that an error occured and check if this flag is set in the rest of the processing.

loop at itab.

if error condition met.

flag = 'E'.

exit.

else.

flag = 'S'.

endif.

endloop.

if flag = 'E'.

write:/ 'Error occured'.

exit.

endif.

Former Member
0 Kudos

Since you want to use error messages also, I would recommend that you use Exception Objects, which can easily be caught by the calling program.

RAISE EXCEPTION TYPE your_exception_object

  • EXPORTING

  • textid =

  • previous =

  • msgid =

  • msgno =

  • msgty =

  • msgv1 =

  • msgv2 =

  • msgv3 =

  • msgv4 =

.

Christian

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please use STOP statement to exit/stop the progam.

Regards,

Ferry Lianto