Traffic Lights in SAP Web Dynpro ALV Table
This SAP Web Dynpro tutorial shows how to use traffic lights on ABAP ALV table in a Web Dynpro component. ABAP developers will find source codes to display traffic lights (images of red, green, yellow signals) on Web Dynpro ALV table.
Below is a sample Web Dynpro application where traffic lights (green, yellow and red lights) are displayed per row according to custom criteria on an SAP ALV table.
Following are the three different traffic light images and corresponding image names: ICON_YELLOW_LIGHT, ICON_RED_LIGHT, ICON_GREEN_LIGHT
Add a table field or a field to your data structure with data type STRING and field name "TRAFFICLIGHTS".
Below screenshot is showing that the field name is exactly used as TRAFFICLIGHTS.
I created a custom data element with data type STRING
Then in an ABAP program, ABAP programmers can update TRAFFICLIGHTS field to one of the valid traffic light colors (red, green, yellow) according to their custom requirements. Programmers can use a LOOP statement to run the custom function for each for for returning the traffic light field value which represents the web image name.
Following ABAP code is showing how to configure ALV table display for showing TrafficLights field as a traffic lights image on a SAP Web Dynpro page.
According to your criterias, ABAP developer should set the TrafficLights field value to one of the following predefined values.
ICON_GREEN_LIGHT ,
ICON_YELLOW_LIGHT or
ICON_RED_LIGHT
To summarize, if you have a field named TRAFFICLIGHTS in your data structure with one of the following constant values ICON_GREEN_LIGHT, ICON_YELLOW_LIGHT or ICON_RED_LIGHT it is possible to display red, green or yellow traffic lights on your ALV table display on SAP Web Dynpro component. The ABAP ALV display should be configured with cell editor set to image for the TRAFFICLIGHTS field. ABAP developers can use the above given sample ABAP codes in their Web Dynpro applications.