‎2006 Oct 17 9:44 AM
User exit is sales order processing where all the line item data in accessible before saving the sales order, before USEREXIT_PRICING_PREPARE_TKOMP..
Objective is to fill the Z field in the TKOMP structure(in the line item level) with a value which can be determined from seeing all the line items.ie.. All the line item data should be visible in processing a single line item.
for example , if i have 5 materials with
material Pricing Group Zcount
M1 PG1 3
M2 PG2 2
M3 PG1 3
M4 PG1 3
M5 PG2 2
in the above example , i've five line items (materials ) where M1,M3,M4 belong to one pricing group PG1 and M2 and M5 belong to another pricing group. Now As 3 materials belong to one PG1 , the respecive line items should be filled the count value 3 (3 materials belogn to PG1 ) .
and based on the TKOMP values (material,sales org,zcount) , my pricing conditions are maintained.
here , when i've entered 5 line items and press "enter", i want to populate the M1 line item with 3 in the form USEREXIT_PRICING_PREPARE_TKOMP, i could not able to caliculate the zcount as 3 as i'm able to access only one line item in TKOMP and one line item in XVBAP. so i cannot get the visibility of all the line items.
so we need the right exit for this requirement before
USEREXIT_PRICING_PREPARE_TKOMP where all the line item visibility is there.
‎2006 Oct 27 3:08 PM
The problem has been solved by triggering the repricing in MV45AFZB, this will help the user to see the correct prices even before saving.
‎2006 Oct 17 11:22 AM
Hi Satish,
Check if you can use
USEREXIT_SAVE_DOCUMENT inside MV45AFZZ in SO user exit.
Rgds,
HR
‎2006 Oct 17 4:26 PM
Hi,
Did you try putting item level data with needed count for individual line item in one internal table using 'USEREXIT_PRICING_PREPARE_TKOMP'& update xvbap before saving sales order(exit for save) using the new internal table ?
Thanks.
‎2006 Oct 17 4:36 PM
I cannot use USEREXIT_SAVE_DOCUMENT inside MV45AFZZ in SO user exit ,as i need to that before saving the document. ie.. when all the line items are entered and pressed enter ,for each line item, TKOMP_PREPARE is triggered and for calculating the zcount , all the line item data should be visible.
for example , if we have 5 line items in the order and i've entered 5 line item data and press "enter" , in the first interation , i'm able to see only the first line item data where i want all line item data to calculate ZCOUNT. this data is not availble either in TKOMP or XVBAP in the first iteration.
‎2006 Oct 17 4:40 PM
Hi Rushali , I'm not trying to update VBAP table but TKOMP table which has got a z field zzcount. but the value of zcount depends on the data of all the line item data which is not availabe when the item level data is accessed.
‎2006 Oct 17 8:13 PM
add your form to determine the vlaue of your field to SAPMV45A (to any include or userexit).
Then in userexit_pricing_prepare_tkomp just perform your_form(sapmv45a) using z_count. In this case XVBAP will be visible in your form.
‎2006 Oct 18 7:59 AM
Hi , actually in the TKOMP_PREPARE also , XVBAP is visible but suppose i i've five line items , in the first iteration of TKOMP_PREPARE , i'm able to see only one line item (ie.. first ) and in the second iteration , i'm able to see 2 line items and in final iteration , i'm able to see all the 5 line items.
but my requirement is in the first iteration itself , i should be able to all the line item data by which i can calculate the zcount for the TKOMP line item. I hope it is clear now.
‎2006 Oct 18 7:12 PM
You can try the following :
add the code to set your field to tkomp_prepare. Works fine only if all line items have different groups
add some code to userexit_save_document_prepare to call repricing in case if there are more than 1 item in the document with the same group... when you call repricing -> your code in tkomp_prepare will be triggered again and you'll have all items in xvbap at this point.
‎2006 Oct 18 7:15 PM
You can actually trigger your code in TKOMP_PREPARE only if repricing is called from save_document_prepare, just set the flag in save_document_prepare and check it in tkomp_prepare.
You have NO way to know in advance in VA01 for example how many items you are going to have in your sales order ... in save_document_prepare you have all items already.
‎2006 Oct 19 8:28 AM
Hi ,How do we trigger the repricing from save_document_prepare.
I could able to find the repricing only in MV45AFZB ,but its not triggering repricing,
‎2006 Oct 20 2:49 PM
HI Satish,
MV45AFZB
FORM USEREXIT_NEW_PRICING_VBKD CHANGING NEW_PRICING.
if vbak-auart eq 'ZTA0'.
new_pricing = 'C'.
endif.
ENDFORM.
For a specific order type you can trigger the repricing.
Hope this helps.
Reward if helpful ***
‎2006 Oct 27 3:08 PM
The problem has been solved by triggering the repricing in MV45AFZB, this will help the user to see the correct prices even before saving.