cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Work Manager customization - adding a new field to equipment details screen (Syclo Agentry)

Former Member
0 Kudos

Hi Experts,

I am trying to add a field (NAME1) on the Equipment details screen under work orders in work manager 5.3 application.

I have performed the following steps, but I am getting an error while connecting to the application.

1) Create extension for Equipment class to add a new field.

2) added the new field (Name1) as the property to the standard object Equipment.

3) Added the field on the screen.

4) Added the field (name1) to the complex table ctEquipment.

5) Added the JAR file to Agentry.ini file.

6) Changed the Class mapping for parameter "Equipment" under group "SAPOBJECT" to point it to the custom (Extended) class.

7) Changed the class mapping for complex table parameter "ctEquipment" under group "CT_SAPOBJECT" to point it to the custom class.

😎 after publishing the changes and re-starting the server, I get following error.

the log file generated (message.log) also has the same description.

What am I missing here? Any help would be really appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

former_member190010
Contributor
0 Kudos

Hi Arihant,

The error you are getting is because you forgot to add the field to the table from the BAPI_WRAPPER that is bringing this data from the SAP backend.

I attach an image with the table you should enhance.

Then, you have to modify the ABAP class handler, in order to retrieve the field data and populate the BAPI Table.

Finally, when finishing editing, remember to restart the Agentry Server so the changes take effect in the server.

You can test if the complex table field is populated, using the ATE (Agentry Test Enviorment).

Go to: Inspect>Complex Tables

Try this, and let me know your results.

Best Regards,

Emanuel

Former Member
0 Kudos

Hi Emanuel,

Thanks for looking into this issue.

I have performed the following steps as suggested by you, still it doesn't seem to work and gives the same error.


Below are the changes done on the ECC Side.

1) Copied the standard equipment class /SYCLO_CL_PM_EQUIPMENT1_DO to custom class ZSYCLO_CL_PM_EQUIPMENT1_DO. Changes made in the GET Method to get custom equipment related data

     

2) Modified the standard equipment structure /SYCLO/PM_EQUI_STR by adding one custom field

     

3) Configured this custom class as the object handler in the equipment mobile data object

     

4) Configured this custom class as the object handler for the equipment complex table

     

5) We are still using the standard BAPI Wrapper itself for getting the equipment data and the added field is reflected in the BAPI Wrapper table parameter

    

Is there something we are missing?

Former Member
0 Kudos

Hi Arihant,

Can you give a try changing your classspath entry of agentry.ini file to the following.

classPath=./java/WMdeloitte.jar;./ini4j.jar;./sapjco.jar;./Java/Agentry-v5.jar;./Java;./Java/SAPWM-6.0.0.0.jar;./Java;./Java/SAPCommon-122971.jar

You need to add your JAR file first and then other JAR files. Try this and let me know if it works for you.

Regards,

Abhishek Wajge

Former Member
0 Kudos

Hi Abhishek,

I just tried this, but it doesn't seem to be working.

Anything else that we can try here?

Former Member
0 Kudos

Hi Arihant,

Did you restart the server after changes.

Also, Did you try using breakpoints in JAVA classes, You can use debugging techniques to know whether control is coming to JAVA API's or not.

Regards,

Abhishek Wajge

former_member190010
Contributor
0 Kudos

Hi Arihant,

As Abhishek mentions, try debugging the Java class.

Try to check if the field "Name1" in class "CustEquipment.java" is being completed with the values you are bringing from the SAP Backend.

Also, you can debug the ABAP class handler, to see if the new values from field "Name1" are being returned from the SAP Backend Tables.

Let us know your results.

Best Regards,

Emanuel

Former Member
0 Kudos

Hi Emanuel,

While debugging, an exception is being thrown while instantiating the custom class.

Below is the screenshot for the same.

Is there any way we can work around this one?

Former Member
0 Kudos

Hi Abhishek,

I had restarted the server after making the changes to the INI file.

Also, an exception is being thrown while the custom class is being instantiated.

I have attached the exception screenshot in a reply to Emanuel below.

Please take a look and suggest a solution.

jason_latko
Advisor
Advisor
0 Kudos

Arihant,

Does that CustEquipment class exist where the error message is looking for it?  Seems like the class cannot be found.  Check your Agentry.ini classpath and make sure that class is included in your source project setup in Eclipse.

Jason Latko - Senior Product Developer at SAP

former_member190010
Contributor
0 Kudos

Hi Arihamt,

Try removing the "IF" condition above the setName1 statement, and let me know what happens.

Best Regards,

Emanuel

Former Member
0 Kudos

Hi Jason,

The class does exist where the code is trying to look for.

We finally figured out that the class didn't define a default constructor (without any parameter) "explicitly" and hence it was not getting instantiated.

Anyway, now we are able to proceed further and overcome the initial exception.

the class looks like this:

However, the custom data sent from ECC ( visible under table parameter after execution of the BAPI) is not reflecting on the screen. I had debugged the Java code and found that the "NAME1" field always remains blank.

I also placed a break point in the parametrized constructor of the custom class, but the control never stopped there. Moreover, the "setName1" method of this class also doesn't get called.

I see that the default constructor of the custom class (without parameters) is called first, which subsequently calls the setProperties(x) method of the base class. irony is, here also, the control doesn't stop in the parametrized constructor of the base class and I don't see any other way in which setProperties() method of the base class can be called. I am attaching a screenshot of the decompiled equipment class for illustration purpose.

Former Member
0 Kudos

Hi Emanuel,

I have removed the IF condition and added a default constructor.

The program looks as below.

However, the data coming sent from ECC (with name1 field value) doesn't get reflected on the screen. I have added few screenshots and description of the problem in the above thread in a reply to Jason Latko.(

Do I have to extend any BAPI handler class or any transaction/steplet also, to get this working?

the Name1 field has data in backend and is being sent in the tabble params of the BAPI, but the screen cannot capture this field.

former_member190010
Contributor
0 Kudos

Hi Arihant,

Is the complex table being populated with the Name1 field?

You can check it in the ATE, under Inspect>ComplexTables.

If the complex table is being populated with this field, this means that the error is in the screen.

Best Regards,

Emanuel

Former Member
0 Kudos

HI Emanuel,

although the field Name1 is populated at the ECC in the BAPI call  and is being returned in the table parameter of the BAPI, the name1 field doesn't get populated here.

Moreover, the entire 'ctequipment' table is blank, but I can see equipment details under object 'workorder'.

In the below screenshot, workorder object has two entries, table 'ctequipment' is blank. and in the next screenshot, 'equipment details' available under 'workorder object'. although Name1 is still missing there.

What have we missed while extending the complex table?

0 Kudos

Hi Arihant,

The equipment data will be displayed based on the filter specified in the MDO "Z_PH_SWM53_EQUIPMENT". Verify you have enabled new field "Name1"  under the Handler Method Field Selector pane of MDO for the equipment complex table.

Test the BAPI "/SYCLO/PM_CTEQUIPMENT_GET" and verify the Name1 filed is returning the value, if not, debugg and see where its failing.

Thanks

Resmi

Former Member
0 Kudos

Hi Resmi,

Thanks for looking into the issue.

As per your suggestion, We have cross checked the configuration at the ECC side.

Can you please confirm if we are looking at the correct tab for the parameter configuration under MDO?

And we see here that these are all SAP Std tables which do not contain our custom name1 field. The name 1 field we added is in the BAPI Wrapper structure /SYCLO/PM_EQUI_STR.





Also, the BAPI "/SYCLO/PM_CTEQUIPMENT_GET" does return the field value for "NAME1", but it doesn't come up on the application.



jason_latko
Advisor
Advisor
0 Kudos

Arihant,

setProperties is usually called from the BAPI Handler class on the POJO when the object hierarchy is being populated during a fetch.  I believe the equipment comes down as a sub-collection belonging to the Workorder?  Find the code in the BAPI handler class that handles the Workorder fetch and find the spot where the equipment is added to the workorder.  Debug from there to see why your extended equipment class is not being instantiated.  I believe you need to override the correct setProperties method or methods to add your NAME1 code and then also call them using super.  Multiple setProperties methods probably exist because they all have different purposes depending on the context in which they are called.  One will apply for a complex table, another for the workorder fetch.  Concentrate on the fetch first because that is what your client screen is displaying.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Hi Jason,

Thank you for your reply.

To summarize, I need to add a standard field 'NAME1' to the "Equipment Details" screen. to achieve this, I had added this field to the "Equipment" object, "Equipment Details" screen and to the structure in ECC.

Also, as you had suggested, equipment object is associated with the complex table "ctEquipment", I have added the field to the complex table as well.

I have created a custom class extending the "equipment" class too.


Now, I can see that the export parameter (table) from the BAPI is holding the values in the field "NAME1". Few questions that I have are:

1) The BAPI for complex table object (/SYCLO/PM_CTEQUIPMENT_GET) seems to be for the ctEquipment complex table. Although, it doesn't return anything and the complex table "ctEquipment" is blank after execution. so what exactly is the purpose of this BAPI?


2) "I believe the equipment comes down as a sub-collection belonging to the Workorder? "

Yes, I see that whatever is being populated on the equipment details screen, comes from the workorder object -> equipment. This  gets populated in the BAPI call /SYCLO/PM_DOEQUIPMENT_GET.  Firstly, the work orders are fetched, and based on this fetch, corresponding "equipments" are fetched.


I have debugged this code and I see that in the "ProcesResults" method, the results of the execution are processed. There, I see that the field "NAME1" doesn't hold any value, although the BAPI is returning the data.

So, the confusion is, why is the value getting disappeared.

Appreciate your help and inputs on the same.

jason_latko
Advisor
Advisor
0 Kudos

Arihant,

You need to continue to debug into the ProcessResults method since this is where that equipment data is populated.  Is the NAME1 value in the BAPI Table populated at this point?  Debug this portion of the code to see what is happening with the equipment handling to see where things are going wrong.  If the BAPI is returning data in NAME1 when you run it outside of the fetch, then you should be getting the data here to use as well.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Hi Jason,

I debugged the EquipmentFetchBAPI class today and I was finally able to add the value of field NAME1 to the equipment object. Moreover, the equipment object is later assigned to the "workorder" object and I see that it is still retaining the NAME1 field's value.

Once the startup and load activities complete, I checked the "Objects" under ATE and there, the work order collection doesn't have the value for NAME1.

jason_latko
Advisor
Advisor
0 Kudos

Arihant,
I am also working with another programmer on this same issue of extending a pojo to add new fields.  Here is what I told him so far:  For some reason, Agentry cannot handle mapping new properties that are added by extending a pojo without some trickery.  It only has visibility into the original pojo’s properties, but not the extended ones.  We came up with a work-around helper class that fixes this by re-creating the finished array as the extended class type, instead of being created with the casting (Address) syntax that throws off Agentry during the mapping back from the array.  You only need to do this if you are adding new properties that you want to bring down to the client.  This has since been fixed/changed in the source code for the newest releases of our products so you don’t need to do anything, but your version of Work Manager suffers from this problem. The helper class is attached and is called SAPObjectArrayFactory.  In order to use it, you will need to extend the WorkorderFetchBAPI class that sets your array of Equipment objects.  Override the method where the collection is actually set, and modify the way this happens using the helper class:

Looking at the current WM code (not yours), I see the line: wo.setEquipment(techObj.getEquipment());  Your version may be different, but you need to find where the equipment array is being set for the workorder.

So, instead of doing: wo.setEquipment(techObj.getEquipment());

Try:

wo.setEquipment((Equipment[]) SAPObjectArrayFactory.createSAPObjectArray(techObj.getEquipment(),SAPObjectFactory.create(_user,"Equipment")));

If the Equipment[] cast doesn't work, try it without.  Not sure if that is necessary.  _user should be your user instance in this case, but always use whatever variable is your current user instance depending on where you are in the code.

This will set the array using your extended pojo and Agentry will be able to see the extended properties for mapping back to client.  Try this and let me know if it works for you.  Please e-mail me directly if you need the SAPObjectArrayFactory class or information about it.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Thank you Jason. your suggestion worked absolutely fine.

Answers (0)