‎2008 May 16 2:08 PM
Hi Friends,
I am using update statement to change LIPS field value.
I have used below code to change the field and it worked fine in dev server. But, in Q while delivery creation(VL01N), for update satement, sy-subrc is 4 and commit work is not happening. In VL02n it's working fine.
*LIPS-MTVFP = ZGL_VL10G_ATP-ZNEW_ATP.
update *LIPS.
if sy-subrc eq 0.
commit work and wait.
endif.
LIPS-MTVFP = ZGL_VL10G_ATP-ZNEW_ATP.
update LIPS.
if sy-subrc eq 0.
commit work and wait.
endif.
kindly suggest on this issue.
Thanks.
Bharat.
‎2008 May 16 2:21 PM
Hi
FIRST THING: don't change a value of std field directly, u shoudl use a BAPI or another std fm;
SECOND THING: NEVER NEVER NEVER call a COMMIT in a std transaction
Now if in VL01 you can't update the LIPS is because the record doesn't exist in database yet.
So u make sure the record u need to update is in database.
Max
‎2008 May 16 2:24 PM
Hello max,
the things is that the code worked fine in development server. it's giving problem in Q.
Thanks.
Bharat
‎2008 May 16 2:42 PM
Hi
I can only think if an UPDATE fails is because the record u want to update is not in db yet.
So u should give us more informations: for example which record u want to update: the item of the delivery u're creating by VL01N or another one?
Max
‎2008 May 16 2:49 PM
Hello Max,
I'm changing LIPS-MTVFP value based on some condition.
Earlier value of LIPS-MTVFP = 'Z3' and am chaning it to 'Z4'.
LIPS-MTVFP = .'Z4'
update LIPS.
if sy-subrc eq 0.
commit work and wait.
endif.
Thanks,
Bharat.
‎2008 May 16 2:53 PM
Ok
But where u're doing it?
In exit of VL01N?
and which are the keys of LIPS?
There's the delivery number (LIPS-VBELN) or not?
‎2008 May 16 2:56 PM
Yes, I'm using it in delivery user exit MV50AFZ1.
The key for LIPS is VBELN and it contain the value.
‎2008 May 16 3:08 PM
Hi
- I'm using it in delivery user exit MV50AFZ1
Are u using th exit USEREXIT_MOVE_FIELD_TO_LIPS?
- The key for LIPS is VBELN and it contain the value
Yes I know it, but which is the document? i.e it's the current document or another one?
Anyway if you try to update the current document u should consider when the exit USEREXIT_MOVE_FIELD_TO_LIPS (but also all exits defined in MV50AFZ1) is called the current delivery is not stored in db yet, so for trx VL01N it means there's no record to be updated in DB.
So the strange behavior is not for quality system, but it's for the dev system.
I think u shouldn't use the UPDATE statament but only u should move the new value, the system'll save it automatically as soon as the user presses save button:
IF LIPS-MTVFP = 'Z3'.
LIPS-MTVFP = .'Z4'
ENDIF.Now probably the problem is the std program replace your new value with the old one again, if it's so u should change the point where u move the value (try to use the exit (try to use the exit USEREXIT_SAVE_DOCUMENT_PREPARE).
Max
Edited by: max bianchi on May 16, 2008 4:09 PM
‎2008 May 16 3:25 PM
I have put my code in FORM USEREXIT_SAVE_DOCUMENT.
And the LIPS-VBELN is having delivery number which is going to be created.
‎2008 May 16 3:44 PM
Hi
It's ok, that explains why the statament UPDATE fails in that exit: here the delivery is not stored in db yet.
The exit USEREXIT_SAVE_DOCUMENT should be use only to store some data in additional custom tables, so it's not a good plave to change a value of delivery.
U should use the USEREXIT_SAVE_DOCUMENT_PREPARE instead of USEREXIT_SAVE_DOCUMENT, here u don't need any UPDATE statament: delete it from your code.
In this new exit u have to loop the internal table XLIPS and change here the value:
LOOP AT XLIPS WHERE MTVFP = 'Z3'.
XLIPS-MTVFP = 'Z4'.
* Check the flag for updating, it has to be:
* I for creating the items (so VL01N);
* U for updating the items (so VL02N)
IF XLIPS-UPDKZ IS INITIAL.
XLIPS-UPDKZ = 'U'.
ENDIF.
MODIFY XLIPS.
ENDLOOP.Max