Tip

Web Dynpro ABAP Quick Tip: Table column sorting in four steps

This tip is for those who are very new to Web Dynpro ABAP and want to learn about the quick tips which can help solve issues. In today’s edition we will be covering table column sorting in four steps.

 

Most of us are familiar with the Table UI element and when we create a normal table and bind it to the context node, during the run time it appears like above. But in this case , the data is not complex or confusing. But sometimes these tables may have more number of columns with numerical values. So to make better sense of the values, most of the customers prefer to have sorting at the column level. Initially the sorting may seem to be a complex process, but no need to worry, Web Dynpro has provided us a table handler to carry out the sorting functionality.

 

1. Create an attribute in the view.

In your view, which holds the table UI element, create an attribute of type IF_WD_TABLE_METHOD_HNDL.

 

2. Populate the instance of the table method handler.

In the WDDOMODIFY , of your view method .Populate the table method handler to the newly created view attribute.

****Code in WDDOMODIFY****************** 

data wd_table type ref to cl_wd_table.

check first_time = abap_true.

* Name of the table UI element to be provided

wd_table ?= view->get_element( 'TBL_AUTHOR' ).

wd_this->table_control

    Requires Free Membership to View

?= wd_table->_method_handler.

*Name of the key attribute of the context node to which the table binding is done to be  provided

wd_this->table_control->set_key_attribute_name( 'USER_ID' ).

 

3. Create an action for the onSort event of the table.

Now we need to create an action for the onSort event of the table UI element. Create a new action and call the apply_sorting method available in the table method handler attribute.

*****code in the onSort event********* 

wd_this->table_control->apply_sorting( ).

 

4.Activate your view and test.

Now you can activate your view and test the application. The new table header will look like follows.

Now on click of the sort icon

The sorting functionality will be available to all the columns of the table.

Mohammed Anzy SWorking as a Development Specialist in SAP Labs.

This content is reposted from the SAP Developer Network.
Copyright 2007, SAP Developer Network


SAP Developer Network (SDN) is an active online community where ABAP, Java, .NET, and other cutting-edge technologies converge to form a resource and collaboration channel for SAP developers, consultants, integrators, and business analysts. SDN hosts a technical library, expert blogs, exclusive downloads and code samples, an extensive eLearning catalog, and active, moderated discussion forums. SDN membership is free.

Want to read more from this author? Click here to read Mohammed Anzy's Weblog. Click here to read more about ABAP on the SDN.



This was first published in August 2007

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.