cancel
Showing results for 
Search instead for 
Did you mean: 

Read SAP MDM Import Server log Programatically

0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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