Hi Jorge,
thanks for your response - I checked in SPRO, and can see that this particular Item Category is configured with 'C - only copy Manual items'.
I will change to 'D' and do some tests.
One question - does this copy control determine items copied within the same order, or between different orders only? My task is to copy items within same order.
In the meantime, I made progress through code - after upadting the QTY on the copied line item, it was necessary to add a bol->modify statement, otherwise it didn't work. Also used the 'BTCondICondLineEasyEntry1' relationship.
Seems to be working now - including code below incase anyone has same issue:
thanks again for your help,
David
code:
***************************************************************************
*Set the Quantity on the COPIED SUB-ITEM
***************************************************************************
lr_collection = lr_admini_new->get_related_entities(
iv_relation_name = 'BTItemSchedlinExt' ).
current ?= lr_collection->get_current( ).
IF current IS NOT BOUND.
current = lr_admini_new->create_related_entity( iv_relation_name = 'BTItemSchedlinExt' ).
ENDIF.
lr_entity ?= current.
lr_collection = lr_entity->get_related_entities(
iv_relation_name = 'BTSchedlinFirst' ).
current ?= lr_collection->get_current( ).
IF current IS NOT BOUND AND lr_entity->is_changeable( ) = abap_true.
current = lr_entity->create_related_entity( iv_relation_name = 'BTSchedlinFirst' ).
ENDIF.
current->set_property(
iv_attr_name = 'QUANTITY' "#EC NOTEXT
iv_value = lv_value_new ).
***************************************************************************
*Update the BOL, or it will not allow you to add condition items
***************************************************************************
lv_bol_core = cl_crm_bol_core=>get_instance( ).
lv_bol_core->start_up( 'BT' ).
lv_bol_core->modify( ).
***************************************************************************
*GET the ITEM CONDITION (Pricing) relationship for original SUB-ITEM
***************************************************************************
lr_coll2 = lr_ent->get_related_entities( iv_relation_name = 'BTItemConditionSet' ).
lr_ent1 ?= lr_coll2->get_current( ).
* IF lr_ent1 IS INITIAL.
* lr_ent1 = lr_child->create_related_entity( iv_relation_name = 'BTItemConditionSet' ).
* ENDIF.
if lr_ent1 is BOUND.
CALL METHOD lr_ent1->get_related_entities
EXPORTING
* iv_relation_name = 'BTCondICondLineAll'
iv_relation_name = 'BTCondICondLineEasyEntry1'
RECEIVING
rv_result = lr_coll1.
***************************************************************************
*Set the Item Condition (Pricing) on the COPIED SUB-ITEM
***************************************************************************
if lr_coll1 is BOUND. "if items Condition items exist
lr_collection = lr_admini_new->get_related_entities(
iv_relation_name = 'BTItemConditionSet' ).
current ?= lr_collection->get_current( ).
IF current IS NOT BOUND.
current = lr_admini_new->create_related_entity( iv_relation_name = 'BTItemConditionSet' ).
ENDIF.
lr_entity ?= current.
lr_collection = lr_entity->get_related_entities(
iv_relation_name = 'BTCondICondLineEasyEntry1' ).
current ?= lr_collection->get_current( ).
IF current IS NOT BOUND AND lr_entity->is_changeable( ) = abap_true.
current = lr_entity->create_related_entity( iv_relation_name = 'BTCondICondLineEasyEntry1' ).
ENDIF.
if lo_entity1 is BOUND.
lo_entity1 ?= lr_coll1->get_first( ). "NEED TO REVISE THIS....
lo_entity1->get_properties( IMPORTING es_attributes = ls_cond ).
current->set_properties( is_attributes = ls_cond ).
endif.
endif.