Skip to Content
Former Member
Apr 10, 2012 at 11:27 AM

Custom development for copying products in follow up quotation from oppt


Hi Experts,

I have done a custom development in which, while creating a follow-up Quotation from an Opportunity, if there is just one product in the follow-up items, the product selection pop-up should be disabled and the product should be automatically added to the Quotation.

For this I disabled the pop-up in method IP_FOLLOWUP (of class : CL_CRM_BT_H_WINDOW), and wrote my custom code in the

WD_CREATE_CONTEXT ( of class ZL_BT115QIT_ITEMS_IMPL, component/view: BT115QIT/Items)

The error is, for VC products (Configurable products, which have sub-items), the products along with the sub-items get copied over to Quotation, but 'Item X : Configure product Y' comes up.

This error does not come for Non VC products (stand alone products).

What could i possibly be missing in my code, that this Configure product error comes up?

The code i added in WD_CREATE_CONTEXT was: (which is similar to code in EH_ONTRANSFER of BTFOLLOWUP component).

BEGIN OF ly_attr_struct,
objkey_a TYPE crmt_doc_flow_id_wrk,
objtype_a TYPE swo_objtyp,
object_id TYPE crmt_object_id_long,
number_int TYPE crmt_item_no,
ordered_prod TYPE crmt_ordered_prod,
description TYPE crmt_description,
target_qty TYPE crmt_target_qty,
target_qty_unit TYPE crmt_target_qty_unit,
mark TYPE string,
product TYPE crmt_object_guid,
header TYPE crmt_object_guid,
parent TYPE crmt_object_guid,
assignment_key TYPE char32,
description_name TYPE bu_descrip,
beg_date TYPE sydatum,
beg_time TYPE sytime,
end_date TYPE sydatum,
end_time TYPE sytime,
itm_usage TYPE crmt_item_usage,
END OF ly_attr_struct.
BEGIN OF ly_guids,
old TYPE crmt_object_guid,
product TYPE crmt_object_guid,
new TYPE crmt_object_guid,
END OF ly_guids.

lv_itm_guid TYPE crmt_object_guid,
lv_tabix TYPE sytabix,
ls_docflow TYPE crmst_docflow_btil,
ls_docflow_hdr TYPE crmst_docflow_btil,
ls_followupitems TYPE ly_attr_struct,
ls_guids TYPE ly_guids,
lt_guids TYPE TABLE OF ly_guids,
lt_guids_parent TYPE TABLE OF ly_guids,
lt_docflow TYPE TABLE OF crmst_docflow_btil,
lr_btadmini TYPE REF TO cl_crm_bol_entity,
lr_btdocflowset TYPE REF TO cl_crm_bol_entity,
lr_btadminh TYPE REF TO cl_crm_bol_entity,
lr_btdocflow TYPE REF TO cl_crm_bol_entity,
lr_producti TYPE REF TO cl_crm_bol_entity,
lr_schedlini TYPE REF TO cl_crm_bol_entity,
lr_schedlin TYPE REF TO cl_crm_bol_entity,
lr_service_i TYPE REF TO cl_crm_bol_entity,
lr_followupitems TYPE REF TO cl_bsp_wd_value_node,
lr_comp TYPE REF TO cl_btfollow_bspwdcomponen_impl,
lr_core TYPE REF TO cl_crm_bol_core,
lr_window TYPE REF TO cl_bsp_wd_window.
DATA: lv_total_size TYPE sytabix,
lv_marked_size TYPE sytabix,
lv_actual_index TYPE sytabix,
lv_count TYPE sytabix VALUE 0,
ls_items_all TYPE ly_attr_struct,
ls_items TYPE ly_attr_struct,
lr_col_all TYPE REF TO if_bol_bo_col,
lr_col_temp TYPE REF TO if_bol_bo_col,
lr_iterator_col TYPE REF TO if_bol_bo_col_iterator,
lr_iterator_temp TYPE REF TO if_bol_bo_col_iterator,
lr_iterator_col_all TYPE REF TO if_bol_bo_col_iterator,
lr_entity TYPE REF TO if_bol_bo_property_access,
lr_entity_mark TYPE REF TO if_bol_bo_property_access,
lr_entity_all TYPE REF TO if_bol_bo_property_access,
lr_follow_up_util TYPE REF TO crm_uiu_bt_gen_follow_up_util.

DATA: lr_cuco TYPE REF TO cl_bt111h_o_cubtdocflowcu_impl,
lr_btitems TYPE REF TO cl_crm_bol_entity,
lr_ent_btadminh TYPE REF TO cl_crm_bol_entity,
follow_up_util TYPE REF TO crm_uiu_bt_gen_follow_up_util,
lr_col TYPE REF TO if_bol_bo_col,
lr_ent_btadmini TYPE REF TO cl_crm_bol_entity,
lr_ent_btadminh1 TYPE REF TO if_bol_bo_property_access,
lr_collection_btadmini TYPE REF TO if_bol_bo_col.
IF follow_up_util IS NOT BOUND.
CREATE OBJECT follow_up_util.
lr_btitems ?= me->typed_context->btitems->collection_wrapper->get_current( ).
lr_collection_btadmini ?= me->typed_context->btadmini->collection_wrapper.
IF lr_btitems IS BOUND.
CALL METHOD lr_btitems->get_parent
rv_result = lr_ent_btadminh.
IF lr_ent_btadminh IS BOUND.
IF lr_ent_btadminh->is_locked( ) EQ abap_false.
lr_ent_btadminh->lock( ).
CHECK lr_ent_btadminh->is_locked( ) EQ abap_true.
lr_ent_btadminh1 ?= lr_ent_btadminh.
lr_col = follow_up_util->get_followup_items( ir_btadminh = lr_ent_btadminh1 ).
IF lr_col IS BOUND.
IF lr_col->size( ) = 1.
follow_up_util->init( ).
lr_col_all = follow_up_util->get_followup_items( ir_btadminh = lr_ent_btadminh1
iv_all = 'X').
lv_total_size = lr_col_all->size( ).
IF lv_total_size > 1.
* lr_col_temp is the collection which will be marked to be transferred to followup doc
lr_col_temp = lr_col->get_copy( ).
* get iterators
lr_iterator_col_all = lr_col_all->get_iterator( ). " all items
lr_iterator_temp = lr_col_temp->get_iterator( ).
* check subitems
lr_entity_all ?= lr_iterator_col_all->get_first( ).
WHILE lr_entity_all IS BOUND.
lr_entity_all->get_properties( IMPORTING es_attributes = ls_items_all ).
ls_items_all-itm_usage = gc_item_usage-configuration.
* mark it automatically only in case of subitem from configuration
IF NOT ls_items_all-parent IS INITIAL AND
( ls_items_all-itm_usage EQ gc_item_usage-configuration OR
ls_items_all-itm_usage EQ gc_item_usage-bom ).
lr_entity_mark = lr_iterator_temp->find_by_property( iv_attr_name = 'OBJKEY_A' iv_value = ls_items_all-parent ).
IF lr_entity_mark IS BOUND .
lv_actual_index = lr_iterator_temp->get_current_index( ).
ADD 1 TO lv_count.
lv_actual_index = lv_actual_index + lv_count.
lr_col->insert( iv_bo = lr_entity_all iv_index = lv_actual_index ).
lr_col->mark( iv_bo = lr_entity_all ).
* update lr_col_temp to determine lower level subitems
lr_col_temp->add( iv_entity = lr_entity_all ).
CLEAR lv_count.
lr_entity_all ?= lr_iterator_col_all->get_next( ).
lr_followupitems ?= lr_col->get_first( ).
WHILE lr_followupitems IS BOUND.
lr_followupitems->if_bol_bo_property_access~get_properties( IMPORTING es_attributes = ls_followupitems ).
* first create new item
ev_guid = lv_itm_guid.
ls_guids-old = ls_followupitems-objkey_a.
ls_guids-product = ls_followupitems-product.
ls_guids-new = lv_itm_guid.
INSERT ls_guids INTO TABLE lt_guids.
INSERT ls_guids INTO TABLE lt_guids_parent.
lr_followupitems ?= lr_col->get_next( ).
lr_followupitems ?= lr_col->get_first( ).
WHILE lr_followupitems IS BOUND.
lr_followupitems->if_bol_bo_property_access~get_properties( IMPORTING es_attributes = ls_followupitems ).
READ TABLE lt_guids INTO ls_guids
WITH KEY old = ls_followupitems-objkey_a
product = ls_followupitems-product.
lv_tabix = sy-tabix.
lv_itm_guid = ls_guids-new.
lr_btadmini ?= lr_btitems->create_related_entity( 'BTOrderItemAll' ).
CHECK lr_btadmini IS BOUND.
lr_btadmini->set_property( iv_attr_name = 'GUID'
iv_value = lv_itm_guid ).
lr_btadmini->set_property( iv_attr_name = 'ORDERED_PROD'
iv_value = ls_followupitems-ordered_prod ).
lr_btadmini->set_property( iv_attr_name = 'PRODUCT'
iv_value = ls_followupitems-product ).
lr_btadmini->set_property( iv_attr_name = 'DESCRIPTION'
iv_value = ls_followupitems-description ).
IF NOT ls_followupitems-parent IS INITIAL.
CLEAR: ls_guids.
READ TABLE lt_guids_parent INTO ls_guids
WITH KEY old = ls_followupitems-parent.
lr_btadmini->set_property( iv_attr_name = 'PARENT'
iv_value = ls_guids-new ).
lr_btadmini->set_property( iv_attr_name = 'PREVIOUS_GUID'
iv_value = ls_guids-new ).
* second create new doc flow for item
lr_btdocflowset ?= lr_btadmini->create_related_entity( 'BTItemDocFlowSet' ).
lr_btdocflowset->set_property( iv_attr_name = 'CRM_GUID'
iv_value = lv_itm_guid ).
lr_btdocflow ?= lr_btdocflowset->create_related_entity( 'BTDocFlowAll' ).
ls_docflow-ref_guid = lv_itm_guid.
ls_docflow-objkey_a = ls_followupitems-objkey_a.
ls_docflow-objtype_a = ls_followupitems-objtype_a.
READ TABLE lt_docflow INTO ls_docflow_hdr
WITH KEY objkey_a = ls_followupitems-header.
ls_docflow-vona_kind = ls_docflow_hdr-vona_kind.
IF ls_docflow-vona_kind = gc_vona_kind-item_copy. "copy from multiple predecessora
ls_docflow-vona_kind = gc_vona_kind-copy_update.
ls_docflow-relationid = ls_docflow_hdr-relationid.
ls_docflow-reltype = ls_docflow_hdr-reltype.
ls_docflow-brel_kind = gc_brel_kind-item_item.
lr_btdocflow->set_properties( ls_docflow ).
* third create new product_i
lr_producti ?= lr_btadmini->create_related_entity( 'BTItemProductExt' ).
lr_producti->set_property( iv_attr_name = 'GUID'
iv_value = lv_itm_guid ).
lr_producti->set_property( iv_attr_name = 'PROCESS_QTY_UNIT'
iv_value = ls_followupitems-target_qty_unit ).
* fourth create new schedlin
lr_schedlini ?= lr_btadmini->create_related_entity( 'BTItemSchedlinExt' ).
lr_schedlin = lr_schedlini->create_related_entity( 'BTSchedlinAll' ).
lr_schedlin->set_property( iv_attr_name = 'QUANTITY'
iv_value = ls_followupitems-target_qty ).
IF NOT ls_followupitems-assignment_key IS INITIAL.
lr_service_i ?= lr_btadmini->create_related_entity( 'BTItemServiceExt' ).
lr_service_i->set_property( iv_attr_name = 'ASSIGNMENT_GUID'
iv_value = ls_followupitems-assignment_key ).
me->typed_context->btadmini->collection_wrapper->add( lr_btadmini ).
lr_followupitems ?= lr_col->get_next( ).
DELETE lt_guids INDEX lv_tabix.
lr_core = cl_crm_bol_core=>get_instance( ).
lr_core->modify( ).