cancel
Showing results for 
Search instead for 
Did you mean: 

Parameter passing for actions binded to custom WD elements

matteo_montalto
Contributor
0 Kudos

Hi all gurus,

this should be a basic question but I'm not able to find any explicit documentation on the argument, so I decided to start a thread in order to get things a bit clear... hope you will support me with suggestions and eventually, links to useful docs.

Shortly; I created via dynamic programming two different buttons:

DATA add_to_bid_button   TYPE REF TO cl_wd_toolbar_button.

DATA add_to_Bid_choice   TYPE REF TO CL_WD_TOOLBAR_BTN_CHOICE.

These buttons have substancially the same meaning; the first is shown when the possible choice is *exactly *one; otherwise, if more choices are determined at runtime, the toolbar button choice one is shown.

Both these  buttons are binded to a custom action, say, "FOO": it has an unique parameter which is WDEVENT, TYPE REF TO CL_WD_CUSTOM_ELEMENT.

Now; I'd like to add to the event's parameters two entry, and specifically:


SELECTION , which will be of type /sapsrm/t_cll_wd_soco_workarea

BIDNUMBER, which will be a CHAR10.

The problem is that I don't know how to add these two additional params at runtime and "bind" them to the buttons.

Starting from the simple CL_WD_TOOLBAR_BUTTON; I create it in this way

    add_to_Bid_button = cl_wd_toolbar_button=>new_toolbar_button( text = 'Add to Bid' id = 'ADD_TO_BID'

                                                                   bind_visible = 'ADD_TO_BID_ENABLE'

                                                                   bind_enabled = 'ADD_TO_BID_ENABLE'

                                                                   ON_ACTION    = 'FOO').


     There's however no option to specify that FOO has additional parameters.

For what concerns the button choice, I add dinamically a menù action item for each entry:

CALL METHOD CL_WD_MENU_ACTION_ITEM=>NEW_MENU_ACTION_ITEM

           EXPORTING

*            BIND_DISABLED_IMAGE_SOURCE =

*            BIND_ENABLED               =

*            BIND_IMAGE_SOURCE          =

*            BIND_NEEDS_MORE_INFO       =

*            BIND_START_SECTION         =

*            BIND_TEXT                  =

*            BIND_TEXT_DIRECTION        =

*            BIND_VISIBLE               =

*            DISABLED_IMAGE_SOURCE      =

*            ENABLED                    = 'X'

*            HOTKEY                     = E_HOTKEY-NONE

             ID                         = item

*            IMAGE_SOURCE               =

*            NEEDS_MORE_INFO            =

             ON_ACTION                  = 'FOO'

*            START_SECTION              =

             TEXT                       = itemlabel

*            TEXT_DIRECTION             = E_TEXT_DIRECTION-INHERIT

*            VIEW                       =

*            VISIBLE                    = 'X'

           RECEIVING

             CONTROL                    = choice.

             .

         CALL METHOD ADD_TO_BID_CHOICE->ADD_CHOICE

           EXPORTING

*            INDEX      =

             THE_CHOICE = choice

             .

Same as before, I can't find a way to specify that each possible chose should trigger FOO with two additional parameters.

So, how can I specify that WDEVENT should contain two additional params? And how to set them dynamically at runtime?

Thanks for your attention and support.

Accepted Solutions (1)

Accepted Solutions (1)

matteo_montalto
Contributor
0 Kudos

Solved passing the internal table defining parameter as follows:

CREATE DATA data_ref LIKE TABLE OF row.

         ASSIGN data_ref->* TO <data>.

         <data> = rows.

         PARAMETER-NAME = 'SELECTION'.

         PARAMETER-DREF = data_ref.

         PARAMETER-TYPE   = CL_ABAP_TYPEDESCR=>TYPEKIND_DREF. "data_ref.

         INSERT PARAMETER INTO TABLE PARAMETERS.

Thanks for your help!

Answers (2)

Answers (2)

Abhinav_Sharma
Contributor
0 Kudos

Hi Matteo,

You can map the additional parameters with the UI elements custom event i.e. wdEvent. UI elements like

DATA add_to_bid_button   TYPE REF TO cl_wd_toolbar_button.

DATA add_to_Bid_choice   TYPE REF TO CL_WD_TOOLBAR_BTN_CHOICE.

contains one method name MAP_ON_ACTION which accepts the parameters of type IF_WD_EVENT=>PARAMETERS.

Here you can enter the additional parameters as follows ( Lets take example of add_to_bid_button and you can do the same for other ).

in wdDoModify get the instance of add_to_bid_button and then call method

   DATA: lt_params like IF_WD_EVENT=>PARAMETERS,
        wa_params type WDR_NAME_VALUE.
 
        wa_params-name = 'SELECTION'.
        wa_params-value = 'value'.
        APPEND wa_params to lt_params.
       
        wa_params-name = 'BIDNUMBER'.
        wa_params-value = 'value'.
        APPEND wa_params to lt_params.

        add_to_Bid_button  ?= view->get_element( ID = 'BUTTON_ID' ).
        add_to_Bid_button->MAP_ON_ACTION( PARAMETERS = lt_params ).
 

Please explore  WDR_NAME_VALUE to work with objects and data types.

Hope this way you can add the parameters and assign the same dynamically.

Cheers!

Abhinav

matteo_montalto
Contributor
0 Kudos

Ok, my mistake, I found an exaustive example from SAP documentation at:

http://help.sap.com/saphelp_erp60_sp/helpdata/en/33/b11042705a5533e10000000a155106/content.htm

There's however a problem trying to pass an internal table as parameter.

According to the documentation, I should insert a "table" parameter as follows:

DATA PARAMETERS TYPE WDR_NAME_VALUE_LIST.

DATA PARAMETER  TYPE WDR_NAME_VALUE.

DATA data_ref TYPE REF TO data.

FIELD-SYMBOLS <data> TYPE any.

" Parameters can be deep data objects (structure/table)

CREATE OBJECT data_ref LIKE table.

ASSIGN data_ref->* TO <data>.

<data> = table.

PARAMETER-NAME = 'TABLE'.

PARAMETER-DREF = data_ref.

PARAMETER-OREF = CL_ABAP_TYPEDESCR=>TYPEKIND_DREF.

INSERT PARAMETER INTO TABLE PARAMETERS.

I tried almost everything but can't get it to work. As LIKE suggests, table should be the name of the internal table (in my case, ROWS, which is a TYPE /sapsrm/t_cll_wd_soco_workarea),

But

CREATE OBJECT data_ref LIKE ROWS.

returns the error:

"Field "LIKE" is unknown. It is neither in one of the specified tables ..."

So CREATE OBJECT doesn't support LIKE. Tried then with TYPE, and using the table type:

CREATE OBJECT data_ref TYPE /sapsrm/t_cll_wd_soco_workarea.

and got the following error:

"DATA_REF" must be an object reference, an interface reference or TYPE ANY".

Tried then  with TYPE ANY, and again, got the same message above.

I'm stuck at that, could anyone suggest how to proceed?
Thanks