on 07-19-2012 3:46 PM
Hi all,
I need to remove some price conditions depending on some conditions.
In badi BBP_DOC_CHANGE_BADI there isn't any parameter for this purpose.
I'm trying to do it putting an enhancement point in the method GET_ITEMS_PRIDOC of class /SAPSRM/CL_PDO_BORF_WRAPPER with the following code:
LOOP AT et_items_pridoc INTO ls_items_pridoc.
IF (some conditions) .
ls_items_pridoc-del_ind = 'X'.
ls_items_pridoc-cond_inactive = 'Y'.
MODIFY et_items_pridoc FROM ls_items_pridoc INDEX lv_tabix.
IF lo_item IS NOT INITIAL.
TRY.
lo_item->/SAPPSSRM/IF_PRIDOC~SET_PRIDOC_RECORD( EXPORTING IS_PRIDOC_RECORD = ls_items_pridoc ).
CATCH /SAPPSSRM/CX_BO_FAILED.
ENDTRY.
ENDIF.
ENDIF.
ENDLOOP.
But by the moment doesn't work.
Do you know how can I remove a price condition? is there any badi ?
Thanks in advance.
Solved, creating a post-exit in method PREPARE_PD_UPDATE of class /SAPSRM/CL_PDO_UPDATE_BUFF_PO.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ricardo,
I understand you are implementing your code in post_exit of the standard class. Instead why dont you get the data from the buffer in the change badi and update the buffer in the change badi itself based on whatever condition you want.
Regards,
Naveen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ricardo,
There is a class /sapsrm/cl_pdo_bo_ctr , method /SAPSRM/IF_PDO_DO_CND~UPDATE_CONDITION .
you can use this method in the change badi to update the condition. See if it works, we used another method
/sapsrm/if_pdo_do_ctr_dis~update_item_ctr_dis to update the distribution based on certain conditions and it worked just fine for us. So try it.
Regards,
Naveen
Hi Ricardo,
I didnt read the PO part, sorry about that. I have done the same thing for a contract and it worked just fine. Hoping for it to work the same way for a PO.
To instantiate the class, its quite simple. Create an instance of the class /SAPSRM/CL_PDO_BO_PO,
using the instance call the instance method which in my case was /SAPSRM/IF_PDO_DO_CND~UPDATE_CONDITION. use the pattern to get the exporting parameter.
Regards,
Naveen
Hi Naveen,
I didn't see the constructor of the class, yes is easy to instanciate it.
I've found a method in the class called /SAPSRM/IF_PDO_DO_PRICE_CALC~UPDATE_PRICE_RECORD. I think I can use it.
The problem is when I try to use it I'm getting a short dump, because an attribute of the class called mo_pdo_price_calc is not initializated. I've found a method I which this parameter is initializated, the method is INITIALIZE_RELATED_DO. But this method is protected so I can't call it from the badi change.
I've checked the class for CTR and the same occurs, there is an attribute called mo_pdo_conditions used in the method /SAPSRM/IF_PDO_DO_CND~UPDATE_CONDITION and exits also the method INITIALIZE_RELATED_DO.
Do you remmenber if you did something to initializate this attribute before to call the method for update the conditions? Do I need to create a subclass for use this protected method or is there another way to do it?
This is my code:
DATA: lv_mode_po TYPE /sapsrm/pdo_inst_mode VALUE 'EDIT',
lo_pdo_po TYPE REF TO /sapsrm/cl_pdo_bo_po.
IF iv_mode EQ 'U'.
TRY.
CREATE OBJECT lo_pdo_po
EXPORTING
iv_header_guid = is_header-guid
iv_mode = lv_mode_po
iv_process_type = ls_header-process_type.
CATCH /sapsrm/cx_pdo_pd_read_error .
CATCH /sapsrm/cx_pdo_wrong_bus_type .
ENDTRY.
IF lo_pdo_po IS NOT INITIAL AND lt_pridoc[] IS NOT INITIAL.
TRY.
CALL METHOD lo_pdo_po->/sapsrm/if_pdo_do_price_calc~update_price_record
EXPORTING
it_pridoc = lt_pridoc.
CATCH /sapsrm/cx_pdo_abort .
ENDTRY.
ENDIF.
ENDIF.
Thanks in advance !
Hi Ricardo,
All that we have done is updated the distribution list based on certain criteria, find below the code.
Data:
lo_pdo_ctr TYPE REF TO /sapsrm/cl_pdo_bo_ctr.
try.
CALL METHOD lo_pdo_ctr->/sapsrm/if_pdo_do_ctr_dis~update_item_ctr_dis
EXPORTING
iv_item = ls_item-guid
it_ctr_distribution = lt_dis1
CATCH /sapsrm/cx_pdo_abort .
endtry.
and this worked.
I will also look for some update condition methods for PO via buffer and get back if I get something.
Regards,
Naveen
Hello Ricardo,
Create a Post exit for method /SAPSRM/CL_PDO_UPDATE_BUFF_PO~prepare_pd_update.
You have parameter ct_pridoc which can be updated. This method is called before updating the PD layer with changes from UI/PDO layer.
Please note you have to call /SAPSRM/IF_PDO_DO_PRICE_CALC~GET_PRICE_RECORDS to get all the condition records for the item and set the delete indicator and append them to CT_PRIDOC.
Regards,
Sushil.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sushil,
Thanks for answer. I've created a post-exit in that method and I'm trying to do it, but by the moment doesn't work.
I don't know how to use the method /SAPSRM/IF_PDO_DO_PRICE_CALC~GET_PRICE_RECORDS you said, so I'm using lo_pd_model->get_item_detail for get the pridoc table.
I've set del_ind to X and I've appended the condition I want to delete to the table CT_PRIDOC. But when I save the PO and go to BBP_PD the condition is still there...
I'm trying now within the same method you said to use the method UPDATE_ITEM_INTERNAL for update the pridoc table but the result is the same...
With the following sample code I'm trying to delete the condition SKTO:
DATA: lT_PRIDOC Type BBPT_PD_PRC,
ls_Pridoc LIKE LINE OF lt_pridoc,
lt_attach TYPE BBPT_PDS_ATT_T,
lt_tol TYPE BBPT_PD_TOL,
ls_Item_u TYPE bbp_pds_po_item_icu,
ls_read_flags TYPE BBPS_DETAIL_REQUESTED,
ls_i_read_flags TYPE BBPS_DETAIL_I_REQUESTED,
lv_tabix TYPE sy-tabix.
IF lo_pd_model IS NOT INITIAL.
lo_pd_model->get_detail(
EXPORTING
iv_guid = mv_header_guid
iv_with_itemdata = abap_true
IS_READ_FLAGS = ls_Read_flags
IMPORTING
es_header = ls_header_pd
et_item = lt_item_pd ).
READ TABLE lt_item_pd INTO ls_item_pd INDEX 1.
CHECK sy-subrc EQ 0.
ls_i_read_flags-partner_tab = 'X'.
ls_i_read_flags-pridoc_tab = 'X'.
ls_i_read_flags-attach_tab = 'X'.
ls_i_read_flags-tol_tab = 'X'.
CALL METHOD lo_pd_model->get_item_detail
EXPORTING
iv_guid = ls_item_pd-guid
iv_object_type = 'BUS2201001'
is_read_i_flags = ls_i_read_flags
IMPORTING
et_attach = lt_attach
et_partner = lt_partner
et_pridoc = lT_PRIDOC
et_tol = lt_tol.
READ TABLE lT_PRIDOC INTO ls_pridoc WITH KEY cond_type = 'SKTO'.
IF sy-subrc EQ 0.
ls_pridoc-del_ind = 'X'.
ls_pridoc-cond_inactive = 'X'.
MODIFY lT_PRIDOC FROM ls_Pridoc INDEX sy-tabix.
* Change the parameter;
READ TABLE ct_pridoc INTO ls_Pridoc WITH KEY p_guid = ls_Item_pd-guid
cond_type = 'SKTO'.
IF sy-subrc EQ 0.
ls_pridoc-del_ind = 'X'.
ls_pridoc-cond_inactive = 'X'.
MODIFY ct_pridoc FROM ls_Pridoc INDEX sy-tabix.
ELSE.
APPEND ls_Pridoc TO ct_pridoc.
ENDIF.
* Update the item;
MOVE-CORRESPONDING ls_item_pd TO ls_Item_u.
TRY.
CALL METHOD lo_pdo_bo_po->update_item_internal
CHANGING
cs_header = ls_header_po
cs_item = ls_Item_u
ct_partner = lt_partner
ct_tol = lt_tol
ct_attach = lt_attach
co_message_handler = lo_message_handler.
CATCH /sapsrm/cx_pdo_abort INTO lx_pdo_abort.
RAISE EXCEPTION lx_pdo_abort.
CATCH /sapsrm/cx_pdo_no_authorizatio INTO lx_pdo_no_auth.
RAISE EXCEPTION lx_pdo_abort.
ENDTRY.
ENDIF.
ENDIF.
Do you know if I need to do something else? or if I'm doing something wrong?
Did you manage to do it?
Thanks !
Regards,
Ricardo.
Place the above code in the post-exit of PREPARE_PD_UPDATE.
The code you are using to get Pricing conditions is fine.
I am thinking if you just open a PO and save it, this piece of code in the post exit may not get called. Try making a small change on the PO and save it.
Please do not call method lo_pdo_bo_po->update_item_internal. This method will update the PDO buffer which is not required at that point.
Please let me know how this condition type SKTO is added into PO item.
Is it from a contract or is it manually added?
Regards,
Sushil.
Hello Sushil,
I've removed the call to the method update_item_internal as you said and I've tried again but doesn't work.
My code in the post-exit is called, I'm debugging every change I do.
The condition SKTO is added automatically from the price schema when the line is added. Is a percentage calculated from other conditions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.