cancel
Showing results for 
Search instead for 
Did you mean: 

MDM Java API for measurment.

Former Member
0 Kudos

Hi,

I am using MDM Java API to display a numeric value attribute, the API that i am using is

MeasurementManager.GetMeasurementManager().GetString(15, 1,1002,1,false,-1);

Invalid measurement id 1002. it is custom measurement ( decibels), so it is generated automatically.

could you please let me know if i am using wrong API or is there any other way that I have to retrieve those.

any help is appreciated?

Thanks

RKR

Edited by: RKR on Jan 23, 2008 4:39 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

This is for the MDM Java API 1, correct? You should use the CatalogData.GetMeasurements() instead.

Former Member
0 Kudos

Hi ALL,

firstly, I would like to thank you for your help regarding this.

As you might have noticed that I am using old API in my applicaiton. I just have this problem with measurements.

@Nick: your solution catalog.getMeasurement() also gives an instance of MeasurementManager which I am already using in my application. it is only failing for custom measurements that aqre client specific.

did anyone use measurement api for custom measurements with the old api?

please help

Thanks

Former Member
0 Kudos

If you do a

new MeasurementManager()

, this instance will not contain any of the user-defined measurements. It will only contain the built-in measurements. Retrieving the instance from

CatalogData.GetMeasurement

will contain both the user-defined measurements and the built-in measurements.

Assuming you're are using the instance from

CatalogData.GetMeasurement

, what was the error you're having? Did you define the measurements and units correctly in the DBMS table?

Former Member
0 Kudos

Nick,

Thanks for your quick reply. I defined one custom measurement correctly in UoM manager, i.e. for decibels and when i view in datamanager it is displayed correctly.

but when i use the measurement api as said in my first post, I get the following error, " Invalid measurement id 1002". 1002 is generated automatically when I created "decibels".

but as you said, I will use the catalogData.getMeasurementManager.GetString() with the same paramters and see if it brings up. I dont have access to the system right now. i will let you know once i test that.

could you please also help me out with the thread that i opened, i.e. regarding the MDM4j support getting deprecated with the sp06. would this application break?

Thanks

Former Member
0 Kudos

Hmm.. unfortunately getting the same error... any other clues..

Code:

String val1 = catalog.GetMeasurements().GetString(aex.GetAttributeValueExAt(k).GetCharacteristics().GetAttributeValueAt(0).GetValue(),aex.GetAttributeValueExAt(k).GetCharacteristics().GetAttributeValueAt(0).GetUnitID(),aex.GetAttributeValueExAt(k).GetAttributeInfo().GetDimensionID(),aex.GetAttributeValueExAt(k).GetAttributeInfo().GetDecimalPlaces(),false,-1);

Printing out the values:

10.0 101 76 0

exception:

Invalid measurement id 76 and/or source unit id 101

Thanks

Former Member
0 Kudos

Since these are user-defined dimensions, I can't determine if it's a bug or not. I will need to get access to your repository. If you can unarchive the repository with schema only, I can check to see if the user-defined dimensions are defined correctly in the repository.

Former Member
0 Kudos

Nick,

could you please let me know your email id?

Thanks

Former Member
0 Kudos

RKR, can you please open an OSS and upload the repository archive (schema only)? I don't really need the repository content.

Former Member
0 Kudos

Nick,

Already I created a message and sent the repository to SAP. The message nr is 0000058253 [High]. It would be great if you get a chance to look into that?

the message has already the code, projects and repository. It has been sitting there for a while.

Former Member
0 Kudos

I downloaded the repository. The following code works fine.


        String msg;
        
        msg = catalog.GetMeasurements().GetString(15, 1,1002,1,false,-1);
        System.out.println(msg);
        msg = catalog.GetMeasurements().GetString(10.0, 101, 76, 0,false,-1);
        System.out.println(msg);

Here's the output:

15.0 dB

10 dBTest

Is your repository setup as a master-slave configuration?

Former Member
0 Kudos

Nick,

thanks for testing. Yep, I think it is master-slave, but not sure. Do you think that is the reason for this error? please let me know. if that is the case, how can we get around this problem.

Thanks

Former Member
0 Kudos

As far as I can tell, user-defined dimensions are not propagated to the slave repository during synchronization. I do believe user-defined dimensions are propagated to the slave repository when you create a new slave.

Did you test using the slave repository or the master repository?

If you can do a quick test connecting to the master repository, that will pretty much confirms it.

Former Member
0 Kudos

Thank you Nick. I will test it and let you know.

Thanks

Former Member
0 Kudos

Hi Nick,

I just wanted to know if there is something wrong with my code in using the catalog object... here is how i create a connection to my MDM system and use the catalog object.

Context ctx = new InitialCOntext();

IConnectionFactory connectionFactory = (IConnectionFactory) ctx.lookup("deployedAdapters/MDM Factory/ shareable/MDM Factory");

ICOnnectionSpec spec = connectionFactory.getConnectionSpec();

spec.setPropertyValue("Username", "rkr");
spec.setProeprtyValue("Password", "rkr1");
spec.setPropertyValue("Server", "<server name>");
spec.setPropertyValue("Port", "<server port>");
spec.setPropertyValue("Repository lang", "<rep lang>");

connection = connectionFactory.getConnectionEx(spec);

INative nativeInterface = connection.retrieveNative();

CatalogData catalog = (CatalogData) nativeInterface.getNative(CatalogData.class.getName());

// I am able to retrieve the catalog object and different values from the catalog and it works fine

String val1= catalog.GetMeasurements().GetString(10.0, 101, 76, 0,false,-1);

Thanks

Former Member
0 Kudos

I don't know too much about the MDM Connector. If you were able to obtain the CatalogData instance and other method calls, for example GetRecordsByIds, are working correctly, then I assume the way you obtain the catalog object is correct.

Former Member
0 Kudos

Nick,

Just curious to know, how did you test this API without using MDM connection. I mean how did you test it without coding for catalog object.

Thanks

Former Member
0 Kudos

I didn't obtain the CatalogData instance from

nativeInterface.getNative(CatalogData.class.getName())

.

Instead my test code obtain the CatalogData by doing something like this:


catalog = new CatalogData();
catalog.Login(...);

It shouldn't matter how you obtain the CatalogData instance as long as that instance is correctly connected to the repository.

Former Member
0 Kudos

Nick,

Thanks for the your reply. Hmm unfortunately, not able to quite figure out yet the reason for not pulling up the custom measurements. will try and let you know.... but please keep me posted if you can think of something else from your side.

Thanks

Former Member
0 Kudos

Did you try testing on the master repository? What was the outcome?

Former Member
0 Kudos

Nick,

I will let you know as soon as I test it. Thanks for all your help.

Thanks

P.S: I assigned the points to your answer and will close the thread as soon as I test it.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Following blogs may help you, it is related to JAVA API 2:

MDM Java API 2 part I

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

MDM Java API 2 part II

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

MDM Java API 2 part III

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

It may help you.

Reward points if found helpful.

Regards

Swapnil.

Former Member
0 Kudos

Hi,

Thanks for the reply, I already looked at the blogs that you sent. I am having hard time in retrieving

images

pdfs

textblocks

attributes

qualified look up tables

and i dont see a good documentation that can help me out in getting these values.

Thanks

Former Member
0 Kudos

You need to use RetrieveBlobCommand to get the actual blob for images, pdfs, text blocks.

RetrieveBlobCommand cmd = new RetrieveBlobCommand(repository.getConnection());

cmd.setSession(repository.getAuthenticatedUserSession().getSession());

cmd.setTableId(tableID);

cmd.setRecordId(recordID);

cmd.setImageVariantId(variantId);

try {

cmd.execute();

} catch (CommandException e) {

e.printStackTrace();

}

MultiregionValue multiRegionValue = (MultiregionValue)cmd.getBlob();

*********************************************************

If you want to just get the information about the blob, then just cast from the Record (records from the appropriate table - Images, PDFs, etc) to the appropriate blob (TextBlobRecord, ImageBlobRecord, etc):

Record record = blobRecords[<i>];

// Casting done to get the properties we need

BlobRecord blob = (BlobRecord) record;

ImageBlobRecord imageBlob = (ImageBlobRecord) blob;

************************************************************

For attributes you need to use RetrieveAttributeCommand to get the attributes and then use the appropriate classes based on the type (TextAttributeProperties for a Text attribute, etc).

Something like:

RetrieveAttributeCommand retAtt =

new RetrieveAttributeCommand(conn);

retAtt.setAttributeId(id);

retAtt.setSession(session);

retAtt.setTaxonomyTableId(new TableId("T5"));

retAtt.execute();

TextAttributeProperties props =

(TextAttributeProperties) retAtt.getAttribute();

System.out.println("Attribute Name = " + props.getName());

TextAttributeValueProperties[] val =

props.getTextAttributeValues();

Then you need to check the Id's to see if you have a match:

if (txtVal.getId().getIdValue()== val[<i>].getId().getIdValue())

Former Member
0 Kudos

Looks like you are using Older version of Java API. Here is the link to the latest Java API [http://help.sap.com/javadocs/MDM/current/index.html|http://help.sap.com/javadocs/MDM/current/index.html]

BR