cancel
Showing results for 
Search instead for 
Did you mean: 

Data display from BAPI

Former Member
0 Kudos

Hi Experts,

When i am testing a BAPI , the data from infotype is displayed as 1265.00 .

But when i am displaying the same data on portal through webdynpro code , the zeros are getting trauncated and it's getting displayed

as 1265 only .

Can anbody please tell me regarding this difference .

Secondly if i want to display my data as 1265.00 only (exactly same as in infotype) , then what modification i need to do in my webdynpro code ?

Thanks a lot in advance .

Accepted Solutions (1)

Accepted Solutions (1)

PradeepBondla
Active Contributor
0 Kudos

HI,

what is the type of attribute in back end and in web dynpro?

PradeeP

Former Member
0 Kudos

Hi Pradeep,

The data is coming from a model attribute and we are diaplaying it on screen afer adding them .

The type of attribute used in webdynpro is float .

Thanks a lot .

Former Member
0 Kudos

Jain,

Please convert the String value into BigDecimal while displaying in the View and you could see the decimals now.

Thanks!

Vivek.

Answers (3)

Answers (3)

nikhil_bose
Active Contributor
0 Kudos

try this code in component controller wdDoInit()


wdContext
.node<BAPI_Node>()    // node contains decimal attribute
.getNodeInfo()
.getAttribute("<dec_attr>") // decimal attribute name
.getModifiableSimpleType()
.setFormat("#,###.00"); // format specification

nikhil

Former Member
0 Kudos

Hi Nikhil,

I modified the code as per your suggestion . But it's giving runtime error saying "must not modify data type of a mapped attribute" .

PradeepBondla
Active Contributor
0 Kudos

Hi jain,

You can display as many zero's as you want after the decimal point, try this

DecimalFormat twoPlaces = new DecimalFormat("0.00");
twoPlaces.format(yourValue);

just for display purpose...

DecimalFormat twoPlaces = new DecimalFormat("0.00");
	wdComponentAPI.getMessageManager().reportSuccess(twoPlaces.format(1));

// it will give the out put of 1.00

PradeeP

Former Member
0 Kudos

Hi Pradip,

I changed the code as per your suggestion . Since then it's not working .

I have pasted the code below . Please help .

*****************************************************************************************************

IWDMessageManager manager = wdComponentAPI.getMessageManager();

float totalAmount;

float total=0;

int n = wdContext.nodexxx().size();

for (int i = 0; i < n; ++i) {

BigDecimal OrderAmount = wdContext.nodexxx().getxxxAt(i).getxxx();

try {

totalAmount =(OrderAmount.floatValue());

total = total + totalAmount;

} catch (NumberFormatException nfe) {

logger.errorT(nfe.getMessage());

totalAmount = 0;

}

}

DecimalFormat twoPlaces = new DecimalFormat("0.00");

* twoPlaces.format(total);*

wdContext.currentContextElement().setTotalOrderAmount(total);

PradeepBondla
Active Contributor
0 Kudos

Hi,

what is the type of TotalOrderAmount attribute? to which you are setting the value?

PradeeP

Former Member
0 Kudos

TotalOrderAmount is a value attribute which i have defined in context .It's type is float .

We are setting the value in TotalOrderAmount and displaying it in browser .

former_member197348
Active Contributor
0 Kudos

Hi Jain,

Try this out.

Create a method in Component controller and write this code. Whenever you call RFC. you have to call this method.

Add this line at the end

twoPlaces.format
(wdContext.currentContextElement().getTotalOrderAmount());

Regards,

Siva

Former Member
0 Kudos

Hi Jain,

you can use both Decimal and BigDecimal as the Data types for Displaying Decimals in the Portal.

Regards,

Sharma.