Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

Environment: Webdynpro Java Portal and SAP MDM   

Scenario 1: Create


  1. Create the BinaryBlobRecord instance(blob_instance) from RecordFactory.createEmptyBinaryObjectRecord(BINARY_OBJECTS_TABLE_ID);
  2. Set all the values that are to be updated in the same instance (blob_instance).**
  • blob_instance.setDataGroupId(<value>)
  • blob_instance.setBinary(<Binary Object Byte[]>);
  • blob_instance.setHasOriginal(<boolean>);

     3. Use CreateRecordCommand create = new CreateRecordCommand(<user session context>); to create the Binary Object Record (B1)

          CreateRecordCommand (MDM Java API Library)

     4. Set the value and Update the Main Table Record (R1) with the Link (B1) Result : We have a record (B1) in the Binary Object table linked to the main table* record (R1).

*Can be table of any type


Scenario 2: Update
To update the BLOB object of that particular Binary Object record (B1).Steps:

  1. Search the Binary Objects table with for the record to be updated
    1. Get the link from the main table record (R1)
    2. The return value is Rec ID of the BLOB (B1).
  2. Create the BinaryBlobRecord instance(blob_instance) from RecordFactory.createEmptyBinaryObjectRecord(BINARY_OBJECTS_TABLE_ID,B1);
  3. Set all the values that are to be updated in the same instance (blob_instance).**
    • blob_instance.setDataGroupId(<value>)
    • blob_instance.setBinary(<Binary Object Byte[]>);
    • blob_instance.setHasOriginal(<boolean>);
  4. Use the ModifyRecordCommand to update the Record.

    ModifyRecordCommand (MDM Java API Library)

Result: The Binary Object is updated and hence there is no need to re-link again.


**For the details about the different Parameters of Binary Objects - Working with Binary Large Objects (BLOBs) - SAP NetWeaver Master Data Management (MDM) 7.1 - SAP Lib...

to set the setDataGroupId(Mandate for all types of BLOBs)

RetrieveGroupTreeCommand tree = new RetrieveGroupTreeCommand(<usersession context>););

tree.setGroupType(GroupTypes.DATA_GROUP_TYPE);

tree.execute();

HierGroupNode node = tree.getGroupTree();

//As per our requirement we just placed all the BLOBs in the first leaf of the node

//you can various options in the HierGroupNode (MDM Java API Library) to traverse and select the relevant leaf.

GroupNodeId gID = node.getAllLeafs()[0].getId();                 

blob_instance.setDataGroupId(gID);                

 

to set the setDataLocationId (Mandatory only for Binary Objects)               

RetrieveGroupTreeCommand location = new RetrieveGroupTreeCommand(<usersession context>);

location.setGroupType(GroupTypes.DATA_LOCATION_TYPE);

location.execute();

HierGroupNode lTree = location.getGroupTree();

//As per our requirement we just placed all the BLOBs in the first leaf of the node

//you can various options in the HierGroupNode (MDM Java API Library) to traverse and select the relevant leaf.

GroupNodeId lID = lTree.getAllLeafs()[0].getId();                

blob_instance.setDataLocationId(lID);


Scenario 3: Deletion
Note : we can delete a Binary Object only if it is not linked anywhere.

Delete the orphaned or the unused records from the Binary Objects table.


  1. Get the Record ID’s from the Binary Object Table

     Using the  RetrieveLimitedRecordsExCommand objExCommand_allData = new RetrieveLimitedRecordsExCommand(<UserSessionContext>);          Command.   

2. Use the below code to get usage of the Binary Object Record (B1).   

RetrieveBinaryObjectUsageCommand objUsageCommand =new                                           RetrieveBinaryObjectUsageCommand(<UserSessionContext>);            

    • objUsageCommand.setTableId(BinaryObjects_tableID));
    • objUsageCommand.setRecordId(B1);
    • objUsageCommand.execute();

     RepositoryItemUsageResult objUsageResult = objUsageCommand .getUsageResult();

     RepositoryItemUsage[] repoUsage=objUsageResult.getUsages();

Refer the link for the return values : Constant Field Values (MDM Java API Library)

If the length of repoUsage is 0 then the Binary Object Record (B1) has no usage. And therefore can be erased.

     3.Use the

     DeleteRecordsCommand objDeleteBLOBRecordsCommand = new DeleteRecordsCommand((<UserSessionContext>);

     DeleteRecordsCommand (MDM Java API Library)

            To delete the Record.

Note :  Trying to delete Binary Object records which are linked will result into an Exception  .

FYI: For your information you can use the Pagination technique for searching Pagination of MDM search result in Java

12 Comments
Labels in this area