Skip to Content

Contact Create address Selection

Hi,

In my requirement, we have added a F4 view for address selection.

i.e.

1. When we create contact, select Account, the Addess(I have added Zfield) gets active with a F4.

2. When we do F4, a window opens with addresses.

3. When we select address, it gets populated in Address field.

4. Without saving, when I select once again address, come back and do SAVE, it saves the 2nd address.

But when I log out and log in. Open the contact created above, it displays the 1st address I had selected, not the 2nd one that I selected and saved.

I have written the following code in my on_close event:

It seems like when it sets value for the attributes, 1st time, not getting updated for 2nd time. It only displays the value when we save it, as Address is a Z attribute. And when we log out and log in the 1st address gets active and displays in my field.Please help.

Edited by: Ginger on Dec 9, 2011 10:22 AM

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Dec 09, 2011 at 04:53 AM

    Following is the code:

    METHOD eh_onclose.

    DATA:lv_city TYPE string,

    lv_region TYPE string,

    lv_country TYPE string,

    lv_street TYPE string,

    lv_postalcod TYPE string,

    lr_current TYPE REF TO if_bol_bo_property_access,

    lr_current1 TYPE REF TO if_bol_bo_property_access,

    lv_contp TYPE bu_partner,

    lv_flag TYPE char1,

    lv_guid TYPE string,

    lv_account TYPE string,

    lv_contact TYPE string.

    DATA:lr_entity TYPE REF TO cl_crm_bol_entity,

    lr_entity1 TYPE REF TO cl_crm_bol_entity.

    DATA lr_core TYPE REF TO cl_crm_bol_core.

    lr_core = cl_crm_bol_core=>get_instance( ).

    lr_current ?= me->typed_context->workaddress->collection_wrapper->get_current( ).

    IF lr_current IS BOUND.

    • IF lr_current->is_property_readonly(

    • 'ADDRESS' ) = abap_false. "#EC NOTEXT

    lr_current->set_property(

    iv_attr_name = 'ADDRESS' "#EC NOTEXT

    iv_value = zl_zbp_cont_zaddressf4n=>gv_string ).

    • ENDIF.

    lr_current->set_property(

    iv_attr_name = 'ADDRESS_GUID' "#EC NOTEXT

    iv_value = zl_zbp_cont_zaddressf4n=>gv_addressguid ).

    lr_current1 ?= me->typed_context->relationship->collection_wrapper->get_current( ).

    lr_current1->get_property_as_value( EXPORTING iv_attr_name = 'CONP_NUMBER' "#EC NOTEXT

    IMPORTING ev_result = lv_contp ).

    ENDIF.

    lr_entity1 ?= lr_current1.

    TRY.

    lr_entity ?= lr_entity1->get_related_entity( iv_relation_name = 'BuilContactPersonStandardAddressRel' ).

    CATCH cx_root .

    ENDTRY.

    IF lr_entity IS BOUND.

    CHECK lr_entity->is_changeable( ) = abap_true.

    lr_entity->switch_to_change_mode( ).

    • me->view_group_context->set_view_editable( me ).

    lv_guid = zl_zbp_cont_zaddressf4n=>gv_addressguid.

    lv_account = zl_bp_cont_contactdetail5_impl=>gv_account.

    lr_entity->set_property_as_string(

    iv_attr_name = 'BP_NUMBER' "#EC NOTEXT

    iv_value = lv_account ).

    lv_contact = lv_contp.

    lr_entity->set_property_as_string(

    iv_attr_name = 'CONP_NUMBER' "#EC NOTEXT

    iv_value = lv_contact ).

    lr_entity->set_property_as_string(

    iv_attr_name = 'ADDRESS_GUID' "#EC NOTEXT

    iv_value = lv_guid )."gv_string )

    lr_entity->set_property_as_string(

    iv_attr_name = 'ADDR_SHORT' "#EC NOTEXT

    iv_value = zl_zbp_cont_zaddressf4n=>gv_string ).

    • ENDIF.

    ELSE.

    TRY .

    lr_entity ?= lr_entity1->create_related_entity( iv_relation_name = 'BuilContactPersonStandardAddressRel' ).

    CATCH cx_root.

    ENDTRY.

    IF lr_entity IS BOUND.

    lr_entity->set_property(

    iv_attr_name = 'ADDRESS_GUID' "#EC NOTEXT

    iv_value = zl_zbp_cont_zaddressf4n=>gv_addressguid )."gv_string )

    lr_entity->set_property(

    iv_attr_name = 'ADDR_SHORT' "#EC NOTEXT

    iv_value = zl_zbp_cont_zaddressf4n=>gv_string )."gv_string )

    lr_entity->set_property(

    iv_attr_name = 'BP_NUMBER' "#EC NOTEXT

    iv_value = zl_bp_cont_contactdetail5_impl=>gv_account ).

    lr_entity->set_property(

    iv_attr_name = 'CONP_NUMBER' "#EC NOTEXT

    iv_value = lv_contp ).

    ENDIF.

    ENDIF.

    lr_current->set_property(

    iv_attr_name = 'ADDRESS' "#EC NOTEXT

    iv_value = zl_zbp_cont_zaddressf4n=>gv_string ).

    lr_core->modify( ).

    me->typed_context->workaddress->collection_wrapper->publish_current( ).

    eh_onsubmitonenter( htmlb_event = htmlb_event

    htmlb_event_ex = htmlb_event_ex ).

    DATA: tx TYPE REF TO if_bol_transaction_context.

    tx = lr_entity->get_transaction( ).

    tx->commit( ).

    ENDMETHOD.

    Edited by: Ginger on Dec 9, 2011 10:22 AM

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.