1. Class have to extend the RunbaseBatch
2. implement the Run() in this method we can call our method which is created for logic(upload()).
3. Implement the pack and unpack methods
4. Implement the dialog() method
5. Construct() method
6. getFromDialog() method
7. Main method
8. Description method
9. Validate method
10.canGoBatch()
11.canGoBatchJournal
--
class INU_UpdExtProcComplete extends runbasebatch
{
DialogField dlgField;
FilenameOpen filenameOpen;
#define.CurrentVersion(1)
#define.Version(1)
#localmacro.CurrentList
filenameOpen
#endmacro
}
--
public void run()
{
if(filenameOpen)
{
if(WINAPI::fileExists(filenameOpen))
this.upload();
else throw error("@SYS26757");
}
super();
}
--
client static INU_UpdExtProcComplete construct()
{
return new INU_UpdExtProcComplete();
}
--
public container pack()
{
return [#CurrentVersion,#CurrentList];
}
--
public boolean unpack(container packedClass)
{
Version version = Runbase::getVersion(packedClass);
switch(version)
{
case #CurrentVersion:
[version, #CurrentList] = packedClass;
break;
default:
return false;
}
return true;
}
--
public boolean getFromDialog()
{
boolean ret;
ret = super();
filenameOpen = dlgField.value();
return ret;
}
--
public Object dialog()
{
DialogRunbase dialog = super();
;
dlgField = dialog.addFieldValue(typeid(FilenameOpen),"","@IST10755","@IST10755");
return dialog;
}
--
void upload()
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row;
FileName filename;
TINS_PurchTable tINS_PurchTable;
PurchId purchId;
str dataArea;
;
row++;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
filename = filenameOpen;
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error("@SYS19358");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
do
{
row++;
purchId = cells.item(row, 1).value().bStr();
dataArea = cells.item(row, 2).value().bStr();
if(purchId)
{
ttsbegin;
select forupdate crosscompany purchTable
where purchTable.PurchId == purchId;
if(tINS_PurchTable.PurchId)
{
changecompany(dataArea)
{
purchTable.OneTimeVendor = Noyes::Yes;
purchTable.doupdate();
info("The purchase id %1 is updated successfully",purchTable.PurchId);
}
}
else
{
info(strfmt("@IST10757",purchId));
}
ttscommit;
}
else
{
throw error(strfmt("@IST10758"));
}
type = cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
}
--
public static void main(Args args)
{
INU_UpdExtProcComplete iNU_UpdExtProcComplete;
;
iNU_UpdExtProcComplete = INU_UpdExtProcComplete::construct();
if(iNU_UpdExtProcComplete.prompt())
iNU_UpdExtProcComplete.run();
}
--
static ClassDescription description()
{
return "@IST10759";
}
--
boolean validate()
{
boolean ret;
ret = super();
if(!winapi::fileExists(filenameOpen))
ret = checkFailed(strfmt("@SYS18678",filenameOpen));
return ret;
}
--
public boolean canGoBatch()
{
return true;
}
--
public boolean canGoBatchJournal()
{
return true;
}
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.
Subscribe to:
Post Comments (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...
Thank you. Much appreciated
ReplyDeleteThis is definitely one of the best articles I have read in this website! Thanks
ReplyDeleteMicrosoft Dynamics CRM Online Training | Dynamics AX Online Training