Import Csv file to Ax 2012 using X++ code and as Runbase batch

class John_RBTestClass extends RunBaseBatch
{
}

client server static ClassDescription description()
{
return “Johnkrish Batch Test”;
}

static void main(Args _args)
{
John_RBTestClass objClass = new John_RBTestClass();
//prompt for runbase framework dialog
if (objClass.prompt())
{
//run the process
objClass.run();
}
}

 

public void run()
{
Bill_Copy bc;

#File
IO iO;
CustAccount custAccount;
CustName custname;
str one;
FilenameOpen filename = @’E:\Johnkrish\Johnkrish.csv’;//To assign file name
Container record;
boolean first = true;

str Delimiter = “,”;
int totalRecords;
;
iO = new CommaTextIo(filename,#IO_Read);
if (! iO || iO.status() != IO_Status::Ok)
{
throw error(“@SYS19358”);
}

record = iO.read();

while(iO.status() == IO_Status::Ok)

{

record = iO.read();

if(!record)

break;
bc.CustName=conpeek(record, 1);
bc.ItemName=conpeek(record, 2);
bc.insert();

}

}

DATA in .Csv file
John,Mobile
Krish,Phone
Gopal,Purse

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s