- Print
- DarkLight
M3CE API V2 How to code
Introduction
Calling M3 API's for M3 Cloud Editions, is a little bit different compared to M3 on premise, very much due to the introduction of ION as a middle layer. This document gives you some examples how to code against M3CE API's.
Examples
Enclosed you find some sample source code. The ”handleException(e)” method call should be seen just as a placeholder for your own exception handling, in whatever way is most suitable for your application.
1. MI method that returns one STAT field but does not take any arguments
PMS100MI pms100mi = new PMS100MI();
GetUserJobStsRequest req = new GetUserJobStsRequest();
GetUserJobStsResult result = null;
try {
result = pms100mi.execute(req);
} catch (IonApiException e) {
handleException(e);
}
String stat = result.getSTAT();
2. MI method that takes a bunch of arguments (mandatory arguments are set in the constructor, optional arguments are set using setters) but does not return any fields (just an IonApiEception in case of errors)
PMS100MI pms100mi = new PMS100MI();
AddInboxOpRequest req = new AddInboxOpRequest(faci, prno, mfno, rpcd, opno, stdt, msti, fidt, mfti, plgr);
req.setPLGR(plgr);
req.setPLG1(plg1);
req.setSLAT(slat);
req.setFRCD(frcd);
req.setFRCT(frct);
req.setSETI(seti);
req.setORQT(orqt);
if (schn != null) {
req.setSCHN(Long.parseLong(schn));
}
req.setSCHS(schs);
try {
pms100mi.execute(req);
} catch (IonApiException e1) {
handleException(e);
return false;
}
return true;
3. Bundled call (executing many MI transactions in one request:
try {
DPS170MI dps170mi = (DPS170MI) exportContext.getMIProgram("DPS170MI");
for (ExportAction ea : exportActions) {
MITransaction miTransaction = new MITransaction(SndInboxDOPRequest.class);
SndInboxDOPRequest req = new SndInboxDOPRequest(
ea.getWarehouse(),
ea.getItemId(),
ea.getPlanningDate(),
ea.getPlannedQty(),
ea.getExportActionOption());
req.setPLPN(ea.getProposalNo());
req.setPLPS(ea.getProposalSubNo());
req.setPSTS(ea.getStatus());
req.setFWHL(ea.getFromWarehouse());
miTransaction.setMiRequest(req);
dps170mi.addTransaction(miTransaction);
}
dps170mi.executeTransactions();
dps170mi.clearTransactions();
return true;
} catch (IonApiException e) {
handleException(e);
return false;
}
There was no response to handle in this example but generally you can iterate through transactions after executeTransactions() and evaluate each response.