Wednesday, October 22, 2014

Execute DB Queries inside Mapper

Even its not encourage to execute direct SQL queries inside the MEC mapper due to performance issue, but If you don't have any other soluion (from APIs for WebServices) rather than that,  you can call DB queries inside the map.

This is not the "Database" tool available in Mapper toolbar. Inside a Java function you can use below to pull some value from the database.

String sql = "SELECT CFFACI FROM "+schema+".CFACIL WHERE CFCONO="+CONO+" AND CFFANM = "+locationCode;

String FACI = "";

 java.sql.Connection con =        
    com.intentia.ec.db.ConnectionPool.getConnection();
 java.sql.Statement stmt = con.createStatement();
 java.sql.ResultSet rs = stmt.executeQuery(sql);

 if (rs.next()) 
 {
    FACI = rs.getString("FACI").trim();
 }

 rs.close(); 
 stmt.close();

Thursday, October 9, 2014

Process Setup of Partner Agreements in Infor Partner Administration Tool (PAT)

In this post, I'll share three different type of process setup in PAT which can be used with a Flat file/Disk-In channel based MEC integration.

1. Read the flat file and push the contained data to M3.
2. Use a trigger file to extract some data from M3 and dump it to a flat file
3. Mixture of both : Read some values from flat file, get some data from M3 and dump it to a flat file.

Note : It's Required to configure the channels and the map should be published prior to get certain process visible in the Process tab.

> Read the flat file and push the contained data to M3.



Use a trigger file to extract some data from M3 and dump it to a flat file and Mixture of Both :


Process setup is same for the 2nd and 3rd scenario, but for the triggered file scenario you must set the input schema as default schema when creating the Map, and it's better if you can create your own flat file definition for the trigger file and map it to first FLAT to XML process.

How to Log and Trace MEC Logs to Verify the Logic

From this post, I'm going to describe two ways that I've used to verify the logic that I have implemented inside of the MEC mapper. This is not the debugging option that is discussed in the "M3 Enterprise Collaborator Mapping Manager User Guide". 

As a best practice you can use the build in logger options as below.


ALL LOGING WITHIN A MAP MAP MUST PREVENT THE USE OF 'System.Out.Println();' AND MUST ONLY USE THE FOLLOWING API'S

cat.info();
cat.warning();
cat.error();
cat.debug();
cat.fatal();
~ M3 Enterprise Collaborator - Best Practices Guide

But, using these loggers unnecessarily will cost some additional I/O cost resulting to drain the performance of the run time server. So it's good to place the logging statements with a boolean flag (initiate a global variable of type boolean) where you can initiate it to true during the development and testing period to enable logging operation.

Ex :
if(debug) {
      cat.info(/*Some comment*/);
}

My advice is to always use a specific prefix as the starting of your comment text to make them locate more faster. So initiate a const string variable and assign a unique value that you can use to identify the map uniquely. For this it's recommended to use the Spec Code, Doc Code, Function Code etc. which is given to you.

as an example :

cat.info( MyMapIdentifier + "Some Comment" ); 

Let's see how to check the logged information.

> Using the Infor LifeCycle Manager
 
1. Logged in to LifeCycle Manager, expand the M3 Enterprise Collaborator x.x.x.x.
2. Right click on MEC and select Manage Application.


3. Click on Events


4. You can view the last 500 events recorded in this window.

   Disadvantage in here is you can use view only the last 500 events (by default), But using the Log search option you can specify a time frame, part of the text message etc. and do an advanced search.

 > Using the MEC Storage Database
You have to have permission to access the database server to use this method. If you are tricky enough, You can locate the login information from the Eclipse (MEC Mapper) preference. Look for the required information inside ION Mapper -> Database Connectivity section.

Then you have to log into the database i.e. if is it Ms-SQL server use SQL Management Studio.  Use the below query to list down the events recorded.

select  LogTime, Message
from dbo.MecLog
where LogTime > 1412853722833
order by LogTime ASC

Before execute this, you have to find the last log time using the same table and set it to the highlighted value. 

Advantage in here is that you can get all the events and you have the power of using the SQL commands.


Tuesday, October 7, 2014

How to Set MEC Outbound File Name Using Code

This article describes how to apply a unique name to the out-bound file that is generated from the MEC.

[Spec Code] + _ [yyyyMMddhhmmss]

First the system date and time has to be generated and assign in to a string variable ( as described in this post ). Then call the below built in method inside a user defined function ( make sure that it's not inside a block which is controlled by a logic). 

setManifestInfo("map:M3_MEC_001", fileName);

then go to Partner Admin -> Manage -> Communication -> Send Tab and select your channel configuration and click on edit.



Now set the File name equally to what you have mentioned inside of setManifestInfo method of your code, but with brackets. Set file extension to " - " (no spaces or quotation marks). Set the value of "Class to make file name unique" to MEC_InfixManifest.

Now trigger your inbound channel and check the output.

Wednesday, October 1, 2014

Get the Date and Time inside MEC mapper

While doing some MEC developments my team has encountered with a requirement where we have to send the result to an outbound as a flat file, and the name of the file should be <specificationCode>.yyyyddmmhhmmss.xml.

I found this class and methods which can cater the above file name generation requirement.

com.infor.ecutil.util.DateTimeConverter c = new DateTimeConverter();
String fileName =  "MyFileName." + c.getEDIDateTime()+""+c.getEDIDateTime("TS")+".xml";

"TS" => the Format Qualifier

I've found the Format Qualifies in Phillip Kuo's web site.