Skip to Content
0

Agentry (Work Manager 6.4): Java Reflection issue - Changing class of a child collection attribute

May 17, 2017 at 09:24 AM

57

avatar image

Hi,

I'm working with Vehicle Stock add-on for Work Manager 6.4. In this Add-on there are the objects StockTransportOrderHeader and StockTransportOrderItem.

I enhanced the second one (Item) by adding serial numbers collection to it. For Java, I had to create new class inheriting from the original one and change the parameter in Config Panel as usual. This is working OK for the STO Creation.

But now I tried to also do the relevant enhancements for the STO fetch. So after an enhancement, the SAP BAPI is already returning the serial numbers, and the custom Java BAPI class is adding the serial numbers to each relevant STO item. All works as expected, and when the Steplet execution reaches the end, I do have all the information as I want:

STOHeader (standard class object)->STOItem(custom class object)->SerialNumber(custom attribute array)

But then, when the Java object is mapped to the Agentry object, the custom attribute of the item is lost, because reflection is not working properly here, the "mapping" classes think that the Item attribute of the STO Header is still the standard class and they igonre my new Serial Numbers attribute.

How can I fix this? It's not possible by enhancing the standard STO Header class because Java does not allow to override an attribute class, just adds a new one with the same name and different type, and then the error is still not solved.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Marçal Oliveras Jun 02, 2017 at 03:35 PM
0

Hi Subash,

I didn't really solve the issue but I implemented a non very elegant but effective work around because I didn't have enough time to investigate the SAP bug. What I did is the following:

1. Created a copy (not a child) of the STOHeader class with the minimum methods but the same attributes than the original and replacing the STOItems array to use my custom one.

2. Created a copy of the Steplet class from SAP to fetch STOs. At the very end it gets an array of STOHeader objects. What I do is to create an array of my own STOHeader object class, copying one by one the data from the other array. This way reflection is not necessary, the items are already the type they need to be and serial numbers are returned to Agentry.

Share
10 |10000 characters needed characters left characters exceeded
Subash Narayan
May 26, 2017 at 04:35 PM
0

Hi Marcal,

This issue is resolved in the ticket. Please let us know your resolution.

Thanks

Subash

Share
10 |10000 characters needed characters left characters exceeded