Thursday, October 17, 2013

Customizing RedPrairie RF Forms (Java Based)

Customizing RedPrairie RF Forms

Java Based MTF Forms

Overview

As of version 2009, RedPrairie uses Java to provide RF forms.  The underlying engine is called "MTF" (Mobile Terminal Framework).  These applications are VT based applications that may be accessed via telnet or ssh protocols.

Deployment Architecture

  1. A MOCA task exists for each vendor and warehouse combination.  The task listens on a specific port and for a specific protocol (i.e. telnet or ssh).  One task serves a single vendor (e.g. LXE, Intermac, or Default) and a specific warehouse
  2. The task also points to a MOCA connection URL.
  3. Clients connect to the specific task using ssh or telnet protocol
  4. If the vendor setup is defined correctly, the form will go directly to the login prompt and device identifier (devcod) will be determined based on RF Vendor setup.  If not defined (e.g. DEFAULT vendor), then system will prompt for a device.  This device is determined based on setup in "RF Terminal Maintenance"

Software Layout

"MTF" is a separate software component similar to MOCA, MCS, SAL, DCS, etc. and exists at the same directory level.  This component is the underlying engine that runs MTF.

The actual forms are provided by the component that uses it, which by default is "DCS" and when we have some customized forms then also "LES".

Within each component that uses MTF, the objects exist in mtfclient/ sub-folder.  The whole solution is compiled using "ant" which works off a file called "build.xml" in $LESDIR.

Within LES folder, the customized objects will exist in "mtfclient\src\java\com\redprairie\les" sub-folder and in that folder you can have one or two sub-folders that represents the customized objects:
  • formlogic 
  • mtfutil
formlogic folder has the forms and mtfutil is needed for common classes. 

RF Form Invocation Mechanism

When MTF calls a form, it uses the "createFormLogic" method, e.g:




As you can see we are calling it by a name and not invoking the java class directly.  This setup is in rf_frm_mst table:





The custom entries have cust_lvl of 10 and the frm_cls points to the actual class path.  You can see how this mechanism allows for overriding standard forms as well:







Creating a new RF Form

So creating a new RF form is quite straight forward, given that you know the underlying mechanism for creating the required java objects.  You will put the new form in the formlogic folder and compile the code.  You will put that in the desired menu and give the permissions to the appropriate roles.  When MTF needs to invoke the form, it will use the rf_frm_mst data to find the highest customization level and instantiate that class.

Overriding Standard Forms

This is the main reason for this blog.  I have seen far too many cases where the override is done by straight copy/paste of standard code and then modifying a few lines of code for the enhancement.  Anyone who understands basic OOP principles will get a heart burn by reading this but unfortunately far too much code exists like that.  Just look in your installation in this folder and see code like "PickupA.java", "DepositA.java", etc. and if that code is based on straight copy/paste of standard code - you are a victim of this practice.  This basically implies that in case of a version upgrade, java is not going to help - you will have to retrofit these forms and somehow obtain the new source code.

Overriding Standard Forms - The Right Way

There is no advantage of using Java in MTF if the language is not utilized fully.  Sure, java syntax is more mature than old RF forms but if you see the code there is really one to one correspondence - actually RedPrairie provides a converter that can take the old "rdt" files and convert them to "java" files.

The advantage is only if "java" is utilized fully.  As always, the RedPrairie architecture is not at fault.  Just like MOCA, MTF framework supports the "right way".

Lets say all you want to do is that when "DepositA" is invoked, it should do something different in "formEntry" than what it does right now.  You can see what it does right now by looking at MTF and MOCA traces.

So the right approach will be to do just that and nothing more:
  • Create your class as an extension of the base form



  • Then override the method that you did not like







Here "formEntry" and "formExit" represent overridden methods that can have any code that you want.

  • And then add an entry to "rf_frm_mst" to call "UsrDepostA" when DEPOSIT_A is called.

Overriding Methods In CWmdMtfUtil

This class is provided by DCS component and it contains several utility methods that are called by various forms.  For example when directed work form is invoked, it calls "getWork" method from this class.  
This class does not have a simple mechanism like forms, i.e. there is no table where we can put our class path so that RedPrairie invokes that instead of this class so this is a bit tricky!

When a form needs to call a method from this, it will have code like:





So what we want to do is put our extended class in this session map.  If we can do that, the concepts described above would work.  So our approach will be:

  • Extend the CWMDMtfUtil class




  • Then override what you did not like




  • And then find a suitable point where we can replace the session map with our object.  A reasonable location may be the undirected menu.  Undirected menu will be overridden using technique described above.




And thats it - now when we go to the undirected menu, after displaying it, it will replace this session variable and from that point on our override method will be invoked.

Conclusion

Cut/paste approach is often employed when modifying the Redprairie code.  This problem exists at all levels - for example the "libsrc\varint" folder sometimes contains large C files with names like "trnAlloc.c" - that is a huge concern because that is core of RedPrairie and if that is customized say good bye to easy upgrades. 

Same issue manifests at RDT level and GUI level.  Even though RedPrairie architecture is almost perfect to support extensions, implementations are often sub-par.  Customers should closely watch what objects are part of the rollouts they receive and if standard objects are being modified a red flag should be raised right there.

We have been able to successfully implement complicated enhancements without touching the underlying standard code.  There could be situations where the only solution is to modify the base code.  In those situations it is better for the customer to give up on the enhancement or come up with some compromise where the base code does not need to be touched.  


    22 comments:

    1. Thank you for this Saad. Very helpful, especially the part about properly overriding existing form methods. I wish to do this, and something similar to extend an MCS form in C# .NET. For now I am trying to get a very simple "Hello World" form to display, but I have troubles getting the app to show up in the client Locate search, within in Visual Studio debug or fully installed on the server. I think I have the proper entry in comp_ver table, but I must be missing something somewhere. Do you plan on covering this topic in the near future, or know of a good place to start?

      ReplyDelete
      Replies
      1. Investing online has been a main source of income, that's why knowledge plays a very important role in humanity, you don't need to over work yourself for money.All you need is the right information, and you could build your own wealth from the comfort of your home! Binary trading is dependent on timely signals, assets or controlled strategies which when mastered increases chance of winning up to 90%-100% with trading. It’s possible to earn $10,000 to $20,000 trading weekly-monthly in cryptocurrency(bitcoin) investment, just get in contact with Mr Bernie Doran my broker. I had almost given up on everything about binary trading and never getting my lost funds back, till i met with him, with his help and guidance now i have my lost funds back to my bank account, gained more profit and I can now trade successfully with his profitable strategies and signals! Reach out to him on Gmail ( BERNIEDORANSIGNALS@GMAIL.COM ) , or his WhatsApp : +1(424)285-0682 for inquiries


        I lost my job few months back and there was no way to get income for my family, things was so tough and I couldn’t get anything for my children, not until a met a recommendation on a page writing how Mr Bernie Doran helped a lady in getting a huge amount of profit every 6 working days on trading with his management

        Delete
    2. Hi Saad, Great article. Got me on the right track to override some RF java methods to temporarily fix some RP bugs.
      Have you found a good method for the .properties files too? If I only place the 'UsrUndirClusterPick.java' file in the formlogic directory, java returns an error it can't find the bundle. I tried to create a properties file that includes the standard product properties field, but It seems like the 'include' directive doesn't work and I ended up copying the whole .properties file from the standard screen...
      Thank you!

      ReplyDelete
    3. Hi Saad,

      Great work blogging about RP. One offtopic question: Is there a way to display dialogs (not error dialogs) in DDA? "set return status" called by action DDA just displays errors and not messages. Thanks in advance.

      ReplyDelete
      Replies
      1. An action can have a dialog for seeking confirmation

        Delete
    4. Thanks!
      Which directory are the regular c functions stored

      ReplyDelete
      Replies
      1. $LESDIR/src/libsrc. You dont have source code for standard C functions

        Delete
    5. Saad. This didn't work for me. I simply tried to show a message onFormEntry and the message did not show. Any ideas what I am doing wrong? I have checked everything including the RF_FRM_MST entry


      Below is the whole code:

      public class UsrDepositA extends DepositA {

      public static final String TEST_MSG = "I sneaked in here.";

      public UsrDepositA (IDisplay _display) throws Exception{
      super(_display);
      }

      protected class FormActions extends CWidgetActionAdapter {

      public boolean onFormEntry(IForm _frm) throws Exception {

      frmMain.promptMessageAnyKey(TEST_MSG);
      return true;
      }

      }
      }

      ReplyDelete
      Replies
      1. What is the entry in rf_frm_mst?

        Delete
      2. This is the entry I have in the RF_FRM_MST.

        rf_frm,cust_lvl,frm_cls,grp_nam,ins_dt,last_upd_dt,ins_user_id,last_upd_user_id
        DEPOSIT_A,10,com.redprairie.les.formlogic.UsrDepositA,usr_data,,,NOUSER,NOUSER


        BTW. This is JDA-WMS 8.2

        Delete
      3. Saad, Can you see anything that I am doing wrong above? I have looked though everything on your blog and I cannot find anything I am doing different. But still I cannot get the overridden code to trigger.

        Delete
    6. This comment has been removed by the author.

      ReplyDelete
    7. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in RedPrairie, kindly contact us http://www.maxmunus.com/contact
      MaxMunus Offer World Class Virtual Instructor led training on RedPrairie. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
      For Demo Contact us:
      Name : Arunkumar U
      Email : arun@maxmunus.com
      Skype id: training_maxmunus
      Contact No.-+91-9738507310
      Company Website –http://www.maxmunus.com



      ReplyDelete
    8. Hello Saad, we are using WMS Red Prarie on our network and we are having some serious Java problems.
      IE is blocking Wms client Java, as unsecure, for now, I have managed to add our WMS server to an exception list on the IE, but we are still experiencing problems with newer Windows OS versions (specifically, Windows 10).
      Sadly, our vendor does not have a solution, do you have any ideas?
      The question is, how to allow WMS applet to run, without constantly updating Java on the WMS server itself.
      Thank you in advance.

      ReplyDelete
      Replies
      1. Kindly elaborate what are you using through IE explorer that requires Java applet? Which version of RP and which product?

        Delete
      2. I realize, that I am dumb as a door knob, when it comes to WMS, so here goes:
        I can login through the SSH to the WMS server in question, can you help me, what are the commands to provide you with the information you need?

        Delete
    9. hi Saad, where can i find more information to create a form

      ReplyDelete
    10. Hello Saad,

      Nice to read your blogs, the more i read more i get somthing new,

      can you please let us know.

      how to setup the rollout process for JDA 2017.2

      ReplyDelete
    11. hello i have a quetion

      how can i compile a new c function in linux? i know that is whit gcc but i can't doit

      ReplyDelete
    12. i was just browsing along and came upon your blog. just wanted to say good blog and this article really helped me.
      https://www.lcrenovation.co.uk/house-extension-in-elephant/
      House Renovations in Elephant

      ReplyDelete
    13. All thanks to Mr Anderson for helping with my profits and making my fifth withdrawal possible. I'm here to share an amazing life changing opportunity with you. its called Bitcoin / Forex trading options. it is a highly lucrative business which can earn you as much as $2,570 in a week from an initial investment of just $200. I am living proof of this great business opportunity. If anyone is interested in trading on bitcoin or any cryptocurrency and want a successful trade without losing notify Mr Anderson now.Whatsapp: (+447883246472 )
      Email: tdameritrade077@gmail.com

      ReplyDelete