Hi Micheal,
We can achieve the required functionality in get_data method. First,Create the button and assign it to concerned action ( initially defined in GET_DEFINITION method ) at UIBB configuration. Now in case if you want it hide it at start up ,& have to modify based on a event ,the visible parameter of the CT_ACTION_USAGE can be used to achieve it.
VISIBLE = CL_WD_UIELEMENT=>E_VISIBLE-NONE. " To hide the UI concerned to method
VISIBLE = CL_WD_UIELEMENT=>E_VISIBLE-VISIBLE." TO show the UI concerned to the method.
In your case , following code will help accordingly. I have changed the visibility of button based on a event, initially I have disable the button and based on certain event I have enabled it again.
data ls_act_def like line of ET_ACTION_DEFINITION.
ls_act_def-ENABLED = 'X'.
ls_act_def-ID = 'ADD'.
ls_act_def-TEXT = 'Add a row'.
ls_act_def-VISIBLE = CL_WD_UIELEMENT=>E_VISIBLE-NONE.
append LS_ACT_DEF to ET_ACTION_DEFINITION.
endmethod.
method IF_FPM_GUIBB_LIST~GET_DATA.
IF IV_EVENTID->MV_EVENT_ID EQ 'FETCH_DATA'.
field-SYMBOLS: <fs_field> like line of CT_ACTION_USAGE.
loop at CT_ACTION_USAGE ASSIGNING <FS_FIELD>.
case <FS_FIELD>-ID.
when 'ADD'. " name of the field
<FS_FIELD>-VISIBLE = CL_WD_UIELEMENT=>E_VISIBLE-VISIBLE.
EV_ACTION_USAGE_CHANGED = ABAP_TRUE.
ENDCASE.
ENDLOOP.
ENDIF.
endmethod.
Regards,
Harsha