Setting ALV row color based on condition in ABAP WebDynpro

...Previous

9. Go to main view context and map the node of the component controller to the view component controller.

10. Go to methods tab and in WDDOINIT method on MAIN view using code wizard set the ‘table’ node as table operation. As shown below.

Source code in WDDOINIT

 DATA LO_ND_TABLE TYPE REF TO IF_WD_CONTEXT_NODE.

    
DATA LT_TABLE TYPE WD_THIS->ELEMENTS_TABLE.
    
data ls_table like LINE OF LT_TABLE.
SELECT * 
from vbap
into CORRESPONDING FIELDS OF TABLE LT_TABLE
UP TO 20 rows.

LOOP AT LT_TABLE into ls_table.
if sy-tabix = 2.
ls_table-celldesign = 
'01'.
MODIFY LT_TABLE from ls_table.
endif.
ENDLOOP.

*   navigate from <CONTEXT> to <TABLE> via lead selection
    LO_ND_TABLE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_TABLE ).

*
    LO_ND_TABLE->BIND_TABLE( NEW_ITEMS = LT_TABLE SET_INITIAL_ELEMENTS = ABAP_TRUE ).

In the below code the red marked section is where the based on condition the color code (01,02..etc) is set to the field celldesign in the ALV.

4.JPG

11.     Go to Component Usage and under properties tab click create to add the ZD_ALV_ROWCOLOR component.

Select the ZD_ALV_ROWCOLOR component to add it.

12. Go to Component Usage and under Context tab Map the ALV node TABLE of the component controller to the DATA of the interface controller of ALV

13.     Go to layout tab of MAIN view and create a VIEWCONTAINER UI element under rootelementcontainer.

Click here to continue...

SAP Virtual/Onsite Trainings

Document Categories:

What's New?

Contribute?

Sample Specs

What's Hot?

Web Dynpro for ABAP Tutorials 


Join the Mailing List
Enter name and email address below:
Name:
Email:
Subscribe  Unsubscribe 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image