on 01-19-2022 12:02 PM
Hello Experts,
The requirement is to prevent line item net value from being negative in sales orders.
For example by mistake, there are more discounts and the net value is being negative, in that case, we need to block the sales order or show the order in the incompletion log.
Please check and suggest.
Thanks and Regards,
Pankaj
Did you try with incompletion log ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pankaj,
Have you tried the "Plus/Minus" field on the Condition Type configuration in V/06 (under control data 1 section)? I am thinking on the lines of making that field "Positive" for the primary condition on the sales order. Lets try it out and see if it works for your requirement.
Thank you.
Kartik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can add logic to calculation type 2 which is used for Net Total on the pricing procedure. But in my opinion, a complete solution should include the config in my previous comment to make sure even condition value is not negative (unless you have a business reason to have a negative value for a primary condition type).
Thank you
Kartik
Technical but more flexible solution will be to implement a user exit with ABAP. In user exit, we add logic to check each item's net value and if it's minus we can display error message/add to incomplete log/block the item.
Below is my sample code and please follow the steps to implement it. The result will look like my screenshot. When the user click save button, the exit is triggered, the error message displayed and save action disallow. The user have to go back once to main screen and go into the item's condition tab to fix the price.
Steps: Go to SE38, go into program MV45AFZZ, find FORM USEREXIT_SAVE_DOCUMENT_PREPARE. Enable implicit exit and create a new custom enhancement at the first line of that form.
Add the following code and activate the enhancement.
You can ask your ABAPer if you have any questions, or you can let me know in the comment.
Similarly, you can add logic to add the message to incompletion log, which you can do by adding message row in XVBUV internal table in the exit.
"Check every sales items for the net value
LOOP AT XVBAP[] ASSIGNING FIELD-SYMBOL(<LW_XVBAP>).
IF <LW_XVBAP>-NETWR < 0. "If net value is minus
MESSAGE 'Negative net value not allowed' TYPE 'E'.
ENDIF.
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
mahajan_pankaj If you want to add the check to incompletion log, just add below code in the same enhancement spot(program MV45AFZZ, find FORM USEREXIT_SAVE_DOCUMENT_PREPARE.) It's working for me.
DATA:ls_tvuvf TYPE tvuvf.
"Check every sales items for the net value
LOOP AT XVBAP[] ASSIGNING FIELD-SYMBOL(<LW_XVBAP>).
IF <LW_XVBAP>-NETWR < 0. "If net value is minus
"Get incomplete procedure for net value
SELECT SINGLE *
FROM tvuvf
INTO ls_tvuvf
WHERE fehgr = tvap-fehgr
AND tbnam = 'VBAP'
AND fdnam = 'NETWR'.
IF sy-subrc = 0.
"Add to incompletion log
APPEND INITIAL LINE TO xvbuv[] ASSIGNING FIELD-SYMBOL(<xvbuv>).
<xvbuv>-mandt = sy-mandt.
<xvbuv>-vbeln = <LW_XVBAP>-vbeln.
<xvbuv>-posnr = <LW_XVBAP>-posnr.
<xvbuv>-tbnam = ls_tvuvf-tbnam.
<xvbuv>-fdnam = ls_tvuvf-fdnam.
<xvbuv>-fehgr = tvap-fehgr.
<xvbuv>-statg = ls_tvuvf-statg.
<xvbuv>-msgkz = ls_tvuvf-msgkz.
<xvbuv>-sortf = ls_tvuvf-sortf.
ENDIF.
ENDIF.
ENDLOOP.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.