cancel
Showing results for 
Search instead for 
Did you mean: 

How to read Taxonomy Attributes of a main table's record !!

Former Member
0 Kudos

Hi Friends,

I am able to retrieve records of the main table using the "RetrieveRecordsByValueCommand" Object. Here i am getting values of all fields which are TEXT. But now i want to read the field values which are Taxonomy Lookup. How to read the Taxonomy attribute values of the main table record.

thanks for your time!!!

Thanks,

Raags

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Plz refer to the URL[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/30aa1447-80a1-2a10-e483-a76087bcb12f]

Rgds,

Krutarth

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Raags,

Please see the link below

[http://help.sap.com/saphelp_mdm550/helpdata/en/43/99c11b7d3e21b5e10000000a1553f6/content.htm]

Regards

Richa

Former Member
0 Kudos

Hi, once you created the connection and the usersession MDM objects, you need the TableID object from the Taxonomy table with the attributes, then you need the RecordID Object from the record you want the values. Once you have this objects, all you need is this piece of code:

static public AttributeLink[] getAttributeLinks(ConnectionAccessor connection, String userSession,

TableId taxonomyTableID, RecordId taxonomyRecordID) {

RetrieveAttributeLinksCommand cmd = new RetrieveAttributeLinksCommand(connection);

cmd.setSession(userSession);

cmd.setTaxonomyTableId(taxonomyTableID);

cmd.setRecordId(taxonomyRecordID);

try {

cmd.execute();

} catch (CommandException e) {

e.printStackTrace();

}

return cmd.getAttributeLinks();

}

You will get an array of AttributeLinks type that you can convert to an AttributeProperties type like this

AttributeProperties[] attributes = new AttributeProperties[als.length];

for(int i=0, j=als.length; i<j; i++) {

attributes<i> = getAttribute(connection, userSession, taxonomyTableID, als<i>.getId());

}

Once you have the data on AttributeProperties, then you can go over the attributes types.

Please let me know if this help.

Regards.

Former Member
0 Kudos

Have you had any success yet? I'm thinking my problem is version related.

Did you make sure to add additional result definitions for the lookup table? I believe you will need to do that for the taxonomy table before you are able to access the attributes.

Former Member
0 Kudos

I found something else that may be useful for you (from the migration document on service marketplace).

Since attributes and their assignments to taxonomy nodes are not part of the repository

schema (they are not maintained using MDM Data Manager), attribute identifiers cannot be

obtained using class RepositorySchema. Attributes are created and modified when a

repository is loaded and therefore attributes could possibly change during run time.

For this reason, any information about attributes must be retrieved using specialized

commands:

The first command RetrieveAttributesCommand is useful if you need a complete list of

all attributes defined for a given taxonomy table.

The second command RetrieveAttributeLinksCommand is preferable if you want to get

a list of all the attributes of a specific record that are available for setting their value. This

command evaluates the existing linkages to attributes of a given taxonomy node and

therefore returns only the valid attributes for a record which is already assigned to a taxonomy

node. This command returns an array of AttributeLink. From each of the array elements

you can retrieve the respective AttributeID and, for example, use this identifier for

composing the call of setAttributeValue().

Former Member
0 Kudos

I also am having this same problem. Have you found the solution to this?

Former Member
0 Kudos

Hello Raags,

as u could be awaare the Taxonomy mode File Import command immediately processes the import file one row at a time without the need for an options dialog. You can use the Import command to import multiple languages for the multilingual attribute properties as described in this section; the guidelines for doing so are summarized in the following table.

This URL could be helpful [http://help.sap.com/saphelp_mdm550/helpdata/en/43/99c11b7d3e21b5e10000000a1553f6/content.htm]

Rgds,

Krutarth

Former Member
0 Kudos

Thanks for responding Kruthart!!

Actually i havent asked the question properly. I am looking for JAVA API method to get the Taxomony field values for the given record of the main table.

Could anyone let me know how to read taxonomy field/attribute values of the main table's record?

Thanks,

Raags

Edited by: Raags on Jan 10, 2008 9:11 AM

Former Member
0 Kudos

This is my dilemma as well. I believe this code will work, I just haven't been able to get the rest working. Maybe you'll have more luck.

Here's what I know so far:

You must set this value to true (on the ResultSetDefinition), this will allow you to access the attributes:

rsd.setLoadAttributes(true);

This code will get the values of the attributes:

AttributeId[] attributes = record.getAttributes(fieldId);

for (int x=0;x<attributes.length;x++)

{

System.out.println(record.getAttributeValue(fieldId, attributes[0]));

}

Former Member
0 Kudos

Thanks for useful code Sarah!! Yeah, Let me chk myself how can i get to there. Would let you if i get any solution.

- Raags

Former Member
0 Kudos

This might be helpful as well: AttributeSearchDimension and AttributeProperties.

Former Member
0 Kudos

Ok, I am partially there! I finally was able to get an actual value! My problem was that I was not checking if the MdmValue was multi-valued. After doing that, this code worked! I still have to do it for multi-values, but that should be the same, just looping through the values. Hope this helps you as well!

MdmValue mdmVal = rec.getAttributeValue(new FieldId("F24_29"),aid);

if(!mdmVal.isMultivalue()){

TextAttributeValue txtVal = ((TextAttributeValue) mdmVal);

AttributeId id = aid;

RetrieveAttributeCommand retAtt =

new RetrieveAttributeCommand(conn);

retAtt.setAttributeId(id);

retAtt.setSession(session);

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

try {

retAtt.execute();

TextAttributeProperties props =

(TextAttributeProperties) retAtt.getAttribute();

TextAttributeValueProperties[] val =

props.getTextAttributeValues();

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

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

System.out.println("Name = " + val<i>.getName());

}

}

} catch (CommandException e) {

// TODO Auto-generated catch block

e.printStackTrace();

//trace.errorT("CommandException : " + e.getMessage());

}

}