Finally found the solution for this problem.
I had to print the Pro forma invoice for all the proforma packing slip.
TO achieve this i did the following thing.
I created new method in salesformletter class.
ex. printProformaInvoice()
In this method copy and paste all the code of run method.
Comment all the code in which remove or delete operation in involved.
//Added on dt 09/08/2012 KD
public void ProformaInvoice()
{
#OCCRetryCount
QueryRun query;
Counter infoLogCounter;
LogText logText;
boolean updateError;
dataAreaId curExtPreProgress = curext();
SalesFormLetterEndMultiThread salesFormLetterEndMultiThread;
FormLetterMultiThread formLetterMultiThread;
;
startDateTimeUpdate = DateTimeUtil::newDateTime(systemdateget(),timenow(),DateTimeUtil::getUserPreferredTimeZone());
this.progressInit("@SYS25781", progressTotal, #AviFormLetter);
progress.setText("@SYS26577");
if (salesParmUpdate.LateSelection)
{
if (!SalesParmUpdate::exist(this.parmId()))
{
this.parmId(NumberSeq::newGetNum(CompanyInfo::numRefParmId()).num());
this.createParmUpdateFromParmUpdateRecord(this.salesParmUpdate());
}
if (this.isInBatch())
{
// this.resetParmListCommonCS();
this.transDate(systemdateget());
}
chooseLines = new QueryRun(salesParmUpdate.LateSelectionQuery);
this.chooseLines();
if (salesParmUpdate.numberOfLines() < 1)
checkFailed("@SYS26185");
}
else
{
if (this.isInBatch())
{
this.transDate(salesParmTable.Transdate);
}
}
if ( reArrangeNow && !this.reArrange(false) &&
!salesTable.QuotationId)
{
throw error("@SYS18447");
}
if (this.canMultiThread())
{
batchHeader = BatchHeader::construct(this.parmCurrentBatch().BatchJobId);
salesFormLetterEndMultiThread = SalesFormLetterEndMultiThread::newFormLetter(this,
salesParmUpdate.ParmId,
salesParmUpdate.Proforma);
batchHeader.addRuntimeTask(salesFormLetterEndMultiThread,this.parmCurrentBatch().RecId);
}
query = this.queryBuild();
if (printout == Printout::After && ! this.proforma())
{
journalList = this.newJournalList();
}
setprefix("@SYS25781");
while (query.next())
{
infoLogCounter = infolog.num();
infolog.updateViewSet(this);
if (printout == Printout::Current || this.proforma())
{
journalList = this.newJournalList();
}
salesParmTable = query.get(tablenum(SalesParmTable));
if (salesParmTable.SalesId != salesTable.SalesId)
{
salesTable = salesParmTable.salesTable();
}
if (this.checkIfSalesOrderExist(salesTable))
{
try
{
if (batchHeader)
{
formLetterMultiThread = FormLetterMultiThread::newFormLetter(this);
batchHeader.addRuntimeTask(formLetterMultiThread,this.parmCurrentBatch().RecId);
ttsbegin;
batchHeader.save();
ttscommit;
}
else
{
this.createJournal();
}
}
catch (Exception::Deadlock)
{
#if.never //#Speedtest
if (speedExecute_Sales)
speedExecute_Sales.timing(SpeedSalesTiming::DeadLockInvoice, salesParmLine.itemId);
#endif
// this.removeRecIdSuspension();
// this.removeJournalFromList();
retry;
}
catch (Exception::UpdateConflict)
{
// this.removeRecIdSuspension();
if (appl.ttsLevel() == 0)
{
if (xSession::currentRetryCount() >= #RetryNum)
{
throw Exception::UpdateConflictNotRecovered;
}
else
{
// this.removeJournalFromList();
retry;
}
}
else
{
throw Exception::UpdateConflict;
}
}
catch (Exception::Error)
{
// this.removeRecIdSuspension();
// this.removeJournalFromList();
updateError = true;
ttsbegin;
logText = Info::infoCon2Str(infolog.copy(infoLogCounter+1,infolog.num()));
infolog.updateViewSet(this, false);
this.setForUpdateSalesParmTable();
salesParmTable.Log = logText;
salesParmTable.updateParmJobStatusContainErrors();
ttscommit;
}
}
else
{
if (salesParmUpdate.SumBy == AccountOrder::None)
info(strfmt("@SYS15067", salesParmTable.SalesId));
}
infolog.updateViewSet(this, false);
}
/* if (batchHeader)
{
batchHeader.save();
}
else
*/
if(!batchHeader)
{
if (printout == Printout::After && ! salesParmUpdate.Proforma)
this.printJournal();
// this.endUpdate();
}
progress = null;
if (updateError)
throw error("@SYS78886");
}
//Ended on dt 09/08/2012 by KD
After doing this the method is ready.
After this,i did modifcation in SalesEditLines form in “CloseOk()” method.
The code is as below.
void closeOk()
{
args args;
object object;
//Added on dt 09/08/2012 by KD
SalesFormLetter sales = SalesFormLetter::construct(DocumentStatus::Invoice);
SalesParmTable salesParm;
//Ended on dt 09/08/2012 by KD
;
if ((salesParmUpdate.GiroType == PaymentStubInclAll::FIK751 || salesParmUpdate.GiroType == PaymentStubInclAll::FIK752)
&& strlen(CompanyInfo::find().fiCreditorID_DK) == 0)
{
throw error("@SYP2557");
}
if (salesParmUpdate.GiroType == PaymentStubInclAll::FIK751)
{
throw error("@SYP2572");
}
if (salesParmUpdate)
salesParmUpdate_ds.write();
if (salesParmTable.RecId)
salesParmTable_ds.write();
if (salesParmSubTable)
salesParmSubTable_ds.write();
if (salesParmLine)
salesParmLine_ds.write();
if (salesEditLinesForm.giro())
element.checkGiroSettings();
salesFormLetter.initParameters(salesParmUpdate.data(),
print_Combo.selection(),
printFormletter.value(),
printCODLabelChoice,
printCallTagChoice,
printShippingLabelChoice,
usePrintManagement.value(),
true);
//
if (EInvoiceParameters_MX::isElectronicInvoiceEnabled())
{
salesFormLetter.initEInvoiceFields_MX(sendByMail_MX.value());
}
//
salesFormLetter.editLinesChanged(editLinesChanged);
salesFormLetter.reArrangeNow(reArrangeNow);
super();
//Added on dt 09/08/2012 by KD
if(chkPrintInvoice.checked())
{
ttsbegin;
salesParm = SalesParmTable_ds.cursor();
sales.salesTable(salesParm.salesTable());
sales.transDate(systemdateget());
sales.proforma(true);
sales.printFormLetter(true);
sales.printCODLabel (NoYes::No);
sales.printFreightSlip (NoYes::No);
sales.printShippingLabel (NoYes::No);
sales.usePrintManagement(false);
sales.creditRemaining(false);
sales.createParmUpdate(false);
sales.initParameters(salesParmUpdate,Printout::Current);
sales.giroType(salesTable.GiroType);
sales.ProformaInvoice();
ttscommit;
}
//Ended on dt 09/08/2012 by KD
}
And then added a new check box control named “chkPrintInvoice” on the form.
This worked for me as it was needed.
Hope this would be helpfull for you.
Thnx,
Kirtan