cancel
Showing results for 
Search instead for 
Did you mean: 

Truncating Leading Zeros & Displaying Decimal Positions in a Webdynpro

Former Member
0 Kudos

Hi All,

I am new to webdynpro and assigned with some issues in webdynpro application, the issues goes like this. i already have a webdynpro application where in i am trying to display a PO as in transaction ME23 with Header and Line Items, In Line Items, i want to Truncate Leading Zeros for material Number & Item Numbers. In the net price i want to display decimal values even if our price don’t have any decimal value. For Example if the net price is 33.33 then i am able to see the value as 33.33. If it’s 33.00 then i am able to see values only as 33. I want to see the exact value as 33.00. Let us know how to over come those issues.

Thanks in advance,

With Best Regards,

Prabahar N.R

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Check this topic about formatting model attributes:

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Prabahar,

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

2. Create a attribute called "vaAmount" of type "ST_Amount".

3. Bind it to the UI element.

4. Set the value to "vaAmount"

Now in the screen you will be able to see the value as per your requirement.

If you would like to display, the values in a table then refer the following thread.

https://www.sdn.sap.com/sdn/collaboration.sdn?node=linkFnode6-1&contenttype=url&content=https://

Hope this solves your problem.

Regards,

Santhosh.C

Former Member
0 Kudos

Hi Santhosh,

Thanks for the detailed steps. I will get back to you after trying out.

Regds,

prabahar N.R

Former Member
0 Kudos

Hi Santhosh,

I failed while executing the steps you mentioned, kindly look into below description for more understanding.

We have an issue like the decimal positions are truncated when the value of decimal places are Zero. For Example if the net price is 99.98 then i am able to see the value as 99.98. If it’s 99.00 then i am able to see values only as 99. I want to see the exact value as 99.00. The values are populated from an RFC Table, which is coming from a Standard BAPI. I find in the implementation, the attributes uses a method called bindText() available in com.sap.tc.webndypro.clientserver.uielip.standard.api.IWDtextview. Below is the piece of code,

com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTextView NetPrice_editor

= (com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTextView)

wdAlterEgo.createElement(com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTextView.class, "Net_Price_editor");

NetPrice_editor.setHAlign(com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDInputFieldAlignment.valueOf("left"));

NetPrice_editor.setWrapping(true);

NetPrice_editor.bindText("bapi_po_getdetail_input.Output.Po_Items.Net_Price");

NetPrice.setTableCellEditor(_Net_Price_editor);

Table.addColumn(Net_Price);

I can see from R/3 back end the values coming with decimal values even if the decimal positions are null. Any suggestions will be very helpful.

With Best Regards,

Prabahar N.R

Former Member
0 Kudos

Hi Prabahar,

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

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

3. Create a value attribute "vaNetPrice" under the value node "vnNetPrice" and set the "type" as created simple type "ST_NetPrice".

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

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

IPrivateCO_ComponentName.IVnNetPriceElement netPriceElement = node.createVnNetPriceElement();

node.bind(netPriceElement);

netPriceElement.setVaNetPrice(parentElement.getNet_Price());

6. Change the binding of the "net price" field.

<i><b>//Your code</b></i>

NetPrice_editor.bindText("bapi_po_getdetail_input.Output.Po_Items.Net_Price");

<i><b>//Changed code</b></i>

NetPrice_editor.bindText("bapi_po_getdetail_input.Output.Po_Items.vnNetPrice.vaNetPrice");

Since the binding in your code still pointing to the RFC field element it is not changing the format of the "Net Price".

If you still require some clarification do let me know.

Regards,

Santhosh.C

Former Member
0 Kudos

Hi Santhosh,

What do you mean by statement

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

I am trying to create a vale node in the Context Mapping. Is it right? What do you mean by RFC Output Table?

I am sorry if my queries sounds silly to you? But it's how it is as i am new to web Dynpro.

Also if could you describe in detail with beginning steps like Creation of Simple Type it will be very very help ful.

Thanks for your continuous support.

With Best Regds,

Prabahar N.R

Former Member
0 Kudos

Hi Prabahar,

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

From the table binding I understood you are binding "PO_ITEMS" to the table UI element. So you have to create the value node "vnNetPrice" under "PO_ITEMS" model node.

You can create this either in the controller's context or in the view's context.

Regaring "Creation of Simple Type" refer "Creating Data Types"

http://help.sap.com/saphelp_nw04/helpdata/en/99/28c30af89be54088286cb3e06672fc/content.htm

Hope this is clear to you.

Regards,

Santhosh.C