Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
need xtab DE api available
kevin23_hy
There is code to create xtab,but it got some error,dont know why,pls help me what need i wanting,thx a lot.<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
public class DynamicCrosstabGeneration {
public DynamicCrosstabGeneration() {
}
ReportDesignHandle designHandle = null;
ElementFactory designFactory = null;
StructureFactory structFactory = null;
// Get Cube from report design
CubeHandle cube = designHandle.findCube("DataCube");
//create crosstab
ExtendedItemHandle extendHandle = CrosstabExtendedItemFactory.createCrosstabReportItem(designHandle.getRoot(), cube, null);
designHandle.getBody( ).add( extendHandle );
CrosstabReportItemHandle crosstabItem = (CrosstabReportItemHandle)CrosstabUtil.getReportItem( extendHandle );
// Create CUSTOMER Dimension binding
ComputedColumn d_customer =
StructureFactory.createComputedColumn( );
d_customer.setName( "CUSTOMERNUMBER" );
d_customer.setExpression( "dimension["Group"]["CUSTOMERNUMBER"]" );
d_customer.setDataType( "Integer" );
// Create CREDITLIMIT Dimension binding
ComputedColumn M_CREDITLIMIT = StructureFactory.createComputedColumn( );
M_CREDITLIMIT.setName( "CREDITLIMIT_Group1/COUNTRY_Group/CUSTOMERNUMBER" );
M_CREDITLIMIT.setExpression( "measure["CREDITLIMIT"]" );
M_CREDITLIMIT.setDataType( "float" );
M_CREDITLIMIT.setAggregateFunction( "sum" );
M_CREDITLIMIT.setAggregateOn( "Group1/COUNTRY,Group/CUSTOMERNUMBER" );
// Add bindings to Crosstab
extendHandle.addColumnBinding( d_customer, true );
// Create Column View
CrosstabViewHandle columnView = crosstabItem.addCrosstabView( ICrosstabConstants.COLUMN_AXIS_TYPE );
DimensionHandle group = cube.getDimension( "Group" );
DimensionViewHandle groupView = columnView.insertDimension( group, -1 );
LevelHandle groupHandle = designHandle.findLevel( "Group/CUSTOMERNUMBER" );//$NON-NLS-1$
groupView.insertLevel( groupHandle, -1 );
// Create Measure View
MeasureHandle measureHandle = cube.getMeasure( "CREDITLIMIT" );
MeasureViewHandle measureView = crosstabItem.insertMeasure( measureHandle, -1 );//$NON-NLS-1$
measureView.addHeader( );
LabelHandle label = designHandle.getElementFactory().newLabel( "CREDITLIMIT" );
label.setText( "CREDITLIMIT" );
measureView.getHeader( ).addContent( label );
// Set the dataitem's resultset column
DataItemHandle customer = designHandle.getElementFactory().newDataItem( "CUSTOMERNUMBER" );
customer.setResultSetColumn( d_customer.getName( ) );
// Add dataitem into group view
groupView.getLevel( 0 ).getCell( ).addContent( customer );
}
</pre>
Find more posts tagged with
Comments
mwilliams
Hi kevin23_hy,
What is the error you're getting?
kevin23_hy
I solved error but i still have a ambiguous about xtab building process and how run normally in platform framework,so can you give a sample code/tutorial to illustrate that. i will appreciate much.