hi copy this code into text file and made it as a xpo
Exportfile for AOT version 1.0 or later
Formatversion: 1
***Element: CLS
; Microsoft Dynamics Class: PwCImport unloaded
; --------------------------------------------------------------------------------
CLSVERSION 1
CLASS #PwCImport
PROPERTIES
Name #PwCImport
Extends #ObjectRun
RunOn #Called from
ENDPROPERTIES
METHODS
Version: 3
SOURCE #classDeclaration
#public class PwCImport extends objectrun
#{
#}
ENDSOURCE
SOURCE #readexcel
#public static server PwC_Import readexcel(filenameopen _file)
#{
#Excel
#AviFiles
SysExcelApplication excelApp = SysExcelApplication::construct();
SysOperationProgress progress = new SysOperationProgress();
SysExcelWorkSheet excelWorksheet;
SysExcelRange excelRange;
SysExcelCells excelCells;
SysExcelCell excelCell;
ComVariant cellValue = new ComVariant() ;
boolean Flag_Found ;
PwC_Import PwC_ImportLocal;
int colno, colno_excel, colno_grid;
int i;
int TotalRow ;
str strvalue ;
COMVariant VariantValue ;
Description Error;
excelApp.workbooks().open( _File);
excelWorksheet = excelApp.worksheets().itemFromNum(1);
excelCells = excelWorksheet.cells();
startlengthyoperation();
flag_found=true ; TotalRow=1 ;
//________________________________________________________
excelCell=excelWorksheet.cells().item(TotalRow+1,1);
strvalue=StrUpr(excelCell.value().bStr());
if(strvalue!="**********")
{
excelworksheet = null;
excelapp.quit();
Throw Error(“Invalid Excel Template. Please use template specified”);
}
//________________________________________________________
progress.setCaption(“Data Import”);
progress.setAnimation(#AviFormLetter);
startlengthyoperation();
ttsbegin;
while (Flag_Found==true)
{
progress.setText(strfmt(“Scanning Records %1”, TotalRow));
//Marked____________________________________________________
PwC_ImportLocal.Marked =NoYes::Yes;
//TransDate_________________________________________________
if(excelWorksheet.cells().item( TotalRow+2,1).value().date())
{
PwC_ImportLocal.Transdate =excelWorksheet.cells().item( TotalRow+2,1).value().date();
}
else
{
Error=Error+"Date ; ";
PwC_ImportLocal.Transdate =datenull();
PwC_ImportLocal.Marked =NoYes::No;
}
//Account___________________________________________________
If(LedgerTable::exist(excelWorksheet.cells().item( TotalRow+2,2).value().bStr()))
{
PwC_ImportLocal.Account=excelWorksheet.cells().item( TotalRow+2,2).value().bStr();
}
else
{
Error =Error+"<A/C>; ";
PwC_ImportLocal.Account ="";
PwC_ImportLocal.Marked =NoYes::No;
}
//Transaction Text_____________________________________________
PwC_ImportLocal.TransTxt =excelWorksheet.cells().item( TotalRow+2,3).value().bStr();
//Offset Account_______________________________________________
If(LedgerTable::exist(excelWorksheet.cells().item( TotalRow+2,4).value().bStr()))
{
PwC_ImportLocal.OffsetAccount =excelWorksheet.cells().item( TotalRow+2,4).value().bStr();
}
else
{
Error =Error+"<Offset A/C>; ";
PwC_ImportLocal.OffsetAccount ="";
PwC_ImportLocal.Marked =NoYes::No;
}
//Amount Check_________________________________________________
if( (excelWorksheet.cells().item(TotalRow+2,5).value().double() && excelWorksheet.cells().item(TotalRow+2,6).value().double()) ||
(!excelWorksheet.cells().item(TotalRow+2,5).value().double() && !excelWorksheet.cells().item(TotalRow+2,6).value().double()) )
{
Error =Error+"<Dr & Cr>; ";
PwC_ImportLocal.Marked =NoYes::No;
}
//DebitAmount__________________________________________________
PwC_ImportLocal.Debit = excelWorksheet.cells().item(TotalRow+2,5).value().double();
//Credit Amount________________________________________________
PwC_ImportLocal.Credit = excelWorksheet.cells().item(TotalRow+2,6).value().double();
//Dimensions___________________________________________________
PwC_ImportLocal.Dimensions[1] =excelWorksheet.cells().item(TotalRow+2,7).value().bStr();
PwC_ImportLocal.Dimensions[2] =excelWorksheet.cells().item(TotalRow+2,8).value().bStr();
PwC_ImportLocal.Dimensions[3] =excelWorksheet.cells().item(TotalRow+2,9).value().bStr();
//Error Description____________________________________________
PwC_ImportLocal.ErrorDesc=Error;
Error=""; // Reset to Null
TotalRow++;
PwC_ImportLocal.insert();
progress.incCount();
if(excelWorksheet.cells().item(TotalRow+2,2).value().bstr()=="")
Flag_Found=false;
}
ttscommit;
endlengthyoperation();
excelworksheet = null;
excelapp.quit();
return PwC_ImportLocal;
#}
ENDSOURCE
ENDMETHODS
ENDCLASS
***Element: FRM
; Microsoft Dynamics Forms unloaded
; --------------------------------------------------------------------------------
FRMVERSION 5
FORM #PwC_Import
PROPERTIES
Name #PwC_Import
ENDPROPERTIES
METHODS
Version: 3
SOURCE #classDeclaration
#public class FormRun extends ObjectRun
#{
FormStringControl fileNameControl;
#define.expImpFileExtension(".xls")
LedgerJournalNameId LJournalName;
#define.currentVersion(1)
#localmacro.CurrentList
LJournalName
#endMacro
#}
ENDSOURCE
SOURCE #run
#public void run()
#{
super();
xSysLastValue::getLast(this);
JournalName.text(LJournalName);
#}
ENDSOURCE
SOURCE #unpack
#public boolean unpack(container packedClass)
#{
int version = runbase::getVersion(packedClass);
switch (version)
{
case #CurrentVersion:
[version,#CurrentList] = packedClass;
return true;
default :
return false;
}
return false;
#}
ENDSOURCE
SOURCE #pack
#public container pack()
#{
return [#CurrentVersion,#CurrentList];
#}
ENDSOURCE
SOURCE #close
#public void close()
#{
super();
LJournalName=JournalName.text();
xSysLastValue::saveLast(this);
#}
ENDSOURCE
SOURCE #initParmDefault
#/ARIJIT
#This method is called when no SysLastValue record can be found in xSysLastValue.GetLast()
#/
#void initParmDefault()
#{
#}
ENDSOURCE
SOURCE #lastValueDesignName
#private IdentifierName lastValueDesignName()
#{
return ‘’;
#}
ENDSOURCE
SOURCE #lastValueElementName
#private IdentifierName lastValueElementName()
#{
return this.name();
#}
ENDSOURCE
SOURCE #lastValueType
#private UtilElementType lastValueType()
#{
return UtilElementType::Form;
#}
ENDSOURCE
SOURCE #lastValueUserId
#private UserId lastValueUserId()
#{
return curuserid();
#}
ENDSOURCE
SOURCE #lastValueDataAreaId
#public dataAreaId lastValueDataAreaId()
#{
return curExt();
#}
ENDSOURCE
SOURCE #init
#public void init()
#{
;
xSysLastValue::getLast(this);
super();
CreateJournal.enabled(false);
PrintTable.enabled(false);
#}
ENDSOURCE
SOURCE #fileNameLookupFilename
#str fileNameLookupFilename()
#{
Filename filepath;
Filename fileName;
Filename fileType;
[filepath, fileName, fileType] = fileNameSplit(fileNameControl.text());
return fileName + fileType;
#}
ENDSOURCE
SOURCE #fileNameLookupTitle
#// AOSRunMode::client
#str fileNameLookupTitle()
#{
return 'Lookup Title: ’ + fileNameControl.label();
#}
ENDSOURCE
SOURCE #fileNameLookupFilter
#container fileNameLookupFilter()
#{
#file
return [WinApi::fileType(’.xls’), #allfilesName+’.xls’, #allFilesType, #allFiles];
#}
ENDSOURCE
SOURCE #fileNameLookupInitialPath
#// AOSRunMode::client
#str fileNameLookupInitialPath()
#{
#WinAPI
Filename filepath;
Filename fileName;
Filename fileType;
[filepath, fileName, fileType] = Global::FileNameSplit(fileNameControl.text());
return filepath;
#}
ENDSOURCE
ENDMETHODS
OBJECTBANK
DATASOURCE
OBJECTPOOL
PROPERTIES
Name #PwC_Import
Table #PwC_Import
AllowEdit #No
AllowCreate #No
AllowDelete #No
InsertIfEmpty #No
ENDPROPERTIES
FIELDLIST
ENDFIELDLIST
ENDOBJECTPOOL
METHODS
Version: 3
SOURCE #displayOption
#public void displayOption(Common _record, FormRowDisplayOption _options)
#{
PwC_Import PwC_Importlocal;
PwC_Importlocal = _record;
super(_record, _options);
if(PwC_Importlocal.ErrorDesc != “”)
{
_options.backColor(8421631); //RED
}
#}
ENDSOURCE
ENDMETHODS
ENDDATASOURCE
ENDOBJECTBANK
JOINS
ENDJOINS
DESIGN
PROPERTIES
Caption #Data Import
TitleDatasource #PwC_Import
SaveSize #Yes
ENDPROPERTIES
CONTAINER
CONTROL GROUP
;==== controlId:12290, containerId: 0, containerdata: 0
;----------------------------------------------------------
PROPERTIES
Name #Group
Width #Column width
Height #Column height
FrameType #Raised 3D
ENDPROPERTIES
CONTAINER
CONTROL GROUP
;==== controlId:12291, containerId:12290, containerdata:12290
;----------------------------------------------------------
PROPERTIES
Name #Header
Width #Column width
FrameType #Edged 3D
Columns #4
ArrangeGuide
ARRAY INDEX Columns
#0
#0
#0
#0
&nb