cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Custom Fields in SAP SYCLO Work Manager App

shankar_agarwal
Contributor
0 Kudos

Dear All

I am trying to add a custom field for poc purpose in Syclo Work Manager Application using following blog.

http://scn.sap.com/people/jemin.tanna/blog/2013/05/17/syclo-extension-first-steps

I have created the required structure but not entirely sure of the linkages.

Got the source code from syclo support team and imported it in Eclipse.I did not see any main project with Agentry application.So I imported Agentry.ini into Eclipse (highlighted in first box).Made a copy of S4SAP-WorkOrder into SycloSAP-Workorder (highlighted in second box)and included the custom code.UI changes were made in SAPWM prj using Agentry-Property perspective as explained in blog.

After this I do not understand how both this project need to be linked.Also how back-end changes will get incorporated is also a confusion. Didn't get any 

further doc on moving ahead.

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Shankar,

The jar must be places in JAVA folder of the server...example: C:\SAP Work Manager\ServerDev\Java

So export ur java project as jar there...

then you must mention this jar in Agentry.ini on server folder:

example:

classPath=./ini4j.jar;./sapjco.jar;./Java/Agentry-v5.jar;./Java;./Java/SAPWM-5.3.0.0.jar;./Java;./Java/SAPCommon-122971.jar;./Java/customWorkOrder.jar;

Now if u have made a customer workorder object(POJO) this gets dynamically created in java code when accessing createObject method of SAPObjectFactory....now this would mean you have to goto parameters tab in config panel and against the name you are using to createObject you will have to give full class path as

ParameterGroup: SAPOBJECT

ParamererName: <name pased to creatObject Method>, in standard it is Workorder

ParameteValue: com.....custom.object..<JAva class name that u created>

And now the new object should come into action.

All the best.

Jemin

Former Member
0 Kudos

Hi Jemin,

While extending an object, I took the approach of copying the standard one along with all the other handler, steplet & BAPI java classes (rather than extending) into a new project and make my changes. But there are other standard components that refer to the project for the standard object which I've copied and changed. So how do those components refer to my custom one as if I then go and change the references to the other standard components, then I end up changing the standard JAR which shouldn't happen.

Kindly can you clear on the above?

Regards,

Gourav

jason_latko
Advisor
Advisor
0 Kudos

Gourav,

You took the wrong approach.  As you have seen, other classes outside of your changes will still reference the old classes.  That is why you will need to extend rather than make copies.  The Factory create methods are designed through reflection to still instantiate the base class types that you should be extending.  This means that your new classes must be extensions of the base classes for this to work correctly.  That way the base class references still resolve without requiring changes to the base code.  The next generation of products coming soon will also use a factory to handle creating the BAPI handler classes which isn't being done currently in the released products.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Hi Jason,

Thanks for your reply.

I understand now why I should take the extension approach and not copy. But then not sure how the approach of copying worked as discussed in the above blog. Is there a way to do that? Would be good to know as a know how.

So as I understand I do not need to change any references in the other components that still points to the base class. Also then do I need to change the param value for SAPOBJECT in the config panel as if I do the factory create method will get FQDN for my class and not the base class but then how the base class will get instantiated?  As soon as I do this, no data gets loaded and and application is blank and I do not seem to find any error in the logs as well.

Also do I need to extend the other class as well like the steplets, stephandlers & the bapi class?

I've added the custom jar for my project in the agentry.ini. I'm working with the Sales Manager app.

Regards,

Gourav

Former Member
0 Kudos

Hi Gourav,

There are two things about extensions...1. copy existing object as new object and reference from the config params. In this case you are right that if there are code blocks that Hardcodedly reference such objects then we have to change the code...2. Most of the code would refer/instantiate objects from the config param itself and hence it should dynamically come to your new class if it is a change in standard param value in configuration...this way you will not need to overwrite a lot of classes.

else you could do is the following:

1. Extend the std class, not copy

2. overwrite methods of interest..specially the ones with BAPI class mapping methods

3. make a new param in config and change all the touch points...that could be lot of classes where you just reference this new class

Hope this helps.

Best Regards,

Jemin Tanna

jason_latko
Advisor
Advisor
0 Kudos

Gourav,

Yes, change the SAPOBJECT in the config panel to point to your new POJO class.  The parent will get instantiated because your new class extends the original.  Just override any methods in your new class by copying the original and modifying to add your new code, or use super.parentmethod syntax to run the parent code first and then add your modifications if the code flow will allow that to work.

You should not need to extend the steplet, as the factory methods there will look up the POJO and stephandler in the config panel again, allowing you to extend those.  If you need to change the stephandler, extend it like you did the POJO and change the config panel param to match your new class.

The BAPI classes are not handled by the factory extension model in the current products, but they should have been.  If you need to modify a BAPI handler class, you will need to copy the class or extend it and have your extended stephandler use your new class instead of the original.  References to the BAPI handler classes will be limited to the stephandlers.  If you run into the problem where a BAPI handler is referenced in multiple stephandlers, you will need to extend them all to correct the old references.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Hi Jason,

According to above, I extended the POJO into a custom one with the same name into my namespace and updated the config param accordingly. Now the BAPI class will pick up my POJO object but as I see the code for the Address object, it also seems to use the factory model. So do I need to change the Address reference to my custom one or will it take my custom one automatically while casting?

If I just need to change the references in the BAPI class to call the custom POJO, Stephandler to call the custom BAPI class or steplet to call the custom stephandler, then as you mention above I do not need to extend the BAPI class, stephandler & steplet as they should pick via reflection. Is that what you mean? Only if I need to do some extra processing there, then I should be extending them?

Also the Address object is being referred to from within the Account object. So should I extend that as well in order to refer to the custom Address object? If yes, then I think I need to follow the above for the Account object as well.

Awaiting your response. Thanks once again.

Regards,

Gourav

Former Member
0 Kudos

Hi Jemin,

Thanks for your response.

Yes I understand it now but as you can see above, I'm still not very clear if I should be extending the BAPI class, step handler & the steplet only to refer my custom POJO or leave it to reflection to pick that up and extend only if I need to do some extra processing.

Your thoughts would be helpful as well along with Jason.

Regards,

Gourav

jason_latko
Advisor
Advisor
0 Kudos

Gourav,

You don't need to change the casting of (Address).  Reflection will handle creating your new object that extends Address as long as you updated the config panel setting for sapObject "Address" to point to your new extended class.  You are correct in that you only need to extend the steplet, stephandler, BAPI handler if you need to make additional changes to those, not just to update the references.  Those will resolve correctly on their own.  You don't need to make any changes to code to refer to your new custom POJO.  The factory engine was designed so you don't need to do that.

Please mark this post as correct or helpful if this solves your issue so others will know the question has been answered.  Thanks!

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Hi Jason,

Thanks so much.

I did as you said and extended my POJO to add a custom field and updated the config panel SAPOBJECT param for Address object with my custom class in custom namespace. Exported the jar under Java folder and updated the classpath in the Agentry.ini. But still it doesn't seem to work and I do not get any data with that. Do not see any error as well in the logs and just see the below:

2014/02/20 16:41:34.840:               throwExceptionToClient::com.syclo.sap.component.account.steplet.AccountFetchSteplet::throwExceptionToClient::44::AccountFetchSteplet - com.syclo.customer.component.salesmanager.object.Address

2014/02/20 16:41:34.840:             AccountFetchSteplet: doSteplet returned false; no data to process

Not sure what's wrong. Kindly can you please suggest further.

Also I'm not the owner of the thread so not able to mark it as answered or close the thread but your answers has been really helpful.

Regards,

Gourav

jason_latko
Advisor
Advisor
0 Kudos

Gourav,

Sorry didn't realize you weren't the original thread owner!  We aren't seeing the entire error message in your post, seems cut off on the right side.  I would suggest you loading the source into Eclipse and debugging it at runtime to see what is wrong.  I believe you need to complie the jar with line numbers as an option to allow debugging.  Are you using SMP or an Agentry stand-alone server?

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Hi Jason,

I'm using stand-alone Agentry Server. To view the complete error message, there is a horizontal scroll bar at the below of my message to scroll it to the right. May be you didn't notice it.

Thanks,

Gourav

jason_latko
Advisor
Advisor
0 Kudos

Gourav,

LOL, I found the scroll bar now!  Didn't help much though.  Try debugging your java as I suggested.  This thread will show you how if you have not done so before:

http://scn.sap.com/thread/3505765

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Hi Jason,

Yes, I'm currently trying to debug it & see if I find anything else in there.

Will let you know.

Thanks,

Gourav

Former Member
0 Kudos

Hi Jason,

I'm able to see the data in there now. I've also added a custom field in there and this is the only field for which I do not see any data.

When I revert back the SAPOBJECT param to point to the standard POJO (for testing purpose only I've updated the standard code with custom fields), I can see the value for the custom field on the device but not when I use my extended Address POJO in the JAR. When I debug, I see it is able to fetch the value from the back end and also set it up using the setProperties method which I've overridden but the field value just does not display it on the device.

Can you please suggest if anything else needs to be done when following this extension approach or what could be the glitch?

Regards,

Gourav

jason_latko
Advisor
Advisor
0 Kudos

Gourav,

If everything is running properly without java errors, then you must have just missed something in your code that is causing this.  What are you doing in your extended code?  If you are bringing down a new field, make sure you make the visibility "public" for the POJO property and that the variable name exactly matches the Agentry object property name.  Using your extended code, if you debug the steplet after the array is populated and ready to be returned to Agentry, can you still see your custom data populated in the POJO objects?

If you still can't figure it out, you could send me the extended code and editor export via e-mail and I will look at them.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Hi Jason,

Yes I'm just bringing in a new field at the moment and have kept the visibility of the POJO property to public & the variable name matches exactly to the name for the object property but still dont see the field value.

I"ve sent you the requested files over your email for your reference.

Thanks so much for all your help.

Regards,

Gourav

jason_latko
Advisor
Advisor
0 Kudos

Gourav,

I responded to you directly via e-mail.  Try my solution and let me know if it works for you, then I will summarize things in this thread once you have it working.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Hi Jemin,

Thanks for writing a nice article on customization of work manager application. I am referring to your post at

I had few questions related to extension of existing work order object. I am trying to show few newly added fields on the work manager application front end. we have made changes in the ECC already.

1) the extension class that you have written, says:

public class Workorder extends SAPObject

Here, I am just confirming that this is not an "Extension" of existing standard workorder class (com.syclo.sap.component.workorder.object)

So, we are just making a copy of previous workorder class and adding it in a new JAR file under custom namespace.

2) Can you please help me on where I can configure the assignment of factory createObject method so that it will now instantiate the custom class directly? I checked for settings in the eclipse based editor but couldn't find it anywhere. Is it to be done at the ECC side?

I could only find the config panel at the ECC side. so does that mean that we have to put the custom java package name in ECC?

3) when we "Extend" the existing work order class, there might be many more classes which are utilizing the base class. for example, steplets will still refer to the base class.

now, if I have to update my custom fields and transmit them back to ECC, this will require me to change many more steplet classes, am I correct?

Appreciate your input on the same.

jason_latko
Advisor
Advisor
0 Kudos

Arihant,

1.  Yes, but I would recommend not copying the old class, but extending the original Workorder and just overriding the required methods to keep things easy to follow and debug, and to avoid needing to change or extend other classes that refer to your POJO.

2.  In the ERP config panel, look at the parameters for your application and modify the entry for group SAPOBJECT matching the class you want to change.

3.  All your steplets should use the object factory to create the POJOs.  This will automatically create your new class that you have now pointed to in the config panel.  This is why you want to extend the original rather than copy it, because of all the other references.  If you extend, the existing references will resolve correctly because your new object is still the same base type, only extended.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Hi Jason,

Thank you so much for your prompt reply.

I ran into a confusion here.

1) Please correct me If I am wrong, changing the object class in the config panel and putting the custom one will take care of subsequent steplets (e.g., getWorkOrdersSteplet) defined for that particular object.

2) I can also see that in the screenshot that Jemin has provided, he has changed the "steplet" to have it point to a custom class, in the eclipse editor.

I was thinking that only one of these two settings will be required for a newly added field. Am I missing something here?

[EDIT]: Does that mean I have to extend the "steplet" classes too, to get the new fields?

Also, Do I have to change the complex tables to add the new field?

I was looking for an exhaustive document on the SCN for the same. I got link for a relevant document at the below URL:  https://community.wdf.sap.corp/docs/DOC-207484 but unfortunately it is not working.

jason_latko
Advisor
Advisor
0 Kudos

Arihant,

1.  You don't need to change any steplets as long as they use the object factory classes to create the POJOs and you have extended the parent POJO and changed the entry in the config panel.

2.  You don't need to point to a custom steplet unless you have created one for some reason.  The existing steplet will work fine.

If you are changing a POJO that is used for a complex table, then of course yes you will need to change the Agentry complex table to add any new fields you are providing.  Also, the config panel group entry for complex table POJOs is CT_SAPOBJECT.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

Thank you Jason. Now the customization seems more clearer to me.

I tried to look for the alternative link for the document at https://community.wdf.sap.corp/docs/DOC-207484 but couldn't find any.

if there is any document on customization and if it is possible for you to share it here on SCN, that will be really helpful for developers.

Former Member
0 Kudos

Hi Jason,

I have created a separate thread ( for customization of work manager application (Adding a new field). Request your input on the same.

Thank you.

Arihant Kothari

Former Member
0 Kudos

Hi Jason,

I think I am up against this exact situation. I need to introduce a new WorkorderFetchBAPI class. If I read your comments correctly it seems that I need to create a new GetWorkOrdersStepHandler class that imports my new FetchBAPI class.

You mentioned the implementation of a Factory model to handle this in the future. Is this scheduled for SWM 6.1? Any idea on when it will be available?

Regards

Marty

jason_latko
Advisor
Advisor
0 Kudos

Marty,

Yes, WM 6.1 implements a BAPI factory so you do not need to create a new step handler that points to your extended BAPI class.  All you need to do is change the config panel entry that points to the existing WorkorderFetchBAPI class and change the class entry to point at your new class.  The factory will handle the rest.

Jason Latko - Senior Product Developer at SAP

Former Member
0 Kudos

How can get hold of 6.1? Do we still need to be waiting on a release?

We are currently working with 6.0 but are targeting 6.1 for our deployment. Would be a shame to be writing this Java code for nothing.

Regards

Marty

Answers (2)

Answers (2)

0 Kudos

Hi Shankar,

If your issue is resolved, please mark this thread answered.

Thanks

Resmi

Former Member
0 Kudos

The Agentry application contains references to various Java classes throughout. To update the java classes you need to export the source projects into a jar, and then copy into the ServerDev/Java folder of your Agentry server.

Michael

shankar_agarwal
Contributor
0 Kudos

Hi Michael

I have created two project where I have made changes.One is copy of Work order object and the other WM application interface.Which projects should be included in the jar.I am not able to add WM application project in jar.

Regards

Former Member
0 Kudos

Hi,

The SAPWM application should be published to the Agentry server using the Publish feature in eclipse.

Depending on your version of WM, you would want to export all the java projects into one Jar, with the possible exception of SAP-common (which may already be its own jar - check the Java folder on your server).

If you use the same file name as the existing jar there are no further changes. If you use a different name, you would have to add it to the path in Agentry.ini

Michael