Thursday, February 11, 2010

SAP ECC6.0 : Auto Create SO (with ref Invoice)

A month more ago, I had undertook an assignment to modify a 3rd Party Commission report to be more dynamic and with the help of a functional along the way. That 3rd Party Commission had originally one type of reporting layout only. With the latest change, it has 4 types of reporting layout. One being able to automatic create Sales Order with reference to Invoice. The other 3 types of reporting will be just reporting only.  

What is more important in this entry that I had finally managed to full this assignment is the overall dynamics of automatic create Sales Order (SO) with reference to invoice. In order for this automatic creation of SO to work it requires a few implementation of User Exit, 2 routines (VOFM) and one customized table to control copy to procedure. The reason behind this requirement ie SO created with reference to Invoice must overwrite the Distribution Channel (VTWEG) checking in VA01; during the creation, SOLD-TO partner must be overwrite; line items in SO will be overwrite, MATNR, ARKTX and PSTYV (item category); and clearing the batch.
Therefore, the 3rd Party Commission report having the automatic SO creation is just a catalyst to fire-up a string of events in the process. The 3rd Party Commission's BDC just enter selected data in first screen, copy with reference is clicked, select first line item, and then clicked the save button. As I'd wrote 3rd Party Commission is just a catalyst so we will proceed to deeper discussion on the User Exits and Routines that will further fulfill this requirement.

Customize Table for copy-to-procedure control
Fields to consider control are VKORG, VTWEG, SPART, KUNNR, ICTP, MATNR, PSTYV, FKARV, and AUARN. Take special consideration on ICTP, IC meaning 2000 inter-company customers and TP meaning 1000 3rd party.

Routine : (VOFM-Copying Req-Orders)
In this part, I need to copy requirement Orders, routine 021, to modify the Distribution Channel (VTWEG) checking. Per standard, if SO being created with reference to Invoice have conflicting of VTWEG, it will display an error message. Therefore, routine 21 will be copied over and make the required changes to cater for Distribution Channel (VTWEG) checking. For a start, the customized table will be query against the VBRK's VKORG, VTWEG and SPART.

Routine : (VOFM-Data Transfer-Orders)
In this part, I need to copy requirement Orders, routine 003, to modify and update SOLD TO partners. As partners being copied SOLD TO, the SHIP TO and the rest will be deleted. Therefore, this routine is to control copying of partners of SO. Condition checking is similar Copying requirements of Orders.

User Exit : MV45AFZZ
1. USEREXIT_MOVE_FIELD_TO_VBAK
The purpose of this user exit is to update Distribution Channel (VTWEG) and update line item's Item Category (PSTYV). During this process, I looped XVBAP so its' line item's item category can be updated. However, there's one consideration to this point, customized table's KUNNR need to be check against KNA1 so to further validate ICTP field and KNA1's KTOKD. For example, if customized table's ICTP field is 'IC' and KNA1's KTOKD is '2000' meaning, PSTYV and VTWEG can be updated.

The above condition I wrote is only validated if VBAK-AUART and VVBRK-FKART matches customized tables' AUARN and FKARV. More important, I found out that for all this updates to be activated, there's this field called SVBAK-TABIX must be updated with a value '1'.

2. USEREXIT_MOVE_FIELD_TO_VBAP
The purpose of this user exit is to update MATNR, ARKTX, KWMENG, ZMENG, FKIMG, VTWEG_AUFT, and update item's position if Invoice is batch-split, and clear CHARG.

Condition for this user exit is similarly to USEREXIT_MOVE_FIELD_TO_VBAK.

There you have it, an automatic creation of SO with extra conditions in the background process. This implementation requires thorough understanding of SO creation. This is just one big part of the development.

You will need help from an SD functional who knows the whole concept of this implementation because there is a need to configure certain items especially allocation of certain item category that can be only use in this application. Therefore, functional and developer should work close with each other.

williamwilstroth... Invoice to SO in automation

No comments:

Post a Comment