Dynamics AX
Im Moment ist der Blog im Entstehen. Es ist im Moment noch eine Ansammlung an kurzen Codestücken und Jobs Eine schönere und genauere Beschreibung folgt.
Donnerstag, 15. Januar 2015
Dynamics AX 2012
How to get the Name and Value from an undefined table and field
while select * from SqlDictionary
where SqlDictionary.tabId == tableName2id(Tablename)
&& SqlDictionary.fieldId != 0
{
fieldname = SqlDictionary.sqlName;
dict = new SysDictField(SqlDictionary.tabId,SQLDictionary.fieldId);
label = strReplace(strReplace(SysLabel::labelId2String(Dict.labelLabel(),LanguageID),"-","_")," ","_");
if(label =="")
{
file.write(strFmt("%1%2.%3,",Praefix,Tablename,FieldName));
}
else
{
file.write(strFmt("%1%2.%3 as %4,",Praefix,Tablename,FieldName,Label));
}
Mittwoch, 17. Dezember 2014
Dynamics AX 2012 SSRS Reports
Create a new SSRS Report:
1. Create the temporary table for the Report
-> ReportTableTMP, ReportLineTMP
-> Set the Parameter TableType to InMemory or TempDB
2. Create the classes for Controller, Contract and Dataprovider
The Controller-Class
public class Report_Controller extends SrsReportRunController
{
}
public static void main(Args _args)
{
Report_Controller controller;
CustInvoiceTrans CustInvoiceTrans;
;Report_Contract contract = new Report_Contract();
Controller = new Report_controller();
Controller.parmReportName(SSRSReportSTr(ReportNAME),DESIGNName));
Controller.parmArgs(_args);
controller.parmLoadFromSysLastValue(false);
controller.parmShowDialog(false); //No Dialog
CustInvoiceTrans = _args.record();
contract.parmCustInvoiceTrans(CustInvoiceTrans);
Controller.parmReportContract().parmRdpContract(contract);
Controller.startOperation();}
The Contract-Class
[DataContractAttribute]
public class Report_Contract
{
CustInvoiceTrans CustInvoiceTrans;
}and the parmMethode for CustInvoiceTrans...
The Dataprovider -Class
[SRSReportParameterAttribute(classStr(Report_Contract))] <-- These Parameter are necessary
public class ReportDP extends SRSReportDataProviderBase
{
ReportTableTmp TableTMP;
REportLineTmp LineTmp;
}
[SRSReportDataSetAttribute(tableStr(ReportTableTmp))]
public ReportTableTmp getReportTableTmp() <-- you Need this for every temporary table you want to use in the Report
{
select * from ReportTableTmp ;
return ReportTableTmp ;
}
[SRSReportDataSetAttribute(tableStr(ReportLineTmp))]
public ReportLineTmp getReportLineTmp()
{
select * from ReportLineTmp;
return ReportLineTmp;
}
[SysEntryPointAttribute]
public void processReport()
{
REportContract contract;
;
contract = this.parmDataContract();
CustInvoiceTrans = contract.parmCustInvoiceTrans();
//Fill the ReportTableTMP
//Fill the ReportLineTMP
}
The MenuItem parameter for the Report

How to call the Report from Code
private void printReport()
{
SRSPrintDestinationSettings printSettings;
Report_contract contract = new Report_contract();
Report_controller controller = new Report_controller( );
;
// set Report Name
controller.parmReportName( ssrsReportStr( ReportNAme,DesignName));
// set contract
contract. parmCustInvoiceTrans( CustInvoiceTrans);
controller.parmReportContract( ).parmRdpContract(contract);
// get Print settings from contract
printSettings = controller.parmReportContract( ).parmPrintSettings();
// set print medium
printSettings.printMediumType( SRSPrintMediumType::Screen);
// supress dialog
controller.parmShowDialog( false);
// run report
controller.startoperation();
}
And now only the Report is missing.
Create a new SSRS Report:
1. Create the temporary table for the Report
-> ReportTableTMP, ReportLineTMP
-> Set the Parameter TableType to InMemory or TempDB
2. Create the classes for Controller, Contract and Dataprovider
The Controller-Class
public class Report_Controller extends SrsReportRunController
{
}
public static void main(Args _args)
{
Report_Controller controller;
CustInvoiceTrans CustInvoiceTrans;
;Report_Contract contract = new Report_Contract();
Controller = new Report_controller();
Controller.parmReportName(SSRSReportSTr(ReportNAME),DESIGNName));
Controller.parmArgs(_args);
controller.parmLoadFromSysLastValue(false);
controller.parmShowDialog(false); //No Dialog
CustInvoiceTrans = _args.record();
contract.parmCustInvoiceTrans(CustInvoiceTrans);
Controller.parmReportContract().parmRdpContract(contract);
Controller.startOperation();}
The Contract-Class
[DataContractAttribute]
public class Report_Contract
{
CustInvoiceTrans CustInvoiceTrans;
}and the parmMethode for CustInvoiceTrans...
The Dataprovider -Class
[SRSReportParameterAttribute(classStr(Report_Contract))] <-- These Parameter are necessary
public class ReportDP extends SRSReportDataProviderBase
{
ReportTableTmp TableTMP;
REportLineTmp LineTmp;
}
[SRSReportDataSetAttribute(tableStr(ReportTableTmp))]
public ReportTableTmp getReportTableTmp() <-- you Need this for every temporary table you want to use in the Report
{
select * from ReportTableTmp ;
return ReportTableTmp ;
}
[SRSReportDataSetAttribute(tableStr(ReportLineTmp))]
public ReportLineTmp getReportLineTmp()
{
select * from ReportLineTmp;
return ReportLineTmp;
}
[SysEntryPointAttribute]
public void processReport()
{
REportContract contract;
;
contract = this.parmDataContract();
CustInvoiceTrans = contract.parmCustInvoiceTrans();
//Fill the ReportTableTMP
//Fill the ReportLineTMP
}
The MenuItem parameter for the Report
How to call the Report from Code
private void printReport()
{
SRSPrintDestinationSettings printSettings;
Report_contract contract = new Report_contract();
Report_controller controller = new Report_controller(
;
// set Report Name
controller.parmReportName(
// set contract
contract.
controller.parmReportContract(
// get Print settings from contract
printSettings = controller.parmReportContract(
// set print medium
printSettings.printMediumType(
// supress dialog
controller.parmShowDialog(
// run report
controller.startoperation();
}
And now only the Report is missing.
Dienstag, 2. Dezember 2014
Mittwoch, 19. November 2014
AX2012: Eine einzelne Finanzdimension aus den Finanzdimensionen raus lösen und in ein Set von Finanzdimensionen hinzufügen. Hier am Beispiel der ProdTable und der Finanzdimension JobID
static void IAXfindLedgerDimension(Args _args)
{
DimensionAttribute DimensionAttribute;
DimensionAttributeValue DimensionAttributeValue;
DimensionAttributeValueSetItem DimensionAttributeValueSetITem,DimensionAttributeValueSetITem2;
DimensionAttributeValueSet DimensionAttributeValueSEt;
ProdTable ProdTable,ProdTable2;
DimensionDefault defaultDimension;
;
ProdTable = ProdTable::find('000585');
ProdTable2 = ProdTable::find('000584');
DimensionAttributeValueSetITem = DimensionAttributeValueSetItem::find(ProdTable.DefaultDimension);
DimensionAttribute = DimensionAttribute::findByName('jobID');
DimensionAttributeValueSet = DimensionAttributeValueSet::find(ProdTable.DefaultDimension);
defaultDimension = DimensionDefaultingService::serviceReplaceAttributeValue(ProdTable2.DefaultDimension, DimensionAttributeValueSet.RecId, DimensionAttribute.RecId);
ttsBegin;
ProdTable2.selectForUpdate(true);
ProdTable2.DefaultDimension = defaultDimension;
ProdTable2.update();
ttsCommit;
}
static void IAXfindLedgerDimension(Args _args)
{
DimensionAttribute DimensionAttribute;
DimensionAttributeValue DimensionAttributeValue;
DimensionAttributeValueSetItem DimensionAttributeValueSetITem,DimensionAttributeValueSetITem2;
DimensionAttributeValueSet DimensionAttributeValueSEt;
ProdTable ProdTable,ProdTable2;
DimensionDefault defaultDimension;
;
ProdTable = ProdTable::find('000585');
ProdTable2 = ProdTable::find('000584');
DimensionAttributeValueSetITem = DimensionAttributeValueSetItem::find(ProdTable.DefaultDimension);
DimensionAttribute = DimensionAttribute::findByName('jobID');
DimensionAttributeValueSet = DimensionAttributeValueSet::find(ProdTable.DefaultDimension);
defaultDimension = DimensionDefaultingService::serviceReplaceAttributeValue(ProdTable2.DefaultDimension, DimensionAttributeValueSet.RecId, DimensionAttribute.RecId);
ttsBegin;
ProdTable2.selectForUpdate(true);
ProdTable2.DefaultDimension = defaultDimension;
ProdTable2.update();
ttsCommit;
}
AX2012
Finanzdimensionen bei einem Debitoren per Code setzen
static void setFinancialDimensionToCustomer(CustAccount _custAccount)
{
CustTable custTable;
Struct struct = new Struct();
container ledgerDimension;
DimensionDefault DimensionDefault;
;
struct.add('BookingChannel', '30');
struct.add('Carrier', '01');
struct.add('Department', '30');
struct.add('Destination', '01');
struct.add('Division', '30');
struct.add('Origin', '01');
struct.add('Product', '30');
ledgerDimension += struct.fields();
ledgerDimension += struct.fieldName(1);
ledgerDimension += struct.valueIndex(1);
ledgerDimension += struct.fieldName(2);
ledgerDimension += struct.valueIndex(2);
ledgerDimension += struct.fieldName(3);
ledgerDimension += struct.valueIndex(3);
ledgerDimension += struct.fieldName(4);
ledgerDimension += struct.valueIndex(4);
ledgerDimension += struct.fieldName(5);
ledgerDimension += struct.valueIndex(5);
ledgerDimension += struct.fieldName(6);
ledgerDimension += struct.valueIndex(6);
ledgerDimension += struct.fieldName(7);
ledgerDimension += struct.valueIndex(7);
ttsBegin;
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
custTable = CustTable::find(_custAccount, true);
custTable.DefaultDimension = DimensionDefault;
custTable.update();
ttsCommit;
}
Finanzdimensionen bei einem Debitoren per Code setzen
static void setFinancialDimensionToCustomer(CustAccount _custAccount)
{
CustTable custTable;
Struct struct = new Struct();
container ledgerDimension;
DimensionDefault DimensionDefault;
;
struct.add('BookingChannel', '30');
struct.add('Carrier', '01');
struct.add('Department', '30');
struct.add('Destination', '01');
struct.add('Division', '30');
struct.add('Origin', '01');
struct.add('Product', '30');
ledgerDimension += struct.fields();
ledgerDimension += struct.fieldName(1);
ledgerDimension += struct.valueIndex(1);
ledgerDimension += struct.fieldName(2);
ledgerDimension += struct.valueIndex(2);
ledgerDimension += struct.fieldName(3);
ledgerDimension += struct.valueIndex(3);
ledgerDimension += struct.fieldName(4);
ledgerDimension += struct.valueIndex(4);
ledgerDimension += struct.fieldName(5);
ledgerDimension += struct.valueIndex(5);
ledgerDimension += struct.fieldName(6);
ledgerDimension += struct.valueIndex(6);
ledgerDimension += struct.fieldName(7);
ledgerDimension += struct.valueIndex(7);
ttsBegin;
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
custTable = CustTable::find(_custAccount, true);
custTable.DefaultDimension = DimensionDefault;
custTable.update();
ttsCommit;
}
Abonnieren
Posts (Atom)