on 03-16-2016 10:00 PM
Hello All,
Is it possible to read the SAP MDM Import server log using MDM Java API?
If not then is there a better way ?
The requirement is to show the end user a customized log (generated out of the system log that MDIS generates)
Pradeep
Hi Pradeep,
You have a couple of options available to achieve this. The first option relies on the Import Server to trigger the import. The 2nd and 3rd option rely on your application to control the import.
1. You could read the log-file using standard Java API, but that would require your portal server to have physical access to the log-folders on the MDM-server. Most of the time this is not possible due to security-reasons.
2. In case your application has control over the import-occurring (so it decides which file and when it is imported) you could also try MDM Java API:
RandomAccessFile f = new RandomAccessFile("<DIRECTORY TO FILE><FILENAME>", "r");
byte[] b = new byte[(int)f.length()];
f.read(b);
PortDataFile pdf = new PortDataFile("<IMPORT FILE NAME>",b);//string filename, byte[] content
PortDataFile[] pdfArray = new PortDataFile[1];
pdfArray[0] = pdf;
// GET THE PORT
GetPortListCommand gplc = new GetPortListCommand(context);
gplc.execute();
PortProperties[] pps = gplc.getPorts();
PortId portId= null;
RemoteSystemId remoteSystemId = null;
for (int i = 0; i < pps.length; i++) {
PortProperties pp = pps[i];
String portCode = pp.getCode();
if (portCode.equals("<PORTCODE>")) {
portId = new PortId(pp.getId().id);
remoteSystemId = new RemoteSystemId(pp.getRemoteSystemId().id);
}
}
// INITIATING COMMAND
ImportFilesCommand ifCmd = new ImportFilesCommand(context);
ifCmd.setFiles(pdfArray);
ifCmd.setSession(ses);
ifCmd.setServerName(mdsName);
ifCmd.setPortId(portId);
ifCmd.setRemoteSystemId(remoteSystemId);
ifCmd.execute();
After execution, you can check with ifCmd.getImportResult() (+ underlying methods) . This does not give you the same level of detail as the log, but might be sufficient.
3. Use ImportRecordsCommand. (Sorry, no example code). This will give you the same level of details as the Import Server Logs. After execution you can use .getImportResult(), which you can split into Succeeded and Failed records + related errormessages.
Hope this helps.
Kind regards,
Gerwin Jansen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.