Anda di halaman 1dari 3

METHOD set_hd_invoice_price.

*-----------------------------------------------------------------* * Object ID: ENR211 * Title: Complaint Pricing from Invoice * Author: LAKKIC Creation Date: 09/12/2013 * Project: eCRM Release: R2 *-----------------------------------------------------------------* * Description * Add the Invoice Price of all items in the return and set it to * header invoice price *-----------------------------------------------------------------* * Pre-requisites: * Net Value to be set at Item level in Complaint *-----------------------------------------------------------------* * Modification History: * Req No. Name Date Description * *-----------------------------------------------------------------* INCLUDE zna_ecrm_constants. DATA : lif_admini_iter lr_collection lcl_admini_entity lcl_adminh_entity lcl_adminh lcl_itemext lcl_item_all lcl_item_coll lv_condvalue lv_netvalue lcl_core lv_proc_type wa_tvarvc_entries lv_inv_currency lv_inv_price lv_total_price TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE TYPE REF TO if_bol_entity_col_iterator, REF TO if_bol_entity_col, REF TO cl_crm_bol_entity, REF TO cl_crm_bol_entity, REF TO cl_crm_bol_entity, REF TO cl_crm_bol_entity, REF TO if_bol_entity_col, REF TO cl_crm_bol_entity_col, string, crmt_net_value_man, REF TO cl_crm_bol_core, crmt_process_type_db, tvarvc, zcdtel000014, zcdtel000013, zcdtel000013.

CLEAR : lv_total_price, lv_inv_currency. TRY. lcl_adminh ?= me->typed_context->btadminh->collection_wrapper->get_current ( ). TRY. CALL METHOD lcl_adminh->get_related_entity EXPORTING iv_relation_name = 'BTHeaderItemsExt' RECEIVING rv_result = lcl_itemext. CATCH cx_crm_genil_model_error cx_crm_genil_duplicate_rel. ENDTRY. ** Get the collection of item entities. lr_collection ?= lcl_itemext->get_related_entities( iv_relation_name = 'BT OrderItemAll' ). lif_admini_iter = lr_collection->get_iterator( ). * Get all the items in the Return request * lif_admini_iter ?= lcl_item_coll->if_bol_entity_col~get_iterator( ). CHECK lif_admini_iter IS BOUND. CHECK lif_admini_iter->size( ) IS NOT INITIAL.

lcl_admini_entity ?= lif_admini_iter->get_first( ). * Get the parent entity and lock the entity lcl_adminh_entity ?= lcl_admini_entity->get_parent( ). lcl_adminh_entity ?= lcl_adminh_entity->get_parent( ). CHECK lcl_adminh_entity IS BOUND. lcl_adminh_entity->lock( ). CHECK lcl_adminh_entity->is_locked( ) = abap_true. * Fetch the Process Type, Check if its Return CALL METHOD lcl_adminh_entity->get_property_as_value EXPORTING iv_attr_name = 'PROCESS_TYPE' IMPORTING ev_result = lv_proc_type. * Fetch the Invoice Currency CALL METHOD lcl_admini_entity->get_property_as_value EXPORTING iv_attr_name = 'ZZINVOICEPR_REFI ' IMPORTING ev_result = lv_inv_currency. CATCH cx_sy_ref_is_initial cx_root. ENDTRY. * Set the Invoice Price for a Return Only READ TABLE i_tvarvc_entries INTO wa_tvarvc_entries WITH KEY name = gc_pricing-ret_ttype low = lv_proc_type. IF sy-subrc = 0. TRY. * Loop on all items, fetch the net value and assign the value to Invoice price f ield. WHILE lcl_admini_entity IS BOUND. ************************************************* * Fetch the Invoice Price at Item and Calculate total CLEAR lv_inv_price. CALL METHOD lcl_admini_entity->get_property_as_value EXPORTING iv_attr_name = 'ZZINVOICEPR_I' IMPORTING ev_result = lv_inv_price. * Total Invoice Price lv_total_price = lv_total_price + lv_inv_price. lcl_admini_entity ?= lif_admini_iter->get_next( ). ENDWHILE. * Set the total invoice price to header invoice price CALL METHOD lcl_adminh_entity->if_bol_bo_property_access~set_property EXPORTING iv_attr_name = 'ZZINVOICEPR_H' iv_value = lv_total_price. * Set the invoice currency to header invoice currency CALL METHOD lcl_adminh_entity->if_bol_bo_property_access~set_property EXPORTING iv_attr_name = 'ZZINVOICEPR_REFH' iv_value = lv_inv_currency. CATCH cx_sy_ref_is_initial cx_root. ENDTRY. * Modify Core

lcl_core = cl_crm_bol_core=>get_instance( ). lcl_core->modify( ). ENDIF. ENDMETHOD.

Anda mungkin juga menyukai