on 11-04-2014 9:04 AM
Hello all,
I am trying to add a button to standard FPM button dynamically.
In an implementation of WD_BADI_DOMODIFYVIEW I have written following code as below -
DATA : lo_toolbar TYPE REF TO cl_wd_toolbar,
lo_toolbar_button TYPE REF TO cl_wd_toolbar_button,
lo_tool_item TYPE REF TO if_wd_toolbar_item.
IF ir_view_info->get_name( ) EQ 'CNR_VIEW'.
lo_toolbar ?= ir_view->get_element( 'TOOLBAR' ).
CALL METHOD cl_wd_toolbar_button=>new_toolbar_button
EXPORTING
enabled = 'X'
id = 'CUST_BUTT'
on_action = 'DOACT'
text = 'Custom Button'
view = ir_view
visible = '02'
RECEIVING
control = lo_toolbar_button.
lo_tool_item ?= lo_toolbar_button.
CALL METHOD lo_toolbar->add_toolbar_item
EXPORTING
index = 7
the_toolbar_item = lo_tool_item.
ENDIF.
In this case, no error is occurring and in ir_view->toolbar attribute toolbar items, i can see the dynamically created button added to the list, but it is not getting displayed.
Can anyone tell what or where am I missing?
Regards,
Yayati
Hello Matteo,
I tried it, but doesn't work. Moreover, If I add button through FPM configuration, then in the component controller method of FPM_OIF_COMPONENT, the event ID is not received, the attribute mv_event_id is not filled. Some default naming convention of standard FPM returns action ID as 'FPM_ACTION_ID_1'.
Hence I have to use a post exit to component controller method onactionbuttonpressed.
By this way I am able to achieve the purpose, but sometimes it gives PDO layer abort message or Interface error message.
My observation is that, the action performed does not refreshes the related quotation UIBB and also the quotation is in approval mode, and the action of this custom button needs BBP_DOC_CHANGE_BADI triggered which happens only in case of 'EDIT' mode.
Regards,
Yayati
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Yayati,
sorry but I don't get exactly your point... let's try to discuss a bit your consideration in order to have a clear view on the issue.
I don't know why your event_id variable is set as blank; it could be that your configuration enhancement is not properly configured, or simply you're looking for it in a wrong place. However, consider that the action_id can be used as well, as it won't change as the binding is 1:1.
Let's move on the issues you're facing:
DATA:
lo_task_factory TYPE REF TO /sapsrm/if_cll_taskcon_factory,
lo_task_container TYPE REF TO /sapsrm/if_cll_task_container,
lo_bom TYPE REF TO /sapsrm/if_cll_bo_mapper,
lo_pdo_base TYPE REF TO /sapsrm/cl_pdo_base,
usermode TYPE /sapsrm/pdo_inst_mode.
lo_task_factory = /sapsrm/cl_ch_wd_taskcont_fact=>get_instance( ).
lo_task_container = lo_task_factory->get_task_container( ).
lo_task_container->get_current_bo_mapper( IMPORTING eo_bo_mapper = lo_bom ).
CHECK lo_bom IS BOUND.
lo_pdo_base ?= lo_bom->/sapsrm/if_cll_xo_mapper~get_pdo( ).
CHECK lo_pdo_base IS BOUND.
CALL METHOD lo_pdo_base->/sapsrm/if_pdo_base~get_mode
RECEIVING
rv_mode = usermode.
usermode can then assume different values as DISPLAY ( /sapsrm/if_pdo_constants_gen_c=>gc_mode_display) or EDIT ( /sapsrm/if_pdo_constants_gen_c=>gc_mode_edit).
There are other ways to determine the current mode, however, this is just an example; you can switch the activation/visibility routine for your button according to the mode.
So probably the best way to understand how to sketch a solution is getting additional info on the requirement, for instance: why it's necessary to pass from BBP_DOC_CHANGE_BADI in order to accomplish the task? Which kind of modifications should be applicable on a document which is currently in approval state?
Best regards,
Matteo
Hi Yayati,
have you tried looking for methods offered by class cl_wd_toolbar_button, such as SET_VISIBLE, or SET_ENABLED?
If dynamic activation is what you need, you could also use the BIND_* version of the above cited methods with reference to a context attribute that you should change at runtime according to your requirement.
Best regards,
M.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Konstantin,
Thanks for quick reply.
I have already read the document. The problem is that, the document ( in this case ) is a quotation/RFX response which comes from an external system through XI/PI interface and in KSRM side, we create the quotation using BBP_PD_QUOTE_CREATE FM.
The point is, the quotation comes in awaiting approval state, in other words in approval mode.
If I add the button through FPM config, the button is displayed, but there is some problem with UIBB config and mode.
In the post exit of CNR_VIEW method buttonpressed, i added the code which needs to be performed on event ID of the button and i add some messages (W,I,E,A) type, but those are not displayed on screen. I found that mapper does not get refreshed in this case.
Hence i thought of adding button dynamically as once BADI is reached, the mapper gets refreshed.
Regards,
Yayati
Agree with Konstantin; probably the best way is to create statically the button via component configuration, and then manage its properties (such as visibility, or activation) w.r.t. your requirement by coding in WD_BADI_DOMODIFYVIEW.
You told:
"If I add the button through FPM config, the button is displayed, but there is some problem with UIBB config and mode."
If you can further elaborate such problems we could try helping with suggestions or sketch of code.
Best regards,
M.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.