static void createInventoryJournal(Args _args)///and also it will import the data from the Excel
{
InventJournalNameId inventJournalNameId = "IMov";///Assign the journal Name
AxInventJournalTrans axInventJournalTrans;
InventJournalTable inventJournalTable;
Dialog dialog;
DialogField dialogField,dialogdate;
Filename filename;
COMVariant cOMVariant;
SysExcelApplication sysExcelApp;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell rCell;
int i,j,k;
SysOperationProgress simpleProgress;
Container filterCriteria;
#avifiles
;
sysExcelApp = SysExcelApplication::construct();///SysExcelApplication
workbooks = sysExcelApp.workbooks();///Workbooks
Dialog = new dialog();
dialogField = dialog.addField(typeId(FileNameOpen),'File Name');
filterCriteria = ['*.xls','*. xlsx'];//// To filter only Excel files
filterCriteria = dialog.filenameLookupFilter(filterCriteria);
dialog.run();
if(dialog.run())
fileName = dialogField.value();
cOMVariant = new COMVariant();
cOMVariant.bStr(fileName);
workBook = workBooks.add(cOMVariant);///Workbook
worksheets = Workbook.worksheets();///WorkSheets
worksheet = worksheets.itemFromNum(1);///WorkSheet
Cells = workSheet.cells();///Cells
i=2;
rCell = Cells.item(i,1);///rCell
if(fileName)
{
ttsBegin;
inventJournalTable.JournalNameId = inventJournalNameId;
inventJournalTable.initFromInventJournalName(InventJournalName::find(inventJournalNameId));
inventJournalTable.insert();
simpleProgress = SysOperationProgress::newGeneral(#aviUpdate,'Importing Transactions',100);///SysProgressOperation
while(RCell.Value().bStr() != '')
{
j++;
simpleProgress.incCount();
simpleprogress.setText(strfmt("Transaction Imported: %1",i));
sleep(10);
simpleprogress.kill();
axInventJournalTrans = new AxInventJournalTrans();
axInventJournalTrans.parmJournalId(inventJournalTable.JournalId);
axInventJournalTrans.parmTransDate(systemdateget());
axInventJournalTrans.parmLineNum(j);
rCell = Cells.Item(i, 1);
axInventJournalTrans.parmItemId(RCell.value().bStr());
rCell = Cells.Item(i, 2);
axInventJournalTrans.axInventDim().parmInventSiteId(rCell.value().bStr());
rCell = Cells.Item(i, 3);
axInventJournalTrans.axInventDim().parmInventLocationId(rCell.value().bStr());
rCell = Cells.Item(i, 4);
axInventJournalTrans.parmQty(rCell.value().double());
rCell = Cells.Item(i, 5);
axInventJournalTrans.parmCostPrice(rCell.value().double());
axInventJournalTrans.save();
i++;
rCell = Cells.Item(i, 1);
}
ttsCommit;
}
}
This blog is for Dynamics AX (AXAPTA) Developers,this will help you for your development issues. This site contains some Microsoft Dynamics AX X++ Codes for use in your day to day use.
23 May 2013
16 May 2013
How to enable and use the "Run As" feature in Windows Server 2003
Enable the Secondary Logon Service
By default, the Secondary Logon service starts automatically when you start Windows. However, an administrator can disable the service. To enable the service if it is disabled:
Log on as Administrator or as a member of the Administrators group.
Click Start, point to Administrative Tools, and then click Computer Management.
Expand Services and Applications, and then click Services.
In the right pane, right-click Secondary Logon, and then click Properties.
Click the General tab.
In the Startup type box, click Automatic, and then click Start under Service status.
Click OK, and then close the Computer Management window.
Use Run As to Start a Program as Another User
To use the "Run as" feature to start a program as another user:
Locate the program that you want to start in Windows Explorer, the Microsoft Management Console (MMC), or Control Panel.
Press and hold down the SHIFT key while you right-click the .exe file or icon for the program, and then click Run as.
Click The following user.
In the User name and Password boxes, type the user name and password of the user whose credentials you want to use to run the program, and then click OK.
NOTE: You can also use the runas command from a command prompt. For more information, click Start, and then click Run. In the Open box, type cmd, and then click OK. At the command prompt, type runas /?, and then press ENTER.
By default, the Secondary Logon service starts automatically when you start Windows. However, an administrator can disable the service. To enable the service if it is disabled:
Log on as Administrator or as a member of the Administrators group.
Click Start, point to Administrative Tools, and then click Computer Management.
Expand Services and Applications, and then click Services.
In the right pane, right-click Secondary Logon, and then click Properties.
Click the General tab.
In the Startup type box, click Automatic, and then click Start under Service status.
Click OK, and then close the Computer Management window.
Use Run As to Start a Program as Another User
To use the "Run as" feature to start a program as another user:
Locate the program that you want to start in Windows Explorer, the Microsoft Management Console (MMC), or Control Panel.
Press and hold down the SHIFT key while you right-click the .exe file or icon for the program, and then click Run as.
Click The following user.
In the User name and Password boxes, type the user name and password of the user whose credentials you want to use to run the program, and then click OK.
NOTE: You can also use the runas command from a command prompt. For more information, click Start, and then click Run. In the Open box, type cmd, and then click OK. At the command prompt, type runas /?, and then press ENTER.
Subscribe to:
Posts (Atom)
Ledger Voucher creation Framework and x++ code to create ledger voucher
Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...
-
{ "Message" : "Please verify that the user is valid and set up correctly." } Sol: System Administration > Se...
-
Please click here to access Custom Workflow step by step process:
-
FormRun formRun = sender.formRun(); Object inventTrans_ds = formRun.dataSource(formDataSourceStr(InventMarking,InventTransO...