cancel
Showing results for 
Search instead for 
Did you mean: 

Raise exception in sap workflow

Former Member
0 Kudos

Hi,

I have a requirement in one of workflow step I am doing some sales order updates when update fails am using Raise statement like 'Raise Order locked'. i did debug my code is working and exception is triggering.

But when i see work item error log error says 'Person doesn't exist 1130016 P'.

1. why this error message is coming

2. why exception details are not displaying which i have raised

3. work item is getting fail but some of updates are getting save in database. I dont want to save the changes in database if any error occur.

Please suggest.

Thanks.

pokrakam
Active Contributor
0 Kudos

How are you:

Performing the update, catching the failure, raising the exception? And how is it handled?

Former Member
0 Kudos

In step, am using oo method. I have created exception(mail_not_sent) for the method in se24.

eg:

method step2.

------

update ztable from lt_tab

lf lv_update is good.

try

send email(importing ev_return = lv_return )

if lv_return = 4.

Raise Mail_Not_sent.

endif.

endtry.

endif.

endmethod.

I am doing Sales order update then sending email. if I get any exception while sending email I want to fail the work item and Sales Order changes should not save in the database.

Let me know if it is not clear.

Thanks, Awaiting response.

Accepted Solutions (0)

Answers (1)

Answers (1)

pokrakam
Active Contributor

There's still a lot of guessing with the pseudocode you provide, but from what I can see this is a straightforward ABAP issue. Please call it from a report and get it to work, then you'll be fin in WF.

A couple of hints:

- Use OO exceptions,

- If you're doing this in WF, I would separate distinct business operations. So posting and sending an email would be separate steps, this makes much clearer and is easier to troubleshoot.

- Regarding saving, you say you're updating a sales order but post pseudocode that your're updating a Z table, so we have no idea what you're really doing. There is no transaction or rollback, so updates are immediate.

Former Member
0 Kudos

-pseudocode I gave to clear the requirement, we have approval process workflow. Report is not an option to us.

-I am using oo exception only. If I raise exception 'Raise Order locked' work item is getting fail but error I see 'Person does not exist ****'.

-Separate steps I cant use, I already moved my workflow to production they do not want do so many changes. Only some meaningful exception they want me to add.

-I am updating sales order only just to make clear pseudocode code I just put z table.

But still I did not get my answer.

Thanks.

pokrakam
Active Contributor

Surely as a developer you should understand the importance of being precise?

Pseudocode is OK for a logic issue, but not for a technical problem. When describing an exception problem, telling us the correct exception type is vital. Writing about classic exception when you're really raising an OO exception doesn't help anyone to identify your problem and just wastes time of those who are trying to help you. The same goes for writing table update instead of the bit that you say isn't working.

Former Member
0 Kudos

Writing about classic exception when you're really raising an OO exception doesn't help anyone to identify your problem and just wastes time of those who are trying to help you

Ok, If I am not using the right approach what is the correct process to follow. Because I want to fail workflow based on my validations if workflow fails to understand others I need to add meaningful message to workflow log.

Please Advice.

Former Member
0 Kudos

I was trying to follow this.

https://blogs.sap.com/2013/04/25/use-exceptions-in-abap-oo-workflow-with-custom-text/

In the oo method added the exception CX_BO_TEMPORARY and in the method coding if my validation fails then I put the code like below.

RAISE EXCEPTION TYPE CX_BO_TEMPORARY EXPORTING textID = '002342DFG56FD98WKREW923S323'.

but I am getting warning messages as below. Please let me know am I following right process.

Old exceptions and class-based exceptions cannot be used at the same time.

The exception CX_BO_TEMPORARY is neither caught nor is it declared in the RAISING clause of "MEHOD_NAME****".

Awaiting for your response.