In this subchapter,through some examples, we will meet the SALV_WD_TABLE standard component and its advantages.
Simple ALV Example
We create a WD component that displays all the information about candidates by using the SALV_WD_TABLE,ALV component. To be able to use this component, we have to firstly define a usage. Figure shows the WD component structure and the usage definition
WD component structure
In the COMPONENTCONTROLLER,we create a node PERSON with thedictionary structure YPERSON,Singleton, Cardinality 0...n and supply function SUPPLY_PERSON.
Context node and supply function
In this case,we have chosen to use a ViewContainerUIElement to embed the Table view of the SALV_WD_TABLE component,but we can embed a view or an interface view directly in a Window if we don’t need additional UI elements.The table view is the central view of an ALV component and represents the container in which the ALV output is displayed.Figure shows the Window structure and the selected Interface View.
Window structure and interface views of the ALV
To be able to create a reverse mapping, we firstly create an interface controller usage.
Interface controller usage
Then,we need to provide the DATA context node with the values from the PERSON context node.
DATA context node must contain the structure and data of the ALV output.The runtime result is presented.
As we have mentioned above,the ALV component offers new capabilities,as follows:
The settings option offers the capability to hide some columns, to create complex searches and complex filters,to change the display mode and to create a print version. We can save the changes we made and assign them to the current user as an initial view.
ALV Configuration Model
To configure an ALV output,we can use: table settings, column settings,field settings,standard function settings or application-specific function settings.
By using the transaction SE24,
we can see the structure of the CL_SALV_WD_CONFIG_TABLE. Here,we find the interfaces and their methods to be used to manipulate the ALV output.
Manipulating the ALV Output:Deleting Rows, Hiding Columns,Table Designing,Sorting
We want to manipulate the ALV output to show only five rows, to use the Table Design Alternating to sort table ascending by the id_country field and to hide the first two columns, Client and ID.We use the below example, where we make some changes. We define a usage at the V_VIEW level.
Defining the usage at the View level
The wdDoInit Hook methodMETHOD wddoinit .
As we can see,we have used the method GET_MODEL from the interface IWCI_SALV_WD_TABLE.This method has no importing parameters and returns a complete Configuration Model(CL_SALV_WD_CONFIG_TABLE).
The ALV component is partly based on the Table UI element.To set the Table design and the number of visible rows,we use the methods set_design and,respectively,set_visible_row_count from the interface IF_SALV_WD_TABLE_SETTINGS.
If we look at the dynamic programming of a Table UI element,we can see that the property for the Table design alternating is cl_wd_table) e_designalternating, and the property VISIBLE_ROW_COUNT is an integer number(in our case, 5).
To delete the two columns, we use the method delete_column from IF_SALV_WD_COLUMN_SETTINGS interface, and to create asort rule we use the methodcreate_sort_rule from the IF_SALV_WD_INTERFACE interface.
The default sorting rule is:
sort_order = if_salv_wd_c_sort => sort_order_asscending
Changing the Cell Editor
As we know,the content of a cell to be displayed is specified by the table cell editor of the column. In the default mode,the table cells are created by using the TextView UI element.
We change the cell editor for the EU Countries column.In this case,we use a linkToURL UI element that opens the web page where we can find all the information about the EU countries.To do this,we need to add some coding at the below example.We need to dynamically create a linkToURL UI element. The Listing shows the additional coding in the wdDoInit Hook method.
Changing the cell editoDATA:lr_column TYPE REF TO cl_salv_wd_column,
Adding a Header for the ALV Table
For an ALV table,we can add a header,too.To do this,we have to use the method CREATE_HEADER of the IF_SALV_WD_TABLE_SETTINGSinterface.
Header for ALV tablDATA:lr_settings_alv_table TYPE REF TO if_salv_wd_table_settings.
Header for ALV table
Setting the Top of List and the End of List for the ALV Output
For an ALV output,we can create a top of list (header text) and an end of list (footer text).As we have seen, the ALV component we have used provides two context nodes,named TOP_OF_LIST and END_OF_LIST.These context nodes hold the data for header and footer. Each context node contains an attribute namedCONTENT of CL_SALV_FORM_ELEMENT type.
To be able to access these context nodes from our view V_VIEW, we have to create a context mapping.
Then,we have to define the basic layout and to create the elements. In our case,we have chosen to use the Row type layout,
class CL_SALV_FORM_LAYOUT_ FLOW.We create a text element for the header and a text element for the footer.
Header and footer for an ALV tableDATA lr_node_top_of_list TYPE REF TO if_wd_context_node.
Adding a Self-Defined UI Element to the ALV Toolbar
On the ALV toolbar,we can add our own UI elements. We add a linkToAction UI element.
Adding a linkToAction UI element to the ALV toolbarDATA lr_linktoaction TYPE REF TO cl_salv_wd_fe_link_to_action.
To transform our linkToAction into another UI element,we have to change the editor type from the linkToAction (CL_SALV_WD_FE_LINK_TO_ACTION) into another allowed type.For example,to have a button editor,we have to changee only the class name: CL_SALV_FE_BUTTON.
When the user presses this link,we have to trigger an event handler method.As we can see,we have not defined an action for this link. To know the UI element that was pressed,we use the ON_FUNCTION event.
We create an event handler method named LINKTOACTION_ACTION and we choose the event ON_FUNCTION.
Event handler method for our self-defined linkToAction
If our link with the ID = “LTA” is pressed,a statement block is executed.
Event handler method
SAP ABAP Web Dynpro Related Tutorials
|SAP ABAP Tutorial|
SAP ABAP Web Dynpro Related Interview Questions
|SAP ABAP Interview Questions||SAP ABAP Web Dynpro Interview Questions|
|Sap Abap Hr Interview Questions||SAP ABAP Dictionary Interview Questions|
|SAP ABAP Enhancement Interview Questions||SAP ABAP Module Pool Interview Questions|
|SAP ABAP Report Developer Interview Questions||SAP ABAP Data Dictionary Interview Questions|
|SAP ABAP ALV Reports Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.