cancel
Showing results for 
Search instead for 
Did you mean: 

New MDM Java API equivalent for CatalogData.AddDataLocation

Former Member
0 Kudos

I am trying to port a utility that uploads PDF files to the MDM PDFs table from the MDM4J Java API to the current MDM Java API. I am having difficulty with the following code:

...

final CreateRecordCommand createRecord = new CreateRecordCommand(connections);

final PdfBlobRecord rec = RecordFactory.createEmptyPdfRecord(getTableId(TableProperties.OBJECT_ACROBAT));

try {

BinaryValue bv = new BinaryValue(bytes);

rec.setBinary(bv);

rec.setDataGroupId(dataGroupId);

rec.setDataSize(new IntegerValue(bytes.length));

rec.setHasOriginal(new BooleanValue(false));

rec.setCode(fileName);

rec.setName(new StringValue(fileName));

rec.setOriginalName(new StringValue(fileName));

rec.setSource( new LookupValue(new RecordId(1)) ); //This is where I am having difficulty

} catch (IllegalArgumentException e) {

e.printStackTrace();

} catch (MdmValueTypeException e) {

e.printStackTrace();

}

...

I had read [this forum post||Save binary object via API 2] and followed the instructions, but the solution didn't work for me; I keep getting an "Already exists" error. If I try to use an ID that doesn't exist in the A2I_CM_DATA_LOCATIONS table, I get the error: "com.sap.mdm.internal.protocol.manual.ServerException: Server error (0xffaab000)"

What I am really looking for is a way to add a Data Location to MDM using the new Java API and get the record ID back to pass to the setSource() method. I have scoured the API reference and am unable to find anything that works.

The way to add a data location in the MDM4J API is very simple:

int origLocationId = catalog.AddDataLocation(filePath, 0, DataLocationType.ComputerLocation);

I am currently on MDM version 5.5.42.75. Any code samples would be greatly appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Doug,

Following link provides you the new JAVA API with their classes and package, it may help you:

http://help.sap.com/javadocs/MDM/current/index.html

OR following are the New MDM JAVA API'S, which also contains some code:

MDM JAVA API 2 introductory series part II

/people/tobias.grunow/blog/2007/12/18/mdm-java-api-2-an-introductive-series-part-ii

MDM JAVA API 2 introductory series part III

/people/tobias.grunow/blog/2007/12/27/mdm-java-api-2-an-introductive-series-part-iii

MDM JAVA API 2 introductory series part IV

/people/tobias.grunow/blog/2008/01/02/mdm-java-api-2-an-introductive-series-part-iv

Hope dis helps you.

Reward points if found useful.

Regards,

Swapnil

Former Member
0 Kudos

Swapnil,

Thank you for the prompt response. As I mentioned in my original post, I have thoroughly reviewed the MDM Java API reference. The blog links are very helpful and I have compiled and run the code from these articles, but they mainly show how to connect to an MDM repository and search for main table records, something I already know how to do.

My questions are more specific:

[1] Does the new MDM Java API allow me to create a data location and return a record id so that I can pass it as a required parameter to upload a PDF file to the repository?

[2] If the answer is yes, can someone please provide a brief code sample on how to do this?

I have already figured out how to retrieve data locations using the new API. Here is a brief example:

...

RetrieveGroupTreeCommand rgtcmd = new RetrieveGroupTreeCommand(connections);

rgtcmd.setSession(sessionId);

rgtcmd.setGroupType(RetrieveGroupTreeCommand.DATA_LOCATION_TYPE);

rgtcmd.execute();

HierGroupNode hgn = rgtcmd.getGroupTree();

HierGroupNode[] children = hgn.getChildren();

for (int i = 0; i < children.length; i++) {

//iterate through child nodes and unpack data location values

}

...

What I can't find in the API reference is a way to create and update this data. Any help is greatly appreciated.

Thanks.

Former Member
0 Kudos

This functionality is missing. It's planned for SP6 Patch 02.

Former Member
0 Kudos

Thanks, Nick. It helps to at least know that I wasn't overlooking something. I look forward to using SP6 Patch 02.

Answers (0)