cancel
Showing results for 
Search instead for 
Did you mean: 

Reterieve all Main table records,including flat, Qualified lookupup,Taxonom

Former Member
0 Kudos

Hi all,

I need to display all Main table records including Text, Flat,Qualified Lookup and taxonomy.

Suppose if i have 1 main table(and only one main table exists) 30 flat tables, 2 Taxonomy table.

and the main table which holds values from this subtables.

while reterieving the main table data; i am able to get all text fields but i am getting null for all the lookup fields.

in com.sap.mdm Package we have a program somethigng like SearchByKeyword, this program is the static way of passing values and display main table records, i need something in dynamic way,because for differnt repositories we cannot go to the program every time and manipulate the code to work with each repository records retrievals.

the problem is i am getting the all 'Text' value records but when commming to looup value records only first record value is displaying and rest all are null.

this is some part of the snippet:

TableProperties[] tabprop = tableComm.getTables();

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

//System.out.print(tabprop<i>.getName().toString());

//System.out.println(" : " tabprop<i>.getId().getString()"\t"+i);

if(tabprop<i>.getType() == TableProperties.MAIN){

productMainTable = tabprop<i>;

productMainTableLookUp.add(productMainTable.getId());

System.out.println("MAIN Tables Code and Name is :"productMainTabletabprop<i>.getName()"size======="productMainTableLookUp.size());

}else if(tabprop<i>.getType() == TableProperties.FLAT){

lookUpTable = tabprop<i>;

productLookUpTables.add(lookUpTable.getId());

System.out.println("FLAT Table Code and Name is :\t"lookUpTabletabprop<i>.getName()"size======="productLookUpTables.size());

}else if(tabprop<i>.getType() == TableProperties.TAXONOMY){

taxonomytable = tabprop<i>;

taxonomytableLookUp.add(taxonomytable.getId());

System.out.println(" Taxonomy Table Code and Name is :\t"taxonomytabletabprop<i>.getName()"size======="taxonomytableLookUp.size());

}else if(tabprop<i>.getType() == TableProperties.QUALIFIED_FLAT){

lookUpQTable = tabprop<i>;

productLookUpQTables.add(lookUpQTable.getId());

System.out.println("Qualified Table Code and Name is :\t"lookUpQTabletabprop<i>.getName()"size======="productLookUpQTables.size());

}

}

System.out.println(" MAIN TABLE :\n ");

for (int j = 0; j < productMainTableLookUp.size(); j++){

tableId = (TableId) productMainTableLookUp.get(j);

GetFieldListCommand getFieldListCommand = new GetFieldListCommand(connPool);

getFieldListCommand.setSession(sessionId);

getFieldListCommand.setTableId(tableId);

try{

getFieldListCommand.execute();

} catch (CommandException e){

e.printStackTrace();

}

rd = new ResultDefinition(tableId);

FieldProperties[] lookupMainFields = getFieldListCommand.getFields();

//mainTableFields = new FieldId[lookupMainFields.length];

for (int m = 0; m < lookupMainFields.length; m++){

//System.out.println(" lookupMainFields[m].getId() :\t "+lookupMainFields[m].getCode());

FieldId[] fields = new FieldId [lookupMainFields.length];

//mainTableFields[m] = lookupMainFields[m].getId();

fields[m] = lookupMainFields[m].getId();

fields[m] = repository.getFieldId("MDMSRM_CATALOG_ITEMS", lookupMainFields[m].getCode());

System.out.println(" Main table feilds are 116"+fields[m]);

rd.setSelectFields(fields);

}

} // 2 For

System.out.println(" FLAT TABLE :\n ");

for (int j = 0; j < productLookUpTables.size(); j++){

tableId2 = (TableId) productLookUpTables.get(j);

GetFieldListCommand getFieldListCommand = new GetFieldListCommand(connPool);

getFieldListCommand.setSession(sessionId);

getFieldListCommand.setTableId(tableId2);

try{

getFieldListCommand.execute();

} catch (CommandException e){

e.printStackTrace();

}

rdFlat = new ResultDefinition(tableId2);

System.out.println("rdflat no of flat table are :"+rdFlat.getTable().getIdValue());

FieldProperties[] lookupFlatFields = getFieldListCommand.getFields();

for (int m = 0; m < lookupFlatFields.length; m++){

System.out.println(" lookupFlatFields[m].getId() :\t "+lookupFlatFields[m].getCode());

flatTableFields = new FieldId[] {lookupFlatFields[m].getId()};

}

} // 2 For

rdFlat.setSelectFields(flatTableFields);

supportingMainResultDefinitions = new ResultDefinition[] ;

retrieveLimitedRecordsCommand.setResultDefinition(rd);

retrieveLimitedRecordsCommand.setSearch(new Search(tableId));

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

retrieveLimitedRecordsCommand.setSupportingResultDefinitions(supportingMainResultDefinitions);

try {

System.out.println("the loop has entered in result definition");

retrieveLimitedRecordsCommand.execute();

System.out.println("the loop has executed the answer");

PrintRecords.toConsole(retrieveLimitedRecordsCommand.getRecords());

} catch (CommandException e) {

e.printStackTrace();

}

//finally destroy the repository session

DestroySessionCommand destroySessionCommand = new DestroySessionCommand(connPool);

destroySessionCommand.setSession(sessionId);

try {

destroySessionCommand.execute();

} catch (CommandException e) {

e.printStackTrace();

return;

}

}

}

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Mary,

If i am able to understand you well you said that you want to retrieve data from the main table along with the data in the lookup fields. Let me first tell you that for the this you need to map your destination field with the appropriate source field in the import manager, here you directly map the source field with the destination field if it flat i.e it is not look up field in some other table, if it is looking up in some other field in other table which is flat than you have to map the source field with the destination field which is <b>being looked</b> up for those values. It might sound confusing ......

Catalog items (Main table) has for example two fields External Manufacturer(Look Up), Product Id(text), here you can map source field to product id field directly in import manager

using field mapping window but to map the External manufacturer field with source you have to see which table is it looking up than select that table as your destination table and map the indiviual fields, then in the MATCH RECORDS PANE select the mapped destntion fields add them to the matching field space take the default import action and import the records, after that you can see the look up field values in the DATA MANAGER.

For your second problem it will show only Distinct Values in the import manager.....

Just see whether this solves your problem .. if it does ......... great

Bye Take Care