- Print
- DarkLight
M3 API (MI) Connectivity Setup
M3 API (MI) Connectivity Setup
Introduction
M3 programs can be called in 2 different ways depending on if it is an API/MI e.g. OIS100MI or a normal M3 program e.g. MMS001.
Call API’s (MI-programs)
Calling M3 API programs, so called MI programs, is done via the MI socket port on M3 server. MI programs have one or several methods, like Get, List, Add, Update.
To enable MI calls:
- Configure the sitedef
Configure the sitedef
You need to set up the following in the site-def to specify which server and port the MI service will run on:
<Property name="movex.api.servername" value="SESEZO21" />
<Property name="movex.api.portnumber" value="21105" />
In addition you can state a specific user to be used for calling api’s, if you are not using the current user to log on api’s:
<Property name="movex.api.username" value="COMFLOW" />
<Property name="movex.api.password" value="password" />
To use a specific user for a specific api call, you can do the following setup and let your code read those parameters instead of above:
<Property name="movex.api.username.OIS100MI" value="COMFLOW" />
<Property name="movex.api.password.OIS100MI" value="password" />
Programing for MI calls
There are multiple variants to call MI. This variant uses generated classes for each MI method, which takes all fields for the method as arguments.
//Set up call using current user (MVXUSERID)
String serverName = SystemWorkspace.getProperty("movex.api.servername");
int portNumber = Integer.parseInt(SystemWorkspace.getProperty("movex.api.portnumber"));
String userName = dialogWorkspace.getSessionValues().getValue("MVXUSERID");
String passWord = "";
try {
passWord = new String (sessionValues.getUserData().getPassword());
} catch (Exception e1) {
}
if (StringUtil.isBlankOrNull(passWord)) {
addAppError(MOVEX, "password.to.m3.not.ok.logout.and.login.again", null, null);
return false;
}
//Init MI program connection
MMS200MI mms200mi = new MMS200MI(serverName, portNumber, userName, passWord);
//Init all parameters to the method call
String stat = null;
if (!StringUtil.isBlankOrNull(mmstat)) {
stat = mmstat;
}
String itds = null;
String fuds = null;
...
//Do the method call and catch a possible error message
UpdItmBasicResp updItmBasicResp = null;
try {
updItmBasicResp = mms200mi.updItmBasic(cono, stat, itno, itds, fuds, dwno, resp, unms, itgr, itcl, buar, itty, tpcd, mabu, chcd, stcd, bacd, vol3, newe, grwe, bypr, wapc, qacd, epcd, pocy, acti, hie1, hie2, hie3, hie4, hie5, grp1, grp2, grp3, grp4, grp5, cfi1, cfi2, cfi3, cfi4, cfi5, txid, ecma, prgp, indi, puun, aluc, ieaa, expd, grmt, hazi, sale, taxc, atmo, atmn, tpli, fcu1, alun, iacp, hdpr, aad0, aad1, chcl, itrc, vtcp, vtcs, ecve, grti, grts, etrf, cawp, cwun, cpun, dsp1, evgr, ilen, iwid, ihei, itru, tecr, exca, accg, cccm, cci1, cri1, hvmt, acrf, itne, spgv, autc, ride, ridc, rnri, safc, rmsg, pdln, cpgr);
} catch (MIException e) {
mms200mi.close();
Object[] messageObjects = new Object[1];
String errMsg = "";
if (!StringUtil.isBlankOrNull(e.getMessage())) {
errMsg = StringUtil.trimTrailing(e.getMessage());
}
if (StringUtil.isBlankOrNull(errMsg)) {
errMsg = "Error MMS200MI updItmBasic";
}
errMsg = errMsg + " ITNO: " + itno;
messageObjects[0] = errMsg;
env.addAppError(MOVEX, "update.item.basic.problems.with.api2", messageObjects, null);
return false;
}
User Setup
M3 users that access api’s are limited to have 16 characters of user id and password, since they are using an internal authentication mechanism and not the same as for the M3 UI. The password is also limited to just use “standard characters”, so special characters, like Swedish one’s does not work.
If the authentication mechanism is not the same for Comflow and M3, the user must be added as a user alias in Comflow, pinpointing the M3 user with Remote system MOVEX or MI (depending on MI implementation).
Call standard M3 programs
Calling M3 standard programs is done via a PCML-definition, which is like a script for how parameters shall be sent and received from the M3 program. Thereby you can run the program’s different panels in the way you have specified it in the PCML.
To be able to call a normal M3 java programs from a rule in Comflow the following is needed
- Comflow site-def needs to be configured
- The jar file “camvx-x.y.z.jar” , like like “camvx-0.9.0.jar”, needs to be installed in M3
- Configure M3 settings
- An autojob for CASRVCL has to be setup in M3 in MNS050
- Start the CSRVASJ-job
Configure site-def
You need to set up the following in the site-def to specify which port the ServerProgramCaller server will run on:
<Property name="connect.mvx.as400.ng.port" value="33001"/>
<Property name="connect.mvx.as400.system" value="1.23.45.67.89"/>
<Property name="connect.mvx.as400.envlib" value="MVXCENV"/>
Note: The default port on the M3 Java Server is normally 33 + <companyNumber> . The <companyNumber> is the company number specified for the Autostartjob for CASRVCL
Download jar file
Enter the URL in your browser https://update.corzia.com/
Log on with your Corzia credentials.
Go to Comflow Connection Kits and down load the jar-file.
Figure 1 https://update.corzia.com/
Setup in M3
To indicate the map where we put the pcml files that defines the program call we need to configure this for M3.
In file _Set_M3.cmd in the M3 map, e.g. C:\M3_v12\env\Comact\ServerScripts
you need to set up SET cpBefore=C:\Comflow\CA_M3_v12
(Different for each installation)
@echo off
:: x
:: =============================================
:: = =
:: = Set values for M3 Server =
:: = ------------------ =
:: = =
:: = Copyright (C) Intentia R&D AB 2003. =
:: = All rights reserved. =
:: = Licensed material property of Intentia. =
:: =============================================
:: Change log
:: ----------
:: Number Date User Description
:: 031120 kavrog0 Created for 12.4.3
:: 031204 kavrog0 Added SessionTester,cpBefore, cpAfter
::
:: ================================================================================
:: = All settings will be done here No changes needed in the _sub-scripts =
:: = Settings for HUM, Market and customer is done in the library list function =
:: = of M3 =
:: ================================================================================
:: ===============================
:: = Root_path : Path to M3 =
:: ===============================
SET Root_path=C:\M3_v12
:: ================================================
:: = Environment: Path to Environment for M3 =
:: ================================================
SET Environment=%Root_path%\env\Comact
:: ========================================
:: = JavaPath: Set the path to the JVM. =
:: ========================================
SET JavaPath=C:\j2sdk1.4.2_13
:: ======================================================================================
:: = cpBefore : Special classpath; added before standard classpath; normally disabled =
:: ======================================================================================
SET cpBefore=C:\Comflow\CA_M3_v12
(Different for each installation)
:: ====================================================================================
:: = cpAfter : Special classpath; added after standard classpath; normally disabled =
:: ====================================================================================
:: SET cpAfter=
:: =====================
:: = Set JVM options =
:: =====================
Setup of CASRVCL in MNS050 in M3
The job CASRVCL has to be setup in MNS050
Start the CSRVASJ-job
Start the job CSRVASJ with the run command
Check in the server view if you see the job CSRV01 below