AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 10.04.2022, 05:57   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
Multiple company selection in an SSRS report (LedgerLegalEntityLookup)
Источник: http://alexvoy.blogspot.com/2022/04/...n-in-ssrs.html
==============

If you need to provide an SSRS report with a multiple company selection, you can opt for a cross-company query. In this case, such an option will be maintained by the system automatically. (You can try this [SrsReportQuery(queryStr(LogisticsEntityLocationUnion))])

But what if you need to do that without the former? In this case you'll need to use LedgerLegalEntityLookup class as follows. Say we deal with some mgcSalesBySegment report, which is meant to return some data for a given selection of legal entities.







I hid some not relevant code; so that you can get the gist.

Data contract mgcSalesBySegmentContract: we keep the user selection of companies as a string.

[DataContract]
[SysOperationContractProcessing(classstr(mgcSalesBySegmentUIBuilder), SysOperationDataContractProcessingMode::CreateUIBuilderForRootContractOnly)]

class mgcSalesBySegmentContract implements SysOperationValidatable
{
...
str legalEntityOptionsStr;
...

///
/// Legal options
///
/// str
/// str
[
DataMember('legalEntityOptions')
,
SysOperationGroupMember('Grouping'),
SysOperationDisplayOrder('5')
]
public str parmLegalEntityOptions(str _legalEntityOptions = legalEntityOptionsStr)
{
legalEntityOptionsStr = _legalEntityOptions;

return legalEntityOptionsStr;
}

}



Report controller mgcSalesBySegmentController: if no companies selected, let's set it to the user's context.

public class mgcSalesBySegmentController extends SrsReportRunController
{

protected void prePromptModifyContract()
{
mgcSalesBySegmentContract dc = this.parmReportContract().parmRdpContract() as mgcSalesBySegmentContract;

...
if (!dc.parmLegalEntityOptions())
{
// Set the default value for the legal entity selection
dc.parmLegalEntityOptions(con2str([curExt()]));
}
}


protected void preRunModifyContract()
{
mgcSalesBySegmentContract dc;
container legalEntityOptions;

dc = this.parmReportContract().parmRdpContract() as mgcSalesBySegmentContract;
legalEntityOptions = str2con(dc.parmLegalEntityOptions());

// Default current company if there were no company specifications provided to the API.
if (legalEntityOptions == conNull())
{
legalEntityOptions = [curExt()];
dc.parmLegalEntityOptions(con2str(legalEntityOptions));
}

}

public static void main(Args _args)
{
mgcSalesBySegmentController controller = new mgcSalesBySegmentController();

controller.parmReportName(ssrsReportStr(mgcSalesBySegment, Report));
controller.parmArgs(_args);
controller.startOperation();
}

}



User interface builder mgcSalesBySegmentUIBuilder: when an SSRS report runs, it shows its dialog twice: the second time in the report viewer, when the report is rendered. Thus we have to override dialog methods in the UIBuilder class to avoid the lovely 'Object reference not set to an instance of an object' error.



public class mgcSalesBySegmentUIBuilder extends SrsReportDataContractUIBuilder
{
mgcSalesBySegmentContract dc;
// Legal entity lookup controls
FormStringControl dialogLegalEntitySelection;
LedgerLegalEntityLookup legalEntityLookup;
int dialogLegalEntityLookupId;
str userLegalEntityRange;
container legalEntityOptions;

///
/// Override this method in order to initialize the dialog fields after the fields are built.
///
public void postBuild()
{
DialogField dialogField;

super();
// parmCompanySelection
dialogField = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(mgcSalesBySegmentContract, parmLegalEntityOptions));
this.setInVisible(dialogField);

this.constructLegalEntityControl(dialog);

}

///
/// post runs
///
public void postRun()
{
super();

this.constructLegalEntityLookup(dialog);
Set userLegalEntitySet = LedgerSecurityHelper::ledgersWithMinimumSecurityAccess(menuItemActionStr(LedgerExchAdj), AccessRight::Edit, MenuItemType::Action);
userLegalEntityRange = LedgerLegalEntityLookup::getLegalEntityRangeFromLegalEntitySet(userLegalEntitySet);
}

///
/// Contstruct
///
/// Dialog
private void constructLegalEntityControl(Dialog _dialog)
{
FormBuildGroupControl currentGroup = _dialog.form().design().control(_dialog.curFormGroup().name());
FormBuildStringControl dialogLegalEntityLookup = currentGroup.addControl(FormControlType::String, 'LegalEntityLookup');
dialogLegalEntityLookup.extendedDataType(extendedTypeNum(LedgerLegalEntitySelection));
dialogLegalEntityLookup.lookupOnly(true);
dialogLegalEntityLookupId = dialogLegalEntityLookup.id();
}

///
/// Constructs the lookup for the legal entity selection.
///
/// The FormStringControl object.
private void legalEntityLookup(FormStringControl _control)
{
legalEntityLookup.lookup(_control.text(), userLegalEntityRange);
}

///
/// Lookup override
///
/// dialog
private void constructLegalEntityLookup(Dialog _dialog)
{
dialoglegalEntitySelection = _dialog.formRun().design().control(dialogLegalEntityLookupId);
legalEntityLookup = LedgerLegalEntityLookup::construct(_dialog.formRun(), dialoglegalEntitySelection);
// populates it from the packed paramater
legalEntityLookup.setSelection(str2con(dc.parmLegalEntityOptions()));
// let's have our own lookup
dialoglegalEntitySelection.registerOverrideMethod(methodstr(FormStringControl, lookup), methodstr(mgcSalesBySegmentUIBuilder, legalEntityLookup), this);
}

///
/// prebuilds
///
public void preBuild()
{
dc = this.dataContractObject() as mgcSalesBySegmentContract;
super();
}

///
/// Gets it back from the dialog
///
public void getFromDialog()
{
super();
dc.parmLegalEntityOptions(con2Str(legalEntityLookup.getLegalEntitySelection()));
}

}



Report data provider mgcSalesBySegmentDP: we need just to convert the saved string back to a container, then we can loop through it as required by the report logic.



[SRSReportParameterAttribute(classStr(mgcSalesBySegmentContract))]
public class mgcSalesBySegmentDP extends SRSReportDataProviderPreProcessTempDB
{
container legalEntityOptions;

public void processReport()
{
mgcSalesBySegmentContract dc;
List legalEntityList;
ListEnumerator legalEntityListEnumerator;
SelectableDataArea companyId;
str companyName;

dc = this.parmDataContract() as mgcSalesBySegmentContract;

this.setUserConnection(tmp);

// getting all selected companies from the report query
legalEntityList = con2List(str2con(dc.parmLegalEntityOptions()));
legalEntityListEnumerator = legalEntityList.getEnumerator();

while (legalEntityListEnumerator.moveNext())
{
companyId = legalEntityListEnumerator.current();
companyName = CompanyInfo::findDataArea(companyId).name();
changecompany(companyId)
{
// Populate the base processing table with data from the appropriate source table
...
}
}
}
}





Источник: http://alexvoy.blogspot.com/2022/04/...n-in-ssrs.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
alirazazaidi: How to add company legal entity report logo in SSRS Report Dynamics 365 for finance and operations Blog bot DAX Blogs 0 18.09.2019 18:11
How to create SSRS report with multiple independent groupings Blog bot DAX Blogs 0 04.10.2015 07:04
ax-erp: Report Data provider [RDP] as data source type in data set – SSRS reports [Dynamics ax 2012] Blog bot DAX Blogs 0 18.07.2012 12:11
emeadaxsupport: New Content for Microsoft Dynamics AX 2012 : October 2011 Blog bot DAX Blogs 0 27.10.2011 17:11
wiki.dynamicsbook: Changes Made in Navision Attain 3.60 Blog bot Dynamics CRM: Blogs 0 02.09.2008 13:23

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 13:34.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.