Application Development 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: 

user exit for sales order

former_member496861
Participant
0 Kudos

Hi all,

I need to add a new field to show Gross Profit % into the front screen where the line item subscreen is.

Would anyone know which userexiit to use to get all the values to calculate gross profit % for each of the item ?

thanks

Joyce

1 ACCEPTED SOLUTION

tushar_shukla
Active Participant
0 Kudos

Joyce,

You can add a custom item level field in 'Additional Data B' screen; for this modify the screen 8459 of SAPMV45A . You need to also add this new field in VBAP table, for this you can add a append structure to VBAP table . This is a modification, and if this screen is being modified for first time in your system, you would require modification key .

Check the OSS note 302497 also if you face any issue .

You can write your logic in Subroutine 'USEREXIT_MOVE_FIELD_TO_VBAP' of program MV45AFZZ .

In this subroutine global internal table and structures are available .

Internal table

XVBAP - current changes

YVBAP - Before changes / Database state

VBAP - data of current line item being processed .

-Tushar Shukla

16 REPLIES 16

Former Member
0 Kudos

Are you talking about the screens which show the different views of item data? lots of possibilities in MV45AFZ* includes, including everyplace there's an opportunity to update XVBAP. I'd look for the subroutines that reference VBAP, but I think you'll have to look up the cost for materials from MM master data.

Interesting concept...all sorts of possibilities/problems come to mind, price changes, cost changes, rejected line items, partial deliveries when cost/price changed, etc. Can't help but wonder why this wouldn't be reported for deliveries or invoices, instead of displayed on the order?

0 Kudos

Hi Breakpoint,

The screen with tab 'Item Overview' is where i will add the new field. To determine min gp%, i would need to get moving avg cost which is in the condition tab. However, i need to find the right exit to get all the price and cost associated for the item,

thanks

Joyce

tushar_shukla
Active Participant
0 Kudos

Joyce,

You can add a custom item level field in 'Additional Data B' screen; for this modify the screen 8459 of SAPMV45A . You need to also add this new field in VBAP table, for this you can add a append structure to VBAP table . This is a modification, and if this screen is being modified for first time in your system, you would require modification key .

Check the OSS note 302497 also if you face any issue .

You can write your logic in Subroutine 'USEREXIT_MOVE_FIELD_TO_VBAP' of program MV45AFZZ .

In this subroutine global internal table and structures are available .

Internal table

XVBAP - current changes

YVBAP - Before changes / Database state

VBAP - data of current line item being processed .

-Tushar Shukla

0 Kudos

Hi Tushar,

I would like to add the new field on the tab 'Item Overview' screen. I will try if the usrexit you mentioned would have the price and cost i am looking for.

thanks

Joyce

0 Kudos

Joyce,

You can get the condition data from global internal table XKOMV . You can find all the global data available in Globals tab of variable in New debugger .

-Tushar

0 Kudos

Hi Tushar,

Some condition from xkomv does not get its full price until much later. This is the concern i have that the exit may not be able to pick up the full price or cost.

thanks

Joyce

0 Kudos

Joyce,

Check the subroutine 'userexit_pricing_prepare_tkomp' of same program . This may be called several times, check the behavior during debugging .

0 Kudos

hi Tushar,

The subroutine tkomp may be a possibility .

thanks for your help.

Joyce

0 Kudos

I don't think that exit is a good approach for your requirement. That's the exit for populating comm fields BEFORE pricing is called for a particular item, not after. And, although there is recursive processing, you're still catching it before, not after, function PRICING is called every time. As BreakPoint indicated, there are multiple attack points that need to be considered and it's not easily done. You may need to consider an implicit enhancement in routines PREISFINDUNG or VBAP_BEARBEITEN_ENDE in addition to using USEREXIT_READ_DOCUMENT during document entry. I don't know what your calculation is, but your other options are to embed the gross profit value in a (statistical) subtotal field in your pricing procedure and display that field or force the percentage in a subtotal field and display that field (either one would be calculated via pricing formula). I still agree with BreakPoint, though; this is something more easily reported-on, not forced into the Overview screen.

0 Kudos

Hi Brad,

Thanks for your good clarification. Yes, i do need to get the final pricing. In routines Preisfindung or vbap_bearbeiten_ende, what kind of changes i need to add in the implicit enhancement ? How would the changes be relate to using UserExit_Read_Document ?

The GP cal of an item is using net value - total cost.

In the other option, if there is subtotal field embedded in pricing procedure, then it would be easier to use one of the userexit , right ?

thanks

Joyce

Edited by: Joyce Chan on Nov 12, 2010 3:21 PM

Edited by: Joyce Chan on Nov 12, 2010 3:22 PM

0 Kudos

I think you need to go with a subtotal field - with a subtotal field you don't need a user exit at all because the field value is calculated everytime the pricing is calculated and stored. The problem is rendering the value on the screen if you really need to do that. Not only do you need to determine the gross profit value, but you have to know the resulting percentage as well and stick that in a field so that it can be displayed (it is not sufficient to use a single calculation and store the % in the rate field because it still needs to be pulled out into a field that can be displayed on screen). I would try to set up two statistical conditions in your pricing procedure - one for gross profit and one for gross profit % with the % field being stored in a subtotal field (1-6 or additional custom subtotals). Calculate both values via pricing formula - use the resulting VBAP field to show the % value.

0 Kudos

Hi Brad,

Why do i have to set up statistical condition in my pricing procedure ? Can it be non-statistical condition ?

thanks

Joyce

0 Kudos

Statistical conditions are used for information purposes and do not affect the value of the item...

0 Kudos

Hi Brad.

Where would i create the custom subtotals that are in pricing procedure ?

Thank you for all good suggestions.

Thank you to everyone who replied. These are informative.

Joyce

Edited by: Joyce Chan on Nov 13, 2010 1:17 PM

0 Kudos

Are you using subtotals 1 - 6 already (see the subtotal column of your PP)? If you need additional ones, you can add fields via append strucs in VBAP/KOMP, e.g., 'ZZWI7'. You can dump condition values directly in the new fields using a calculation type formula:


add xkwert to komp-zzwi7.

Or you can accumulate values into a statistical subtotal using other work fields available (such as 'XWORKF' (subtotal 'F') and grab the values for the new field in a calculation formula:


komp-zzwi7 = xworkf.

Be sure to initialize any new fields in USEREXIT_XKOMV_BEWERTEN_INIT in RV61AFZB.

0 Kudos

Hi Brad,

I am using one of the subtotal 1-6. I was thinking of assigned a subtotal to the GP field but the subtotals are already used up.

I guess one cannot create new subtotal but instead add field via the append strucs as you stated.

Thank you so much for your help. Appreciate it,

Joyce