MEC Part 10 – MEC and Event Analytics

In my previous post we discussed how to trigger a MEC process based on an event occurred in M3 using Event Hub. The example we discussed was triggering a MEC process whenever a customer order line is added.

However, in some instances we need to filter out unwanted events and trigger MEC processes only when a particular scenario is occurred, say the MEC process should only be triggered when a Customer Order Line with zero price is entered. In such situations Event Analytics comes in to play.

Event Analytics is also subscribed to Event Hub, but it provides the option to define rules in it. The Event Analytics only publishes the events that satisfy the defined rules. In this post, I am not going to discuss in detail about how to define Event Analytics Rules. The intention of this post is to explain you how to use Event Analytics with MEC.

The example we are going to use here is triggering a MEC process when a customer order line with zero price is entered.

Defining the Event Analytics Rule

1. Go to Event Analytics Management Pages and Create a new Session.

01

2. In the dialog box displayed, give a name to the session and click OK. Once the session is created go to Rules.

02

3. Create a new rule.

03

4. In the dialog box displayed, give the rule a name and click OK.

04

5. Edit the newly created rule and replace the existing sample code with below code and Save it.

package com.lawson.eventhub.analytics.drools;

import com.lawson.eventhub.analytics.drools.model.Event;
import com.lawson.eventhub.analytics.drools.model.HubEvent;
import com.lawson.eventhub.analytics.drools.model.Session;
import com.lawson.eventhub.analytics.drools.model.Start;
import com.lawson.eventhub.analytics.drools.model.Stop;
import com.lawson.eventhub.analytics.drools.model.Time;
import com.lawson.eventhub.analytics.drools.model.Util;
import com.lawson.eventhub.EventOperation;
import com.lawson.eventhub.EventPriority;

declare HubEvent
     @typesafe(false)
end

rule "LinesWithZeroPrices Subscription"
     @subscription1(M3:OOLINE:C)
     then
end

rule "LinesWithZeroPrices Rule"
     no-loop
     when
     event: HubEvent(
          publisher == "M3", 
          documentName == "OOLINE", 
          operation == EventOperation.CREATE, 
          elementValues["NEPR"] == "0.0"
     )
     then
     event.postEvent("LinesWithZeroPrices");
end

6. Go back to the rules and mark the new rule as active.

05

7. Once the rule is activated, go back to sessions and start the newly created session.

06

Subscribing MEC to the Event Analytics Rule

8. Once the Event Analytic Rule is defined and activated, go to Partner Admin Tool → Manage → EventHub Subscriptions → New.

9. Define the new subscription in the same way that we defined the Event Hub subscription. However, there is a small difference in the way that you have to define the subscription rule. In this case the publisher should be EventAnalytics and the Document Name should be the name of the Event Analytic Rule. So the subscription rule would be EventAnalytics:LinesWithZeroPrices. Priority and operation character are not required.

07

10. Assign the new subscription to the MEC-M3-EventHub Receiving channel (refer the previous post).

Note: Remember to remove the Event Hub subscription that we created in the previous post if it is still active.

11. Restart MEC, Event Hub and Event Analytics components.

12. Now whenever a zero priced item is added to a customer order, Event Analytics will generate an event and it will flow in to MEC since MEC is subscribed to this event. If the item price is not zero, no event will be flown in to MEC.

Create a new Partner Agreement and use AnalyticsHubValue XML detection (or create a new XML detection) in the Partner Admin Tool to detect the received event and trigger a MEC process. Below is a sample event file that is coming in to MEC from Event Analytics.

08

Have a Nice Day…

Advertisements

MEC Part 9 – MEC and Event Hub

In the previous post we discussed about how to use printing of a M3 document to trigger a MEC process using MBM initiator. In this post we will look at how to use M3 Event Hub to trigger a MEC process based on an event occurred in M3.

If you are familiar with the Publisher-Subscriber Design Pattern, M3 Event Hub acts as an event publisher, which broadcasts  defined events when they occur. Any channel subscribed to M3 Event Hub can receive these events. MEC provides a option of subscribing its receiving channels to Event Hub, so that it can receive events published by the Event Hub and trigger MEC processes based on these events.

Let’s say we want to trigger a MEC process, whenever a new Customer Order Line is added to a customer order.

1. First of all a receiving channel should be defined in the Partner Admin Tool to receive events from M3 Event Hub. For that go to Partner Admin → Manage → Communication → Receive Tab and create a new Receiving channel. Give a desired name and set the protocol to EventHub Subscriber. You can leave the other parameters as they are.

01

2. Now we have to subscribe to an event in M3 so that Event Hub generates a trigger when that particular event occurs. This can be directly done through Partner Admin Tool. For that, go to Partner Admin → Manage → EventHub Subscriptions → New.

02

3. Give a name and a description to the subscription. In this case we are trying to capture the event of adding a customer order line. So I have named it as Customer Order Line Create Event.

4. Then we have to define the subscription rule in the below pattern.

03

5. According to above pattern, our subscription rule would be M3:OOLINE:C: :P2. Once the subscription rule is entered click OK.

04

6. Now this newly created subscription should be assigned to a receiving channel. For that, select the created subscription from EventHub Subscriptions list and click Edit. In the displayed dialog tick the correct receiving channel.

05

7. For this subscription to take effect MEC and Event Hub components should be restarted. Once these components are up, go to Event Hub Management Pages.

8. Newly created MEC receiving channel MEC-M3-EventHub should now be in the subscribers list and there should be one subscription in this subscriber.

08

9. If you go in to the subscriptions, you will see the subscription we defined in the Partner Admin.

07

10. Now whenever a customer order line is added (a record is created in OOLINE table), Event Hub will generate an event and it will flow in to MEC since MEC is subscribed to this event.

Create a new Partner Agreement and use AnalyticsHubValue XML detection (or create a new XML detection) in the Partner Admin Tool to detect the received event and trigger a MEC process.

09

Have a Nice Day…

MEC Part 8 – Using MBM Initiator

So far we have discussed how to setup a partner agreement and how to develop a MEC map so that MEC can send the details coming from an external application into M3.

In some cases, we will have to send details from M3 to external applications. For this also we will have to use a Partner Agreement and a MEC map to retrieve the information from M3 and put them into a output file. However, there should be a trigger to initiate the MEC process in this case.

M3 has provided different methods to trigger MEC processes based on different events occurred in M3 and MBM initiator is one of those methods. This can be used to trigger a Partner Agreement when a M3 document is generated.

In this post we will see how to setup MBM initiator for Customer Order Confirmation, so that a MEC process can be triggered, whenever an Order confirmation is printed.

1. There is a Default channel provided by MEC (Default MvxNGIn) to receive MBM Initiator files from M3 when they are generated. This should be enabled first in the Partner Admin Tool → Manage → Communication → Receive Tab.

0

2. Reload MEC Communication channels from LCM. You should now see a new communication channel called Default MvxNGIn. Note down the port. This Port no can be changed from the Partner Admin Tool if required.

00.jpg

3. Now, this newly enabled MEC receiving channel should be defined as a Output service in M3. For this, first add MEC Server as a output server in MNS218.

01

4. Define a output service type in MNS217. Interface should be XMLOUT.

02.jpg

5. Then create a Output service in MNS216. Server Id and Service Type should be the ones we created in step 3 and 4 respectively. Port no should be the one that was noted down in step 2.

03

6. Goto CRS116 and check if there is a Document Media called MBM. If not click on Actions → F14 (Gen Standard).

04

7. Make sure that the document for which you are going to generate the MBM initiator, is defined in CRS928. If not generate all standard documents by clicking Actions → F14 (Gen Standard).

8. Now we have to define the required document in CRS945. In this case, we need to generate the MBM Initiator for the Order Confirmation and the Document Number of the Customer Order Confirmation is 231 (OIS606PF).

9. If the Confirmation MBM should only be generated for a given Division, put the division code, else leave it blank. Put the document number and press Enter.

05.jpg

10. Based on the selection fields defined in the CRS928 for the given document, you can control the generation of MBM initiator. For instance, according to my CRS928 setup, the selection field for OIS606PF is Customer. So if I put a customer number here when adding a record to CRS945, the MBM initiator will only be generated for the customer orders created against that particular customer. However, in this example I want to generate the MBM initiator for all the confirmations, so I am going to leave this blank. Click Create.

06.jpg

11. Once the record is added to CRS945, go to Relate Options → Media from CRS.

12. In CRS949, connect the MBM media control object to 231 document. Make sure that the Copy parameter is set to 2 if the MBM initiator should be generated for both original document and copies.

07

13. Make sure that Media Control Selections are set to 3 in MNS204 for the selected document.

08.jpg

Whenever you print Customer Order Confirmation, M3 should now submit a MBM initiator file to MEC. MEC receives this initiator file through the MvxNGIn channel. Create a new Partner Agreement and use one of the standard XML detection in the Partner Admin Tool to detect the generated MBM Initiator File.

09

Have a Nice Day….

MEC Part 7 – Set Proper Name for the Output File

In my last post we looked at how to develop a MEC mapping and how that can be used in a Partner Agreement. However, the name of the output file that is created in the process is an auto-generated one which is not really meaningful.

Output Files

In some integrations, the output file name becomes very important because the 3rd party application decides what to do with the MEC output file completely based on its name. Therefore, it is really important to put a meaningful name to the output file.

In the example we looked at in the previous post, let’s say that we need to set the output file name to CustomerOrderCreate_<<CustomerPortalOrderId>>_<<DateTime>>.xml

Along with every MEC message processed, a manifest file is generated. We can map a value from this manifest file as the file name of the output file. To do this,

  1. First we need to store the desired file name in the manifest file
  2. Then when the output file is sent to the output channel, it should read the file name from the manifest file and assign it as the file name.

Storing File Name in Manifest File

1. At the end of the MEC mapping add a new Java Function as show below.

Update Manifest

2. Implement below code in the Java function. We use a standard MEC function called setManifestInfo() to store our file name to a new variable in the manifest file. The new variable that we are adding to the manifest file is map:fileName.

private void manifestUpdate() throws Throwable {
	java.text.DateFormat dateFormat = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
		
	java.util.Date date = new java.util.Date();
		
	String dateTime = dateFormat.format(date);
		
	String fileName = "CustomerOrderCreate_" + i_CustomerPortalOrderId.trim() + "_" + dateTime;

	setManifestInfo("map:fileName", fileName);
}

3. Save the update MEC mapping in the MEC database, generate it, publish it and reactivate it.

Assigning File Name to the Output File

1. This should done in the Send channel. For that go to Partner Administrator → Manage → Communications → Send

Send Channels

2. Change the required send channel as shown below. Assign map:fileName variable to File Name and check Make file name unique parameter.

Send Channel

Drop a customer order create request to the input folder and check the output file generated. Now the output file will contain a meaningful name.

Have a nice day….

MEC Part 6 – Your Very First MEC Mapping

In this post we will see how to develop a MEC mapping to create basic customer order inside M3 and return the Order number of the created customer order back. First download the input and output XML schema required for the mapping from my previous post.

Now open the MEC Mapper. I assume that at this point you have already setup a workspace and configured MEC mapper with required server connection details. We have already discussed how to setup MEC mapper in one of my previous posts.

Developing the MEC Map

1. Once you log in to the MEC Mapper, right click on the Mapping Explorer and click on New Project.

New Project

2. In New Mapping Project window, give Project a name (CustomerPortal) and click Next. This will create a new project.

3. Right click on the newly project and click on New Mapping.

New Mapping

4. In New Mapping Name and Document window, give mapping a name (CustomerPortal_CustomerOrderCreate).

5. Then select input and output XML schema that you have already downloaded and click Next.

New mapping window

6. In Root Elements window see if MEC mapper has correctly identified the root elements of both input and output schema. For input schema, it should be CustomerOrder and for Output schema it should be CustomerPortalResponse. Click Finish.

7. This will add the new mapping to the project. Double click on the newly created MEC map to open it in the Mapping Manager. Below image illustrates different component in the Mapping Manager.

Mapping Manager

8. First we will read Order Header Details from input schema in to the MEC mapping. For that we will add a Java function to the mapping. Click on the Java under Core Functions in toolbox and then click on the sequence list area.

Adding a Java Function

9. Once the Java function is added to the mapping, click on the select tool in toolbox.

10. Then click on the newly added java function and go in to Properties tab in Mapping Console area. In properties, give function a proper name and a description.

Functions Properties

11. Then we need to add input variables to this function to read values from input schema and pass then in to the function. For that right click on the function and click on Add Input Parameter.

Adding an input Parameter

12. Once the input parameter is added, click on it and go to properties. In properties, give input parameter a proper name and a description. It would be a good practice to put an “i” in front of the parameter to identify that it is an input.

Input Parameter

13. We will now assign the customer number from input schema to the newly added input parameter. For that, select Link tool in toolbox, click on CustomerNumber node in input schema and then click on the newly added input parameter (i_CustomerNumber).

Input Parameter Assignment

14. In the same way, assign remaining Order Header details in input schema to input parameters.

All Input Parameters

15. Then we need to add output parameters to this functions to take some data out. For that right click on the Java function → Add Output Parameter.

Output Parameters

16. Once the output parameter is added, go to properties and give proper name and description. In the same way, add output parameters for all required outputs. It would be a good practice to put an “o” in front of the parameter to identify that it is an output.

All Output parameters added

17. Now we need to define the relationship between input parameters and output parameters. This should be done using the code behind this java function. To access the code behind this java function, right click on the function → Edit Java Code.

Java Code

18. Any new code that you are implementing, should go with in the main function in the code. Anything that is written outside the function gets deleted every time you go in to the code.

/**
* Java Function to read Order Header Details from input Schema
**/
private void readOrderHeaderDetails() throws Throwable {
	// Please implement me
}

19. Implement below Code in to define the relationship between input and output parameters. You do not need to define these parameters as variables, because MEC mapper has already done that for you. Once the code is implemented, save the java class and close it.

private void readOrderHeaderDetails() throws Throwable {
	o_CustomerNumber = (i_CustomerNumber == null) ? "" : (i_CustomerNumber.trim());
	o_CustomerPortalOrderId = (i_CustomerPortalOrderId == null) ? "" : (i_CustomerPortalOrderId.trim());
	o_CustomerPoNumber = (i_CustomerPoNumber == null) ? "" : (i_CustomerPoNumber.trim());
	o_RequestedDeliveryDate = (i_RequestedDeliveryDate == null) ? "" : (i_RequestedDeliveryDate.trim());
	o_CustomerContact = (i_CustomerContact == null) ? "" : (i_CustomerContact.trim());
	o_PaymentMethod = (i_PaymentMethod == null) ? "" : (i_PaymentMethod.trim());
	o_PaymentTerm = (i_PaymentTerm == null) ? "" : (i_PaymentTerm.trim());
	o_DeliveryMethod = (i_DeliveryMethod == null) ? "" : (i_DeliveryMethod.trim());
	o_DeliveryTerm = (i_DeliveryTerm == null) ? "" : (i_DeliveryTerm.trim());
	o_CustomerName = (i_CustomerName == null) ? "" : (i_CustomerName.trim());
	o_AddressLine1 = (i_AddressLine1 == null) ? "" : (i_AddressLine1.trim());
	o_AddressLine2 = (i_AddressLine2 == null) ? "" : (i_AddressLine2.trim());
	o_AddressLine3 = (i_AddressLine3 == null) ? "" : (i_AddressLine3.trim());
	o_AddressLine4 = (i_AddressLine4 == null) ? "" : (i_AddressLine4.trim());
	o_City = (i_City == null) ? "" : (i_City.trim());
	o_State = (i_State == null) ? "" : (i_State.trim());
	o_PostalCode = (i_PostalCode == null) ? "" : (i_PostalCode.trim());
	o_Country = (i_Country == null) ? "" : (i_Country.trim());		
}

20. Whatever comes in as order header details in the input XML, we have passed in to output parameters. However, these output parameters are local to the java function we just created; hence will not be able to use them in any other function in the mapping. Therefore we now need to assign these output parameters to a set of global parameters. To create a global parameter, right click  on Variables and Constants tab in Mapping Console → Create Variable.

Create Global Variable

21. Give proper name and a description for the variable. It would be a good practice to put a “g” in front of the variable to identify that it is global. In the same way, define all other required global variables as well.

Global Variables

22. Data type for all variables are set to String and initial value of the variable is set to blank.

23. Now we need to assign the output parameters from ReadOrderHeaderDetails java function to relevant global variables. We will first assign o_CustomerNumber to gCustomerNumber. For that click on gCustomerNumber, drag it and drop it on o_CustomerNumber.

Assigning Global Variable

24. In the same way assign all required output parameters to global variables.

All global variables assigned

25. Now we have read all header details from the input XML and create the customer order header inside M3. We can use OIS100MI – AddBatchHead API. We will add this API to the mapping. For that add M3 API tool under M3 Functions in toolbox to the sequence list area after the ReadOrderHeaderDetails function.

M3 API

26. In the window that is opened, select a location to retrieve API details and click Next. (Make sure you have setup M3 API Connectivity in ION Mapper Preferences). This will retrieve the list of APIs from M3.

M3 API Connection

27. In the next window select the required API and click finish.

API List

28. This will add the API in to the mapping. Then click Select in toolbox.

API added to the mapping

29. Now we have to give inputs to this API. Drag gCustomerNumber variable and drop it on CUNO input of the API. This will assign the value in gCustomerNumber variable to CUNO input in the API.

30. In the same way connect other variables as well. We can define a global constant called gCompany, set value to a desired company number and assign that to CONO input of the API.

31. This API returns Temporary Order Number as an output and we need to store that in a variable, so that it can be used later in the mapping. For that, define a string global variable called gTempOrderNumber and assign that to ORNO output field of the API.

API Inputs and Outputs

32. In the same way, add OIS100MI – AddBatchAddress API to pass address details in to M3. In this case you will have to use gTempOrderNumber as an input. To provide ADRT input in the API, you will have to define another constant called gAddressType and set it to “1”.

Add Address

33. Now we need to add order lines to the order. There can be multiple order lines in an order. Therefore we need to execute OIS100MI – AddBatchLine API again and again for each order line coming in OrderLine nodes in the input XML. For that first we add a Loop to the Mapping. Loop tool is located under Core Functions in toolbox.

34. Then link OrderLine Node with the loop as shown below.

Loop

35. Go to Loop’s properties and check if Condition is set to Execute FOR EACH element. Give a proper name to the loop (OrderLineIterator).

Order Line Loop

36. We need to read order line details from the input schema. For that, add new java function in to the loop. Just like the ReadOrderHeaderDetails function, read line details from the schema and assign them to a set of global variables.

37. Then add OIS100MI-AddBatch API also in to the Loop and map the correct inputs.

Order Line Loop

38. Finally, we have to execute OIS100MI – Confirm to confirm the order inside M3. Assign the output fields to global variables.

OIS100MI - Confirm

39. If gStauts is 90, customer order has been correctly create in M3 and gOrderNumber should contain the firmed Customer Order number. If gStatus is 15, there is an error in the Order Header. If gStatus is 25, there is an error in the Order Lines. Now we need to map required detail output schema. For that first add a java function like below in to the Map.

OutputMapper

40. Implement below code in the above java function.

private void mapOutputs() throws Throwable {
		
	o_Environment = "TEST";
	o_Entity = "CustomerOrder";
	o_Operation = "Create";
		
	o_CustomerPortalOrderId = i_CustomerPortalOrderId;
		
	if(i_Status.equals("90")){
			
		o_OrderNumber = i_OrderNumber;
		o_Result = "OK";
		o_Message = "Customer Order was created successfully!";
			
	} else if(i_Status.equals("15")){
			
		o_OrderNumber = "";
		o_Result = "NOK";
		o_Message = "Error in Order Header. Check temporary order " + i_OrderNumber + " in OIS275.";
			
	} else if(i_Status.equals("25")){
			
		o_OrderNumber = "";
		o_Result = "NOK";
		o_Message = "Error in Order Lines. Check temporary order " + i_OrderNumber + " in OIS275.";
			
	} else {
			
		o_OrderNumber = "";
		o_Result = "NOK";
		o_Message = "Error ocurred. Check temporary order " + i_OrderNumber + " in OIS275.";
			
	}
}

41. Finally map output parameters in MapOutput Function in to output schema.

Map Outputs

42. Save the mapping. Then we need to validate the mapping to see if there are any errors. For that right click on the mapper → Validate. If there are no errors you will see a green light in Mapping Console area.

Validate

Publishing and Activating a MEC Map

1. Open the MEC Map that you need to add in to the server.

2. First we need to save the mapping to the MEC database. For that right click on the mapper → Save.

3. In Mapping Database window, select the MEC database you want to save the mapping to and click Finish

MEC DB

4. If the mapping is saved to the database successfully, you will see a green light in Mapping Console.

Green Light

5. Then we need to generate this mapping and publish it, so that it can be used in a XML transform process. Right click on the mapper → Generate, then Publish. If there are no errors, you will again see a green light in mapping console area.

6. After the MEC Mapping is published in the server, it should be activate that. For that go to MEC Management Pages in LCM.

7. Then go to Server → Mappings tab, find your MEC mapping in the list and click Activate.

Activating a Mapping

Using a MEC mapping in Partner Agreement

1. Once the MEC mapping is published and activated go to the Process tab of the Partner Agreement where this MEC mapping should be used. We will use the CustomerOrderCreate Agreement that has already been setup.

2. Add XML Transform process to the process list.

XML Transform Process

3. In Configuration for XML Transform window, select the required MEC Mapping for the transform and an API reference to execute APIs in the Mapping. Then click OK.

XML Transform Configuration

4. Make sure that XML Transform process is placed between Archive and Send process. Then add another archive process after the XML transform. Final list of processes look like below.

Processes

5. Save the Agreement.

Drop this XML in to the input channel (change the data in the XML to match your M3 configuration) and if the Customer Order is created in M3 without any issue, you should get below output.

<CustomerPortalResponse>
	<ResponseHeader>
		<Environment>TEST</Environment>
		<Entity>CustomerOrder</Entity>
		<Operation>Create</Operation>
	</ResponseHeader>
	<ResponseBody>
		<CustomerOrder>
			<Result>OK</Result>
			<Message>Customer Order was created successfully!</Message>
			<CustomerPortalOrderId>CP0000-000010023</CustomerPortalOrderId>
			<M3OrderNumber>0010001548</M3OrderNumber>
		</CustomerOrder>
	</ResponseBody>
</CustomerPortalResponse>

If this works, you have completed your first MEC mapping successfully.

Have a nice day…

Installing MEC Mapper

MEC Mapper is an Add-in that is installed in Eclipse IDE.

1. Download the latest version of Eclipse from this link and install it in a location where it does not spaces in the file path. In my case it is going to be C:\Development\Infor\MEC\MECMapper.

2. Then download the latest MEC mapper add-in from infor download center.

3. Open Eclipse and select a workspace. I am using C:\Development\Infor\MEC\Projects\Lankeshawara as my workspace.

4. Once eclipse IDE is opened, go to Help → Install New Software.

Install New Software

5. In Install window, click Add.

02

6. In Add Repository dialog box click on Archive and locate the MEC mapper plug-in. Then click OK. This will list the ION Mapper (MEC Mapper) in the grid. Select it and click Next.

ION Mapper install

7. In the next window it will show you Install Details. Click Next.

8. Next window will ask you to Review the license, accept the license agreement and click Finish. Eclipse will then install the plugin and ask you to restart eclipse once the installation is completed.

9. Once eclipse is restated go to Windows → Preferences.

10. In Preferences window click on ION Mapper.

Preferences

11. As soon as you click on ION Mapper, eclipse will ask to setup a password. If not click on Set New Password to setup a password.

12. In XML Editor, give the path of your favourite text editor. In my case i am using Notepad++.

External Text Editor

13. Then expand ION mapper and setup Database Connectivity, M3 API Connectivity, Server Connectivity and SQL Connectivity. You should be able to find all the data required to setup these connections in the exit document provided by the technical consultant who did the server installation.

Server Details

14. Click OK and exit from the Preference window.

15. Now we need to change the perspective of eclipse. For that go to Windows → Perspective → Open Perspective → Other.

Open Perspective

16. In Open Perspective window, select Mapping Development and click OK.

List of Perspectives

This will change the perspective of Eclipse to MEC Mapper like below. Now you are ready to start developing MEC mappings.

MEC Perspective

Have a nice day….

MEC Part 5 – XML Transform Process

So far we have looked at how to configure an input channel, output channel and a partner agreement. In this post we will look at how to perform some task based on the message received from the from an external application. For this we can XML transform process in MEC processes.

The scenario we are using in this series of posts is an integration between a 3rd party Customer Portal and M3. The first integration is creating a customer order inside M3 using the details coming from the application. Format of the Customer Order Creation Request looks like below.

<CustomerPortalRequest>
  
    <RequestHeader>
        <Environment>TEST</Environment>
        <Entity>CustomerOrder</Entity>
        <Operation>Create</Operation>
    </RequestHeader>
    
    <RequestBody>
        <CustomerOrder>
        </CustomerOrder>
    </RequestBody>

</CustomerPortalRequest>

This request is identified using XML detection and the content within RequestBody node is passed in to XML transform process (how this is done is discussed in my previous post). The format of the XML that is going in to XML Transform process looks like below.

<CustomerOrder>
    <OrderHeader>
        <CustomerNumber>000100</CustomerNumber>
        <CustomerPortalOrderId>CP0000-000010023</CustomerPortalOrderId>
        <CustomerPoNumber>PO-99333-222</CustomerPoNumber>
        <RequestedDeliveryDate>20160213</RequestedDeliveryDate>
        <CustomerContact>Mr. James George</CustomerContact>
        <PaymentMethod>FAC</PaymentMethod>
	<PaymentTerm>C30</PaymentTerm>
	<DeliveryMethod>U30</DeliveryMethod>
	<DeliveryTerm>PRP</DeliveryTerm>
        <DeliveryAddress></DeliveryAddress>
    </OrderHeader>

    <OrderLines>
        <OrderLine>
            <ItemNumber>412000-100301</ItemNumber>
            <Quantity>12</Quantity>
            <UpcCpde>22311110</UpcCode>
        </OrderLine>

        <OrderLine>
            <ItemNumber>412000-100302</ItemNumber>
            <Quantity>15</Quantity>
            <UpcCode>22311111</UpcCode>
	</OrderLine>
    </OrderLines>
</CustomerOrder>

What XML transformation does is, it takes XML input, performs some tasks based on the content in the XML and generates an output file if required. XML transformation is done by a MEC mapping and that can be developed using MEC Mapper (ION Mapper), which is an add-in for Eclipse IDE that Infor has released along with the MEC package.

In this example, the XML transform process should read the above input XML, create the customer order inside M3 and then output the Order number of the customer order created. The format of the output XML file looks like below.

<CustomerPortalResponse>
  
    <ResponseHeader>
        <Environment>TEST</Environment>
        <Entity>CustomerOrder</Entity>
        <Operation>Create</Operation>
    </ResponseHeader>
    
    <ResponseBody>
        <CustomerOrder>
            <Result>OK</Result>
            <Message>Order was created successfully</Message>
            <CustomerPortalOrderId>CP0000-000010023</CustomerPortalOrderId>
            <M3OrderNumber>0010000432</M3OrderNumber>
        </CustomerOrder>
    </ResponseBody>

</CustomerPortalResponse>

Based on above input and output XML formats, we need to first develop respective XML schema (refer W3Shcools to learn more about XML schema), because MEC mapper requires XML schema to develop mapping.

I have given the input and output XML schema for customer order creation MEC mapping below and we are going to use these two in our next post to develop our very first MEC Mapping.

Until next time… Have a nice day…