cancel
Showing results for 
Search instead for 
Did you mean: 

at a2i.core.Value.GetStringValue(Unknown Source)

Former Member
0 Kudos

Hi,

could somebody tell me what the problem is with the code below (MDM API)?

I keep getting this error everytime the program process the "msgMan.reportSuccess(partnerId.GetStringValue());" lines:

ERROR:

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

java.lang.ClassCastException

at a2i.core.Value.GetStringValue(Unknown Source)

at com.sap.components.MDMWD.GetRecordID(MDMWD.java:547)

at com.sap.components.wdp.InternalMDMWD.GetRecordID(InternalMDMWD.java:173)

at com.sap.components.MDMWDView.onActionlogon(MDMWDView.java:154)

at com.sap.components.wdp.InternalMDMWDView.wdInvokeEventHandler(InternalMDMWDView.java:138)

Source Code:

IWDMessageManager msgMan =

wdControllerAPI.getComponent().getMessageManager();

try {

//Define Result Set (Table structure)

ResultSetDefinition rsd =

new ResultSetDefinition("MDM_BUSINESS_PARTNERS");

Search search = new Search("MDM_BUSINESS_PARTNERS");

rsd.AddField("MDM_PARTNER_ID");

rsd.AddField("MDM_FIRST_NAME");

rsd.AddField("MDM_SECOND_NAME");

A2iResultSet rs = catalogData.GetResultSet(search, rsd, null, true, 0);

Value partnerId = new Value();

Value firstName = new Value();

Value secondName = new Value();

if (rs.GetRecordCount() > 0) {

id = rs.GetRecordIDAt(0);

for (int i = 0; i < rs.GetRecordCount(); i++) {

partnerId = rs.GetValueAt(i, "MDM_PARTNER_ID");

firstName = rs.GetValueAt(i, "MDM_FIRST_NAME");

secondName = rs.GetValueAt(i, "MDM_SECOND_NAME");

msgMan.reportSuccess(partnerId.GetStringValue()); <<<------ ERROR (Line 547).

msgMan.reportSuccess(firstName.GetStringValue());

msgMan.reportSuccess(secondName.GetStringValue());

}

msgMan.reportSuccess(rs.toString());

}

} catch (StringException e) {

msgMan.reportException(e.getMessage(), false);

}

Accepted Solutions (0)

Answers (3)

Answers (3)

diego_gaudenzi
Participant
0 Kudos

What you have to use is the internal record Id of the record. Every record has an internal record id which is passed to the different functions. So if you read the record the record Id should be already available in the result set.

The method was called GetRecordIDAt(row).

Regards,

Diego.

diego_gaudenzi
Participant
0 Kudos

I already fixed the problem myself.

Thanks for replying back.

Diego.

Former Member
0 Kudos

Hi,

can you share your solution with us plz?

regards

Former Member
0 Kudos

The problem is partnerId is not defined as Text in the console.

You have two options.

You can use GetValueTypeForField method of CMFieldType to return ValueType for the field.

You have to cast it accordingly.

The other option is to cast it depending on the type as defined in Console.

Also refer to a2i.core.Value Class as well.

Hope this helps

diego_gaudenzi
Participant
0 Kudos

Actually this code below works just for the partnerId but it does not work for the First Name and Second Name which are text fields:

msgMan.reportSuccess(partnerId.GetData().toString()); <--- Works fine

msgMan.reportSuccess(firstName.GetData().toString()); <--- Error Out Why?

msgMan.reportSuccess(secondName.GetData().toString());

br,

diego.