Monday, February 1, 2010

Creating a M3 Web Service

I recently needed to use Lawson Web Services (LWS) for M3 to address some automation issues that APIs did not exist for.  LWS allows Web Services to programmatically access most M3 programs and function.

In this post I will show how to create a Web Service.  In a subsequent post I'll show how to consume this Web Service from Microsoft Excel.

Creating a Web Service to calculate the Cost of a variant (PCS230)


In this example we will start by loading PDS001, choose Related Options, Product Costing to start PCS230 and then run Costing for type 3 (standard):


Step 1 - Set programs to use A panel if possible
LWS works best with programs that can use the A panel.  We'll set PDS001 to use this:
Step 2 - Document the field names to enter data in programs/panels
When creating the Web Service we will need to specify the field names in panels we want to change
Step 3 - Document the key presses required
The Web Service will follow almost exactly the same key presses as is used in Workplace/Smart Client/Smart Office, so document the panel sequence, fields and keys pressed.

Our process is as follows
  • PDS001/A - Set WWFACI (Facility), W1PRNO (Product Number)
  • PDS001/A - Choose function 25 (Calculate Cost)
  • PCS230/E - Set WWPCTP (Costing Type), WWPCDT (Costing Date), WWCOUP (Calc purch/dist), WWPPRD (Purch price dt), WWSTRD (Structure Date), WWALVL (All levels)
  • PCS230/E - Press ENTER, then ENTER again (to accept the warning that the standard cost will be updated)
  • PCS230/F - Press ENTER
  • PDS001/A - Press F3 to exit the program
Step 4 - Build the Web Service in LWS
Note that you need to have LWS up and running.  Follow Lawson's instructions in the LWS Instllation Guide & User guide for this.  Check diagnostics in LWS to confirm that your setup is correct.  It should look something like this:

4.1 Create a new Web Service


4.2 Then define the parameters for the program to be called and test. This video is too large to embed here so click to see Web Service Creation Walkthrough

A few final notes about creation of Web Services:
  • When creating Web Services you can turn on the Interactive option for particular program/panels.  This is very useful to diagnose problems.
  • Web Services do not allow for branching logic within the Web Service. If you need to perform different actions based on the data, you will need to create a different Web Service for each action.
  • Not all programs allow for Web Services.  There appears to be a way to turn the warning off within LWS for this, however I have not yet tested this.

48 comments:

  1. Awesome post. thanks for the tutorial! Keep the information coming!

    In regards to your post about uploading information through excel, there is a Lawson product that also preforms this action called Smart Data. I can see endless possibilities through your post though. Thanks again for spending the time to figure this stuff out and share.

    ReplyDelete
  2. Hi. yes, really great. Only problem for me (creating WebServices via Designer is ok..) is to implement webservices in the Excel similar to the post about API (MvxSock). Somehow I do not get the link against webservice calls in VB in Excel :-(

    ReplyDelete
  3. Hi
    Thanks a lot for sharing a lot of good knowledge about the more technical stuff. Regarding web-service I have a specific problem regarding MMS100, where the "to warehouse is on the F-panel in web-service framework, but the F-panel does not exist i M3. Have you heard about this problem before - and have you got a solution to come across it ??

    ReplyDelete
    Replies
    1. Hi Jan, no I haven't come across that problem before.

      A few thoughts:
      1. If the web service also exposes the to location in the E panel then just remove the F panel from your panel sequence & don't get web services to look at it.

      2. If you're creating DOs you may want to look at the APIs DPS170MI or MHS850MI.AddDO. You can create DOPs and DOs respectively from those APIs. You could expose these via Web Services for consistency.

      3. You should probably log an issue on CASE for this.

      Cheers, Al.

      Delete
  4. Hi
    Have now found a solution. It is a bit lit your first proposal. Screen sequense must be E, but if using a distribution order it automatically shows picture F in Web-service. At bit tricky :-)

    Regards
    Jan

    ReplyDelete
    Replies
    1. Hello Jan

      Can you please share your idea or solution as we have the same issue

      Delete
  5. Another question regarding web-services. I would like to select a record in web-service, but have not found the correct syntax. What is the correct syntax for selecting a record based on parameters ?

    Kind regards
    Jan Pedersen

    ReplyDelete
    Replies
    1. Hi Jan. Sorry I missed this question when you posted it in August. Can you be a little more specific? I'm not sure what the issue is.

      Regards,

      Al.

      Delete
  6. Hi Al,

    Great blog! I find it very informative since i'm new to LWS.

    Have you ever tried creating web-service for PPS170? Im kind of stuck here because it doesn't support change using panel A. So it needs to start in Panel B, but in Panel B I can't identify how to select a specific data. Any suggestion? Thank you very much. :)

    Regards,
    LCA

    ReplyDelete
    Replies
    1. Hi LCA,

      I haven't created a Web Service for PPS170, but have created many web services using the B panel. For PPS170 I would suggest that you create a custom sorting order and view that sorts and displays by the Planned Purchase Order number (PLPN). You can then specify this sorting order, view and planned PO number in the web service to select the line you want.

      Regards, Al.

      Delete
    2. Hi Al,

      Thanks for your reply.

      If we now have view and sorts thru Planned PO (PLPN) in PPS170, how do we set it in the webservice to select the line we want?

      Thanks again.

      LCA

      Delete
    3. Hi LCA,

      You'd normally set the panel sequence, sorting order and view on the B panel, pass the order number to the filter field and have ENTER on the B panel. You would also set OPT2 = 2 to go in change mode. This may be made more complex by the Change on PPS170 being PPS171 so you will need to add a related option.

      But - I haven't built for this specific scenario. I'd need to sit down and look at it to provide complete advice. You may be at the stage where you should buy some consulting assistance to get you going?

      Regards, Al.

      Delete
  7. Hi there,

    Has anyone built sucessfully a web service for PDS002 ?? (materials and operations)...I tried building one using PDS001 (main) and PDS002 (related)..and i get this warning when calling PDS002 method: "Programs with editable lists should only be used with the Interactive feature, and will not work as non-interactive services"...I just decided to go further and after using U instead B panel, it doesn't work when running it.

    Regards,

    G.Z.

    ReplyDelete
    Replies
    1. Hi GZ. I have created web services against PDS002 without issue. However, as there are APIs for this program you may find it better to wrap the API in a Web Service.

      Where I have had issues is PMS100/101. When I needed to manipulate materials and operations for released MOs I first needed to remove the restrictions on the PMS100 program in the controlling XML file. Search for the error / warning message you see in Web Services design studio in the web services path. You will find an XML with that message in it. Comment out the message against the program and you're away.

      Of course, as you're removing a restriction that Lawson put in place you have to be careful, but as long as you test thoroughly you should be fine.

      Regards, Al.

      Delete
    2. Thanks Alistair,

      API works fine...actually main reason to use LWS is i want to do pds013, since no API available i have to use LWS...with pds002 not having A panel is a bit challenging...i am using A panel and option 11 in pds001, U panel and option 20 in pds002 but it won't work...seems you have to select the right fields in pds002 which i still can't find.

      Regards,

      G.Z.

      Delete
    3. Hi GZ. I'd recommend you try using the B panel then. Apart from dynamic screens that have control tables which define the nature of the columns e.g. accounting rules, discount table etc. I haven't had any problems building web services on programs where there was no A panel and only a B panel.

      Regards, Al.

      Delete
    4. Hi, I'm trying something very similar to G.Z., PDS001/A --> PDS002/U --> PDS008. The WS runs without error but doesn't make any changes. In which program were you suggesting switching to B panel instead of A and why?
      Sharon

      Delete
    5. Hi Sharon, have you tried debugging your Web Service by ticking the Interactive option on first the PDS002/U screen, and then if that works the PDS008 screen?

      This will allow you to at least confirm that the correct programs are being opened. Once you have each program opening, add the parameters, one by one, until you confirm they are being populated correctly and then call the related option to proceed to the next program.

      In a quick look at this I've successfully gone PDS001/A -> PDS002/U and populated the line selection parameters into PDS002/U. I haven't managed to get PDS013 opening yet, but I need to move on to my day job now sorry.

      Configuration so far:

      PDS001
      Panel sequence: A (ENTER)
      Input parameters: W1PRNO, W1STRT, WWFACI, WWOPT2

      Related option from PDS001 to PDS002

      PDS002
      Panel sequence: U (ENTER)
      Input parameters: WBOPNO, WMMSEQ, WWOPT2

      Hope that helps.

      Regards, Al.

      Delete
  8. Thanks for your quick reply Al.
    I'm working with Movex 12 Workplace and MWS 1.6.

    I've tried checking the box where it says: "Open the program in Movex Net Extension when it reaches this panel, if the MWSF session is running with the interactivity extension." Maybe it's not running with the extension, or else I don't know where to look, but I don't see in Movex or in Fiddler any interactivity.

    To the problem itself: I've been told here that MWS can't handle more than two program levels. If you or anyone else has any concrete information otherwise, I'll be happy to know I haven't been wasting my time trying.

    Thanks, Sharon

    ReplyDelete
  9. Hi Folks,

    1)I wanna know have any one tried to create a Web Service for OIS831.
    Actual problem is that it takes PriceLstTable and Priority and after hitting f5 it changes sub file view and then after inserting Business Chain we can hit create option .
    I prepared the WS for the same and it runs successfully but it does not create the records and issue is my LWS Designer is not having interactive option so I am not able to check it out .

    2)How we can update Text Panel suppose I wanna update Supplier Text on T Panel so how I can I do as there is no such T Panel mentioned.

    3)How can we consume WS without connecting to Client VPN i.e WSDL produced is accessed only when I am connected to Client VPN once I disconnect the WSDL page is not Loaded.

    4) How to consume the Web Service for ex the above How is the above WS in Example consumed.
    And How many are the methods to call/consume the WS.

    Please provide examples or Code or XML files.
    Thanks in advance!!

    ReplyDelete
  10. Hi Kiran,

    1. Display Web Services don't work well for dynamic screens. You can use a web service wrapping an API or use a SQL web service to insert the data.

    2. Try wrapping CRS980MI the Text Blocks interface

    3. You can download the wsdl and import into your application. This will allow you to build code against the web service. However you will of course not be able to call the web service without being connected to the VPN.

    4. Use Soap UI ( http://www.soapui.org/ ) for testing your web services. There is an example set of .Net code in another blog post here ( http://movexblog.blogspot.com/2012/11/lawson-web-services-and-net-guest-post.html ) which shows the process of consuming these web services in C#

    Hope that helps,

    Al.

    ReplyDelete
  11. Any idea how to call a SQL WS from excel macro.

    ReplyDelete
    Replies
    1. Hi Kiran,

      I use Pocket Soap ( http://www.pocketsoap.com/pocketsoap/ ) for this.

      Cheers, Al.

      Delete
  12. Hi I want to download data in to Excel file using SQL webservices and Excel Macro .
    Please provide some examples.

    ReplyDelete
  13. Hi there

    First of all thanks for this great tutorial which has helped me a lot before.

    Has anyone used LWS with OIS215?

    I am trying to validate cash sale payments, M3 manual process is:
    1. OIS215/B -> enter invoice no and Create/option 1
    2. OIS215/B -> enter cash, payer etc and Validate/F14

    but cant get it to work via LWS. Is it even possible as there is just one panel but two actions?

    ReplyDelete
  14. Hello Jan
    We have the same requirement (MMS100) of To Warehouse issue and could you please advise your solution in creating web service (with E & F Panel).

    ReplyDelete
  15. Regarding web-service I have a specific problem regarding MMS100, where the "to warehouse is on the F-panel AND DOES NOT EXISTS IN E PANEL in web-service framework, BASED ON ORDER TYPE CONFIG SYSTEM IS EITHER CALLING E PANEL (FOR REQUISTION) AND F PANEL (FOR DISTRIBUTION). Have you heard about this problem before - and have you got a solution to come across it ??

    ReplyDelete
    Replies
    1. Hi Mohamed, I haven't looked at this specifically before, but why don't you create two web services - one that calls the E panel and one that calls the F panel. Better still for MMS100 - use the API MHS850MI.AddDO that's exists for the creation of DOs and ROs.

      Delete
    2. Hello AL
      Thanks for your feedback. I have tried using MHS850MI but it does not have he "To Warehouse" TWLO Field (Which is available in F Panel of MMS100), Our business needs to develop 1 web service fulfilling the RO and DO's. Appreciate your feedback.

      Delete
    3. CUNO is the to warehouse field in this API.

      Delete
  16. Hi AL
    Thanks for your advise. However, I need to automate MHS850 message to MMS100 without manually doing the Validate & Execute messages thru webservice.

    Appreciate your advise.
    Thanks

    Mohamed Sithik

    ReplyDelete
  17. Set the processing code (first field in the API) to *exe

    You should probably read the Warehouse Integration manual. Search for MHS850 on Xtreme. Or engage a consultant to assist. My team would be happy to help :)

    ReplyDelete
  18. Hi AL

    Thanks, Since M3 Implementation is in progress, I would take advise from our local Infor Consultants.

    Thanks once again for your support.

    ReplyDelete
  19. This comment has been removed by the author.

    ReplyDelete
  20. Hi AL
    Greetings!. Need your advise on below question , Like we create customer web service for adhoc requirement, is it possible to create customer M3 API's becoz I would like use these custom M3 APIs in BOD Mapper in Eclipse (for Interfaces). Appreciate your feedback.

    ReplyDelete
    Replies
    1. Mns185+crs990mi, mdbreadmi or in 13.4 exportmi (with all the fixes installed) provide get and list custom API facilities. For add, update or delete functions if the API doesn't exist then you need to look at web services.

      Delete
  21. Hi AL
    Thanks for your advise. These Programs are restricted to use single table only and CMS010, 15 has a facility to join tables, However I have made web service for my adhoc request, how to link this web service to new custom API as BOD mapper does not support calling the web service and it supports only API calls, because we need to do the task for Data Migration.
    Thanks

    ReplyDelete
    Replies
    1. Hi Mohammed. Best to talk with your consulting partner I think. This sort of thing is much easier to sort out when there is context. Again, my team can help, but if you're solely engaging with Infor right now then you should probably direct your specific queries there as they'll have the context.

      Regards

      Al

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

    ReplyDelete
  23. Hello AL
    Greetings!. I have created WebService with SQL Query for simple master uploading (There is no Standard API and M3 Display program also not working). It is working finr but while using SDT tool to upload the data thru Excel sheet, it gives the error "RowNo=4
    No matching field names: No fields have been added to the web service (the SOAP body). Check input."
    Appreciate your advise, Checked here, No one knows.

    ReplyDelete
    Replies
    1. Hi Mohamed, as it appears to be an issue with the sdt tool, which you have licensed from Infor, you should log an incident in Xtreme for support.

      Delete
  24. Hi AL
    Thanks for your advise, I have created Infor Extreme Ticket.

    ReplyDelete
  25. Hi AL
    Greetings!. I need your valuable feed back on the below web service
    While creating CAS380 with Display Programs Start with 'B' Panel, but the issue is the Default Inputs are Facility and Item No then after hitting the Enter Key in same Panel, other Mandatory Input Attribute is being displayed. It seems to be based on Item No + Facility the Inputs are being changed. How to over come this issue as we have defined panel 'B' with Enter and E as well.
    Appreciate your feedback.

    ReplyDelete
    Replies
    1. Dynamic screens in M3 do not work well with Web Services.

      Delete
  26. Hi all,
    How to consume related webservice through EXCEL macro. i need to run PCS280 excel macro from MMS003.I'm using pocketsoap but giving me error 'element missing "PCS280"'.
    Appreciate your feedback

    ReplyDelete
  27. This comment has been removed by the author.

    ReplyDelete
  28. Hi All
    M3 Custom Webservices (WSDL) are compatible with Rest API, We have requirement to create simple SQL Webservices for external use as Rest web service (Json output) . Can any one Please advise.

    ReplyDelete
    Replies
    1. Lws/mws are soap only. The new ips m3 cloud web services are exposed via ion API which is rest/JSON, but you can't build or expose SQL calls in ips.

      However on prem and m3 cloud both have exportmi now which exposes sql-like functionality which you can access via the native rest apis.

      Delete