on 11-04-2010 10:52 PM
SRM gurus,
We are upgrading the SRM from 4.0 to 7.0.
In SRM 4.0, we used BADI BBP_DOC_CHANGE_BADI to modify the shopping cart values.
In SRM 4.0, this BADI have all the data for all line items of shopping cart imported at the same time for modify.
In SRM 7.0, this BADI only have the current line item passed into this BADI and not even all the data for the current line item are available at the same time.
Is there a better BADIs or enhancements or any other methods in SRM 7.0 that I can manipulate all the line items in the shopping cart at the same time?
Thanks in advance!
Fisher Li
It is possible to use this BADI to do this, you just have to do a couple extra steps to get all the data. The IT_ITEM parameter in the BADI will contain the information for the item you are currently working with. For all the other items on the shopping cart, you will need to make a call to function module BBP_PD_SC_GETDETAIL. All the other items for the shopping cart will be contained in the E_ITEM output parameter of that function. You can then manipulate the item data however you want and just add the records to the ET_ITEM output table of the BADI.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Seth,
Thank you very much for your input.
What I tried to do was that if I did not enter preferred vendor for line items 1 to 10, after I entered a preferred vendor for line item 11, I wished I could use this badi to automatically populate the same preferred vendor for line item 1 to line item 10 without manually going back to edit the data one by one.
I can do that in SRM 4.0 but I can not do that in SRM 7.0.
I tried your way and it seemed that the BADI will not change any data beyond the current line item.
Best regards,
Fisher
Hi Fisher,
It sounds like you are trying to do something similar to what I used DOC_CHANGE_BADI to do. I used it to set a default vendor across all items that did not have a vendor set already. You should be able to use this BADI to change any of the items on your shopping cart by appending the item line to the output parameter, ET_ITEM, whether the item record comes from IT_ITEM (the current item) or from the call to BBP_PD_SC_GETDETAIL.
Can you post the code of your implementation?
Seth,
Here is the codes that I tried.
Again, the SRM version is 7.0.
CALL FUNCTION 'BBP_PD_SC_GETDETAIL'
EXPORTING
I_GUID = IS_HEADER-GUID
I_WITH_ITEMDATA = 'X'
TABLES
E_ITEM = SC_ITEM
E_ACCOUNT = SC_ACCOUNT
E_PARTNER = SC_PARTNER.
LOOP AT IT_ITEM INTO LS_IT_ITEM.
Check if any line item other than the one being edited is free text line item
LOOP AT SC_ITEM INTO LS_SC_ITEM WHERE NUMBER_INT <> LS_IT_ITEM-NUMBER_INT
AND CATALOGID = ''
AND CATALOGITEM = ''
AND DEL_IND IS INITIAL
AND BE_OBJECT_ID IS INITIAL. " No purchase req created yet
Free text line item found
Check if preferred vendor has been entered for this line item
LOOP AT SC_PARTNER INTO PF_PARTNER WHERE P_GUID = LS_SC_ITEM-GUID
AND PARTNER_FCT = '00000039' " Preferred vendor
AND PARTNER_NO <> ''. " Vendor guid number
ENDLOOP.
CHECK SY-SUBRC <> 0.
preferred vendor has not beeen entered for this line item
CLEAR W_FOUND.
CLEAR PF_PARTNER.
Get the Preferred vendor from shopping cart that user entered earlier
LOOP AT SC_PARTNER INTO PF_PARTNER WHERE PARTNER_FCT = '00000039' " Preferred vendor
AND PARTNER_NO <> ''. " Vendor guid number
W_FOUND = 'Y'.
ENDLOOP.
IF SY-SUBRC <> 0.
Get the Preferred vendor from current line that is being edited
LOOP AT IT_PARTNER INTO PF_PARTNER WHERE PARTNER_FCT = '00000039' " Preferred vendor
AND PARTNER_NO <> ''. " Vendor guid number
W_FOUND = 'Y'.
ENDLOOP.
ENDIF.
CHECK W_FOUND = 'Y'.
This "free text" line item doesn't have preferred vendor assigned.
Populate preferred vendor for this line items.
PF_PARTNER-P_GUID = LS_SC_ITEM-GUID.
CALL FUNCTION 'GUID_CREATE'
IMPORTING
EV_GUID_16 = PF_PARTNER-PARTNER_GUID.
APPEND PF_PARTNER TO LT_ET_PARTNER.
ENDLOOP.
ENDLOOP.
ET_PARTNER[] = LT_ET_PARTNER[].
If I'm reading this right, it looks like you are trying to loop through IT_ITEM (the current item table), then inside that, you are trying to loop through the list of existing items (SC_ITEM) you pulled from BBP_PD_SC_GETDETAIL, where the item number is the same the number from the current item. Is this correct?
The problem with this is if IT_ITEM is a newly-entered item, it is not going to match any lines inside SC_ITEM. SC_ITEM will only contain items you have entered previously, so the code inside that loop is not going to execute when you enter a new item.
Seth,
Sorry about the confusion.
The 'not equal' sign was edited out by the SDN posting board from my codes. (Very strange)
Actually I was looping through the shopping cart to get the line items that DO NOT have the same line item number as the current line.
So the first few lines will be like the following.
LOOP AT IT_ITEM INTO LS_IT_ITEM.
Check if any other line item in shopping cart is free text line item
LOOP AT SC_ITEM INTO LS_SC_ITEM WHERE NUMBER_INT not equal LS_IT_ITEM-NUMBER_INT
AND CATALOGID = ''
AND CATALOGITEM = ''
AND DEL_IND IS INITIAL
AND BE_OBJECT_ID IS INITIAL. " No purchase req created yet
Also I would like to stress that after I enter the preferred vendor for the current line, all the following NEW line items will have the preferred vendor populated correctly as the way I wanted. It is the lines created before the preferred vendor was entered will not automatically populated.
If I try to add the vendor info to the ET_PARTNER for the other line items, do I also need to add the corresponding line items to ET_ITEM?
Fisher
Seth,
Let me re-post the codes again because there were several places that I had "not equal" sings.
What I tried to do is populate the preferred vendor for those lines created BEFORE the preferred vendor was entered for the current line.
LOOP AT IT_ITEM INTO LS_IT_ITEM.
Check if any other line item in shopping cart is free text line item
LOOP AT SC_ITEM INTO LS_SC_ITEM WHERE NUMBER_INT not EQ LS_IT_ITEM-NUMBER_INT
AND CATALOGID = ''
AND CATALOGITEM = ''
AND DEL_IND IS INITIAL
AND BE_OBJECT_ID IS INITIAL. " No purchase req created yet
Free text line item found
Check if preferred vendor has been entered for this line item
LOOP AT SC_PARTNER INTO PF_PARTNER WHERE P_GUID = LS_SC_ITEM-GUID
AND PARTNER_FCT = '00000039' " Preferred vendor
AND PARTNER_NO not EQ ''. " Vendor guid number
ENDLOOP.
CHECK SY-SUBRC not EQ 0.
preferred vendor has not been entered for this line item
CLEAR W_FOUND.
CLEAR PF_PARTNER.
Get the Preferred vendor from shopping cart that user entered earlier
LOOP AT SC_PARTNER INTO PF_PARTNER WHERE PARTNER_FCT = '00000039' " Preferred vendor
AND PARTNER_NO not EQ ''. " Vendor guid number
W_FOUND = 'Y'.
ENDLOOP.
IF SY-SUBRC not EQ 0.
Get the Preferred vendor from current line that is being edited
LOOP AT IT_PARTNER INTO PF_PARTNER WHERE PARTNER_FCT = '00000039' " Preferred vendor
AND PARTNER_NO not EQ ''. " Vendor guid number
W_FOUND = 'Y'.
ENDLOOP.
ENDIF.
CHECK W_FOUND = 'Y'.
This "free text" line item doesn't have preferred vendor assigned.
Populate preferred vendor for this line items.
PF_PARTNER-P_GUID = LS_SC_ITEM-GUID.
CALL FUNCTION 'GUID_CREATE'
IMPORTING
EV_GUID_16 = PF_PARTNER-PARTNER_GUID.
APPEND PF_PARTNER TO LT_ET_PARTNER.
ENDLOOP.
ENDLOOP.
ET_PARTNER = LT_ET_PARTNER.
That could be it. I'm looking over my own code where I set the vendor (not the preferred vendor, but the logic should be the same) and I see that I always add the corresponding item to ET_ITEM for every partner I add to ET_PARTNER, even though the item itself is not modified. It's worth a shot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.