cancel
Showing results for 
Search instead for 
Did you mean: 

Issue while retrieving data from BAPI

Former Member
0 Kudos

Problem:

The initial exception that caused the request to fail, was:

com.sap.dictionary.runtime.DdException: Wrong amount type (not decimal): Unit service cannot be instantiated

at com.sap.dictionary.runtime.DdBroker.getUnitService(DdBroker.java:215)

at com.sap.dictionary.runtime.DdBroker.getUnitService(DdBroker.java:233)

at com.sap.tc.webdynpro.services.datatypes.core.DataTypeBroker.getUnitService(DataTypeBroker.java:337)

at com.sap.tc.webdynpro.progmodel.context.DataAttributeInfo.initReferenceAttribute(DataAttributeInfo.java:342)

at com.sap.tc.webdynpro.progmodel.context.NodeInfo.initStructureType(NodeInfo.java:708)

... 30 more

I have a BAPI - ZPM_CREATE_ORDER. I am trying to write a record to that BAPI. Did the Model Import from R/3[including the Commit ].

The structures of BAPI are like this:

Zpm_create_Order_Input

Order - Zpm_Hdr

Operations - [ Line Items structure ]

I have created the mapping between Model & Custom Controller with Order & Operations. Did the mapping between the Custom Controller & the View Controller. Binded them to the UI elements from View Controller with an input form.

But there are ABAP - decimal fields under Operations - price & Amount which are a Currency field and Quantity . So when I just try to run the application, I get the amount mismatch error. When I say run, I could n’t even see the GUI even. I get the 500 error with the above problem.

I read in the forums that I need to declare as a Simple type and re cast the fields to right type and bind that structure back. How ever, I could n’t get the complete understanding of it.

For a Retrieval Bapi with the exact same structure, the same issue if I map the Operations. How ever, if I skip the Operations and just map the Order i.e., header, then I could retrieve the records.

Interestingly even if I just map a String(char) field under Operations structure I am getting teh same error.

Any help is appreciated. Thanks in advance...

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Vivek,

the context attribute to which you map this BAPI field-what is the data type of this attribute?

Is it BigDecimal? I think the equivalent of ABAP decimals is BigDecimal in WD Java.

Regards,

Satyajit.

Former Member
0 Kudos

Hi Satyajit,

The data types of the structure that is failing contains couple of types: Chars (Strings), currency, quantity (numeric). The structure contains 15 to 20 fields at least 10 of them I need to display.

Even if I just take the Char fields in that structure and do the partial mapping from Model to all the way till the UI elements, I am getting the same error.

Thank you

--Vivek

Former Member
0 Kudos

Hi Vivek,

In your custom controller context, you should have a model node which is the replica of your BAPI model. In that node, the fields in the input structure should be of type from the BAPI. For example, types.Waers for Currency.

Do you have something like that?

Regards,

Satyajit.

Former Member
0 Kudos

Satyajit,

You are right. One of the fields needed is Waers(currency) which I have mapped from the Model to Custom Controller. I think, that is one of the causes but there are other fields too (for instance, Decimal type).

The surprising thing to me is that, even if I just map the character fields in that structure and not map the Decimal or Currency fields, then also I am getting the same error.

Thanks for the Reply...

--Vivek

Former Member
0 Kudos

Hi Vivek,

The problem is not on the web dynpro side. make the fields as a character fields and convert them into decimal in the BAPI. This the standard approach to implement business logic, on the backend. On the front end, you should not do any type castings and etc complex things.

Thanks,

Raj.