Hi there,
I’m currently in the process of understanding how a report within AX has been developed within the USR layer. I understand everything apart from a method written within the main method section. The method described is documented directly below.
Data Source
Ledgertrans_1(ledgertrans) - one table
Method Class Declaration
public class ReportRun extends ObjectRun
{
str PeriodNo;
}
Method
void period()
{
ledgerperiod lperiod;
while select lperiod
where ledgertrans_1.TransDate >= lperiod.PeriodStart
&& ledgertrans_1.TransDate <= lperiod.PeriodEnd
&& lperiod.PeriodCode == 1
{
PeriodNo = lperiod.Commentaries;
break;
}
}
The report itslf is based on an AutoDesignSpec. There is a Body section and within this section there is a display method:
display str GetPeriod()
{
element.period();
return PeriodNo;
}
I can then see that a string has been added to be displayed on the report and the Data Method property has been set to GetPeriod.
When I run the report, the output displays the financial period (Commentaries field i.e. Period 7) which is great but I do not understand how the period method can recognise what period the ledgertrans.transdate is in. How is it picking the correct line within the ledgerperiod table? This is what I would like to understand.
When I add a break point to the Period method (documented below), when I step trough the WHILE STATEMENT I can see that AX understands exactly what ledgerperiod record is linked to the ledgertrans query.
void period()
{
ledgerperiod lperiod;
while select lperiod
where ledgertrans_1.TransDate >= lperiod.PeriodStart
&& ledgertrans_1.TransDate <= lperiod.PeriodEnd
&& lperiod.PeriodCode == 1
{
PeriodNo = lperiod.Commentaries;
break;
}
}
Can anyone please explain to me how AX works this the period out. Is there more code being executed somewhere. I’ve explored both tables and cannot see any relationships between these 2 tables.
Would appreciated any feedback.
Thanks and kind regards,
Tom