cancel
Showing results for 
Search instead for 
Did you mean: 

Forcing a decimal

Former Member
0 Kudos

Hi

I have some data returned by an RFC which is bound to a table. This contains some Amount fields. The problem is that if there is no decimal value then the Amount is represented as a whole number without the decimals.

We would like to force the zeroes even if there are no decimal values returned by the RFC. Any input in this regard would be of great help.

regards

ceci

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ceci,

1. You can create a simple type and set the format for that simple type with decimal places. (####.00)

2. You have to create the value node and create the value attributes similar to the return table structure of the RFC.

3. Set the data type of the "Amount" value attribute with the created simple type.

4. Loop through the model node and set the data to the value node.

Hope this helps you.

Regards,

Santhosh.C

Former Member
0 Kudos

Hi Santhosh

But when I execute the RFC from the ABAP side, I am getting the data with decimal places.

Why do I have to create a simple type to get the decimal places?

regards

ceci

Former Member
0 Kudos

Hi Ceci,

It happens internally, when the data comes to the webdynpro side, the decimals are automatically formatted.

Thats why you don't see the decimals.

Regards,

Santhosh.C

Former Member
0 Kudos

Hi Santhosh

do i really have to loop through the model node and populate the value node?

is it possible to avoid the looping?

regards

ceci

Former Member
0 Kudos

Hi Ceci,

To avoid looping through the model node and assign it to the value node. You can create a value node and value attribute under the model node with the cardinality 1:1 and by using the supply function you can avoid looping through the model node.

Refer the blog "Supply functions in WebDynpro"

/people/sap.user72/blog/2005/03/15/supply-functions-in-webdynpro

Hope this helps. If you require more info on this send a reply.

Regards,

Santhosh.C

Former Member
0 Kudos

Hi Santhosh

thanks for the support. could you give me some sample code?

regards

ceci

Former Member
0 Kudos

Hi Ceci,

I don't have the samle code with me right away. I will send the code to you by tomorrow.

Regards,

Santhosh.C

Former Member
0 Kudos

Hi Ceci,

1. Create a simple type "ST_Amount", built-in type decimal and in the "Representation" mention the "Format" as "#,###.00##"

2. Create a value node "vnAmount" with cardinality 1:1 and "singleton=false" under the RFC output table.

3. Create a value attribute "vaAmount" under the value node "vnAmount" and set the "type" as created simple type "ST_Amount".

4. Click on the value node and create a supplyfunction.

5. Goto the implementation tab and write the following code.

IPrivateCO_ComponentName.IVnAmountElement amountElement = node.createVnAmountElement();

node.bind(amountElement);

amountElement.setVaAmount(parentElement.getRFCAmount());

6. In the Table UI element change the binding of the amount field. Select the newly created a value attribute.

This will solve your problem.

Regards,

Santhosh.C

Answers (0)