Skip to Content

How to write program for edit button on crm web ui?

Hello Experts,
My assignment is to create custom table and custom structures.

Attach custom class to custom component via SM34.

Attach custom structures to component via GENIL_MODEL_EDITOR.

Create custom UI component and assigned model to ui component.

My problem is when user click on "edit" button the data in over view page was not getting edited.

i wrote code but it's not working fine, please give any suggestions.

below is my code:

METHOD if_bsp_wd_toolbar_callback~get_buttons.

CALL METHOD super->if_bsp_wd_toolbar_callback~get_buttons
RECEIVING
rt_buttons = rt_buttons.

DATA: ls_button TYPE crmt_thtmlb_button_ext,
lr_employee TYPE REF TO cl_crm_bol_entity.

lr_employee ?= me->typed_context->zemployee->collection_wrapper->get_current( ).

CLEAR ls_button.

ls_button-on_click = 'edit'.
ls_button-type = cl_thtmlb_util=>gc_icon_edit.
ls_button-page_id = me->component_id.

IF lr_employee IS BOUND AND view_group_context->is_any_view_editable( ) = abap_false
AND lr_employee->is_change_allowed( ) = abap_true.
ls_button-enabled = abap_true.
ELSE.
ls_button-enabled = abap_false.
ENDIF.
APPEND ls_button TO rt_buttons.

CLEAR ls_button.

end method.

and another code for eh_on edit is follows:

METHOD eh_onedit.

DATA: lr_entity TYPE REF TO cl_crm_bol_entity.

lr_entity ?= me->typed_context->zemployee->collection_wrapper->get_current( ).

CHECK lr_entity IS BOUND.

CHECK lr_entity->is_change_allowed( ) = abap_true .

lr_entity->lock( ).

IF lr_entity->is_locked( ) = abap_false.

me->view_group_context->reset( ).

ELSE.
me->view_group_context->set_all_editable( ).

ENDIF.

end method.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Sep 12, 2017 at 08:41 AM

    Hi,

    Let's take sales order as an example

    in the EH_ONEDIT method of class CL_BT115H_S_DETAILS_IMPL, it has code to lock the entity, like

    if lr_ent->is_locked( ) = abap_true.

    me->view_group_context->set_view_editable( me ).

    lr_vgc ?= view_group_context->get_dependant_vg_context( ).

    lr_vgc->set_all_editable( ).

    else.

    lr_ent->lock( ).

    if lr_ent->is_locked( ) eq abap_true.

    view_group_context->set_view_editable( me ).

    lr_vgc ?= view_group_context->get_dependant_vg_context( ).

    lr_vgc->set_all_editable( ).

    endif.

    endif.

    Then in the method where buttons are defined like IF_BSP_WD_TOOLBAR_CALLBACK~GET_BUTTONS, it has code to check if the entity is locked. If locked, then the button is enable.

    Implementation Class CL_BT115H_S_SOHOVERVIEW_IMPL->IF_BSP_WD_TOOLBAR_CALLBACK~GET_BUTTONS

    * SAVE button (New Concept: SAVE is enabled as soon as the object is locked)

    IF lv_archived = abap_false.

    ls_button-type = cl_thtmlb_util=>gc_icon_save.

    ls_button-on_click = 'SAVE'.

    ls_button-page_id = me->component_id.

    lr_tx = lr_entity->get_transaction( ).

    IF lr_entity IS BOUND.

    ls_button-enabled = lr_entity->is_locked( ).

    ENDIF.

    IF lv_archived = abap_false.

    APPEND ls_button TO rt_buttons.

    ENDIF.

    CLEAR ls_button.

    I hope the above information helps.

    Add comment
    10|10000 characters needed characters exceeded