cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Logic - Sales Document Item Check - Messages

sri_vishnu
Product and Topic Expert
Product and Topic Expert
0 Kudos
235

Hello Experts,

In Custom Fields Fiori app under Custom Logic, I implemented "Sales Item Check" BADI under Business Context Sales: Sales Document Item.

Purpose was to validate some Custom fields from Additional Data A tab on the Sales Order in the BADI in method CHECK_FIELDS

The way to raise an error message in this BADI method is to fill messages parameter table like below

 

append value #( messagetype = 'E' messagetext = 'Value missing for field YY1_FIELD_SDI.'  ) to messages.

 

 
The raised message then goes into VA01/VA02 log (accessed by clicking CTRL+SHIFT+F2)
 
sri_vishnu_0-1723601796044.png
 
The Log button on Clicking will show the error message like below

sri_vishnu_1-1723601987335.png

Now the issue I am facing is, even if the Error is corrected on the Item, the message in the log still remains. We can only append new message in the messages table of the BADI method but there is nothing in the documentation about how to remove an existing error message from the log

How, can we remove the message from the log once we find the error is resolved?

Best regards

 

 
 
View Entire Topic
AndreasMuno
Product and Topic Expert
Product and Topic Expert
0 Kudos

Thank you for your question, @sri_vishnu.

the code you shared shows you appended the error message table.

In the same way you probably have an "if condition then append error to error table" you would now need to remove that message when the condition is not met: 

LOOP AT messages WHERE messagetext = 'Value missing for field YY1_FIELD_SDI.'.
DELETE messages INDEX sy-tabix.
ENDLOOP.

If that solves your problem, please mark this question as resolved. Thank you.

AndreasMuno
Product and Topic Expert
Product and Topic Expert
0 Kudos
PS: For the end user, you may actually want to tell them the name of the field they see on the screen. That should be a business term, not a technical field name. You may also want to try tinkering with the so-called field status. If it allows managing custom fields you might find a status called 'mandatory' or something to that effect which automatically controls for user input being provided. #KeepEndUsersHappyAndProductive
sri_vishnu
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Andreas,

Thank you for taking time and responding, really appreciate it!

I already tried, what you suggested but it doesn't work

The thing is that the messages table parameter in Sales Document Item Check BADI method CHECK_FIELDS, that triggers for each item as soon as it is changed, always comes empty when the method is triggered (even if there are already messages in the Sales Order -> Log). So there is no error message to delete from it.

So this messages table parameter, in Sales Document Item Check BADI method CHECK_FIELDS, only allows inserting a message into the message log but there is no way to delete it

Second issue is that these error messages DON'T stop the Sales Order from getting saved as well!

On the other hand the messages table parameter in Sales Document Item Check Before Save BADI method, that triggers when Save button is pressed, clears the log automatically if we don't raise any error message and only shows error log, if we append an error message. It also stops the Sales Order from getting saved if we append error into messages table parameter

I believe this (not being able to clear errors and saving order even if there is an error in Sales Document Item Check BADI) is a product issue, you can replicate from your side

I will raise a note to SAP development team

Best regards,

Vishnu T