cancel
Showing results for 
Search instead for 
Did you mean: 

CRM_COPY_BADI for item categories???

Former Member
0 Kudos

Hello Gurus,

              When we are working with copy control for business transactions we define a copy routine while customizing and we will pass it as filter value for this badi, so this badi will trigger. I want to know when this badi will exactly trigger in the case of item categories and what are the setting that we need to do???

Thanks in Advance.

Regards,

Krishna.

Accepted Solutions (1)

Accepted Solutions (1)

former_member219209
Participant
0 Kudos

Hi Bala,

For item level copy control, you need maintain the copying routine in copy control of item categories under following spro path,

Spro-->CRM-->transaction-->basic settings-->copy control for transactions-->define copy control for item categories.

After that you need maintain the filter value in BADI and add the custom logic.

From eg: you can maintain copying routine ZXYZ for item ZAGN to ZTAN item categories.

The badi will get triggered while you are creating follow up from quotation to sales order. This will hit for only items. IF you want to change any data in item level while creating followup process this badi can used.

Regards,

Vignesh

Former Member
0 Kudos

Hi Vigneshwaran,

   Thanks for the reply. When i define a copy control from quotation to sales order transaction type i will maintain a copy routine ZXYZ and pass it as filter value for the badi, now this BADI will trigger when i click on  Create Follow up in the quotation transaction. Now my question is Can i pass the same copy routine ZXYZ when maintaining copy control for the item categories ZAGN to ZTAN ?? Will the same Badi trigger for item categories also?? When and at which position will this badi will trigger in case of item categories??? Will it trigger on clicking save??

Thanks & regards,

   Krishna.

former_member219209
Participant
0 Kudos

Hi krishna,

This BADI will trigger at time of clicking the follow up button. If you maintain same copying routine for both transaction as well as item. First it will hit for header, from the badi methods signature you can able to get the header guid and you can make changes in header details.

Next for example if you have three items in the document, the badi will trigger for three times with specific item guid and corresponding item related details can be changed.

These all will happen at time of clicking on follow up buttons.So for above example BADI should hit four times with corresponding guid.

Regards,

Vignesh

Former Member
0 Kudos

Hi Vigneshwaran,

  Thanks for your inputs. Then this Badi will trigger only when we click on Create follow up. I have a doubt here :

When we maintain same copy routine for header and item, why the Badi would trigger for 4 times?? 

It will trigger once for the header and in the above example as we maintain copy control from ZAGN to ZTAN item categories it will trigger for the second time. that's it r8?

Thanks & Regards,

    Krishna.

former_member219209
Participant
0 Kudos

Hi Krishna,

Generally if you click follow up button first time BADI will trigger with header details after that some pop up will raised in web-ui like selecting sales org  and contact person  and one popup will be raised for selecting items need to be copied. At that time of choosing items then badi will trigger for each item with corresponding details.

You can also check the badi methods signature. There you will find only structures as exporting and importing parameter like CS_ORDERADM_I. So at one time it can hold only one record and not more than one value like tables.

For better understanding put a break point in badi implementation and create a followup and check the values in structure in debugging then you will get a clear idea.

Regards,

Vignesh

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Bala krishna,

I have the similar requirement where i have to restrict the items based on channel_type and fullfilment_type zfields values from indirect quote.

the logic is below, the problem i am facing is the copy badi is copying all the items instead of restricting them to the condition..

condition is channel_type = 2 & fullfilment_type = 2 then it should not allow the items to copy but the order is having all the items copied..

please help me as i am CLEARING cs_orderadm_i but items are getting copied to order.

DATA: lt_header_guid     TYPE crmt_object_guid_tab,

         ls_header_guid     TYPE crmt_object_guid,

         lv_distributor_no  TYPE crmt_partner_no,

         ls_orderadm_i      TYPE crmt_orderadm_i_badi,

         lv_item_type       TYPE crmt_item_type_db,

         ls_input_fields    TYPE crmt_input_field_names_tab,

         lt_partner_h       TYPE crmt_partner_external_wrkt,

         lw_partner_h       TYPE crmt_partner_external_wrk,

*        lt_product_i       TYPE crmt_product_i_wrkt,

*        lw_product_i       TYPE CRMT_PRODUCT_I_WRK,

         lt_orderadm_h      TYPE crmt_orderadm_h_wrkt,

         lw_orderadm_h      TYPE crmt_orderadm_h_wrk,

         lt_ref_orderadm_i  TYPE crmt_orderadm_i_wrkt,

         lw_ref_orderadm_i  TYPE crmt_orderadm_i_wrk,

         lv_chnl_type       TYPE zadtel0000my,

         lv_ff_type         TYPE zadtel0000cb,

         lv_fct             TYPE crmt_partner_fct,

         w_req_objects      TYPE crmt_object_name,

         t_req_objects      TYPE crmt_object_name_tab.

*  CONSTANTS :  c_orderadm_h(10)           TYPE c                          VALUE 'ORDERADM_H' ,

*               c_orderadm_i(10)           TYPE c                          VALUE 'ORDERADM_I' ,

*               c_partner_h(8)             TYPE c                          VALUE 'PARTNER'    .

*              c_part_fun_disti           TYPE crmt_partner_fct           VALUE 'ZR000001'.

**Orderadm_h

*  CLEAR  w_req_objects.

*  MOVE   c_orderadm_h TO w_req_objects.

*  INSERT w_req_objects INTO TABLE t_req_objects.

*

**orderadm_i

*  CLEAR  w_req_objects.

*  MOVE   c_orderadm_i TO w_req_objects.

*  INSERT w_req_objects INTO TABLE t_req_objects.

*

**partner_h

*  CLEAR w_req_objects.

*  MOVE   c_partner_h TO w_req_objects.

*  INSERT w_req_objects INTO TABLE t_req_objects.

   ls_orderadm_i    = cs_orderadm_i.

   ls_input_fields  = ct_input_field_names.

   ls_header_guid   = is_ref_orderadm_i-header.

   APPEND ls_header_guid TO lt_header_guid.

   CALL FUNCTION 'CRM_ORDER_READ'     "CRM_ORDER_READ fm

     EXPORTING

       it_header_guid       = lt_header_guid

*      it_requested_objects = t_req_objects

*      iv_mode              = 'C'

     IMPORTING

       et_orderadm_h  = lt_orderadm_h

       et_orderadm_i  = lt_ref_orderadm_i

       et_partner     = lt_partner_h

*      et_product_i   = lt_product_i

    EXCEPTIONS

           document_not_found   = 1

           error_occurred       = 2

           document_locked      = 3

           no_change_authority  = 4

           no_display_authority = 5

           no_change_allowed    = 6

           OTHERS               = 7.

   IF sy-subrc = 0.

* Get partner for distribution channel

     READ TABLE lt_partner_h INTO lw_partner_h WITH KEY partner_fct = 'ZR000001'.

     IF sy-subrc = 0.

       lv_distributor_no = lw_partner_h-partner_no.

       lv_fct            = lw_partner_h-partner_fct.

     ENDIF.

*Get Distribution Channel, fulfillment type and item category

     READ TABLE lt_orderadm_h INTO lw_orderadm_h WITH KEY guid = ls_header_guid.

     IF sy-subrc = 0.

       lv_chnl_type = lw_orderadm_h-zz_chanl_typ.

     ENDIF.

     lv_ff_type   = is_ref_orderadm_i-zz_fulfilmnt_typ.

     lv_item_type = is_ref_orderadm_i-itm_type.

   ENDIF.

*  IF ( lv_item_type = 'ZBAS' ). "or ( lv_item_type is not initial ) .

   CASE lv_chnl_type.

     WHEN 03.

*      IF ( lv_fct IS INITIAL ). "AND ( lv_ff_type IS INITIAL ).

       IF ( lv_fct IS INITIAL ).

         CLEAR:cs_orderadm_i.

         REFRESH: ct_input_field_names.

         cs_orderadm_i    = ls_orderadm_i.

         ct_input_field_names  = ls_input_fields.

*      ELSEIF ( lv_fct IS NOT INITIAL ). "AND ( lv_ff_type IS INITIAL ).

       ELSEIF ( lv_fct IS NOT INITIAL ).

         CLEAR:cs_orderadm_i.

         REFRESH: ct_input_field_names.

       ENDIF.

     WHEN 02.

       IF "( lv_fct IS INITIAL ) AND

           ( lv_ff_type = '01' ).

         CLEAR:cs_orderadm_i.

         REFRESH: ct_input_field_names .

         cs_orderadm_i    = ls_orderadm_i.

         ct_input_field_names  = ls_input_fields.

       ELSEIF "( lv_fct IS INITIAL ) AND

         ( lv_ff_type = '02' ).

         CLEAR: cs_orderadm_i.

         REFRESH: ct_input_field_names.

       ENDIF.

   ENDCASE.

*  ENDIF.