Create a Class :
class ImportCsv extends Runbasebatch
{
Filename ItemFileName;
Filename filename;
DialogField dialogFilename;
{
Filename ItemFileName;
Filename filename;
DialogField dialogFilename;
#define.CurrentVersion(1)
#define.Version1(1)
#localmacro.CurrentList
fileName
#endmacro
}
#define.Version1(1)
#localmacro.CurrentList
fileName
#endmacro
}
public Object dialog()
{
DialogRunbase dialog = super();
;
{
DialogRunbase dialog = super();
;
dialogFilename = dialog.addField(typeId(FilenameOpen));
dialogFilename.value(filename);
dialogFilename.value(filename);
return dialog;
}
}
public boolean getFromDialog()
{
;
fileName = dialogFileName.value();
return super();
}
{
;
fileName = dialogFileName.value();
return super();
}
void ImportInventtable()
{
CommaIo file = new commaIo(ItemFileName,’r’);
Container con;
InventTable inventTable;
Inventtable Inventtable;
int x,y;
;
{
CommaIo file = new commaIo(ItemFileName,’r’);
Container con;
InventTable inventTable;
Inventtable Inventtable;
int x,y;
;
file.inFieldDelimiter(‘,’);
if (file)
{
ttsbegin;
while(file.status() == IO_Status::OK)
{
con = file.read();
if (con)
{
Inventtable = Inventtable::find(conpeek(con,2));
if(Inventtable)
{
Inventtable.InventTableId = conpeek(con,1);
Inventtable.ItemId = conpeek(con,2);
Inventtable.Name = conpeek(con,4);
Inventtable.validateWrite();
Inventtable.insert();
x++;
}
else
{
y++;
}
}
}
}
ttscommit;
info(strfmt("%1 record(s) imported, %2 record(s) not found",x,y));
}
if (file)
{
ttsbegin;
while(file.status() == IO_Status::OK)
{
con = file.read();
if (con)
{
Inventtable = Inventtable::find(conpeek(con,2));
if(Inventtable)
{
Inventtable.InventTableId = conpeek(con,1);
Inventtable.ItemId = conpeek(con,2);
Inventtable.Name = conpeek(con,4);
Inventtable.validateWrite();
Inventtable.insert();
x++;
}
else
{
y++;
}
}
}
}
ttscommit;
info(strfmt("%1 record(s) imported, %2 record(s) not found",x,y));
}
public container pack()
{
return [#CurrentVersion,#CurrentList];
}
{
return [#CurrentVersion,#CurrentList];
}
public void run()
{
this.ImportInventtable();
super();
}
{
this.ImportInventtable();
super();
}
public boolean unpack(container packedClass)
{
Version version = runbase::getVersion(packedClass);
;
switch (version)
{
case #CurrentVersion:
[version,#CurrentList] = packedClass;
break;
default:
return false;
}
return true;
}
{
Version version = runbase::getVersion(packedClass);
;
switch (version)
{
case #CurrentVersion:
[version,#CurrentList] = packedClass;
break;
default:
return false;
}
return true;
}
public boolean validate()
{
if (false)
return checkFailed("");
return true;
}
{
if (false)
return checkFailed("");
return true;
}
static void main(Args _args)
{
ImportCsv ImportCsv ;
FormRun formRun;
Args args;
;
ImportCsv = new ImportCsv ();
if (ImportCsv .prompt())
{
ImportCsv .run();
}
{
ImportCsv ImportCsv ;
FormRun formRun;
Args args;
;
ImportCsv = new ImportCsv ();
if (ImportCsv .prompt())
{
ImportCsv .run();
}
}
No comments:
Post a Comment