DataEntryForm.CreateByReport

Syntax

CreateByReport(report: IPrxReport);

Parameters

report. Regular report linked to data entry form.

Description

The CreateByReport constructor creates an instance of data entry form based on the regular report, which is linked with the data entry form.

Example

Executing the example requires that the repository contains a standard cube with the STD_CUBE identifier. Cube dimensions are based on dictionaries with the DICT_FIRMS, DICT_INDICATORS and CALENDAR indicators. It is also required to be a data entry form, for which the specified macro is set as an executable method for a custom button.

Add links to the Dimensions, Metabase, Report system assemblies. Add links to the assemblies required for working with data entry forms.

Public Sub AddTable(Report: IPrxReport);
Var
    Mb: IMetabase;
    Sheet: IPrxSheet;
    DEForm: IDataEntryForm;
    TArea: IDefTableArea;
    Dim1, Dim2, DimCalc: IDefDimension;
    Ind1, Ind2, Ind3: IDefIndicator;
    Sel: IDimSelection;
    SourceKey: Integer;
Begin
    Mb := MetabaseClass.Active;
    
// Create a single sheet
    Sheet := Report.Sheets.Add("Sheet for new table");
    
// The current data entry form instance
    DEForm := New DataEntryForm.CreateByReport(Report);
    DEForm.refreshOnEdit := 
True;
    
// Create a new table area
    TArea := DEForm.InputAreas.CreateTableArea(Sheet.Key, 11);
    TArea.MultiLevelTopHeader := 
True;
    TArea.ColumnBehaviour := emTabRowInsert.insert;
    TArea.RowBehaviour := emTabRowInsert.insert;
    
// Add dimensions
    Dim1 := TArea.defDimensions.AddItem(Mb.GetObjectKeyById("DICT_FIRMS"));
    Dim1.place := DimPlace.Side;
    Dim2 := TArea.defDimensions.AddItem(Mb.GetObjectKeyById(
"DICT_INDICATORS"));
    Dim2.place := DimPlace.Side;
    
// Add a data source
    SourceKey := Mb.GetObjectKeyById("STD_CUBE");
    TArea.defSources.AddItem(SourceKey);
    
// Create indicators and set their selection
    // Indicator 1
    Ind1 := TArea.defIndicators.AddItem(SourceKey);
    DimCalc := Ind1.defDimensions.ItemByKey(Mb.GetObjectKeyById(
"CALENDAR"));
    Sel := DimCalc.CreateSelection;
    Sel.DeselectAll;
    Sel.SelectElement(Sel.Dimension.Elements.FindById(
"YEARS:2016"), False);
    DimCalc.ElemsSelection := Sel;
    
// Indicator 2
    Ind2 := TArea.defIndicators.AddItem(sourceKey);
    DimCalc := Ind2.defDimensions.ItemByKey(Mb.GetObjectKeyById(
"CALENDAR"));
    Sel := DimCalc.CreateSelection;
    Sel.DeselectAll;
    Sel.SelectElement(Sel.Dimension.Elements.FindById(
"YEARS:2017"), False);
    DimCalc.ElemsSelection := Sel;
    
// Change location of dimensions by indicator
    Ind2.defDimensions.Swap(Ind2.defDimensions.Item(0).key, Ind2.defDimensions.Item(1).key);
    Ind2.name := 
"Cube1 - indicator2";
    
// Change location of indicators
    TArea.defIndicators.Swap(Ind1.unical, Ind2.unical);
    
// Change location of indicators
    TArea.defDimensions.Swap(Dim1.Key, Dim2.Key);
    
// Add a dimension as indicator
    Ind3 := TArea.defIndicators.AddItem(Dim1.Key);
    
// Apply changes to data entry form
    DEForm.inpuTAreas.ApplyAreaToReport(TArea.id);
    DEForm._Dispose;
End Sub AddTable;

After the macro is executed, a new sheet is created in the data entry form. The following is executed on the sheet: a table area is created, a data source and dimensions are added, three indicators are created. Location of dimensions is set up in the indicators and in the table area.

See also:

DataEntryForm