Skip to Content
author's profile photo Former Member
Former Member

Creating Debit Memo Request and changing mvgr1 field in vbap

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on May 03, 2011 at 11:56 PM

    Instead of changing xvbap-mvgr1, try to change VBAP-MVGR1 in USEREXIT_MOVE_FIELD_TO_VBAP.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.