Skip to Content
0
Former Member
May 28, 2011 at 11:34 AM

Adding Model Attribute to Context Node

417 Views

Hi CRM Guru,

I have an requirement where Personnel Number(PERNR from BP_EMPL) needs to be displayed in BP_CONT View.

Actually for employee and contact person we are calling BP_CONT(Via Logical link) only as for both the operations are same in our case so we are not calling BP_EMPL while creating employee.

Now requirement is add PERNR(Personnel No) while creating Employee. But in BP_CONT/ContactDetails PERNR field is not available.

Now to acheive this i have enhanced BP_CONT/ContactDetails and adding model attribute in Context Node HEADER.

Model attribute is added using relation between BuilHeader and BuilEmp in WIzard. There are intermediate relation in this.

After i am done with creation of Model Attribute, i got below code in GET_Attribute method.

Then in configuration i made this personnel field avaialbe in my View(BP_CONT). But now my attribute is filled with "BulHeader Not Bound" value and i think it is not able to create relation.

Is my approach to this requirement is correct or do i need to do something else to achive solution. Please help.

Code in getter method of Model attribute.

DATA: current TYPE REF TO if_bol_bo_property_access.

DATA: dref TYPE REF TO data.

value =

'BuilHeader not bound'."#EC NOTEXT

if iterator is bound.

current = iterator->get_current( ).

else.

current = collection_wrapper->get_current( ).

endif.

TRY.

DATA: coll TYPE REF TO if_bol_entity_col.

DATA: entity TYPE REF TO cl_crm_bol_entity.

entity ?= current.

coll = entity->get_related_entities(

iv_relation_name = 'BuilEmplResponsRel' ). "#EC NOTEXT

current = coll->get_current( ).

IF current IS NOT BOUND.

RETURN.

ENDIF.

entity ?= current.

coll = entity->get_related_entities(

iv_relation_name = 'BuilGetEmplForHeaderRel' ). "#EC NOTEXT

current = coll->get_current( ).

IF current IS NOT BOUND.

RETURN.

ENDIF.

TRY.

dref = current->get_property( 'PERNR' ). "#EC NOTEXT

CATCH cx_crm_cic_parameter_error.

ENDTRY.

CATCH cx_sy_ref_is_initial cx_sy_move_cast_error

cx_crm_genil_model_error.

RETURN.

ENDTRY.

IF dref IS NOT BOUND.

value =

'BuilHeader/BuilEmplResponsRel/BuilGetEmplFor... not bound'."#EC NOTEXT

RETURN.

ENDIF.

TRY.

value = if_bsp_model_util~convert_to_string( data_ref = dref

attribute_path = attribute_path ).

CATCH cx_bsp_conv_illegal_ref.

FIELD-SYMBOLS: <l_data> type DATA.

assign dref->* to <l_data>.

  • please implement here some BO specific handler coding

  • conversion of currency/quantity field failed caused by missing

  • unit relation

  • Coding sample:

  • provide currency, decimals, and reference type

  • value = cl_bsp_utility=>make_string(

  • value = <l_data>

  • reference_value = c_currency

  • num_decimals = decimals

  • reference_type = reference_type

  • ).

value = '-CURR/QUANT REF DATA MISSING-'.

CATCH cx_root.

value = '-CONVERSION FAILED-'. "#EC NOTEXT

ENDTRY.

Thanks,

Harsh