cancel
Showing results for 
Search instead for 
Did you mean: 

Z-field in Additional data B not updated by modifying XVBAP from MV45AFZZ

csayak
Explorer
0 Kudos
758

Hello All,

I am trying to update the value of a z-field in Additional data B tab based on the user status selected by an user.

Requirement:

When an user changes the user status (from 'A' to 'B') for a line item from the Status tab in a Sales Order and SAVES the Order, the value of a Z-field (X) present in the Additional data B tab of the same line item should be removed.

I have written my logic by creating an enhancement in the FORM USEREXIT_SAVE_DOCUMENT_PREPARE of the include program MV45AFZZ.

Logic applied:

For every line item in XVBAP and for the respective object number (OBJNR) the user status is read using the FM STATUS_READ.

Now, if the STATUS is Equals to 'B', the value of the Z-field (X) for the respective line item in XVBAP has been cleared and XVBAP has been modified with blank value.

Issue:

Even after.modifying XVBAP, the value is not getting updated and the Z-field (X) continues to have the same value while the user status already got updated from 'A' to 'B'.

Can anyone suggest anything regarding this issue?

csayak
Explorer
0 Kudos

Hello SAP Community,

Can someone please response, if this is known?

venkateswaran_k
Active Contributor
0 Kudos

Please provide the code you have written under this FORM USEREXIT_SAVE_DOCUMENT_PREPARE.

While updating, please use the code option provided in the window. That will give us the facility to read the code perfectly,

Tomas_Buryanek
Active Contributor
0 Kudos

Are you changing xvbap (structure) or xvbap (internal table) values?
It should be internal table what you need to change.

csayak
Explorer
0 Kudos

tomas.buryanek I have first modified the work area (XVBAP) and then using that have modified the internal table (XVBAP).

csayak
Explorer
0 Kudos

venkateswaran.k - Here you go...

IF ( sy-tcode EQ lc_tcde ) AND "tcode:VA02

( idoc_edidc-docnum IS INITIAL ). "Not triggered through IDOC

IF xvbap[] IS NOT INITIAL.

LOOP AT xvbap.

CALL FUNCTION 'STATUS_READ'

EXPORTING

objnr = xvbap-objnr

only_active = 'X'

TABLES

status = lit_stats

EXCEPTIONS

object_not_found = 1

OTHERS = 2.

READ TABLE lit_stats WITH KEY stat = lc_B TRANSPORTING NO FIELDS.

IF sy-subrc EQ 0. " If status changed to 'B'

xvbap-z1 = 0.

xvbap-z2 = ' '.

MODIFY xvbap TRANSPORTING z1 z2.

ENDIF.

ENDLOOP.

ENDIF.

ENDIF.

csayak
Explorer
0 Kudos

I made few observations...

As per the requirement, the user will be changing the Status (from 'A' to 'B') from the Status tab in the item level of the Sales Order. So, in XVBAP the update flag (updkz) is not 'U' and this is why no values are getting modified even after my code is executed during SAVE operation.

When any changes are made in the Sales Order (VBAP), XVBAP contains the line item details with the changed values (along with UPDKZ = 'U') and YVBAP contains the old values.

So, I was wondering if I can copy the line from XVBAP to YVBAP and append it to YVBAP internal table and then modify XVBAP with UPDKZ as 'U' and Z fields as '0' and ' ' respectively.

But I am not sure if I should be doing this, as I am aware XVBAP & YVBAP are constantly compared during the entire SAVE operation and making any changes might cause a problem later... Confused again..!!!!!

Accepted Solutions (0)

Answers (1)

Answers (1)

venkateswaran_k
Active Contributor
0 Kudos

Hi

Please put a break point in this exit and include and see if it is trapped in save. You can put your code there and see if it stops there.

Include : MV45AFZA


USEREXIT_REFRESH_DOCUMENT

Regards,

Venkat

venkateswaran_k
Active Contributor
0 Kudos

csayak

Did you check this exit?

csayak
Explorer
0 Kudos

Yes, I did check this.. but then I also made some observations. My code was not working as XVBAP did not have the updkz field as 'U' as the user is only changing the status from 'A' to 'B' in this case. So, even when I am putting my code in USEREXIT_REFRESH_DOCUMENT, it is not updating the values in the Sales Order.