Skip to Content
Author's profile photo Former Member



WebDynpro (both Java and ABAP edition) provides great options for formatting majority of data types. However, certain applications have own types (or if you like domains in RDBMS world) and demand even more – phone numbers, SSN, credit card numbers etc. WebDynpro does not support these capabilities out of the box, but you may roll your own solution using calculated attributes.


We have Phone Number data type from backend. Originally it is a field of type long. But we want to display it in user-friendly manner, something like (123)456-7890 for value 1234567890.


You have already an attribute in context node, say Phone (phone number with extension code) of type long.

    1. Create calculated attribute

PhoneFormatted of type string:

    1. create sub-node with cardinality 1..1 and selection 1..1 as direct child of aforementioned node;

create string attribute PhoneFormatted here of type string;

    1. select calculated in properties and WD generates getter / setter methods for attributes in controller.
    1. Add the following block to the custom coding area of controller:

//@@begin others
private MessageFormat fmtPhone = new MessageFormat
final private static Pattern PHONE = Pattern.compile

    1. Complete code for calculated attribute getter:

//@@begin javadoc:getPhoneFormatted(IPrivateRTFViewerCV.IContextElement)

  1. Declared getter method for attribute PhoneFormatted of node <SubNodeName>

  1. @param element the element requested for the value

  1. @return the calculated value for attribute PhoneFormatted

public java.lang.String get

//@@begin javadoc:setPhoneFormatted(IPrivateRTFViewerCV.IContextElement, java.lang.String)

  1. Declared setter method for attribute PhoneFormatted of node <SubNodeName>

  1. @param element the element to change the value

  1. @param value the new value for attribute PhoneFormatted

public void set

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Maksim Rashchynski
      Maksim Rashchynski
      Hey, seems like you have figured out first usefull purpose of setter method in calculated attributes :-).
      Author's profile photo Former Member
      Former Member

      Not actually the first 😉

      First one was obvious and used intuitively by many of developers: it is simple read-only calculated attribute that converts Boolean to WDVisibility, or negate Boolean, or convert some "state" (numeric value) to WDTextViewSemanticColor etc.

      Oh, you mean "mutator" part...

      Then first one was described in this tutorial:

      So this is actually 2-nd application 😉