cancel
Showing results for 
Search instead for 
Did you mean: 

Pass a parameter in event

Former Member
0 Kudos

How can I pass parameters in event?

Say, I have a SAVE button in 3 different views. All will do more or less the same task and so they all call a common module.

But I need to pass some flag or variables from each view to do view-specific task.

How to pass data with each event?

Thanks in adv.

Accepted Solutions (1)

Accepted Solutions (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

The common logic should be a separate method callable from all views. The save buttons should have specific actions assigned for each view and of course corresponding event handler methods, in this methods, you can call the common functionality in all of the event handler methods.

Regards,

RIch Heilman

Answers (3)

Answers (3)

Former Member
0 Kudos

All ideas from Koen, Rich and Anuj will work.

To address the question literally as asked, pass a parameter in event,

this is also possible. This can make sense under some circumstances.

You can set a button, so that the action called then receives this parameter.

for example Used when multiple buttons should call same action.

how....

CL_WD_BUTTON->map_on_action( parameters = plist )

you need to get the button element from view first..

then use the map on action method to add your parameters.

These will be passed to the action when the button is pressed.

Of course Koen's recommendation is easier, and suits 90% + situations.

So try the easier way first.

Cheers

Phil

Former Member
0 Kudos

That's the thing I was looking for Phil.

I can address this issue by declaring global attributes, but i wanted to know how to pass parameters in event per se!

One reason why I asked this question:

See example WDT_TABLE. In VIEW_2, in the MY_BOOKING_TABLE, there is an action ON_CHANGE_FLIGHT which is assigned to onLeadSelect event.

In the event handler method, they have one more parameter NEW_ROW_ELEMENT.

Now where does this NEW_ROW_ELEMENT come from?

Can you tell me this also please?

Thanks again.

Former Member
0 Kudos

Hi Expets. Any reply to my query?

I post it again:

See example WDT_TABLE. In VIEW_2, in the MY_BOOKING_TABLE, there is an action ON_CHANGE_FLIGHT which is assigned to onLeadSelect event.

In the event handler method, they have one more parameter NEW_ROW_ELEMENT.

Now where does this NEW_ROW_ELEMENT come from?

Also, one thing I wanted to confirm. Is the context element from where the evvent was fired (for eg on_enter) always passed along with the event? i.e. can I just import contextt element too, and assume it shall be pointing to the element from where the event was fired?

Thanks.

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Aishi

When you try to assign an action to onSelect property of a Table control,

try to use the create option available against onSelect Property where you

enter the Action name and there is a check box available, if you check it

all the parameters are automatically passed by the framework.

Regards

Abhimanyu L

former_member196517
Contributor
0 Kudos

Hi,

have a global attribute ( component controlller) like name of view and in wdoinit of all view set the value and then in your common module you check this and perform accordingly...

thanks

Anuj

Former Member
0 Kudos

Hi,

i do this by having the same action name 'save',

but a different id, you can then filter the id in a case structure

grtz

Koen

Former Member
0 Kudos

what do you mean by different ID? Thanks