cancel
Showing results for 
Search instead for 
Did you mean: 

Extend Object Model for BP (new custom field)

Former Member
0 Kudos

Hello Experts,

I am quite new to SAP. Recently I was given a task to create a custom field called "Agent" (used to select an individual account) and display it on Web Client. I had to use Extend Object Model for Business Partner in SPRO. I've walked through the guide, published on http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/4048d161-9ac1-2e10-3bbf-baef73d78... . I've created Key, Structure, Class and Table with two elements (bp_guid and char).

Now I wonder how to add new field to Web Client using (I suppose) transaction BSP_WD_CMPWB. Please help me walk through it.

Thank you in advance.

Best regards,

Andrew

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hey guys,

I've managed to create custom fields where I wanted them to be. But there's another problem. I've created those fields in business hours relation. There are field to choose an employee and communication channel like e-mail, fax, etc.Anyway i still have a little problem.


When I click on a new button on business hours assignment block I see a view of new business hours element (as it should be). There are my two new fields. They're mandatory fields so I need to fill them. When I do this and fill all other fields (even those which aren't mandatory), I click the back button (the one which save the data). There is no error and I'm returning to the standard account view. Now, when I want to edit created object. I click the edit button. When the view changes to business hours view, my fields of employee and the channel are not filled out. But when I fill them now, on edit screen, they would be saved.


When I debug the redefinition of method MODIFY there is some problem with lwa_key. While creating the new business hours element the lwa_key equals 0, but when I edit the object it has some value. Here's the code of modify method (the assign part):


TRY.

      lv_obj ?= iv_ref.

      CATCH: cx_sy_assign_cast_error.

        EXIT.

    ENDTRY.

    lv_obj->get_key( IMPORTING es_key = lwa_key ).

    IF lwa_key IS INITIAL.

      lr_parent = lv_obj->get_parent(

      CALL METHOD lr_parent->get_key

        IMPORTING

          es_key = ls_parent_key.

    ENDIF.

    lv_delta = lv_obj->get_delta_flag( ).

    IF lv_delta EQ if_genil_cont_simple_object=>delta_created.

      lwa_key-parent_guid = ls_parent_key-partner_guid.

      CLEAR: lwa_global_bol_data, gt_global_bol_data.

      MOVE-CORRESPONDING  lwa_key TO lwa_global_bol_data.

      TRY.

          CALL METHOD lv_obj->set_key

            EXPORTING

              is_object_key = lwa_key.

        CATCH cx_crm_genil_duplicate_key.             

      ENDTRY.

      lv_obj->get_attributes( IMPORTING es_attributes = lwa_bol_data ).

      lv_obj->get_attributes( IMPORTING es_attributes = lwa_bol_data_chg ).

      lr_obj_prop = lv_obj->get_attr_props_obj( ).

      CALL METHOD lr_obj_prop->get_name_tab_4_property

        EXPORTING

          iv_property = if_genil_obj_attr_properties=>modified

        IMPORTING

          et_names    = lt_changed_fields.

      LOOP AT lt_changed_fields INTO lwa_changed_fields.

        ASSIGN COMPONENT lwa_changed_fields OF STRUCTURE lwa_bol_data_chg TO

<new_data>.

        ASSIGN COMPONENT lwa_changed_fields OF STRUCTURE lwa_global_bol_data

TO <old_data>.

        <old_data> = <new_data>.

      ENDLOOP.

      APPEND lwa_global_bol_data TO gt_global_bol_data.

    ENDIF.

Former Member
0 Kudos

Problem solved.

I had to add a check statement for lr_parent after first if statement like that:


CASE lr_parent IS NOT INITIAL.

former_member182421
Active Contributor
0 Kudos

I think you took the long path, I would undo what you did and enhance the BP using AET,

http://help.sap.com/saphelp_crm700_ehp02/helpdata/en/01/320bd270e84f419953906fe8050ed1/frameset.htm

If you search thorugh SCN for AET you will find plenty of posts.

Cheers!

Luis

Former Member
0 Kudos

I know how to do it using the AET. The idea was to practice the other solution.

Best regards,

Andrew K.

former_member182421
Active Contributor
0 Kudos

Sorry I didn't know you know about AET, to avoid this kind of confusions I would suggest to specify with more detail your original question, that begin said , using AET I didn't find a single scenario which i needed to implement the other approach, in terms of productivity and SAP support didn't make sense to me.

Former Member
0 Kudos

I will be more precise next time.

Anyway, thank you.

Best regards,

Andrew

former_member182421
Active Contributor
0 Kudos

You need to:

1- Enhance the component

2- Enhance the View

3- In best scenario you will have your BOL model avaliable on the BOL browser (only to check)

4- You "will" need to add your BOL model in the view creating a new context (Note you need to have the BUILDHEADER respresentation as context node, that's because you BOL is a child of this one)

Let's see how it goes

Former Member
0 Kudos

Great! Thank you.

I've managed to add new field to WebClient.

Unfortunatly I have another problem. After I've added that new field I'm not able to set a value on it. It's not editable and it contains system message "BP_GUIDnot bound", like this:

Any suggestions how to fix it?

Best regards,

Andrew K.

Former Member
0 Kudos

Hi,

I believe the above said issue appears when there is no instance of the attribute u are trying to display on the view. We have an option to select "Always create an instance" while creation of view. Since the model was enhanced, the particular attribute may not have instance during initialization.

So u could modify the IF_BSP_MODEL~INIT method of the corresponding context node class and pass initial value to the model.

-

Anish

former_member182421
Active Contributor
0 Kudos

Yup, I always mark the "create instance"

Former Member
0 Kudos

I have deleted previous enhancement and added new one, selecting create instance checkbox. Unfortunatly I still have this problem.

What else can I do?

Former Member
0 Kudos

Hi,

I suppose other attributes are not having this issue.

I once had one such issue and i had to redefine the method i mentioned earlier.

The node was not initializing, so have to implement the same


method IF_BSP_MODEL~INIT.

DATA:

lt_params           TYPE            crmt_name_value_pair_tab,
ls_params          
TYPE            crmt_name_value_pair,
lr_core            
TYPE REF TO     cl_crm_bol_core,
lr_factory         
TYPE REF TO     cl_crm_bol_entity_factory,
lr_bo_coll         
TYPE REF TO     if_bol_bo_col,
lr_connobj         
TYPE REF TO     cl_crm_bol_entity.

* calling the super class
super->if_bsp_model~init(
id    = id
owner = owner ).

*  Setting parameter value
ls_params-name    =
'xxxxxx'.  "<-- Pass attribute name
ls_params-
value   = ''.
APPEND ls_params TO lt_params.


* creating instance of the BOL core
lr_core = cl_crm_bol_core=>get_instance( ).


*  Calling factory method for connection object node creation
lr_factory = lr_core>get_entity_factory(
'xxxxx' ). <-- Pass the object name
lr_connobj = lr_factory->create( lt_params ).

* adding the entity into the colletion
CREATE OBJECT lr_bo_coll TYPE cl_crm_bol_bo_col.


lr_bo_coll->add( lr_connobj ).


set_collection( lr_bo_coll ).

endmethod.

-

Anish

former_member182421
Active Contributor
0 Kudos

As I didn't implemented the solution on the doc, I have no idea what can be missing, Did you debug the ON_NEW_FOCUS method? Probably is raising an exception on the create/get related entity method