cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

VL01N FIELD validation with Z_USEREXIT_SAVE_DOCEMENT causing error DBSQL_DUPLICATE_KEY_ERROR

vieet
Explorer
0 Kudos
820

Hi Gurus,
As per the business requirement , I have added custom field ZZETA to LIKP table along with screen enhancement using BADI LE_SHP_TAB_CUST_HEAD.
TR got moved to production and everything was working fine. Now the user asked me he needs validation before saving in VL01N for ZZETA which I have added.
I have done some research and implemented the implicit enhancement for USEREXIT_SAVE_DOCUMENT in MV50AFZ1 .

                                   
The following is the code used in the enhancement implementation.

vieet_0-1718298849174.png

I am just validating the custom field with empty ZZETA and the following message is getting displayed

vieet_1-1718298995258.png

So far it is fine.

Now I have inserted ZZETA date and saved. 

vieet_2-1718299168153.png

The document got saved.

When I closed the page the following page is getting displayed.

vieet_3-1718299262900.png

 From ST22 analysis,

ABAP programming error
DBSQL_DUPLICATE_KEY_ERROR
CX_SY_OPEN_SQL_DB
SAPLV05I
An exception has occurred in class "CX_SY_OPEN_SQL_DB". This exception was not
caught
in procedure "SD_PARTNER_UPDATE" "(FUNCTION)" or propagated by a RAISING
clause.
Since the caller of the procedure could not have anticipated this
exception, the current program was terminated.
The reason for the exception occurring was:
The reason for the exception is:
When an Open SQL array insert is performed, trying to insert a record
into the database table "VBPA" causes the function to terminate if a
record with the same key already exists.

The major concern here is though it is showing that Delivery of the product has been saved , it is not

getting updated in the LIKP table.



However, I am not working on VBPA table in this scenario. How to fix this error ?

Is that the code which is causing the issue, though there is no syntax error ? OR 

is this the wrong FM USEREXIT_SAVE_DOCUMENT I have used for validation ?

I am completely clueless now..............................Plz give me some hint how to proceed further.

 

Accepted Solutions (0)

Answers (1)

Answers (1)

Aukasz_SaBek
Active Participant
0 Kudos

Hi, 

i recommend to delete modification in USEREXIT_SAVE_DOCUMENT in MV50AFZ1 and implement BADI LE_SHP_DELIVERY_PROC. In method SAVE_DOCUMENT_PREPARE add Your check, and change type message to type E - Error not I - Information. This should solved Your problem. 

Ask a Question