‎2009 Dec 03 5:59 PM
Hi,
I want to poulate item catagory which is there In vbap-pstyv field based on order reason. these order reason will keep on changing while creating the order or changing based on this the corresponding item catagory should display.
Please suggest any user exits or badi's or others.
Ex : if the order reason = 'shiipping'.
vbap-pstyv = 'ZOR'.
ENDIF.
I have written the code in sales order user exit MV45AFZZ ( Move_filds_vbap ) It is not working.
‎2009 Dec 03 8:29 PM
been a while since I did this, but I think you need SAVE_DOCUMENT_PREPARE subroutine....there I'd modify the contents of VBAP or XVBAP...I've forgotten which SAP supplies at that point. If XVBAP, YVBAP would contain prior to changes data.
‎2009 Dec 03 11:44 PM
No, you should not use USEREXIT_SAVE_DOCUMENT_PREPARE for switching item categories or any other field that affects pricing or other item critical processes. There is no re-pricing determination at that point (or re-determination of other critical values) unless you stop the process and force it manually. You should also not change values of fields that are critical to the document behind-the-scenes because the user never knows that it happens.
As for using order reason to determine item category, it's not a very good idea unless you restrict the changing/setting of the value and then use USEREXIT_SOURCE_DETERMINATION to set the value as the line items are entered. This user exit is specifically provided for complex planta and item category determination logic.
I don't understand why the order reason would change during the creation of the document and as line items are entered - the order reason value should be constant and known by the user before entering the document. I would look into using a different order type which drives the item category determination via configuration, use the user exit above (only after the order reason has been finalized), or use a front-end to make all determinations beforehand and then create the order via the BAPI call. This is a common approach for complex order entry.