2002mm Pur s4 PR Modify Item Badi
2002mm Pur s4 PR Modify Item Badi
2002mm Pur s4 PR Modify Item Badi
BADI: MM_PUR_S4_PR_MODIFY_ITEM
Logic:
if PURCHASEREQUISITIONITEM-PURCHASEREQUISITIONITEM = 10.
ENDIF.
**// ---For Account Assignment category = 'F'----- //
if purchaserequisitionitem-accountassignmentcategory = 'F'.
ENDLOOP.
ENDIF.
if purchaserequisitionitem-accountassignmentcategory = 'P'.
ENDLOOP.
ENDIF.
if purchaserequisitionitem-accountassignmentcategory = 'K'.
ENDIF.
Please find the below logic to check the Badi fucntionality works fine
Sample Logic:
Unloading point=”testbadiunload”
Steps:
In XT1:
MANUALLY ENTERD GL
PROPER ERROR: ERROR LIKE THIS EVENTHOUG H THIS COST CENTER IS PROPER .,
On click of order this error occur because: In the badi logic in custom field logic app: The gl account
should have 10 DIGIT VALUE.
Important:
EG: 10010000 (CURRENTLY IS IT S8) . SO IN THE BADI PREFIX IT WITH TWO MORE ZEROS.
SO IT WILL BE 0010010000
2nd error :cost center 2443455 was set in the logic as per 1st snapshot. Now on order since this cost
center does not exist the proper error message occurs.
Now the item description in the Badi was set to TESTITEM BADI
THE item description upon ordering of pr via badi. In the aove snapshot syuou can see the item
descriptio ssS Hello reema caring person and now it got changed to Test item badi on click of order
Material group change scenario in Item details:
As per the logic in Badi the material group was changed to =A001.
As per the Badi validation logic the Unloading point value is :TESTBADIUNLOAD
Also check them same in me 51n in xt1:
And the error occurs:Account10000 does not exisit in the chart of accounts
Scenario Badi logic
The Init; test item badi,pgrp:001,trackingno:L01,ial data entered by the user in me51n got changed
susccefully from values presetnin badi logic
[06-Nov-19 11:55 AM] Elsy Easow, Reema:
purchaserequisitionitemchange-purchaserequisitionitemtext = 'TESTITEMBADI'.
purchaserequisitionitemchange-materialgroup = 'A001'.
purchaserequisitionitemchange-PURCHASINGGROUP = '001'.
purchaserequisitionitemchange-STORAGELOCATION = '101A'.
purchaserequisitionitemchange-REQUIREMENTTRACK = '01'.
purchaserequisitionitemchange-DELIVERYDATE = '20091205'.
purchaserequisitionitemchange-PURCHASEREQUISITIONRELEASEDATE ='20091205'.
purchaserequisitionitemchange-PURCHASEREQUISITIONPRICE = '100'.
purchaserequisitionitemchange-PRICEUNIT = '10'.
Eg: text
2ND LOGIC:
purchaserequisitionitemchange-purchaserequisitionitemtext = 'TESTITEMBADI'.
purchaserequisitionitemchange-materialgroup = 'A001'.
purchaserequisitionitemchange-PURCHASINGGROUP = '001'.
purchaserequisitionitemchange-STORAGELOCATION = '101A'.
purchaserequisitionitemchange-REQUIREMENTTRACK = '01'.
purchaserequisitionitemchange-DELIVERYDATE = '20091205'.
purchaserequisitionitemchange-PURCHASEREQUISITIONRELEASEDATE ='20091205'.
purchaserequisitionitemchange-PURCHASEREQUISITIONPRICE = '100'.
purchaserequisitionitemchange-PRICEUNIT = '10'.
purchaserequisitionitemchange-SUPPLIER = '10300081'.
purchaserequisitionitemchange-FIXEDSUPPLIER = '10010000013'.
purchaserequisitionitemchange-PURCHASINGORGANIZATION = '1010'.
purchaserequisitionitemchange-PURCHASECONTRACT = '4500001370 '.
purchaserequisitionitemchange-PURCHASECONTRACTITEM = '00010 '.
purchaserequisitionitemchange-purordsuppliermaterialnumber = 'X'.
purchaserequisitionitemchange-PURCHASINGINFORECORD = '5300000000'.
Xt1:
By QTY BASIS :
By percentage
F-order:
By qt:
Wbs elemtn:internal incident raised
NetweorK:
By qty:
Percentage:
SSPP PR:
LOGIC:
2ND LOGIC:
lOGIC:
g/l:
44000000
Cost center:10101201
Cost center order created with : 65008400 as g/l and cost center as 10101602. PR
Now via MY pr : the values changed as per Badi logic to 440000000, 10101201
F: order:
The values should change to 65008400and order to 10000001 and successful change happene.d
In me 51n also upon entering the category as K and F the values get changed
Pr created:100003028
K by qty :
Percentage”: f order
K by pqty
F by percentage:
K by qty and k by percentage
Ssppr:
Test scenarios
https://support.wdf.sap.corp/sap/support/message/002075129400001168382020
Step1: We need to login to Proj_fin_controller/Welcome1!
Eg name : CXL200403-1
Step4: we can log to create pr app and enter p as account category
and get the internal id:00003583
Step5: now create another Wbs element with the last 8 digit of the external wbs element is the same as
that of the internal id of another wbs element
External Internal
CXL200403-1 00003583
CHECK00003583 00003590
Step6:Now we can log to administrator role and in custom field and logic app implement the badi for
MODIY ITEM BADI
Step7:
When the Badi is Published and there is no logic for Wbs element being active.
* if purchaserequisitionitem-accountassignmentcategory = 'P'.
* LOOP AT purchaserequisitionitemaccchng ASSIGNING <ls_acct> .
* <ls_acct>-glaccount = '0010010000'.
* <ls_acct>-wbselement = '00003583'.
* ENDLOOP.
* ENDIF.
STEP12:
SCENARIO2:
User in custom logic app in administrator makes the logic for Account category P active. (I,e the code is
not commented for project accoutnign category)
Note for gl account please prefix with two zeros prior to the gl number. For wbs element please enter
the internal id only .
if purchaserequisitionitem-accountassignmentcategory = 'P'.
LOOP AT purchaserequisitionitemaccchng ASSIGNING <ls_acct> .
<ls_acct>-glaccount = '0010010000'.
<ls_acct>-wbselement = '00003583'.
ENDLOOP.
ENDIF.
Step13;
Step14: now user navigate to the above create pr via MY PR APP and now as per the Badi logic we can
see that the values from the Badi wbselement = '00003583' pointing to CXL200403-1 will be present .
so since the badi logic is present the values form the Badi logic will take the priority .
So similarly the same scenarios can be tested for cost center , asset, internal order also .
if purchaserequisitionitem-accountassignmentcategory = 'P'.
LOOP AT purchaserequisitionitemaccchng ASSIGNING <ls_acct> .
<ls_acct>-glaccount = '0010010000'.
<ls_acct>-wbselement = '00003583'.
ENDLOOP.
ENDIF.
if purchaserequisitionitem-accountassignmentcategory = 'K'.
LOOP AT purchaserequisitionitemaccchng ASSIGNING <ls_acct> .
<ls_acct>-glaccount = '0010010000'.
<ls_acct>-costcenterbycocode = '0010101201'.
<ls_acct>-unloadingpointname = '1'.
ENDLOOP.
ENDIF.
if purchaserequisitionitem-accountassignmentcategory = 'F'.
LOOP AT purchaserequisitionitemaccchng ASSIGNING <ls_acct> .
* <ls_acct>-glaccount = '0051100000' . .
* <ls_acct>-ORDER = '000001000001'.
* <ls_acct>-glaccount = '0010010000' . .
* <ls_acct>-ORDER = '000001000020'.
ENDLOOP.
ENDIF.
purchaserequisitionitemchange-requestedquantity = 100.
purchaserequisitionitemchange-currency = 'USD'.
purchaserequisitionitemchange-fullname = 'SAPSAI'.
purchaserequisitionitemchange-addressstreetname = '123,KUNDALHALLI'.
Ce2105 scope:
Code:
*GOODSRECEIPTISEXPECTED
ELSE.
ENDIF.
*GOODSRECEIPTISNONVALUATED
ELSE.
ENDIF.
*INVOICEISEXPECTED
ELSE.
ENDIF.
*4. INVENTORYSPECIALSTOCKTYPE
ELSE.
ENDIF.
*5. CONSUMPTIONPOSTING
ELSE.
ENDIF.
ENDLoop.
The warnings are appearing because automatically the functionality in in such a way sthat GR AND
INVPOICE ASRE LWASY TICKETD IN ME 51N . THAT IS WHY ON ORDER IN SS PPR IF VALUE IS SET
WARNING OCCURS FOR THESE TWO FIELDS
FOR TOTHER THREE FIELDS VALUES ARE NOT SET AND HENCE ERROR MESSAGES APPEAR AS PER THE
CODE LOGIC
LOGIC::
UNCHECK ALL THE HTREE FLAAGS AND CHECK . NOW ALL FIVE FIELDS VALUES ARE NOT SET . WE
SHOULD GET ERROR
CASE3:
CASE3:UNCHECK GR NON VALUATED AND CHECK WARNING IS COMING
CASE4:IF WE CHOOSE gr non vluated to be set then we also have to set mandatorily the GR field as well ,
else we get FI error
Now use case for checking value is set and w
INVENTORYSPECIALSTOCKTYPE
CONSUMPTIONPOSTING
Now In modify Badi reema has set the value for INVENTORYSPECIALSTOCKTYPE and
CONSUMPTIONPOSTING WITH A VALUE
So on editing the pr we will get for these two fields warning message (value is set)
User while creating the pr unchecks the flag for the three fields
Now modiufy badi code is written to ensure value is set for tehse three fields
Now we can see that the value for all three fields are set (logic hits modufy badi)
Code:
if PURCHASEREQUISITIONITEM-PURCHASEREQUISITIONITEM = 10.
purchaserequisitionitemchange-GOODSRECEIPTISEXPECTED = 'X'.
purchaserequisitionitemchange-GOODSRECEIPTISNONVALUATED = 'X'.
purchaserequisitionitemchange-INVOICEISEXPECTED = 'X'.
purchaserequisitionitemchange-INVENTORYSPECIALSTOCKTYPE = 'T'.
purchaserequisitionitemchange-CONSUMPTIONPOSTING = 'A'.
ENDIF.
Use case2:
Now after ordering and in display we can see that the three fields are unchecked.
if PURCHASEREQUISITIONITEM-PURCHASEREQUISITIONITEM = 10.
purchaserequisitionitemchange-GOODSRECEIPTISEXPECTED = ''.
purchaserequisitionitemchange-GOODSRECEIPTISNONVALUATED = ''.
purchaserequisitionitemchange-INVOICEISEXPECTED = ''.
purchaserequisitionitemchange-INVENTORYSPECIALSTOCKTYPE = 'T'.
purchaserequisitionitemchange-CONSUMPTIONPOSTING = 'A'.
ENDIF.
The ocde now sees the modify badi
So this not set value is picked up by check badi and throws not set