* Its a basic code for read and move file, you need to add some more methods depend upon requirement.
public void run()
{
#File
IO iO;
Container record;
boolean first = true;
boolean validJournal;
LedgerJournalId journalId;
TransTxt transTxt;
RefRecId refRecId;
LedgerDimensionDefaultAccount offsetAccount;
Voucher voucher;
INC_GLParameters parameters;
LedgerJournalNameId sybaseCollectionType, axJournalName;
Name sybaseDate, sybaseTime, sybaseVoucherNum, sybaseSCode, sybaseCostCenter, sybaseYearTag, sybaseRemarks;
Name sybaseMethodOfPay, sybasePostingProfile, sybaseBranchNum, sybaseYear, sybaseUser, sybaseVoucherDate, sybasePCode;
AmountMST sybaseDebitAmount, sybaseCreditAmount;
Name axDate, axTime, axVoucherNum, axSCode, axCostCenter, axYearTag, axRemarks;
Name axMethodOfPay, axPostingProfile, axBranchNum, axYear, axUser, axVoucherDate, axPCode;
AmountMST axDebitAmount, axCreditAmount;
INC_SybaseTansaction sybaseTansaction;
INC_CostCenter costCenter;
INC_SybasePaymMethods sybasePaymMethods;
INC_CostCenterDimension costCenterDimension;
custLedger custLedger;
CustLedgerAccounts custLedgerAccounts;
int rwCnt;
System.Array files;
FilePath fPath;
Filename fileName,
filePath,
fileType;
FileNameType fPattern = “*.csv”;
int fileCount;
int i;
str nextFile;
DimensionStorage dimensionStorage;
DimensionAttribute branchDimensionAttribute;
DimensionAttributeValue newBranchValue;
container dimConAttr, dimConValue;
real numPatientId, numFileNo;
str dumpFPath;
Set permissionSet;
Filename fType;
//this.header();
try
{
select firstOnly parameters;
fPath = parameters.IntegrationFolder;
new InteropPermission(InteropKind::ClrInterop).assert();
files = System.IO.Directory::GetFiles(fPath, fPattern);
if (files)
{
fileCount = files.get_Length();
if(fileCount)
{
for(i=0; i 1) //To skip header of csv
{
sybaseCollectionType = conPeek(record, 1);
sybaseDate = conPeek(record, 2);
sybaseTime = conPeek(record, 3);
sybaseVoucherNum = conPeek(record, 4);
sybaseSCode = conPeek(record, 5);
sybaseCostCenter = conPeek(record, 6);
sybaseYearTag = conPeek(record, 7);
sybaseRemarks = conPeek(record, 8);
sybaseMethodOfPay = conPeek(record, 9);
sybasePostingProfile = conPeek(record, 10);
sybaseDebitAmount = conPeek(record, 11);
sybaseCreditAmount = conPeek(record, 12);
sybaseBranchNum = conPeek(record, 13);
sybaseYear = conPeek(record, 14);
sybaseUser = conPeek(record, 15);
sybaseVoucherDate = conPeek(record, 16);
sybasePCode = conPeek(record, 17);
select firstOnly sybaseTansaction where sybaseTansaction.SybaseTransCode == sybaseCollectionType;
axJournalName = sybaseTansaction.AXTransCode;
select firstOnly sybasePaymMethods where sybasePaymMethods.SybasePaymMetghodCode == sybaseMethodOfPay;
axMethodOfPay = sybasePaymMethods.AXPaymMethodCode;
select firstOnly costCenter where costCenter.SybaseCostCenter == sybaseCostCenter;
axCostCenter = costCenter.AXCostCenterCode;
select custLedgerAccounts
join custLedger
where CustLedgerAccounts.PostingProfile == custLedger.PostingProfile
&& custLedger.PostingProfile == sybasePostingProfile;
axCreditAmount = sybaseCreditAmount;
axDebitAmount = sybaseDebitAmount;
axRemarks = sybaseRemarks;
select costCenterDimension where costCenterDimension.CostCenter == sybaseCostCenter;
//Validations. Do not proceed to insert data
if (!sybaseCollectionType)
{
validJournal = checkFailed(strFmt(“Please enter jounal name in the import sheet %1, row number %2”, nextFile, rwCnt));
continue;
}
if (!sybasePostingProfile)
{
validJournal = checkFailed(strFmt(“Please enter posting pofile in the import sheet %1, row number %2”, nextFile, rwCnt));
continue;
}
if (validJournal)
{
if(rwCnt == 2)
{
this.createHeader(axJournalName);
}
this.createLines( parameters.CustAccount
, “”
, axRemarks
, axCreditAmount
, axDebitAmount
, sybaseVoucherNum
, sybaseYearTag
, sybaseUser
, custLedgerAccounts.SummaryLedgerDimension,
sybasePostingProfile
, costCenterDimension.DimensionDefault);
}
}
}
}
//Move file after reading successfully.
if (validJournal)
{
io = null;
info(strFmt(“Journal %1 created”, ledgerJournalTable.JournalNum));
System.IO.File::Move(nextFile, dumpFPath);
info(‘Source file is moved to dump folder’);
ttsCommit;
}
else
{
checkFailed(strFmt(“Errors recorded in file %1”, nextFile));
ttsAbort;
}
}
}
else if(!fileCount)
{
checkFailed(strFmt(“Source CSV file is not found in given location %1”, nextFile));
}
}
}
catch(Exception::Error)
{
throw error(“Error in creating Journals”);
//ttsAbort;
}
}
public void run()
{
#File
IO iO;
Container record;
boolean first = true;
boolean validJournal;
LedgerJournalId journalId;
TransTxt transTxt;
RefRecId refRecId;
LedgerDimensionDefaultAccount offsetAccount;
Voucher voucher;
INC_GLParameters parameters;
LedgerJournalNameId sybaseCollectionType, axJournalName;
Name sybaseDate, sybaseTime, sybaseVoucherNum, sybaseSCode, sybaseCostCenter, sybaseYearTag, sybaseRemarks;
Name sybaseMethodOfPay, sybasePostingProfile, sybaseBranchNum, sybaseYear, sybaseUser, sybaseVoucherDate, sybasePCode;
AmountMST sybaseDebitAmount, sybaseCreditAmount;
Name axDate, axTime, axVoucherNum, axSCode, axCostCenter, axYearTag, axRemarks;
Name axMethodOfPay, axPostingProfile, axBranchNum, axYear, axUser, axVoucherDate, axPCode;
AmountMST axDebitAmount, axCreditAmount;
INC_SybaseTansaction sybaseTansaction;
INC_CostCenter costCenter;
INC_SybasePaymMethods sybasePaymMethods;
INC_CostCenterDimension costCenterDimension;
custLedger custLedger;
CustLedgerAccounts custLedgerAccounts;
int rwCnt;
System.Array files;
FilePath fPath;
Filename fileName,
filePath,
fileType;
FileNameType fPattern = “*.csv”;
int fileCount;
int i;
str nextFile;
DimensionStorage dimensionStorage;
DimensionAttribute branchDimensionAttribute;
DimensionAttributeValue newBranchValue;
container dimConAttr, dimConValue;
real numPatientId, numFileNo;
str dumpFPath;
Set permissionSet;
Filename fType;
//this.header();
try
{
select firstOnly parameters;
fPath = parameters.IntegrationFolder;
new InteropPermission(InteropKind::ClrInterop).assert();
files = System.IO.Directory::GetFiles(fPath, fPattern);
if (files)
{
fileCount = files.get_Length();
if(fileCount)
{
for(i=0; i 1) //To skip header of csv
{
sybaseCollectionType = conPeek(record, 1);
sybaseDate = conPeek(record, 2);
sybaseTime = conPeek(record, 3);
sybaseVoucherNum = conPeek(record, 4);
sybaseSCode = conPeek(record, 5);
sybaseCostCenter = conPeek(record, 6);
sybaseYearTag = conPeek(record, 7);
sybaseRemarks = conPeek(record, 8);
sybaseMethodOfPay = conPeek(record, 9);
sybasePostingProfile = conPeek(record, 10);
sybaseDebitAmount = conPeek(record, 11);
sybaseCreditAmount = conPeek(record, 12);
sybaseBranchNum = conPeek(record, 13);
sybaseYear = conPeek(record, 14);
sybaseUser = conPeek(record, 15);
sybaseVoucherDate = conPeek(record, 16);
sybasePCode = conPeek(record, 17);
select firstOnly sybaseTansaction where sybaseTansaction.SybaseTransCode == sybaseCollectionType;
axJournalName = sybaseTansaction.AXTransCode;
select firstOnly sybasePaymMethods where sybasePaymMethods.SybasePaymMetghodCode == sybaseMethodOfPay;
axMethodOfPay = sybasePaymMethods.AXPaymMethodCode;
select firstOnly costCenter where costCenter.SybaseCostCenter == sybaseCostCenter;
axCostCenter = costCenter.AXCostCenterCode;
select custLedgerAccounts
join custLedger
where CustLedgerAccounts.PostingProfile == custLedger.PostingProfile
&& custLedger.PostingProfile == sybasePostingProfile;
axCreditAmount = sybaseCreditAmount;
axDebitAmount = sybaseDebitAmount;
axRemarks = sybaseRemarks;
select costCenterDimension where costCenterDimension.CostCenter == sybaseCostCenter;
//Validations. Do not proceed to insert data
if (!sybaseCollectionType)
{
validJournal = checkFailed(strFmt(“Please enter jounal name in the import sheet %1, row number %2”, nextFile, rwCnt));
continue;
}
if (!sybasePostingProfile)
{
validJournal = checkFailed(strFmt(“Please enter posting pofile in the import sheet %1, row number %2”, nextFile, rwCnt));
continue;
}
if (validJournal)
{
if(rwCnt == 2)
{
this.createHeader(axJournalName);
}
this.createLines( parameters.CustAccount
, “”
, axRemarks
, axCreditAmount
, axDebitAmount
, sybaseVoucherNum
, sybaseYearTag
, sybaseUser
, custLedgerAccounts.SummaryLedgerDimension,
sybasePostingProfile
, costCenterDimension.DimensionDefault);
}
}
}
}
//Move file after reading successfully.
if (validJournal)
{
io = null;
info(strFmt(“Journal %1 created”, ledgerJournalTable.JournalNum));
System.IO.File::Move(nextFile, dumpFPath);
info(‘Source file is moved to dump folder’);
ttsCommit;
}
else
{
checkFailed(strFmt(“Errors recorded in file %1”, nextFile));
ttsAbort;
}
}
}
else if(!fileCount)
{
checkFailed(strFmt(“Source CSV file is not found in given location %1”, nextFile));
}
}
}
catch(Exception::Error)
{
throw error(“Error in creating Journals”);
//ttsAbort;
}
}
No comments:
Post a Comment