web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / i-am-ax-pankaj / created date time old date ...

created date time old date time insert in AX 2012

I AM AX PANKAJ Profile Picture I AM AX PANKAJ 419

public class AWE_BillingTransaction
{
}

public static void main(Args _args)
{
AWE_BillingTransaction AWTrans;
AWTrans = new AWE_BillingTransaction();
AWE_BillingTransaction::Run();
}

Static server void Run()
{
AweBillingTransactions awTrans;
container record;
str Delimiter = ",";
int totalRecords;
AweExternalSystem externalSystem;
AweRecordStatus recordStatus;

fileIOpermission permission;
Set PermissionSet;
TextIo textiO;
FilenameOpen sfileName = @"D:\pankaj kumar\Billing Staging table data New.csv"; 
container c;
int i=1;
IO iO;
#file
;
PermissionSet = new Set(Types::Class);
PermissionSet.add(new FileIoPermission(sfilename,'r'));
PermissionSet.add(new OverwriteSystemFieldsPermission());
CodeAccessPermission::assertMultiple(PermissionSet);

iO = new CommaTextIo(sfilename,#IO_Read);

if (!iO || iO.status() != IO_Status::Ok)
{
warning("Error in opening import file");
throw(Exception::Error);
}

try
{
ttsbegin;
record = io.read();
while(iO.status() == IO_Status::Ok)
{

record = iO.read();
if(!record)
break;
totalRecords = totalRecords + 1;
awTrans.clear();
awTrans.overwriteSystemfields(true);
awTrans.AXCustomerAccount = conPeek(record,1);
awTrans.AXLegalEntity = conPeek(record,2);
awTrans.AXSalesAgreement = conPeek(record,3);
awTrans.BillingAmount = conPeek(record,4);
awTrans.BillingCode = conPeek(record,5);

awTrans.(fieldNum(AweBillingTransactions, BillingDate )) = DateTimeUtil::removeTimeZoneOffset(str2datetime(conPeek(record,6),213), DateTimeUtil::getCompanyTimeZone());

awTrans.BillingTax = conPeek(record,7);
awTrans.CustomerAccount = conPeek(record,8);
awTrans.EnrollmentNumber = conPeek(record,9);
awTrans.InvoiceNumber = conPeek(record,10);
awTrans.MessageId = str2guid(conPeek(record,11));
awTrans.OrderId = conPeek(record,12);
awTrans.OrgId = conPeek(record,13);
awTrans.OriginalLine = conPeek(record,14);

awTrans.(fieldNum(AweBillingTransactions, PostingDate )) = DateTimeUtil::removeTimeZoneOffset(str2datetime(conPeek(record,15),213), DateTimeUtil::getCompanyTimeZone());

awTrans.PremiseNumber = conPeek(record,16);
awTrans.Processed = conPeek(record,17);
awTrans.ProductCode = conPeek(record,18);
awTrans.SourceName = conPeek(record,19);
awTrans.SourceProductCode = conPeek(record,20);
awTrans.TaxAmount = str2num(conPeek(record,21));
awTrans.TaxCode = conPeek(record,22);

awTrans.(fieldNum(AweBillingTransactions, CreatedDateTime )) = DateTimeUtil::removeTimeZoneOffset(str2datetime(conPeek(record,23),213), DateTimeUtil::getCompanyTimeZone());

awTrans.note = conPeek(record,24);
awTrans.RecordStatus = conPeek(record,25);


awTrans.(fieldNum(AweBillingTransactions, OrigPostingDate )) = DateTimeUtil::removeTimeZoneOffset(str2datetime(conPeek(record,26),213), DateTimeUtil::getCompanyTimeZone());

awTrans.ErrorSORefRecId = str2int64(conPeek(record,27));

awTrans.insert();
awTrans.overwriteSystemfields(false);
}
CodeAccessPermission::revertAssert();
ttscommit;
}
catch(Exception::Error)
{
Throw(Exception::Error);
}
info(strFmt("Total Read Records = %1",totalRecords));

}

Comments

*This post is locked for comments