on 12-10-2007 1:21 PM
How do I save a file via the API 2?
Any exsample will help me alot!
I'm trying to save a object to the table Binary_Objects, but I get the error: "com.sap.mdm.internal.protocol.manual.ServerException: Server error (0xffaab000)"
I assume you are trying to create a BinaryBlobRecord in the Binary_Object Table.
Here is some code that works:
BinaryBlobRecord record = RecordFactory.createEmptyBinaryObjectRecord(tableId);
record.setBinary(new BinaryValue(bytes));
record.setDataSize(new IntegerValue(size));
record.setHasOriginal(new BooleanValue(true));
record.setDataGroupId(node.getId()); // get the node using RetrieveGroupTreeCommand command.
record.setSource(new LookupValue(new RecordId(1))); // see below
record.setCode(name); // The code has to be unique, so you can add a random number to the name.
record.setName(new StringValue(name))
CreateRecordCommand createRecordCommand = new CreateRecordCommand(connection);
createRecordCommand.setSession(authenticatedUserSession);
createRecordCommand.setRecord(record);
createRecordCommand.execute();
If you don't set the source properly , you will get that error. For setSource method, you need to set a Location ID. With API 5.5 SP5, most likely there is no way to create a new location ID and we have to use one of the existing Location IDs. Just to make the code work, I used "new LookupValue(new RecordId(1)) ", which requires having at least one file uploaded to the table via MDM Data manager and use the first part of its location ID.
For setDataGroupID, first create the group node in the MDM Data Manager and find the node in the GroupTree with API. To get the GroupTree, use RetrieveGroupTreeCommand.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.