Wednesday, November 17, 2010

To create sales order from text file by using AxSalesTable and AxSalesLine Classes.


static void loadCSVFileSalesOrder(Args _args)
{
Dialog dialog;
DialogField dialogFileName;
SysOperationProgress simpleProgress;
Filename filename;
FileIOPermission permission;
TextIO textIO;
NumberSeq numSeq;
InventTable inventTable;
str s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12;
Real r1,r2,r3,r4,r5,r6;
int i1,i2,i3,i4,i5,i6,i;
Container c1,c2;
Container filterCriteria;
AxSalesLine axSalesLine = new axSalesLine();
AxSalesTable axsalesTable = new axSalesTable();
#File
#avifiles
;
dialog = new Dialog("Importing Text File");
dialogFileName = dialog.addField(typeid(Filenameopen), "File Name");
filterCriteria = ['*.txt'];
filterCriteria = dialog.filenameLookupFilter(filterCriteria);
dialog.run();

if (dialog.run())
filename = dialogFileName.value();

if(!filename)
{
info("Filename must be filled");
throw("");
}

permission = new fileIOpermission(filename,#io_read);
permission.assert();
textIO = new TextIO(filename,#io_read);
textIO.inFieldDelimiter(';');///Change the Delimeter if it is , or ; etc

simpleProgress = SysOperationProgress::newGeneral(#aviUpdate, 'Importing sales data',100);

if(textIO)
{
while(textIO.status() == IO_Status::Ok)
{
c1 = textIO.read();
s11 = conpeek(c1,1);
if(strlen(s11) > 1)///checks for the customer account
{
axsalesTable.parmSalesId();
axsalesTable.parmCustAccount(Conpeek(c1,1));// Cust Account
axsalesTable.save();

axSalesLine.parmSalesId(axsalesTable.parmSalesId());
axSalesLine.parmItemId(Conpeek(c1,2));//ItemId
axSalesLine.axInventDim().parmInventSiteId(Conpeek(c1,3));//// InventSiteId
axSalesLine.axInventDim().parmInventLocationId(Conpeek(c1,4));//// InventLocationId
axSalesLine.parmSalesQty(conpeek(c1,5));//Sales Quantity
axSalesline.parmSalesPrice(conpeek(c1,6));//Sales Price
axSalesLine.save();

i++;
simpleProgress.incCount();
simpleprogress.setText(strfmt("Lines imported: %1", i));
info(strfmt("Sales Order : %1 has been created",axsalesTable.parmSalesId()));
sleep(10);
}

}
}
}

2 comments:

  1. Hi,

    Do you have any job to import sales order into Axapta from Excel but not from CSV format.

    If So can you please send the excel format and job to my mail id axuser2011@live.com

    Thanks in advance

    ReplyDelete
  2. Hi, I need some help with importing data from excel to DAX , would you be able to help ? My email is aznan7879@gmail.com

    I don't mind to pay...

    ReplyDelete