I'm trying to create a Debit Memo Request when there is a contract. During this process, I want to change the vbap-mvgr1 field if it's a certain project type. I've tried almost all of the userexits in Include MV45AFZZ using xvbap. I've mostly tried userexit_move_field_to_vbap, userexit_save_document and userexit_save_document_prepare. In debug mode I see it change, but it doesn't change in VBAP. I was able to create code using the enhancement framework and it update the screen in va02, but it still didn't update VBAP. I'm not sure what else to try. It appears to be material driven and we're not changing the actual mvgr1 field in the material master, but we want to change it based on project type on the Debit Memo Request.
Here is sample code:
data: zzvbak like vbak.
data: zzprps like prps.
if vbak-auart = 'ZDRU'.
case xvbap-mvgr1.
when '006'.
select single * into zzvbak from vbak
where vbeln = xvbap-vgbel
and auart = 'ZPC'.
if sy-subrc = 0.
select single * into zzprps from prps
where pspnr = xvbap-ps_psp_pnr.
if zzprps-prart = 'AM' or zzprps-prart = 'ME'.
xvbap-mvgr1 = '102'.
elseif zzprps-prart = 'AD' or zzprps-prart = 'ND'.
xvbap-mvgr1 = '302'.
endif.
endif.
when '104'.
select single * into zzvbak from vbak
where vbeln = xvbap-vgbel
and auart = 'ZPC'.
if sy-subrc = 0.
select single * into zzprps from prps
where pspnr = xvbap-ps_psp_pnr.
if zzprps-prart = 'AM' or zzprps-prart = 'ME'.
xvbap-mvgr1 = '101'.
elseif zzprps-prart = 'AD' or zzprps-prart = 'ND'.
xvbap-mvgr1 = '301'.
endif.
endif.
endcase.
endif.
Instead of changing xvbap-mvgr1, try to change VBAP-MVGR1 in USEREXIT_MOVE_FIELD_TO_VBAP.
Add a comment