Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

User Exitt for sales order processing (TKOMP)

satishgunda
Product and Topic Expert
Product and Topic Expert
0 Likes
5,382

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.

1 ACCEPTED SOLUTION
Read only

satishgunda
Product and Topic Expert
Product and Topic Expert
0 Likes
3,339

The problem has been solved by triggering the repricing in MV45AFZB, this will help the user to see the correct prices even before saving.

11 REPLIES 11
Read only

Former Member
0 Likes
3,339

Hi Satish,

Check if you can use

USEREXIT_SAVE_DOCUMENT inside MV45AFZZ in SO user exit.

Rgds,

HR

Read only

Former Member
0 Likes
3,339

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.

Read only

satishgunda
Product and Topic Expert
Product and Topic Expert
0 Likes
3,339

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.

Read only

satishgunda
Product and Topic Expert
Product and Topic Expert
0 Likes
3,339

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.

Read only

Former Member
0 Likes
3,339

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.

Read only

satishgunda
Product and Topic Expert
Product and Topic Expert
0 Likes
3,339

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.

Read only

0 Likes
3,339

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.

Read only

0 Likes
3,339

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.

Read only

satishgunda
Product and Topic Expert
Product and Topic Expert
0 Likes
3,339

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,

Read only

0 Likes
3,339

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 ***

Read only

satishgunda
Product and Topic Expert
Product and Topic Expert
0 Likes
3,340

The problem has been solved by triggering the repricing in MV45AFZB, this will help the user to see the correct prices even before saving.