cancel
Showing results for 
Search instead for 
Did you mean: 

How to populate Tree structure from BAPI while tree grows or shrinks

Former Member
0 Kudos

Hi All

Currently I am populating the tree structure from BAPI based on the HLevel (Hierarchy Level) parameter, but when ever insertion and deletion happens in the tree at any level in the UI and at the same time i am updating these tree node values with HLevel value(example : 1 is first level , 2 is second level, 3 is third level etc) updating successfully& correctly into the BAPI, no issues.

Once it is updated into the BAPI, next time when i refreshed the UI then i am not populating the tree structure correctly from BAPI with updated new nodes based on the HLevel. when tree struture grows or shrinks in the BAPI after updating into BAPI from UI then i am not populating the tree sturcture correctly based on the HLevel value from the BAPI.

Please let me know any sample code how to populate tree structure correctly when tree structure grows or shrinks based on the HLevel value ( Hierarchy Level , for example : 1 is level , 2 is 2nd level , 3 is third level nodes etc)

anybody helps in this regard with sample code on the populating tree tructure then it would be great help to me.

Thanks in advance

Regards

Kalki Reddy

Edited by: KalkiReddy on Nov 29, 2009 3:48 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Bapi output node:


Value	| Text	| HLevel
01	| A	| 1			
0101	| AA  	| 2
010101	| AAA	| 3
01010B	| AAB	| 3
0102	| AB	| 2
02	| B	| 1
0201	| BA   	| 2

This code is used to build the tree in wdDoInit method


	IE_T_CatalogueNode catalogueNode = wdContext.nodeE_T_Catalogue();
	int size = catalogueNode.size();
	
	ICatalogoElement level1elem = null;
	
	for (int i = 0; i < size; i ++)
	{
		IE_T_CatalogueElement catalogueElem = catalogueNode.getE_T_CatalogueElementAt(i);
	
		if (catalogueElem.getLevel().equals("1")) 
		{
			// 1 Livello
			level1elem = wdContext.createCatalogoElement();
			level1elem.setKATALOGART_CODE(catalogueElem.getKatalogart());
			level1elem.setCODEGRUPPE_CODE(catalogueElem.getCodegruppe());
			level1elem.setCODE(catalogueElem.getCode());
			level1elem.setCODE_DESCR(catalogueElem.getKatalogart_Descr());
			level1elem.setDESCR(catalogueElem.getKatalogart_Descr());
			wdContext.nodeCatalogo().addElement(level1elem);

			for (int j = i + 1; j < size; j ++)
			{
				IE_T_CatalogueElement catalogueElem2level = 
									catalogueNode.getE_T_CatalogueElementAt( j );
				
				String level2 = catalogueElem2level.getLevel();
				
				if (level2.equals("2"))
				{
					ICatalogoElement level2elem = level1elem.nodeChild().createCatalogoElement();
					level2elem.setKATALOGART_CODE(catalogueElem2level.getKatalogart());
					level2elem.setCODEGRUPPE_CODE(catalogueElem2level.getCodegruppe());
					level2elem.setCODE(catalogueElem2level.getCode());
					level2elem.setCODE_DESCR(catalogueElem2level.getCodegruppe_Descr());
					level2elem.setDESCR(catalogueElem2level.getCodegruppe_Descr());
					level1elem.nodeChild().addElement(level2elem); 
					
					for (int k = j + 1; k < size; k ++)
					{
						IE_T_CatalogueElement catalogueElem3level = 
											catalogueNode.getE_T_CatalogueElementAt( k );
				
						String level3 = catalogueElem3level.getLevel();
				
						if (level3.equals("3"))
						{
							ICatalogoElement level3elem = level2elem.nodeChild().createCatalogoElement();
							level3elem.setKATALOGART_CODE(catalogueElem3level.getKatalogart());
							level3elem.setCODEGRUPPE_CODE(catalogueElem3level.getCodegruppe());
							level3elem.setCODE(catalogueElem3level.getCode());
							level3elem.setCODE_DESCR(catalogueElem3level.getCode_Descr());
							level3elem.setDESCR(catalogueElem3level.getCode_Descr());
							level2elem.nodeChild().addElement(level3elem); 
						}
					}					
				}
			}
		}
	}   

Damiano

Answers (0)