cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Web Service - No error messages

ACORDERO
Participant
0 Kudos

Hi,

I've created a new custom BO and added a validation in script 'OnSave', this is very simple, when ELEMENT1 == "TEST" then throw an error message "TEST not valid" and return False. Afterwards I've created a Web Service to create, update and read this BO.

All the operations work fine but when I test my validation (sending ELEMENT1 = "TEST" in create or update operations), as expected, the entry is not created in the BO, but I do not get any error message, the Log element is always empty.

Why don't I get my custom error message in the response?

For standard validations, Log element contains the error message, for example:

         <Log>

            <MaximumLogItemSeverityCode>3</MaximumLogItemSeverityCode>

            <Item>

               <TypeID>015(/AP_ESI_COMMON/)</TypeID>

               <SeverityCode>3</SeverityCode>

               <Note>Instance with the same key (1605) already exists</Note>

            </Item>

         </Log>

Thanks,

Alejandro Cordero.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I believe it works.

The problem here is that the unique standard validation "Instance with the same key (1605) already exists" runs before your custom validations. That's why you cannot see it in the response.

Try creating an entry with a different key and see if your validations show up.



ACORDERO
Participant
0 Kudos

Hi Fernando,

Sorry, maybe I wasn't clear. I included that XML only to show that when there is a standard error the Log element is populated.

This is the response I get when I throw my custom error (the entry is not created).

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">

   <soap-env:Header/>

   <soap-env:Body>

      <n0:MyCustomBO_sync xmlns:n0="http://sap.com/xi/SAPGlobal20/Global" xmlns:prx="urn:sap.com:proxy:LFW:/1SAI/TA234234234234234234234:804">

         <Log/>

      </n0:MyCustomBO_sync>

   </soap-env:Body>

</soap-env:Envelope>

Thanks,

Alejandro.

former_member186648
Active Contributor
0 Kudos

Hi,

have you defined the error message at the BO like this:

businessobject raises Error_Message

{

message Error_Message text "TEST not valid";

...

Thanks, Pradeep.

ACORDERO
Participant
0 Kudos

Yes, I have.

And in my script, I'm using Error_Message.Create("E");


Thanks,

Ale.

Former Member
0 Kudos

Can you share your snippet?

Have you used "raise" before "Error_Message.Create("E");" ?

ACORDERO
Participant
0 Kudos

Hi Fernando,

That was the problem, I didn't use 'raise'!

So this works:

raise Error_Message.Create("E");

Thanks very much,

Alejandro.

Former Member
0 Kudos

It shouldn't be possible to activate the script file with such snippet without the "Raise" reserved word.

I had this problem in the past, took me some time to figure out what was wrong.

Answers (1)

Answers (1)

former_member186648
Active Contributor
0 Kudos

Hi,

I guess save messages won't be part of webservice response.

You could put the same validation in AfterModify.

Thanks, Pradeep.

ACORDERO
Participant
0 Kudos

Hi Pradeep,

When I throw the error in AfterModify or BeforeSave, I do not get any message in the response.

Thanks,

Alejandro.