on 02-23-2006 5:39 PM
Hi all.
I have this problem... after some validation, some positions of the sales order must be either deleted or blocked. I'm trying to do this in user exit SAVE_DOCUMENT_REFRESH, in include MV45AFZA using the BAPI BAPI_SALESORDER_CHANGE. If i run the BAPI in se37, it makes all the modifications correctly, but when i run it in the user exit, it returns error V1 045 'Enter the document number'. The data passed to the BAPI is exactly the same in both cases, i even try putting a break point in the user exit, and on that moment ran the BAPI in se37, and it work out correctly. Did anyone ever had this problem?
I'm on SAP ECC 5.0
Are you in create mode(VA01) or change mode (VA02)?.
In most of the internal tables within SAPMV45A there is a field called UPDKZ that is used to control what happens to the record. This is espicially important in change mode. This field has to be set to:
'D' - Delete
'U' - Update
'I' - Insert.
It is also important with the user exits to manage both the X and Y internal tables. For example YVBAP should contain the data before the change and XVBAP should contain the record with the updated data.
Also, if you are trying to delete an item, you probably need to make sure that all of the data for that item is deleted - vbap, vbep, vbpa, etc.
Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chris. I've tried using the xvbap internal table and it worked out fine when i need to create a new record in vbep table, but when i want to delete an item in the sales order, i put a 'D' to the field xvbap-updkz, but it doesn't delete it. Is there any other field i should consider?
I'm usin USEREXIT_SAVE_DOCUMENT_PREPARE in MV45AFZZ.
Thanx!
I'm trying to do this while changing the order. This is the code in my user exit....
FORM userexit_save_document_prepare.
......
VALIDATION AND SELECT POSITION
......
xvbap-updkz = 'D'.
MODIFY xvbap INDEX sy-tabix.
LOOP AT xvbep WHERE posnr EQ xvbap-posnr.
xvbep-updkz = 'D'.
MODIFY xvbep INDEX sy-tabix.
ENDLOOP.
ENDFORM. "USEREXIT_SAVE_DOCUMENT_PREPARE
*eject
Jesus,
I have added some code to what you sent. The key to the below code is you need to append the Y tables before making modifications to the X tables.
One other thing. If this doesn't work try updating the YVBAP/YVBEP-UPDKZ field with 'D'. I forget if for deleting you need this in both tables or not.
INSERT THIS CODE
read table yvbap with key posnr = XVBAP-POSNR.
if sy-subrc ne = 0.
append xvbap to yvbap.
endif.
xvbap-updkz = 'D'.
MODIFY xvbap INDEX sy-tabix.
LOOP AT xvbep WHERE posnr EQ xvbap-posnr.
INSERT THIS CODE
read table yvbep with key posnr = xvbep-posnr
etenr = xvbap-posnr.
if sy-subrc ne 0.
append xvbep to yvbep.
endif.
xvbep-updkz = 'D'.
MODIFY xvbep INDEX sy-tabix.
ENDLOOP.
Chris
Hey Chris, thanx a lot! this is how i solved it...
xvbap-updkz = 'D'.
MODIFY xvbap INDEX sy-tabix.
READ TABLE yvbap WITH KEY posnr = xvbap-posnr.
IF sy-subrc EQ 0.
yvbap-updkz = 'D'.
MODIFY yvbap INDEX sy-tabix.
ENDIF.
LOOP AT xvbep WHERE posnr EQ xvbap-posnr.
xvbep-updkz = 'D'.
MODIFY xvbep INDEX sy-tabix.
ENDLOOP.
LOOP AT yvbep WHERE posnr EQ xvbap-posnr.
yvbep-updkz = 'D'.
MODIFY yvbep INDEX sy-tabix.
ENDLOOP.
Jesus,
Are you trying to change a different order with the BAPI then the one you are editing?
What you are trying to do is not clear. If you are trying to manipulate data in the current sales order you are working on, take a look at some of the other SAPMV45A user exits. For example you can manipulate data in subroutine USEREXIT_SAVE_DOCUMENT_PREPARE in program MV45AFZZ before the sales order is changed. For example if you want to block items you can loop at internal table XVBAP and set the appopriate blocks.
Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chris. Thanx for your reply...
I'm trying to modify the same order with the BAPI. I did try to use the USEREXIT_SAVE_DOCUMENT_PREPARE but it doesn't allow me to delete nor add a new position to the order. There are 3 things i have to do to the order, depending on a validation and a user choice:
1) Add a new Schedule line (Table VBEP) and block the current position (Field ABGRU)
OR
2) Delete the current position
OR
3) Do nothing
You <u><b>cannot</b></u> update the same order while in the same order using the BAPI. You don't have to. You are already in the sales order processing, why do you need to call another BAPI to change the same sales order? All you need is to modify the internal table xvbap and set the deletion indicator or add a record to xvbep internal table and remove the old one.
If this is happening after the order is created, you can simply write a program to take the user choices and call the BAPI. If you want to do this dynamically while creating and changing the order, then you need to use the MV45AFZZ.
Srinivas
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.