cancel
Showing results for 
Search instead for 
Did you mean: 

Checking for errors before saving in CRMD_ORDER

Former Member
0 Kudos

Hi,

I have a requirement where I need to check if any errors exist before being able to save a document in t-code CRMD_ORDER. If any error exists, then user should not be able to save the document.

Currently, if even if errors exist, the user is able to save the document. But this should not be allowed.

I searched for BADI for this and found method CHECK_BEFORE_SAVE in BADI ORDER_SAVE. But not sure of how to check if errors exist. Can someone please guide me on how to do this?

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

khalil_serrhini
Contributor
0 Kudos

Hi Manvi,

I have two different options for you to gte the info you need !

Well first i would like to confirm you that the Badi you re trying to use is the right one. You can raise an error and cancel saving in case you want. And then, well you can either check dirrectly in a table or using a call function see if ticket is flagged on error

1 - Using table: In table CRM_JCDS or in table CRM_JEST if for guid of your ticket you have an entry with stat = I1030 and flagged to INACT = ' '; then the ticket contains at least one error

2 - Using call function:

call function 'CRM_STATUS_CHECK'

exporting

objnr = lv_guid

status = 'I1030' " = gc_status-error (CRM_STATUS_CON)

exceptions

object_not_found = 1

status_not_active = 2

others = 3.

PS: in Order to get the guid of your ticket you can use table crmd_orderadm_h. Using ID of ticket you ll be able to retrieve guid corresponding to it

Hope this helps

Regards,

Khalil

Former Member
0 Kudos

Thanks Khalil for your reply. But the issue is that I can retrieve the status only after the document has been saved to the DB. But I want to know check for errors when the document is created and prevent saving if errors are present.

I have been able to find a FM CRM_MESSAGES_CHECK_FOR_ERRORS which gives an exception 'ERRORS_EXIST' if errors are present. But now the issue is that I am unable to take the user back to the screen to modify/change the data. That is that if there are errors present, then the user should be taken to the same screen to make changes and try saving again. Hope you understand the issue and can provide a solution.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

It was my requirement also, I wanted to make Change Manager , Category , Priority and Ibase/Component fields mandatory & if they didnt enter anything it shouldn't allow the user to save / create CR. In customizing even if you do atleast one change manager required like that also, it will generate the CR but there will be an error msg.

What we did here is using SHD0 transaction create a screen variant & there make these fields as mandatory, so w/o those fields it will not allow u to save the CR doc

regds,

Kallu

Former Member
0 Kudos

Hi,

Thanks for your reply. The issue is that even if the mandatory fields have been entered by the user, there may be certain other errors like which may arise due to incorrect data. In that case also, the user should not be able to save in CRMD_ORDER.

Please let me know if you have any solutions for the same.

Thanks