cancel
Showing results for 
Search instead for 
Did you mean: 

ALV + on_lead_select event

former_member474221
Participant
0 Kudos

Hi All,

I have used the std ALV component in my component. the scenario is working fine...below the ALV(A) i have another table(B) ...

when a particular row in the ALV is selected the corresponding records in table(B) should be shown....

I have written a supply function for table(B)....so whenever the record in A is selected I get records in B...

Although this is what i want I do not understand how is this working????

As i read somewhere that

"you have to create an event handler method for the event ON_LEAD_SELECT of the

ALV component" ???

however in my case I did not create any event handler method in my consumer component and still the lead selection of ALV works???

Edited by: hema T on Jan 23, 2012 5:16 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Hema,

There are 2 ways you can achieve this.

1. Subscribe to the ON_LEAD_SELECT event that the ALV interface controller provides.

2. Supply function - your node is bound to the DATA node of the ALV interface so on defining a supply function it auomatically gets executed on lead select in an ALV.

You have used the 2nd alternative and that is how it is working.

Thanks & Regards,

Gayathri Shanbhag

former_member474221
Participant
0 Kudos

Hi Gayathri

Ok. but for the ALV i have not mentioned any ACTION on the OnLEADSELECT section......infact there is no OnLeadSelect section on the UI for the ALV where i can specify the action....

Then how is the ALV automatically understanding the lead selection and going to the supply function of the child node...????

Pls reply???

Former Member
0 Kudos

Hi Hema,

I had assumed this.

You have 2 nodes - parent node and child node.

On click of an entry in an ALV bound to parent node you want the table bound to child node to display CORRESPONDING data.

I assumed you have defined a supply function for the parent node, if this is the case, you are doing a data binding between the node 'DATA' of an ALV and the parent node right? As the parent node data is displayed in the ALV and there is a lead select, I guess the supply function of the parent node is called. Here have you written the code to popluate the child node in your supply function? If yes, then this may be how it is populating the second table.

Thanks & Regards,

Gayathri Shanbhag

former_member474221
Participant
0 Kudos

Hi Gayathri,

Yes the mapping is between DATA and Parent node....but the supply function is attached to the child node and NOT the parent node...

So I wonder how the LEAD SELCTION of ALV ( parent node ) is getting triggered automatically and the control is going to the SUPPLY function thus populating the child node...

My doubt is how is the ALV lead selction gettin triggereed without specifying any ACTION etc and how is the supply function getting called automatically

pls reply

Former Member
0 Kudos

Hi Hema

The supply function for a child node is executed on lead select of an entry in the parent node, and that element of parent node is passed to the supply function of the child node as an input parameter.

You can go to the supply function of the child node and see an input called PARENT_ELEMENT, this refers to the selected element of the parent node.

There was a typo in my previous reply - the supply function of the child node is called & not the parent node.

[Check this|http://help.sap.com/saphelp_nw70ehp1/helpdata/en/f1/177741adb7167de10000000a155106/content.htm]

Thanks & Regards,

Gayathri Shanbhag

former_member474221
Participant
0 Kudos

Hi Gayatri

Thanks for a very good answer.....I thought that we always have to use a ACTION in the onLeadSelect even for the parent in the UI and then call the supply function from there....

Now I know ( and I have even tried ) that the Onleadselection is fired automatically for the parent node and the control goes to supply function automatically...

Thanks and let me know if the above assumption is wrong

Former Member
0 Kudos

Hi Hema

What you have tried is one way of doing it which worked.

There is always another way where in one subscribes to the on_lead_select of an ALV interface in the view through an event handler and writes the code there.

Either ways it works.

Thanks & Regards,

Gayathri Shanbhag

Answers (2)

Answers (2)

former_member184578
Active Contributor
0 Kudos

Hi Hema,

Yes you have to create an event handle for on_lead_select event of ALV. Go to methods tab, enter method name, select event handler type and press F4 and select on_lead_select event of SALV_WD_TABLE at event column.

check step 18 in this article for reference: [ALV on_lead_select in WDA|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/7020c76f-c40e-2e10-a795-d88e67740ee4?QuickLink=index&overridelayout=true]

hope this helps u.,

Thanks & Regards,

Kiran.

former_member182372
Active Contributor
0 Kudos

"you have to create an event handler method for the event ON_LEAD_SELECT of the ALV component" ???

This statement is valid for regular table's UI element ON_LEAD_SELECT event, ALV however already defined that event handler in view controller so you don't have to.