AX Integration, updating table in SQL
//This class created by Kiran on 20-Jun-19 for PSA integration
class ALE_ReturnInvoiceIdToDB extends RunBaseBatch
{
System.Data.OleDb.OleDbConnection objConn;
System.Data.OleDb.OleDbCommand cmdInsert,cmdUpdate,cmdSelect;
System.Data.OleDb.OleDbDataReader reader,readerUpdate;
container resultCon;
str connectStr;
ProjParameters projParameters;
}
>>.....................>>>>>>>>>>>>>>>>>>
public boolean canGoBatch()
{
return true;
}
...............................................................
protected boolean canGoBatchJournal()
{
return true;
}
.......................................................
public container pack()
{
return conNull();
}
.............................
public boolean runsImpersonated()
{
return true;
}
..........................
public boolean unpack(container _packedClass)
{
return true;
}
........................
static ClassDescription description()
{
return "Return AX Invoice Id to DB";
}
.................................
public static void main(Args args)
{
ALE_ReturnInvoiceIdToDB returnInvoiceIdToDB = new ALE_ReturnInvoiceIdToDB();
if (returnInvoiceIdToDB.prompt())
{
returnInvoiceIdToDB.run();
}
}
..................................
public void run()
{
str datestr;
String255 err;
projParameters = ProjParameters::find();
connectStr = 'Provider=SQLNCLI11;Integrated Security=SSPI;' +'Persist Security Info=False;Initial Catalog=' +
projParameters.ALE_PSA_StagingDBName + ';Data Source=' + projParameters.ALE_PSA_StagingDBServer + ';'+ 'User id= ;Password=';
try
{
this.hourJournal();
this.expenseJournal();
this.milestone();
}
catch(Exception::Error)
{
error('An Exception has occurred');
}
if(objConn)
{
objConn.Close();
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
private void hourJournal()
{
QueryBuildDataSource qbds;
Query q;
QueryRun qr;
QueryBuildRange qbr;
ALE_STG_HourJournal ale_STG_HourJournal,ale_STG_HourJournalUpdate;
ttsBegin;
objConn = new System.Data.OleDb.OleDbConnection(connectStr);
objConn.Open();
q = new query();
qbds = q.addDataSource(tableNum(ALE_STG_HourJournal));
qbds.addRange(fieldNum(ALE_STG_HourJournal,Status)).value('3');
qr = new QueryRun(q);
while (qr.next())
{
ale_STG_HourJournal = qr.get(tableNum(ALE_STG_HourJournal));
if(ale_STG_HourJournal.AXInvoiceId)
{
cmdUpdate = objConn.CreateCommand();
cmdUpdate.set_CommandText(strFmt('UPDATE HourJournal SET AXInvoiceId =' + "'%1'" + ' where GUID = ' + "'%2'",ale_STG_HourJournal.AXInvoiceId,ale_STG_HourJournal.GUID));
cmdUpdate.ExecuteNonQuery();
//update_recordSet ale_STG_HourJournalUpdate
//setting ProcessingStatus = Ale_ProcessingStatus::Processed
//where ale_STG_HourJournalUpdate.RecId == ale_STG_HourJournal.RecId;
}
}
ttsCommit;
}
//This class created by Kiran on 20-Jun-19 for PSA integration
class ALE_ReturnInvoiceIdToDB extends RunBaseBatch
{
System.Data.OleDb.OleDbConnection objConn;
System.Data.OleDb.OleDbCommand cmdInsert,cmdUpdate,cmdSelect;
System.Data.OleDb.OleDbDataReader reader,readerUpdate;
container resultCon;
str connectStr;
ProjParameters projParameters;
}
>>.....................>>>>>>>>>>>>>>>>>>
public boolean canGoBatch()
{
return true;
}
...............................................................
protected boolean canGoBatchJournal()
{
return true;
}
.......................................................
public container pack()
{
return conNull();
}
.............................
public boolean runsImpersonated()
{
return true;
}
..........................
public boolean unpack(container _packedClass)
{
return true;
}
........................
static ClassDescription description()
{
return "Return AX Invoice Id to DB";
}
.................................
public static void main(Args args)
{
ALE_ReturnInvoiceIdToDB returnInvoiceIdToDB = new ALE_ReturnInvoiceIdToDB();
if (returnInvoiceIdToDB.prompt())
{
returnInvoiceIdToDB.run();
}
}
..................................
public void run()
{
str datestr;
String255 err;
projParameters = ProjParameters::find();
connectStr = 'Provider=SQLNCLI11;Integrated Security=SSPI;' +'Persist Security Info=False;Initial Catalog=' +
projParameters.ALE_PSA_StagingDBName + ';Data Source=' + projParameters.ALE_PSA_StagingDBServer + ';'+ 'User id= ;Password=';
try
{
this.hourJournal();
this.expenseJournal();
this.milestone();
}
catch(Exception::Error)
{
error('An Exception has occurred');
}
if(objConn)
{
objConn.Close();
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
private void hourJournal()
{
QueryBuildDataSource qbds;
Query q;
QueryRun qr;
QueryBuildRange qbr;
ALE_STG_HourJournal ale_STG_HourJournal,ale_STG_HourJournalUpdate;
ttsBegin;
objConn = new System.Data.OleDb.OleDbConnection(connectStr);
objConn.Open();
q = new query();
qbds = q.addDataSource(tableNum(ALE_STG_HourJournal));
qbds.addRange(fieldNum(ALE_STG_HourJournal,Status)).value('3');
qr = new QueryRun(q);
while (qr.next())
{
ale_STG_HourJournal = qr.get(tableNum(ALE_STG_HourJournal));
if(ale_STG_HourJournal.AXInvoiceId)
{
cmdUpdate = objConn.CreateCommand();
cmdUpdate.set_CommandText(strFmt('UPDATE HourJournal SET AXInvoiceId =' + "'%1'" + ' where GUID = ' + "'%2'",ale_STG_HourJournal.AXInvoiceId,ale_STG_HourJournal.GUID));
cmdUpdate.ExecuteNonQuery();
//update_recordSet ale_STG_HourJournalUpdate
//setting ProcessingStatus = Ale_ProcessingStatus::Processed
//where ale_STG_HourJournalUpdate.RecId == ale_STG_HourJournal.RecId;
}
}
ttsCommit;
}
No comments:
Post a Comment