I have the following scenario:
I must update field VBKD-VSART when the sales order is being saved. I am using include MV45AFZZ
.
If I write the following code in Forms USEREXIT_SAVE_DOCUMENT
, USEREXIT_SAVE_DOCUMENT_PREPARE
or USEREXIT_MOVE_FIELD_TO_VBKD
, it will lead to a short dump (Error POSTING_ILLEGAL_STATEMENT):
LOOP AT xvbkd ASSIGNING FIELD-SYMBOL(<ls_vbkd>).
<ls_vbkd>-vsart = '01'.
ENDLOOP.
Form USEREXIT_MOVE_FIELD_TO_VBKD
also does not work because action needs to be triggered only at saving the order.
Only way I managed to avoid the short dump is by writing the code in a enhancement in form USEREXIT_SAVE_DOCUMENT_PREPARE
, but the new value is not being saved!
In the same enhancement XVBAP
fields are being successfully changed, but not my XVBKD
field.
What should I do different?
The update indicator was initial.
Since the order quantity was changed, the update indicator was set automatically for XVBAP
, but for XVBKD
it had to be set manually:
LOOP AT xvbkd ASSIGNING FIELD-SYMBOL(<ls_vbkd>).
<ls_vbkd>-vsart = '01'.
IF <ls_vbkd>-updkz NE 'D' AND <ls_vbkd>-updkz NE 'I'.
<ls_vbkd>-updkz = 'U'.
ENDIF.
ENDLOOP.