Skip to Content
Business applications whose usage spans multiple countries usually handle multiple currencies.. And with it comes , multiple currency formats.

How have been handling this in WebDynpro til now?

Some methods we have been following are…
We create a simple type , of base type Integer.. and in its external representation we give the format that is required.

External Representation: “##,###.000#”

 

What does it do ?
         It takes the integer value and formats it to the particular format for display. This method can be used when we need percentage displays or if we have format decimals in a specific way.
One other commonly used method is usage of modifiable simple types.

attributeInfo.getModifiableSimpleType().setFormat(“#,###.00#” );

A handicap with these methods being , we cannot implement them in instances when we use a single  value attribute to display different currencies each having a different format.

One quick fix would be to utilize the calculated attribute feature in WebDynpro. We can determine the currency used in the accessor and format the amount accordingly. This is not a neat solution as we need to hard-code the format for each currency. Taking into account all the currencies and formatting them accordingly would make the solution untidy.

To facilitate this process, SAP has introduced “setR3NormalizingFormattingService”.Unfortunately the catch is , its usage isn’t straightforward.
It’s usage is defined in the following section.

Scenario:
ITELO customer needs an application to keep track of their monthly telephone usage in their administrative offices.
They have 32 offices across the world in different regions. They need a report which displaysthe monthly telephone expenditure in their local currency and the equivalent amount in euros.

Two S/w developers are working on it.Dev 1 needs to provide the solution. Dev 2 is the other developer in the team.

Dev 1 : Hi Dev2. I am facing an issue on this ITELO customer requirement. Could you help me on this ?
Dev 2 : Yes Sure. What is the issue?
Dev 1 : I need to format amounts based on the currency they belong to. I am not able to find out a generic solution to implement it. The customer does not want us to hard code any values.

Dev 2 : Haven’t you worked on”setR3NormalizingFormattingService”. This was introduced for this exact requirement.
Dev 1 : Oh that’s cool ! How do i use? Any documentation?
Dev 2 : It is a function listed under interface IWDAttributeInfo.

 void setR3NormalizingFormattingService (boolean formatting)

When set to true , values are sent to Adaptive RFC in a normalized fashion i.e. with 2 decimal places. But on display an appropriate formatting function is invoked and the currency value is formatted.

 
Dev 1: Thanks a lot for the information.. I will work on it..
 
After a while….
 
Dev 1 : oh oh !This thing is not working.. Its throwing me an error “The attribute is not based on a structure field.”. Why should it be a part of a structure. What nonsense!
Dev 2 : There is a sound logic behind it..it does have point.. I should have explained its working better..
 
This is how. !
 
Navigate to Dictionary -> Structures
1. Create an a structure with element of type CURR Simple type.
2. Create another element.. “Cost”of type decimal and in its reference element select the CURR element we have created in step 1.
 

image

 
This definition is used by WebDynpro at run time to determine the type of currency the amount belongs to.
 
For example ,in a value node..(created based on our structure) there is one element whose “Cost” is 100.00 and “Currency” is INR. 
   
When displaying this amount, the webdynpro runtime does the following activities.
 
1. Read the “Cost” attribute’s attribute info
2. Find its parent structure
3. Read the reference currency attribute, if any. i.e. “Currency”.
4. Obtain currency Key stored in this currency value attribute, for the particular node element
5. Each currency has an equivalent simple type (an xml file)defined. Read the appropriate currency simple type from the dictionary .
6. Parse the simple type file and obtain the corresponding format.
6. Apply this format to the value stored in “Cost” for the corresponding currency key.
 
Pretty Simple, Isn’t it.
 
A structure is hence mandatory.
 
The following shows the value”100.00″ formatted based on the currency selected.
 

image

 
 
And thus the”ITELO Development” story ended. .. !
 
I hope this information was interesting and useful. 
 
Many thanks to Bertram Ganz and Uwe Reeder for elucidating on the intricacies of this function.
 

 

To report this post you need to login first.

5 Comments

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

  1. Lee Fox
    Thanks much for the very useful info.  One question i have is how this can be used effectively with model nodes.  For instance, I’m working on invoice edit screens.  There are many money related fields at both the header and line item levels. 

    Any ideas?

    Thanks again,
    Lee

    (0) 
    1. Bharathwaj Ragothaman Post author
      You are welcome ! In case of Model nodes , if the data type of the  model attribute is based on CURR , then , you can get the attribute info and use setR3NormalizingFormattingService directly. In this case , the mapping between amount and currency simple type in webdynpro is handled already.

      For instance , in SE11 search for GESBB .. this is based on CURR and stores the amount in DEC .

      So… for proper utilization of this function , create the data type in the backend as CURR..

      Hope this helps.

      Regards
      Bharathwaj

      (0) 
      1. Lee Fox
        When i try that I get the following error
        “Field Wrbtr does not have any reference field”
        i can’t added a reference from inside Web Dynpro IDE on model dictionary structures.  what am i missing?  is there something i need to have done on the R3 side?  I double checked that the field is based on CURR.

        Thanks much,
        Lee

        (0) 
        1. Bharathwaj Ragothaman Post author
          Hi ,

          Sorry that I had mislead you.. I had assumed it would take from the currency type..

          A closer look at it revealed that we have to look at the associated structure in the backend.

          For example , in my case PTRA_WEB_RECEIPTS_EXT is the structure which has PAY AMOUNT of type GESBB.

          If you double click on PAY AMOUNT , you can see a section called reference field. Here the refernce is defined.

          This should resolve your problem….

          Regards
          Bharathwaj

          (0) 

Leave a Reply