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.


  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.

  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 :-(

  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 ??

    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.

  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 :-)


  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

    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.



  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. :)


    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.

    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.


    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.

  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.



    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.

    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.



    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.

    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?

    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:

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

      Related option from PDS001 to PDS002

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

      Hope that helps.

      Regards, Al.

  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

  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!!

  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 ( ) for testing your web services. There is an example set of .Net code in another blog post here ( ) which shows the process of consuming these web services in C#

    Hope that helps,


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

    1. Hi Kiran,

      I use Pocket Soap ( ) for this.

      Cheers, Al.

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

  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?