Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Update VBKD-IHREZ field in MV45AFZZ Exit on price redetermination

Former Member
0 Kudos

Hello Experts,

I want to update VBKD-IHREZ with a value everytime I do update pricing in a sales order.

I am able to update VBKD-IHREZ while creating sales order.But when I change the same sales order and redetermine the price my logic in MV45AFZZ doesnot update VBKD-IHREZ.I have tried to put in logic in USEREXIT_SAVE_DOCUMENT and USEREXIT_MOVE_FIELD_TO_VBKD also but not able to update vbkd-IHREZ on price redtermination in a sales order.

Kindly provide me with your suggestion on how this can be achieved.

Thanks

Vijaya

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Can you place the logic, i will check it and try o help you

Regards,

Ravi

10 REPLIES 10

Former Member
0 Kudos

Hi,

Can you place the logic, i will check it and try o help you

Regards,

Ravi

0 Kudos

Logic is fine as it is updating correctly during CREATION of sales order.The problem is only when I try to change the sales order and update the pricing and then save,I expect to update VBKD-IHREZ with a new different value on change of sales order but it doesnot do the same.

0 Kudos

Your update to VBKD-IHREZ is not happening in change mode because of how SAP calculates the delta of changes to update in VA02.

There is no delta that needs to be calculated during creation mode so the update will happen during VA01 save

I will give you the solution to this when I can access my system where I have similar coding to achieve this.

0 Kudos

Thanks Vishnu...I shall be awaiting for your reply

0 Kudos

Hello Vijayalaxmi,

The below code should work in MV45AFZZ -> USEREXIT_SAVE_DOCUMENT_PREPARE. You can replace 'VALUE' with your own value that you want to assign to VBKD-IHREZ.


  FIELD-SYMBOLS: <fs_xvbkd> LIKE xvbkd.
  DATA: ls_yvbkd LIKE yvbkd.

* Sales doc is in creation mode
IF t180-trtyp = charh.
* Update VBKD header (posnr = 000000)
  LOOP AT xvbkd ASSIGNING <fs_xvbkd>
    WHERE updkz NE chard AND posnr = '000000'.
    <fs_xvbkd>-ihrez = 'VALUE'.
  ENDLOOP.
ENDIF.

* Sales doc is in change mode
IF t180-trtyp = charv.
* Update VBKD header (posnr = 000000)
  LOOP AT xvbkd ASSIGNING <fs_xvbkd>
    WHERE updkz NE chard AND posnr = '000000'.
*   Append Y-table and set update flag if necessary
    IF <fs_xvbkd>-updkz EQ space.
*   Save unchanged version of XVBKD to YVBKD
      ls_yvbkd = <fs_xvbkd>.
      APPEND ls_yvbkd TO yvbkd.
      <fs_xvbkd>-updkz = charu.
      upd_vbkd = charu.
    ENDIF.
    <fs_xvbkd>-ihrez = 'VALUE'.
  ENDLOOP.
ENDIF.

In change mode (t180-trtyp = charv = 'V'), YVBKD should contain unchanged data and XVBKD should contain the current data for the update to happen in the save document prepare user exit. The above logic ensure that it is the case when we change XVBKD-IHREZ. The above logic is as per the guide lines in SAP note 178328.

By the way it is a good practice to put this code in an INCLUDE within USEREXIT_SAVE_DOCUMENT_PREPARE.

Best regards

Vishnu T

0 Kudos

Ok...Thankyou very much.I will try this and let you know if it worked.

Moreover,I want to update IHREZ at item level not at header level.Will this work at item level also?

Thanks,

0 Kudos

If you look at the coding I was looping over XVBKD in both creation and change modes but restricting WHERE POSNR = '000000'. You can remove that WHERE clause like below to update both header (posnr = 000000) and items. Of course, if you want to assign different values for different items for VBKD-IHREZ, you need to retrieve the corresponding value within the LOOP on XVBKD

FIELD-SYMBOLS: <fs_xvbkd> LIKE xvbkd.
DATA: ls_yvbkd LIKE yvbkd.

* Sales doc is in creation mode
IF t180-trtyp = charh.
* Update VBKD header and items
  LOOP AT xvbkd ASSIGNING <fs_xvbkd>
    WHERE updkz NE chard.
    <fs_xvbkd>-ihrez = 'VALUE'.
  ENDLOOP.
ENDIF.

* Sales doc is in change mode
IF t180-trtyp = charv.
* Update VBKD header and items
  LOOP AT xvbkd ASSIGNING <fs_xvbkd>
    WHERE updkz NE chard.
*   Append Y-table and set update flag if necessary
    IF <fs_xvbkd>-updkz EQ space.
*   Save unchanged version of XVBKD to YVBKD
      ls_yvbkd = <fs_xvbkd>.
      APPEND ls_yvbkd TO yvbkd.
      <fs_xvbkd>-updkz = charu.
      upd_vbkd = charu.
    ENDIF.
    <fs_xvbkd>-ihrez = 'VALUE'.
  ENDLOOP.
ENDIF.

0 Kudos

Hi Vishnu,

I implemented this code and it worked successfully.Thanks a ton to you.Full Points to you.

Regds,

Vijaya

Former Member
0 Kudos

Hi Vijayalakshmi,

Which way you are going to update the VBKD-IHREZ for sale order update by using BDC or anything ?

Regards,

Chandrakumar S

0 Kudos

I am updating VBKD-IHREZ in MV45AFZZ program in the routines mentioned in my query above.