Application Development and Automation 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: 
Read only

Issue Raising Error in a class

Former Member
0 Likes
1,136

Hi Experts,

I have created a static class which calls a BAPI to create job.

The way i am handling error message is as shown below:

   APPEND LINES OF lt_return TO et_message_log.->exporting parameter

   LOOP AT lt_return INTO lw_return WHERE type CA 'AE'.

   RAISE EXCEPTION TYPE cx_bapi_error
       EXPORTING

         status = lt_return.

ENDLOOP.

ET_MESSAGE_LOG is export parameter of the class.

This method is also used by workflow and the concerned person is saying that the method doesnt return an error because it isnt handling exceptions.

When i test the method in se24 it raises exception popup CX_BAPI_ERROR and when i close pop-up i am getting error in message log.

Is this the right way to raise exception ? I dont know why workflow cannot capture these errors.

Please advice,.

Hi Experts,

I have created a static class which calls a BAPI to create job.

The way i am handling error message is as shown below:

   APPEND LINES OF lt_return TO et_message_log.->exporting parameter

   LOOP AT lt_return INTO lw_return WHERE type CA 'AE'.

   RAISE EXCEPTION TYPE cx_bapi_error
       EXPORTING

         status = lt_return.

ENDLOOP.

ET_MESSAGE_LOG is export parameter of the class.

This method is also used by workflow and the concerned person is saying that the method doesnt return an error because it isnt handling exceptions.

When i test the method in se24 it raises exception popup CX_BAPI_ERROR and when i close pop-up i am getting error in message log.

Is this the right way to raise exception ? I dont know why workflow cannot capture these errors.

Please advice,.

5 REPLIES 5
Read only

dirk_wittenberg
Contributor
0 Likes
961

Hi,

please post the whole signature of the method.

Does this signature contain the exception CX_BAPI_ERROR ?

And you need only one RAISE-statement  outside the loop:

LOOP AT lt_return INTO lw_return WHERE type CA 'AE'.

  EXIT.

ENDLOOP.

IF SY-SUBRC EQ 0.


   RAISE EXCEPTION TYPE cx_bapi_error
       EXPORTING

         status = lt_return.
ENDIF.

Regards

Dirk

Read only

0 Likes
961

Hi Drik,

The signature do contain the exception CX_BAPI_ERROR.

OK. i can raise the statement once but will that help?

Read only

0 Likes
961

Hi

the exception will always be raised just once because the loop will be left the first time.

No it won't help, just makes the code cleaner.

The signature is ok. Does the task contain an exit corresponding with the exception?

Read only

0 Likes
961

I was expecting workflow to catch the exception raised from workflow class which i build.

But then i myself had to handle the exception and this was the problem.

Thanks all

Read only

RaymondGiuseppi
Active Contributor
0 Likes
961

How did you define exceptions and corresponding exception handlers in your Workflow  (Exceptions Tab Page) ?

Regards,

Raymond