Friday, January 24, 2014
To modified a particular field in table for update and refresh by Automatically if thr any change occur in X++
TO modified particular in table through X++ by Automatically if thr any change occur
Form -> Grid->Field -> method overwritee ( modified)
and below code to update
public boolean modified()
{
boolean ret;
ret = super();
QualityInspectionTable_DS.research();
QualityInspectionTable_DS.refresh();
QualityInspectionLine_DS.research();
QualityInspectionLine_DS.refresh();
return ret;
}
Form -> Grid->Field -> method overwritee ( modified)
and below code to update
public boolean modified()
{
boolean ret;
ret = super();
QualityInspectionTable_DS.research();
QualityInspectionTable_DS.refresh();
QualityInspectionLine_DS.research();
QualityInspectionLine_DS.refresh();
return ret;
}
update table
To update a field value in Table and ill sum the value in one field to update in another table.
Code in table level by Update method( where u want to change record and update status)
public void update()
{
QualityInspectionLine _QualityInspectionLine;
QualityInspectionTable _QualityInspectionTable;
super();
select sum(percent) from _QualityInspectionLine where _QualityInspectionLine.ProjectID == this.ProjectID
&& _QualityInspectionLine.InspectionStatus == InspectionStatus::Completed;
select forUpdate _QualityInspectionTable where _QualityInspectionTable.ProjectID == this.ProjectID;
ttsBegin;
_QualityInspectionTable.TotalProgress = _QualityInspectionLine.percent;
_QualityInspectionTable.doUpdate();
ttsCommit;
}
Code in table level by Update method( where u want to change record and update status)
public void update()
{
QualityInspectionLine _QualityInspectionLine;
QualityInspectionTable _QualityInspectionTable;
super();
select sum(percent) from _QualityInspectionLine where _QualityInspectionLine.ProjectID == this.ProjectID
&& _QualityInspectionLine.InspectionStatus == InspectionStatus::Completed;
select forUpdate _QualityInspectionTable where _QualityInspectionTable.ProjectID == this.ProjectID;
ttsBegin;
_QualityInspectionTable.TotalProgress = _QualityInspectionLine.percent;
_QualityInspectionTable.doUpdate();
ttsCommit;
}
To Filter a record by dialog field thorugh X++ method clicked
// To Filter a record by dialog field thorugh X++ method clicked
// Date field
void MethodName()
{
EmployeeDetails Emp_1;
EmployeeTMP EmpTmp;
Dialog dialog;
DialogGroup dialogGroup;
DialogField dialogFieldDateOfJoining1;
DialogField dialogFieldDateOfJoining2;
dialog = new Dialog("Employee DateOfJoining Filter");
dialogGroup = dialog.addGroup("Employee Date Of Joining");
dialogFieldDateOfJoining1 = dialog.addField(extendedTypeStr(DateofJoining),"Date Of Joining > = :");
dialogFieldDateOfJoining2 = dialog.addField(extendedTypeStr(DateofJoining),"Date Of Joining < = :");
delete_from EmpTmp;
if(dialog.run())
{
//delete_from EmpTmp;
while select Emp_1 where Emp_1.DateofJoining >= dialogFieldDateOfJoining1.value() && Emp_1.DateofJoining <= dialogFieldDateOfJoining2.value()
{
EmpTmp.EmpCode = Emp_1.EmpCode;
EmpTmp.EmpName = Emp_1.EmpName;
EmpTmp.EmployeeDesgination = Emp_1.EmployeeDesgination;
EmpTmp.Age = Emp_1.Age;
EmpTmp.DateOfBirth = Emp_1.DateOfBirth;
EmpTmp.DateofJoining = Emp_1.DateofJoining;
EmpTmp.DateOfTermination =Emp_1.DateOfTermination;
EmpTmp.Salary = Emp_1.Salary;
EmpTmp.CurrencyValue = Emp_1.CurrencyValue;
EmpTmp.TypeOfJob = Emp_1.TypeOfJob;
EmpTmp.YearsOfExperience = Emp_1.YearsOfExperience;
EmpTmp.insert();
}
EmployeeTMP_ds.research();
EmployeeTMP_ds.refresh();
}
// element.close();
element.detach();
}
// Int field
void method name()
{
EmployeeDetails Emp_1;
EmployeeTMP EmpTmp;
Dialog dialog;
DialogGroup dialogGroup;
DialogField dialogFieldEmpCode1;
DialogField dialogFieldEmpCode2;
dialog = new Dialog("Employee Code Filter");
dialogGroup = dialog.addGroup("Employee Code");
dialogFieldEmpCode1 = dialog.addField(extendedTypeStr(EmpCode),"EmpCode > :");
dialogFieldEmpCode2 = dialog.addField(extendedTypeStr(EmpCode),"EmpCode < :");
delete_from EmpTmp;
if(dialog.run())
{
//info(dialogFieldEmpCode1.value());
//info(dialogFieldEmpCode2.value());
// delete_from EmpTmp;
while select Emp_1 where Emp_1.EmpCode > dialogFieldEmpCode1.value() && Emp_1.EmpCode < dialogFieldEmpCode2.value()
{
EmpTmp.EmpCode = Emp_1.EmpCode;
EmpTmp.EmpName = Emp_1.EmpName;
EmpTmp.EmployeeDesgination = Emp_1.EmployeeDesgination;
EmpTmp.Age = Emp_1.Age;
EmpTmp.DateOfBirth = Emp_1.DateOfBirth;
EmpTmp.DateofJoining = Emp_1.DateofJoining;
EmpTmp.DateOfTermination =Emp_1.DateOfTermination;
EmpTmp.Salary = Emp_1.Salary;
EmpTmp.CurrencyValue = Emp_1.CurrencyValue;
EmpTmp.TypeOfJob = Emp_1.TypeOfJob;
EmpTmp.YearsOfExperience = Emp_1.YearsOfExperience;
EmpTmp.insert();
}
EmployeeTMP_ds.research();
EmployeeTMP_ds.refresh();
}
// element.close();
element.detach();
}
// Enum Field
void method Name()
{
EmployeeDetails Emp_1;
EmployeeTMP EmpTmp;
Dialog dialog;
DialogGroup dialogGroup;
DialogField dialogFieldEmployeeDesgination;
dialog = new Dialog("Employee Designation Filter");
dialogGroup = dialog.addGroup(" Employee Designation");
dialogFieldEmployeeDesgination = dialog.addField(enumStr(EmployeeDesgination),"EmployeeDesgination :");
delete_from EmpTmp;
if(dialog.run())
{
//delete_from EmpTmp;
while select Emp_1 where Emp_1.EmployeeDesgination ==dialogFieldEmployeeDesgination.value()
{
EmpTmp.EmpCode = Emp_1.EmpCode;
EmpTmp.EmpName = Emp_1.EmpName;
EmpTmp.EmployeeDesgination = Emp_1.EmployeeDesgination;
EmpTmp.Age = Emp_1.Age;
EmpTmp.DateOfBirth = Emp_1.DateOfBirth;
EmpTmp.DateofJoining = Emp_1.DateofJoining;
EmpTmp.DateOfTermination =Emp_1.DateOfTermination;
EmpTmp.Salary = Emp_1.Salary;
EmpTmp.CurrencyValue = Emp_1.CurrencyValue;
EmpTmp.TypeOfJob = Emp_1.TypeOfJob;
EmpTmp.YearsOfExperience = Emp_1.YearsOfExperience;
EmpTmp.insert();
}
EmployeeTMP_ds.research();
EmployeeTMP_ds.refresh();
}
// element.close();
element.detach();
}
// Date field
void MethodName()
{
EmployeeDetails Emp_1;
EmployeeTMP EmpTmp;
Dialog dialog;
DialogGroup dialogGroup;
DialogField dialogFieldDateOfJoining1;
DialogField dialogFieldDateOfJoining2;
dialog = new Dialog("Employee DateOfJoining Filter");
dialogGroup = dialog.addGroup("Employee Date Of Joining");
dialogFieldDateOfJoining1 = dialog.addField(extendedTypeStr(DateofJoining),"Date Of Joining > = :");
dialogFieldDateOfJoining2 = dialog.addField(extendedTypeStr(DateofJoining),"Date Of Joining < = :");
delete_from EmpTmp;
if(dialog.run())
{
//delete_from EmpTmp;
while select Emp_1 where Emp_1.DateofJoining >= dialogFieldDateOfJoining1.value() && Emp_1.DateofJoining <= dialogFieldDateOfJoining2.value()
{
EmpTmp.EmpCode = Emp_1.EmpCode;
EmpTmp.EmpName = Emp_1.EmpName;
EmpTmp.EmployeeDesgination = Emp_1.EmployeeDesgination;
EmpTmp.Age = Emp_1.Age;
EmpTmp.DateOfBirth = Emp_1.DateOfBirth;
EmpTmp.DateofJoining = Emp_1.DateofJoining;
EmpTmp.DateOfTermination =Emp_1.DateOfTermination;
EmpTmp.Salary = Emp_1.Salary;
EmpTmp.CurrencyValue = Emp_1.CurrencyValue;
EmpTmp.TypeOfJob = Emp_1.TypeOfJob;
EmpTmp.YearsOfExperience = Emp_1.YearsOfExperience;
EmpTmp.insert();
}
EmployeeTMP_ds.research();
EmployeeTMP_ds.refresh();
}
// element.close();
element.detach();
}
// Int field
void method name()
{
EmployeeDetails Emp_1;
EmployeeTMP EmpTmp;
Dialog dialog;
DialogGroup dialogGroup;
DialogField dialogFieldEmpCode1;
DialogField dialogFieldEmpCode2;
dialog = new Dialog("Employee Code Filter");
dialogGroup = dialog.addGroup("Employee Code");
dialogFieldEmpCode1 = dialog.addField(extendedTypeStr(EmpCode),"EmpCode > :");
dialogFieldEmpCode2 = dialog.addField(extendedTypeStr(EmpCode),"EmpCode < :");
delete_from EmpTmp;
if(dialog.run())
{
//info(dialogFieldEmpCode1.value());
//info(dialogFieldEmpCode2.value());
// delete_from EmpTmp;
while select Emp_1 where Emp_1.EmpCode > dialogFieldEmpCode1.value() && Emp_1.EmpCode < dialogFieldEmpCode2.value()
{
EmpTmp.EmpCode = Emp_1.EmpCode;
EmpTmp.EmpName = Emp_1.EmpName;
EmpTmp.EmployeeDesgination = Emp_1.EmployeeDesgination;
EmpTmp.Age = Emp_1.Age;
EmpTmp.DateOfBirth = Emp_1.DateOfBirth;
EmpTmp.DateofJoining = Emp_1.DateofJoining;
EmpTmp.DateOfTermination =Emp_1.DateOfTermination;
EmpTmp.Salary = Emp_1.Salary;
EmpTmp.CurrencyValue = Emp_1.CurrencyValue;
EmpTmp.TypeOfJob = Emp_1.TypeOfJob;
EmpTmp.YearsOfExperience = Emp_1.YearsOfExperience;
EmpTmp.insert();
}
EmployeeTMP_ds.research();
EmployeeTMP_ds.refresh();
}
// element.close();
element.detach();
}
// Enum Field
void method Name()
{
EmployeeDetails Emp_1;
EmployeeTMP EmpTmp;
Dialog dialog;
DialogGroup dialogGroup;
DialogField dialogFieldEmployeeDesgination;
dialog = new Dialog("Employee Designation Filter");
dialogGroup = dialog.addGroup(" Employee Designation");
dialogFieldEmployeeDesgination = dialog.addField(enumStr(EmployeeDesgination),"EmployeeDesgination :");
delete_from EmpTmp;
if(dialog.run())
{
//delete_from EmpTmp;
while select Emp_1 where Emp_1.EmployeeDesgination ==dialogFieldEmployeeDesgination.value()
{
EmpTmp.EmpCode = Emp_1.EmpCode;
EmpTmp.EmpName = Emp_1.EmpName;
EmpTmp.EmployeeDesgination = Emp_1.EmployeeDesgination;
EmpTmp.Age = Emp_1.Age;
EmpTmp.DateOfBirth = Emp_1.DateOfBirth;
EmpTmp.DateofJoining = Emp_1.DateofJoining;
EmpTmp.DateOfTermination =Emp_1.DateOfTermination;
EmpTmp.Salary = Emp_1.Salary;
EmpTmp.CurrencyValue = Emp_1.CurrencyValue;
EmpTmp.TypeOfJob = Emp_1.TypeOfJob;
EmpTmp.YearsOfExperience = Emp_1.YearsOfExperience;
EmpTmp.insert();
}
EmployeeTMP_ds.research();
EmployeeTMP_ds.refresh();
}
// element.close();
element.detach();
}
Backup Excel data to table through X++
// Backup Excel data to table through X++
Void clicked()
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
Name name;
FileName filename;
EmployeeBackup employeeBackup;
Args args = new Args();
int row;
int empcode;
str salary;
str age;
str YearsOfexperience;
str empname;
TypeOfJob jobtype;
EmployeeDesgination employeedesgination;
employeedesgination tmpDesgination;
CurrencyValue currencyValue;
currencyValue tmpCurrency;
date dateofbirth,dateofjoining,dateofreveling;
;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
//specify the file path that you want to read
filename = "C:\\Test.xlsx";//FIle path
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error("File cannot be opened");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1); //Here 1 is the worksheet Number
cells = worksheet.cells();
do
{
row++;
empcode = any2int(cells.item(row,1).value().double());
empname = cells.item(row,2).value().bstr();
tmpDesgination = str2enum(employeedesgination,cells.item(row, 3).value().bStr());
dateofjoining = any2date(cells.item(row,4).value().date());
dateofreveling = any2date(cells.item(row,5).value().date());
dateofbirth = any2date(cells.item(row,6).value().date());
age = any2str(cells.item(row,7).value().toString());
salary = any2str(cells.item(row,8).value().toString());
tmpCurrency = str2enum(currencyValue,cells.item(row,9).value().bStr());
jobtype = str2enum(jobtype,cells.item(row, 10).value().bStr());
YearsOfexperience = any2str(cells.item(row,11).value().toString());
employeeBackup.EmpCode = empcode;
employeeBackup.EmpName = empname;
employeeBackup.EmployeeDesgination = tmpDesgination;
employeeBackup.DateofJoining = dateofjoining;
employeeBackup.DateOfTermination = dateofreveling;
employeeBackup.DateOfBirth = dateofbirth;
employeeBackup.Age = age;
employeeBackup.Salary = salary;
employeeBackup.CurrencyValue = tmpCurrency;
employeeBackup.TypeOfJob = jobtype;
employeeBackup.YearsOfExperience = YearsOfexperience;
employeeBackup.insert();
type = cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
super();
}
Void clicked()
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
Name name;
FileName filename;
EmployeeBackup employeeBackup;
Args args = new Args();
int row;
int empcode;
str salary;
str age;
str YearsOfexperience;
str empname;
TypeOfJob jobtype;
EmployeeDesgination employeedesgination;
employeedesgination tmpDesgination;
CurrencyValue currencyValue;
currencyValue tmpCurrency;
date dateofbirth,dateofjoining,dateofreveling;
;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
//specify the file path that you want to read
filename = "C:\\Test.xlsx";//FIle path
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error("File cannot be opened");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1); //Here 1 is the worksheet Number
cells = worksheet.cells();
do
{
row++;
empcode = any2int(cells.item(row,1).value().double());
empname = cells.item(row,2).value().bstr();
tmpDesgination = str2enum(employeedesgination,cells.item(row, 3).value().bStr());
dateofjoining = any2date(cells.item(row,4).value().date());
dateofreveling = any2date(cells.item(row,5).value().date());
dateofbirth = any2date(cells.item(row,6).value().date());
age = any2str(cells.item(row,7).value().toString());
salary = any2str(cells.item(row,8).value().toString());
tmpCurrency = str2enum(currencyValue,cells.item(row,9).value().bStr());
jobtype = str2enum(jobtype,cells.item(row, 10).value().bStr());
YearsOfexperience = any2str(cells.item(row,11).value().toString());
employeeBackup.EmpCode = empcode;
employeeBackup.EmpName = empname;
employeeBackup.EmployeeDesgination = tmpDesgination;
employeeBackup.DateofJoining = dateofjoining;
employeeBackup.DateOfTermination = dateofreveling;
employeeBackup.DateOfBirth = dateofbirth;
employeeBackup.Age = age;
employeeBackup.Salary = salary;
employeeBackup.CurrencyValue = tmpCurrency;
employeeBackup.TypeOfJob = jobtype;
employeeBackup.YearsOfExperience = YearsOfexperience;
employeeBackup.insert();
type = cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
super();
}
Creation of dialog and dialog field Example
//Creation of dialog and dialog field Example
void method name()
{
Dialog dialog;
DialogGroup dialogGroup;
DialogField dialogFieldCustAccount;
DialogField dialogFieldCurrency;
DialogField dialogFieldVendAccount;
DialogField dialogFieldCustomerGroup;
DialogField dialogFieldInclTax;
dialog = new Dialog("Simple Dialog");
dialogGroup = dialog.addGroup("Customer");
dialogFieldCustAccount = dialog.addField(extendedTypeStr(CustAccount));
dialogFieldCustomerGroup = dialog.addField(extendedTypeStr(CustGroupId));
dialogGroup = dialog.addGroup("Currency");
dialogFieldCurrency = dialog.addField(extendedTypeStr(CurrencyCode));
dialogGroup = dialog.addGroup("Vendor Details");
dialogFieldVendAccount = dialog.addField(extendedTypeStr(VendAccount));
dialogGroup = dialog.addGroup("Tax Group");
dialogFieldInclTax = dialog.addField(extendedTypeStr(InclTax));
if(dialog.run())
{
info(dialogFieldCustAccount.value());
info(dialogFieldCurrency.value());
info(dialogFieldCustomerGroup.value());
info(dialogFieldVendAccount.value());
info(dialogFieldIncltax.value());
}
}
void method name()
{
Dialog dialog;
DialogGroup dialogGroup;
DialogField dialogFieldCustAccount;
DialogField dialogFieldCurrency;
DialogField dialogFieldVendAccount;
DialogField dialogFieldCustomerGroup;
DialogField dialogFieldInclTax;
dialog = new Dialog("Simple Dialog");
dialogGroup = dialog.addGroup("Customer");
dialogFieldCustAccount = dialog.addField(extendedTypeStr(CustAccount));
dialogFieldCustomerGroup = dialog.addField(extendedTypeStr(CustGroupId));
dialogGroup = dialog.addGroup("Currency");
dialogFieldCurrency = dialog.addField(extendedTypeStr(CurrencyCode));
dialogGroup = dialog.addGroup("Vendor Details");
dialogFieldVendAccount = dialog.addField(extendedTypeStr(VendAccount));
dialogGroup = dialog.addGroup("Tax Group");
dialogFieldInclTax = dialog.addField(extendedTypeStr(InclTax));
if(dialog.run())
{
info(dialogFieldCustAccount.value());
info(dialogFieldCurrency.value());
info(dialogFieldCustomerGroup.value());
info(dialogFieldVendAccount.value());
info(dialogFieldIncltax.value());
}
}
Calculation Of Explosive Qty, whether item Qty in warehouse is exceed or within in a limit
// Calculation Of Explosive Qty, whether item Qty in warehouse is exceed or within in a limit - - For purchase order - purchpackingslipjournalpost (class) - create new method as Explosive qty and call this method in endpost method to purchpackingslipjournalpost
private void CalculationOfExplosiveQty()
{
ExplosiveQty netExplosiveQty;
InventTable _InventTable;
InventSum _InventSum;
InventLocation _InventLocation;
PurchParmLine _PurchParmLine,_PurchParmLine1;
InventDim _InventDim,_InventDim1;
real totalQty,PhysicalQty;
PurchId _PurchId;
;
while select _InventDim1 group by InventLocationId join _PurchParmLine1 where _PurchParmLine1.ParmId == PurchParmTable.ParmId
&& _InventDim1.inventDimId == _PurchParmLine1.InventDimId
{
totalQty =0;
info(strFmt("%1",_InventDim.InventLocationId));
while select _PurchParmLine join _InventDim group by InventLocationId where _PurchParmLine.ParmId == PurchParmTable.ParmId
&& _InventDim.inventDimId == _PurchParmLine.InventDimid
&& _InventDim.inventlocationid == _InventDim1.inventlocationid
{
_PurchId = PurchParmLine.OrigPurchId;
select _InventTable where _InventTable.ItemId == _PurchParmLine.ItemId;
netExplosiveQty = _InventTable.ExplosiveQty;
select _InventLocation where _InventLocation.InventLocationId == _InventDim.InventLocationId;
totalQty += PurchParmLine.ReceiveNow * netExplosiveQty;
}
PhysicalQty = 0;
while select _InventSum join _InventDim join _InventTable where _InventSum.InventDimId == _InventDim.inventDimId
&& _InventDim.InventLocationId == _InventDim1.InventLocationId
&& _InventTable.ItemId == _InventSum.ItemId
{
PhysicalQty += _InventSum.PhysicalInvent * ((_InventTable.ExplosiveQty == 0)? 1 : _InventTable.ExplosiveQty) ;
// info(strFmt("%1 : %2",_InventSum.PhysicalInvent,_InventDim.InventLocationId));
}
// info(strFmt("%1 : %2",PhysicalQty,totalQty));
if(_InventLocation.ExplosiveLimit < totalQty + PhysicalQty)
{
info(strFmt("Limit Exceed in wearhouse %1",_InventDim1.InventLocationId));
}
else
{
info("Purchase Order Posted");
}
}
}
private void CalculationOfExplosiveQty()
{
ExplosiveQty netExplosiveQty;
InventTable _InventTable;
InventSum _InventSum;
InventLocation _InventLocation;
PurchParmLine _PurchParmLine,_PurchParmLine1;
InventDim _InventDim,_InventDim1;
real totalQty,PhysicalQty;
PurchId _PurchId;
;
while select _InventDim1 group by InventLocationId join _PurchParmLine1 where _PurchParmLine1.ParmId == PurchParmTable.ParmId
&& _InventDim1.inventDimId == _PurchParmLine1.InventDimId
{
totalQty =0;
info(strFmt("%1",_InventDim.InventLocationId));
while select _PurchParmLine join _InventDim group by InventLocationId where _PurchParmLine.ParmId == PurchParmTable.ParmId
&& _InventDim.inventDimId == _PurchParmLine.InventDimid
&& _InventDim.inventlocationid == _InventDim1.inventlocationid
{
_PurchId = PurchParmLine.OrigPurchId;
select _InventTable where _InventTable.ItemId == _PurchParmLine.ItemId;
netExplosiveQty = _InventTable.ExplosiveQty;
select _InventLocation where _InventLocation.InventLocationId == _InventDim.InventLocationId;
totalQty += PurchParmLine.ReceiveNow * netExplosiveQty;
}
PhysicalQty = 0;
while select _InventSum join _InventDim join _InventTable where _InventSum.InventDimId == _InventDim.inventDimId
&& _InventDim.InventLocationId == _InventDim1.InventLocationId
&& _InventTable.ItemId == _InventSum.ItemId
{
PhysicalQty += _InventSum.PhysicalInvent * ((_InventTable.ExplosiveQty == 0)? 1 : _InventTable.ExplosiveQty) ;
// info(strFmt("%1 : %2",_InventSum.PhysicalInvent,_InventDim.InventLocationId));
}
// info(strFmt("%1 : %2",PhysicalQty,totalQty));
if(_InventLocation.ExplosiveLimit < totalQty + PhysicalQty)
{
info(strFmt("Limit Exceed in wearhouse %1",_InventDim1.InventLocationId));
}
else
{
info("Purchase Order Posted");
}
}
}
About Dynamics AX
Why Microsoft Dynamics AX?
Microsoft Dynamics AX core strengths are in manufacturing and distribution. More than 60% of Microsoft Dynamics AX users are from these industries.
Microsoft Dynamics AX allows you to share and update information across the company in real time, across multiple sites and in multiple countries. Microsoft Dynamics AX is an all-inclusive, company-wide ERP system that customizes to your business.
Microsoft Dynamics AX is completely integrated from your platform up through the end-user business solutions applications.
Microsoft Dynamics AX works like and with familiar Microsoft software, automating and streamlining business processes and connecting you with global customers, business partners and subsidiaries in a way that helps you drive business success.
Microsoft Dynamics AX has fully integrated financials, eliminating the need for duplicate data entry in other areas of the business. Microsoft Dynamics AX provides greater insight into your finances and improves your ability to make the right decisions quickly.
Microsoft Dynamics AX is an object oriented ERP solution that has the lowest total cost of ownership in the market.
Microsoft Dynamics AX fits perfectly in the manufacturing industry with its multi-item dimensions capability, multi-storage capability, multi-language support and its open-source integrated development environment.
Microsoft Dynamics AX core strengths are in manufacturing and distribution. More than 60% of Microsoft Dynamics AX users are from these industries.
Microsoft Dynamics AX allows you to share and update information across the company in real time, across multiple sites and in multiple countries. Microsoft Dynamics AX is an all-inclusive, company-wide ERP system that customizes to your business.
Microsoft Dynamics AX is completely integrated from your platform up through the end-user business solutions applications.
Microsoft Dynamics AX works like and with familiar Microsoft software, automating and streamlining business processes and connecting you with global customers, business partners and subsidiaries in a way that helps you drive business success.
Microsoft Dynamics AX has fully integrated financials, eliminating the need for duplicate data entry in other areas of the business. Microsoft Dynamics AX provides greater insight into your finances and improves your ability to make the right decisions quickly.
Microsoft Dynamics AX is an object oriented ERP solution that has the lowest total cost of ownership in the market.
Microsoft Dynamics AX fits perfectly in the manufacturing industry with its multi-item dimensions capability, multi-storage capability, multi-language support and its open-source integrated development environment.
Creation RDP and Contract Class
DP CLASS
[SRSReportParameterAttribute(classstr
(SRSRDPCustTableContractClass))]
class SRSRDPClass extends SRSReportDataProviderBase
{
CustTemp custTemp;
}
[SRSReportDataSetAttribute("custTemp")]
public custTemp getcustTemp()
{
select * from custTemp;
return custTemp;
}
[SysEntryPointAttribute(false)]
public void processReport()
{
CustTable custTable;
SRSRDPCustTableContractClass
srsRDPCustTableContractClass;
AccountNum accountNum;
srsRDPCustTableContractClass = this.parmDataContract()
as srsRDPCustTableContractClass;
accountNum =
srsRDPCustTableContractClass.parmAccountNum();
while select * from custTable where
custTable.AccountNum == accountNum
{
custTemp.AccountNum =
custTable.AccountNum;
custTemp.PriceGroup =
custTable.PriceGroup;
custTemp.Currency =
custTable.Currency;
custTemp.insert();
}
}
-----------------------------------------------------------------------
-------------------------------------------
CONTRACT CLASS
class SRSRDPCustTableContractClass
{
AccountNum accountNum;
}
[DataMemberAttribute("AccountNum")]
public AccountNum parmAccountNum(AccountNum
_accountNum = accountNum)
{
accountNum = _accountNum;
return accountNum;
}
[SRSReportParameterAttribute(classstr
(SRSRDPCustTableContractClass))]
class SRSRDPClass extends SRSReportDataProviderBase
{
CustTemp custTemp;
}
[SRSReportDataSetAttribute("custTemp")]
public custTemp getcustTemp()
{
select * from custTemp;
return custTemp;
}
[SysEntryPointAttribute(false)]
public void processReport()
{
CustTable custTable;
SRSRDPCustTableContractClass
srsRDPCustTableContractClass;
AccountNum accountNum;
srsRDPCustTableContractClass = this.parmDataContract()
as srsRDPCustTableContractClass;
accountNum =
srsRDPCustTableContractClass.parmAccountNum();
while select * from custTable where
custTable.AccountNum == accountNum
{
custTemp.AccountNum =
custTable.AccountNum;
custTemp.PriceGroup =
custTable.PriceGroup;
custTemp.Currency =
custTable.Currency;
custTemp.insert();
}
}
-----------------------------------------------------------------------
-------------------------------------------
CONTRACT CLASS
class SRSRDPCustTableContractClass
{
AccountNum accountNum;
}
[DataMemberAttribute("AccountNum")]
public AccountNum parmAccountNum(AccountNum
_accountNum = accountNum)
{
accountNum = _accountNum;
return accountNum;
}
Form to Form by CMD Button(Clicked)
//Form to Form by CMD Button(Clicked)
void clicked()
{
Args args;
FormRun formRun;
;
args = new Args();
args.name(formStr(FormDet));
//args.caller(this);
formRun = classFactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.detach();
super();
}
void clicked()
{
Args args;
FormRun formRun;
;
args = new Args();
args.name(formStr(FormDet));
//args.caller(this);
formRun = classFactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.detach();
super();
}
Running the report via code
Running the report via code
private void generateVendBalanceReport()
{
SrsReportRunController reportRunController;
Map queryContracts;
MapEnumerator mapEnum;
Query query;
QueryBuildRange range;
SrsReportDataContract contract;
VendBalanceReportContract rdpContract;
FilePath outputPath = "c:\\";
;
// Create the report run controller
reportRunController = new SrsReportRunController();
reportRunController.parmReportName('VendBalanceReport.AutoDesign1');
reportRunController.parmLoadFromSysLastValue(false);
// Set printer settings (print to file, format, filename, etc).
contract = reportRunController.parmReportContract();
contract.parmPrintSettings().printMediumType(SRSPrintMediumType::File);
contract.parmPrintSettings().overwriteFile(true);
contract.parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
contract.parmPrintSettings().fileName(outputPath + "VendBalanceReport.pdf");
// Use our custom-defined report contract class
rdpContract = contract.parmRdpContract() as VendBalanceReportContract;
rdpContract.parmToDate(systemDateGet());
rdpContract.parmIncludeVendorsWithoutTransactions(true);
// Add a range to the query (filter vendors that begin with '3').
queryContracts = contract.parmQueryContracts();
mapEnum = queryContracts.getEnumerator();
while(mapEnum.moveNext())
{
// Get the query and update the datasource as required
query = mapEnum.currentValue();
range = SysQuery::findOrCreateRange(query.dataSourceTable(tableNum(VendTable)),fieldNum(VendTable,AccountNum));
range.value('3*');
}
// Run the report
reportRunController.runReport();
}
private void generateVendBalanceReport()
{
SrsReportRunController reportRunController;
Map queryContracts;
MapEnumerator mapEnum;
Query query;
QueryBuildRange range;
SrsReportDataContract contract;
VendBalanceReportContract rdpContract;
FilePath outputPath = "c:\\";
;
// Create the report run controller
reportRunController = new SrsReportRunController();
reportRunController.parmReportName('VendBalanceReport.AutoDesign1');
reportRunController.parmLoadFromSysLastValue(false);
// Set printer settings (print to file, format, filename, etc).
contract = reportRunController.parmReportContract();
contract.parmPrintSettings().printMediumType(SRSPrintMediumType::File);
contract.parmPrintSettings().overwriteFile(true);
contract.parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
contract.parmPrintSettings().fileName(outputPath + "VendBalanceReport.pdf");
// Use our custom-defined report contract class
rdpContract = contract.parmRdpContract() as VendBalanceReportContract;
rdpContract.parmToDate(systemDateGet());
rdpContract.parmIncludeVendorsWithoutTransactions(true);
// Add a range to the query (filter vendors that begin with '3').
queryContracts = contract.parmQueryContracts();
mapEnum = queryContracts.getEnumerator();
while(mapEnum.moveNext())
{
// Get the query and update the datasource as required
query = mapEnum.currentValue();
range = SysQuery::findOrCreateRange(query.dataSourceTable(tableNum(VendTable)),fieldNum(VendTable,AccountNum));
range.value('3*');
}
// Run the report
reportRunController.runReport();
}
Save SSRS report to pdf that uses Controller classes [Dynamics AX 2012]
// Save SSRS report to pdf that uses Controller classes [Dynamics AX 2012]
http://alfasith.blogspot.com/2013/07/save-ssrs-report-as-pdf-or-print-it.html
static void myJobPrintReportMail(Args _args)
{
SrsReportRun reportRun;
Query query;
SRSReportPrintDestinationSettings SRSReportPrintDestinationSettings;
SRSPrintDestinationSettings srsPrintSettings;
;
delete_from SRSReportPrintDestinationSettings;
reportRun = new SRSReportRun();
reportRun.reportName("Vend.Report"); //<ReportName>.<DesignName>
srsPrintSettings = reportRun.printDestinationSettings();
srsPrintSettings.printMediumType(SRSPrintMediumType::Email);
srsPrintSettings.emailTo("mail@gmail.com");
srsPrintSettings.emailAttachmentFileFormat(SRSReportFileFormat::PDF);
srsPrintSettings.emailSubject(strfmt('vendor report – %1', systemdateget()));
srsPrintSettings.pack();
reportRun.showDialog(false);
reportRun.init();
reportRun.run();
}
static void San_SaveReportToPDFFromController(Args _args)
{
SalesInvoiceController salesInvoiceController;
SalesInvoiceContract salesInvoiceContract;
Args args = new Args();
SrsReportRunImpl srsReportRun;
CustInvoiceJour custInvoiceJour;
ReportName reportName = "SalesInvoice.Report";
;
select firstOnly custInvoiceJour;
args.record(custInvoiceJour);
salesInvoiceController = new SalesInvoiceController();
salesInvoiceController.parmReportName(reportName);
salesInvoiceContract = salesInvoiceController.parmReportContract().parmRdpContract();
salesInvoiceContract.parmRecordId(custInvoiceJour.RecId);
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo());
salesInvoiceController.parmArgs(args);
srsReportRun = salesInvoiceController.parmReportRun() as SrsReportRunImpl;
salesInvoiceController.parmReportRun(srsReportRun);
salesInvoiceController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
salesInvoiceController.parmReportContract().parmPrintSettings().overwriteFile(true);
salesInvoiceController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
salesInvoiceController.parmReportContract().parmPrintSettings().fileName(‘c:\\SR_SalesInvoice.pdf’);
salesInvoiceController.runReport();
}
static void SR_SaveReportToPDFFromController(Args _args)
{
SalesInvoiceController salesInvoiceController;
SalesInvoiceContract salesInvoiceContract;
Args args = new Args();
SrsReportRunImpl srsReportRun;
CustInvoiceJour custInvoiceJour;
ReportName reportName = "SalesInvoice.Report";
;
select firstOnly custInvoiceJour;
args.record(custInvoiceJour);
salesInvoiceController = new SalesInvoiceController();
salesInvoiceController.parmReportName(reportName);
salesInvoiceContract = salesInvoiceController.parmReportContract().parmRdpContract();
salesInvoiceContract.parmRecordId(custInvoiceJour.RecId); // Record id must be passed otherwise the report will be empty
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo()); // comment this code if tested in pre release
salesInvoiceController.parmArgs(args);
srsReportRun = salesInvoiceController.parmReportRun() as SrsReportRunImpl;
salesInvoiceController.parmReportRun(srsReportRun);
salesInvoiceController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
salesInvoiceController.parmReportContract().parmPrintSettings().overwriteFile(true);
salesInvoiceController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
salesInvoiceController.parmReportContract().parmPrintSettings().fileName(‘c:\\SR_SalesInvoice.pdf’);
salesInvoiceController.runReport();
}
http://alfasith.blogspot.com/2013/07/save-ssrs-report-as-pdf-or-print-it.html
static void myJobPrintReportMail(Args _args)
{
SrsReportRun reportRun;
Query query;
SRSReportPrintDestinationSettings SRSReportPrintDestinationSettings;
SRSPrintDestinationSettings srsPrintSettings;
;
delete_from SRSReportPrintDestinationSettings;
reportRun = new SRSReportRun();
reportRun.reportName("Vend.Report"); //<ReportName>.<DesignName>
srsPrintSettings = reportRun.printDestinationSettings();
srsPrintSettings.printMediumType(SRSPrintMediumType::Email);
srsPrintSettings.emailTo("mail@gmail.com");
srsPrintSettings.emailAttachmentFileFormat(SRSReportFileFormat::PDF);
srsPrintSettings.emailSubject(strfmt('vendor report – %1', systemdateget()));
srsPrintSettings.pack();
reportRun.showDialog(false);
reportRun.init();
reportRun.run();
}
static void San_SaveReportToPDFFromController(Args _args)
{
SalesInvoiceController salesInvoiceController;
SalesInvoiceContract salesInvoiceContract;
Args args = new Args();
SrsReportRunImpl srsReportRun;
CustInvoiceJour custInvoiceJour;
ReportName reportName = "SalesInvoice.Report";
;
select firstOnly custInvoiceJour;
args.record(custInvoiceJour);
salesInvoiceController = new SalesInvoiceController();
salesInvoiceController.parmReportName(reportName);
salesInvoiceContract = salesInvoiceController.parmReportContract().parmRdpContract();
salesInvoiceContract.parmRecordId(custInvoiceJour.RecId);
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo());
salesInvoiceController.parmArgs(args);
srsReportRun = salesInvoiceController.parmReportRun() as SrsReportRunImpl;
salesInvoiceController.parmReportRun(srsReportRun);
salesInvoiceController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
salesInvoiceController.parmReportContract().parmPrintSettings().overwriteFile(true);
salesInvoiceController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
salesInvoiceController.parmReportContract().parmPrintSettings().fileName(‘c:\\SR_SalesInvoice.pdf’);
salesInvoiceController.runReport();
}
static void SR_SaveReportToPDFFromController(Args _args)
{
SalesInvoiceController salesInvoiceController;
SalesInvoiceContract salesInvoiceContract;
Args args = new Args();
SrsReportRunImpl srsReportRun;
CustInvoiceJour custInvoiceJour;
ReportName reportName = "SalesInvoice.Report";
;
select firstOnly custInvoiceJour;
args.record(custInvoiceJour);
salesInvoiceController = new SalesInvoiceController();
salesInvoiceController.parmReportName(reportName);
salesInvoiceContract = salesInvoiceController.parmReportContract().parmRdpContract();
salesInvoiceContract.parmRecordId(custInvoiceJour.RecId); // Record id must be passed otherwise the report will be empty
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo()); // comment this code if tested in pre release
salesInvoiceController.parmArgs(args);
srsReportRun = salesInvoiceController.parmReportRun() as SrsReportRunImpl;
salesInvoiceController.parmReportRun(srsReportRun);
salesInvoiceController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
salesInvoiceController.parmReportContract().parmPrintSettings().overwriteFile(true);
salesInvoiceController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
salesInvoiceController.parmReportContract().parmPrintSettings().fileName(‘c:\\SR_SalesInvoice.pdf’);
salesInvoiceController.runReport();
}
From Date to Todate filter
// From Date to TOdate filter
void clicked()
{
SalesTablesReport salesTablesReport;
TempSalesRep tempSalesRepins;
//delete_from tempSalesRepins;
// info(strFmt("%1",fromdate.dateValue()));
delete_from TempSalesRep;
while select salesTablesReport where salesTablesReport.FromDate >= (fromdate.dateValue())
&& salesTablesReport.ToDate <=(todate.dateValue())
{
tempSalesRepins.CustAccount = salesTablesReport.CustAccount;
tempSalesRepins.FromDate = salesTablesReport.FromDate;
tempSalesRepins.ToDate = salesTablesReport.ToDate;
tempSalesRepins.insert();
// info(strFmt("%1",salesTablesReport.FromDate));
}
TempSalesRep_ds.research();
TempSalesRep_ds.refresh();
}
void clicked()
{
SalesTablesReport salesTablesReport;
TempSalesRep tempSalesRepins;
//delete_from tempSalesRepins;
// info(strFmt("%1",fromdate.dateValue()));
delete_from TempSalesRep;
while select salesTablesReport where salesTablesReport.FromDate >= (fromdate.dateValue())
&& salesTablesReport.ToDate <=(todate.dateValue())
{
tempSalesRepins.CustAccount = salesTablesReport.CustAccount;
tempSalesRepins.FromDate = salesTablesReport.FromDate;
tempSalesRepins.ToDate = salesTablesReport.ToDate;
tempSalesRepins.insert();
// info(strFmt("%1",salesTablesReport.FromDate));
}
TempSalesRep_ds.research();
TempSalesRep_ds.refresh();
}
Steps to create a Number sequence
steps: to create a Number sequence
1. Create
an edt : CarId .
AOT >> Extended Data Types(String) >> New >> Properties
>> Name >> Car Id.
2. Write a code on
lode module() on NumberSeqModuleProject
{
datatype.parmDatatypeId(extendedTypeNum(Car
Id));
datatype.parmReferenceHelp(literalStr("@SYS334483"));
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmWizardHighest(999999);
datatype.parmSortField(20);
datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
this.create(datatype);
}
3.Write a method on
Projparameters Table
client server static NumberSequenceReference
numRefcarId()
{
return NumberSeqReference::findReference(extendedTypeNum(car
Id));
}
4.Write a job and run
that
static void Carid(Args _args)
{
NumberSeqModuleProject NumberSeqModuleProject
= new NumberSeqModuleProject();
;
NumberSeqModuleProject.load();
}
5. Then run the wizard
Organization
Administration >> CommonForms >>
Numbersequences>>Numbersequences>> Generate >> run the
wizard.
6.Now we have to check
the number sequence is correctly working for that write a job:
static void number(Args _args)
{
NumberSeq numberSeq;
CarId num;
;
numberSeq = NumberSeq::newGetNum(ProjParameters::numRefcarId());
num = numberSeq.num();
info(num);
}
Run the
above job.We will find the generated Number sequence. .
7. Now we want that
Number Sequence in form level(Car Table):
Declare the number
sequence On Form Declaration:
public class FormRun extends ObjectRun
{
NumberSeqFormHandler numberSeqFormHandler;
}
8. Write the NumberSeqFormHandler()
in form methods node.
NumberSeqFormHandler
numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler =
NumberSeqFormHandler::newForm(ProjParameters::numRefcarId ().NumberSequenceId,
element,
CarTable_DS,
fieldNum(CarTable,
Car Id)
);
}
return numberSeqFormHandler;
}
9.Write the close() on
the form methods node.
void close()
{
if (numberSeqFormHandler)
{
numberSeqFormHandler.formMethodClose();
}
super(); }
10. Then final add the
below methods on data source methods node
Create()
void create(boolean append = false,
boolean extern = false) // If created externally
{
element.numberSeqFormHandler().formMethodDataSourceCreatePre();
super(append);
if (!extern)
{
element.numberSeqFormHandler().formMethodDataSourceCreate(true);
}
}
Delete()
public void delete()
{
element.numberSeqFormHandler().formMethodDataSourceDelete();
super();
}
Write()
public void write()
{
super();
element.numberSeqFormHandler().formMethodDataSourceWrite();
}
Validate Write()
public boolean validateWrite()
{
boolean ret;
ret = super();
ret =
element.numberSeqFormHandler().formMethodDataSourceValidateWrite(ret)
&& ret;
if (ret)
{
CarTable.validateWrite();
}
return ret;
}
Link Active()
public void linkActive()
{
;
element.numberSeqFormHandler().formMethodDataSourceLinkActive();
super();
}
Now our
numberseqence is generated .
Subscribe to:
Posts (Atom)
Convert Call stack to readable format in D365FO X++
//Input --container _xppCallStack = xSession::xppCallStack(); Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...
-
Restore .bacpac file to Development VM Steps: 1. Take Backup of AxDB database from Development VM 2. Open Command Pr...
-
Posting Vendor invoice based on Product receipt public void postPurchaseInvoiceJournal() { VendPackingSlipJour vendP...
-
Code for reserve and unreserved sales order lines Inputs : SalesLine, InventDim (Combination to reserve), Qty Note : To Reserve -> Pass...