on 2023 Mar 20 4:03 PM
Hi there,
I´m new to the "BADI World", but I have an issue I´m trying to solve:
My Procurement Team wants a PO-Workflow, which only will be triggered AGAIN, when the price rises. I therefore implemented this code in BADI MMPUR_PO_WORKFLOW_RESTART:
DATA newPoValue TYPE P.<br> DATA newNetPriceAmount TYPE P.<br> DATA oldPoValue TYPE P.<br> DATA oldNetPriceAmount TYPE P.<br><br> workflowrestarttype = 'N'.<br><br><br> LOOP AT PURCHASEORDERITEM INTO DATA(N_PO_ITEM).<br> newPoValue = newPoValue + N_PO_ITEM-netamount.<br> newNetPriceAmount = newNetPriceAmount + N_PO_ITEM-NetPriceAmount.<br> ENDLOOP.<br><br><br> LOOP AT PURCHASEORDERITEM_DB INTO DATA(O_PO_ITEM).<br> oldPoValue = oldPoValue + O_PO_ITEM-netamount.<br> oldNetPriceAmount = oldNetPriceAmount + N_PO_ITEM-NetPriceAmount.<br> ENDLOOP.<br><br><br> IF newPoValue GT oldPoValue.<br> workflowrestarttype = 'R'.<br> RETURN.<br> ELSEIF newNetPriceAmount GT newNetPriceAmount. "If Net Amount for line item 1 is changed then Conditional Restart<br> workflowrestarttype = 'R'.<br> RETURN.<br>ENDIF.
The code itself works quite well. The Idea was: If the price rises, trigger again the workflow, in any other case --> proceed.
I also already tried to just put
DATA newPoValue TYPE P.<br> DATA newNetPriceAmount TYPE P.<br> DATA oldPoValue TYPE P.<br> DATA oldNetPriceAmount TYPE P.<br><br> workflowrestarttype = 'N'.<br>
as the only code, to see if it is the right BADI to achieve my goal, well, it didnt work.
Question:
We now have the issue, when the procurement manager enters the Order Confirmation for the PO, the Workflow will be triggered again.
How can I adjust that the Workflow of the PO will only be triggered (in case a OC is entered) when the price of the OC rises, but not in any other case?
Hi there I now found the solution.
First, these are my settings
And this is my code which solved it:
DATA newPoValue TYPE P.
DATA newNetPriceAmount TYPE P.
DATA oldPoValue TYPE P.
DATA oldNetPriceAmount TYPE P.
CASE workflowrestarttype.
WHEN 'R'.
LOOP AT PURCHASEORDERITEM INTO DATA(N_PO_ITEM)."loop all PO Items from the new state
IF N_PO_ITEM-purchasingdocumentdeletioncode <> 'L'."process item if not deleted
newPoValue = newPoValue + N_PO_ITEM-netamount."add the values of the position up
newNetPriceAmount = newNetPriceAmount + N_PO_ITEM-NetPriceAmount."save value of total order value
ENDIF.
ENDLOOP.
LOOP AT PURCHASEORDERITEM_DB INTO DATA(O_PO_ITEM). "loop all PO Items from the prior state
IF O_PO_ITEM-purchasingdocumentdeletioncode <> 'L'. "process item if not deleted
oldPoValue = oldPoValue + O_PO_ITEM-netamount. "add the values of the position up
oldNetPriceAmount = oldNetPriceAmount + N_PO_ITEM-NetPriceAmount. "save value of total order value
ENDIF.
ENDLOOP.
IF newPoValue GT oldPoValue. "If the total Purchase order has risen, than restart the workflow
workflowrestarttype = 'R'.
RETURN.
ELSEIF newNetPriceAmount GT newNetPriceAmount. "If the total NetPrice has risen, than restart the workflow
workflowrestarttype = 'R'.
ELSE.
workflowrestarttype = 'N'.
RETURN.
ENDIF.
ENDCASE.
I hope this helps others aswell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In our system I've found that the _DB parameters are supplied only with data for changed items, so your old PO value will only be correct if all items were changed.
I've resorted to a local class which selects from the database and then replaces/supplies with data supplied to the Business Add-In. I wish I had a better solution, but I haven't come up with one yet. Since there is no distinction (as far as I have been able to find) between an unchanged item and a new item in PURCHASEORDERITEM etc the _DB parameters can't be initialized from the other parameters.
User | Count |
---|---|
102 | |
9 | |
7 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.