Hi there –
I have a requirement to copy an order item to a sub-item,based on certain conditions. (in EH_ONCOPY)
Everything is working fine for the copy (material, qty etc.), except for the item pricing conditions – one manual item condition is not being copied over, and so the screen field CONDITIONAMOUNT1 is not updated. (this is a user input value on original line, that I want to copy to the new line when they hit ‘Copy’)
I have tried various approaches , using the relationships BTItemConditionSet, and BTCondICondLineAll but with no success. I also tried
to use BTCondICondLineEasyEntry1 but again, could not get it to work
I am using code such as this, to iterate through the original condition lines (lr_coll1), and to try to add them to the new condition lines(lr_coll2):
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 = 'BTCondICondLineAll' ).
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 = 'BTCondICondLineAll' ).
lr_entity ?= current.
CALL METHOD lr_entity->get_related_entities
EXPORTING
iv_relation_name = 'BTCondICondLineAll' "Get Item Pricing entity which is to be changed
RECEIVING
rv_result = lr_coll2.
if lr_coll1 is BOUND.
lo_entity1 ?= lr_coll1->get_first( ).
WHILE lo_entity1 is bound.
lo_entity2 = lo_entity1.
lr_coll2->add( iv_entity = lo_entity2 ).
lo_entity1 ?= lr_coll1->get_next( ).
ENDWHILE.
endif.
Is this the correct approach?
If someone can give some guidance on how to do this, it would be greatly appreciated.
Thanks,
David