note about studying ALV in abap webdynpro

Simple Example for Using ALV
1. create component
2. create component controller’s context

NODE_FLIGHT, dictionary structure: SFLIGHT, attribute of structure: CARRID, CONNID

NODE_FLIGHTTAB, dictionary structure: SFLIGHT, cardinality: 0..n, attribute of structure: CARRID, CONNID, FLDATE, CURRENCY, PLANETYPE, SEATSMAX, SEATSOCC and PAYMENTSUM

clear property of dictionary structure to prevent ALV component from showing all the fields of structure SFLIGHT
3. create method for filling the fights: FILL_FLIGHTTAB

get flight node

get flight element

get attributes of element

dynamic generate sql where statement

select data into internal table and bind it to node NODE_FLIGHTTAB
4. create search view

mapping component context NODE_FLIGHT to view context

create input group, below it create two input fields, use Create Container Form from context menu.

create search button and it’s action, in implementation code call component method FILL_FLIGHTTAB
5. create layout view

create a view, set layout property to MaxtrixLayout

create two elements of type View_Container_UIElement, name is SEARCH and TABLE, setting layout of both view to MaxtrixHeadData.
6. embed layout view to window

embed search view to node SEARCH in layout view
7. use another component

define component usage Name: ALV, Component: SALV_WD_TABLE

mapping component context node NODE_FLIGHTTAB to node DATA of interface controller of ALV component

embed view SALV_WD_TABLE of component ALV to node TABLE of layout view
8. create and test Web Dynpro Application

Programming the ALV Configuration Model
1. create component from previous example
2. create view RESULTVIEW
in view context, copy and map context node NODE_FLIGHT from component controller’s context
create a node named CONTAINER, it’s type is ViewContainerUIElement
3. in properties tab of view RESULTVIEW, click new button to define the component usage of SALV_WD_TABLE
4. implement method WDDOINIT of view RESULTVIEW

instantiate used component, use code wizard.

get ALV configuration mode, use code wizard.

configure alv component:

set visible row count to 5

sort descended by column occupied seats
5. display a icon in ALV column

in component controller, add a node STATUS under node NODE_FLIGHTTAB, type is STRING

in component method FILL_FLIGHTTAB, set the value of node STATUS

in view RESULTVIEW, update the mapping

in method WDDOINIT of view RESULTVIEW, set cell editor of column SEATSOCC to image: cl_salv_wd_uie_image, and delete column display in ALV
6. change embed view of node TABLE in view LAYOUT to view RESULTVIEW, and embed view SALV_WD_TABLE of ALV into element CONTAINER of view RESULT
7. create and test Web Dynpro Application

Editing ALV
1. create component from previous example
2. add some code in method WDDOINIT of view RESULTVIEW
get column PRICE
create an object represented a input field, value_fieldname setting to PRICE
set cell editor of column price to the above object

set readonly property of ALV setting to false
3. create save button in layout of view RESULTVIEW
create corresponding SAVE action, in the action call method data_check of ALV component
4. create event handler ONDATACHECK
get node NODE_FLIGHTTAB and it’s value
save data in database, in this example it’s a fake code
get current controller, get it’s message manager
report a success message via call method report_success of message manager
5. create and test Web Dynpro Application

Using Events with ALV Tables
1. create component from CONFIG component
2. add some code in method WDDOINIT of view RESULTVIEW
get column CARRID
create button cellEditor and bind to column CARRID
get column CONNID
create link_to_action cellEditor and bind to column CONNID
3. create a node in context of view RESULTVIEW, name is EVENT_PROPERTIES, set the cardinality to 0..n

add two attributes to the newly created node, set name to NAME and VALUE, both of type STRING
4. create event handler method ONCLICK for ON_CLICK event of ALV interface controller
information about event in method parameter r_param, for example, r_param->colum, r_param->index, r_param->attribute, r_param->value
store those informations in a internal table, and bind this table of node EVENT_PROPERTIES
5. display the event
add a table control in the view RESULTVIEW and bind to node EVENT_PROPERTIES
6. create and test Web Dynpro Application

Using ALV with a Dynamic Context Node
1. create component
2. create view, and create a context node INPUT with attribute TABLENAME of type STRING
create button show and action SHOW
create container UI element CONTAINER
3. create dynamic context node
in method ONACTIONSHOW, fill the following code:
get node INPUT and the value of attribute TABLENAME
get root node info
create a node dynamically, cl_wd_dynamic_tool=>create_nodeinfo_from_struct
crate a internal table which type is table of INPUTTABLE
get data via dynamic sql statement and bind to the new created node
4. declare usage of the ALV component inside new created component
declare usage of the ALV component inside new created view
5. set data to ALV display
instantiate the ALV component
call method SET_DATA of interface controller of ALV component
6. embed view TABLE in ALV component in the container of view RESULTVIEW
7. create and test Web Dynpro Application

Comments are closed.