Skip to Content

In many everyday developments, programmers are required to reinvent the way that the data is displayed, in some cases representing the status of a record with a column of colors or intuitive images. Therefore, programmers must devise methods and alternatives for the end user to read the information needed in a simple and fast way. One of the many options is the use of OVS (Object Value Selector), but the option that I propose is the use of the DropDownByKey component provided by WebDynpro Java.

 

Prerequisites:
The tutorial for creating a mobile application for laptops is available on:
http://help.sap.com/saphelp_nwmobile71/helpdata/en/8F/0B674240449C60E10000000A1550B0/frameset.htm

 

Example Scenario:
When we handle service orders or other business items, certain fields of the record contain codes that represent the state of a record or provide unintuitive data to the end user. To solve this problem, a programmer needs to translate these codes to readable text for users, using certain programming techniques. In our case, we propose a simple and practical idea to solve this issue using the DropDownByKey component; an element provided by the WebDynpro Java Framework.

 
From the image, we can tell that the status of the order is displayed with a single character (0 or 1). This data has no meaning to the end user. The solution is based on the implementation of the DropDownByIndex element at the status column in the orders table.

 

Step by step solution:
The first step is to identify the data element that is being shown in the context of that element, in our case is a simple type CHAR1.
 

We have two ways to implement the solution:
1. Creating elements in the enumeration section for simple type CHAR1 of our local dictionary.
2. Dynamically creating these items (my preferred option) in the code.
To achieve this, we must implement the following code anywhere on our application. I recommend creating a method in the component controller class.

 public void FillStatusOptions() {
// @@begin FillStatusOptions()

//Getting Modifiable Simple Type info from the context attribute STATUS
ISimpleTypeModifiable orderType = wdContext
      .nodeORDERHEADER_ORDERHEADER().getNodeInfo().getAttribute(
 “STATUS”).getModifiableSimpleType();

//Getting Getting Modifiable Simple Type’s value set
IModifiableSimpleValueSet vS = orderType.getSVServices()
 .getModifiableSimpleValueSet();

//Setting the keys and texts
vS.put(“0”, “Inactive”);
vS.put(“1”, “Active”);
  // @@end
}

Then we call the method from a convenient place. In my case, it is called in wdDoInit() from the Component Controller Class.

 public void wdDoInit() {
  // @@begin wdDoInit()
  FillStatusOptions();
  // @@end
}

Now go to the view, locate the status column of the table and remove the graphic elements (TextEdit) and then insert a DropDownByKey element.
Bind the desired attribute (STATUS) on the selectedKey property of our element:

After deploying, the table would look like this:

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply