Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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

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;

}

}

}

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question