we created a new controls (allow customer invoice , dis allow customer invoice )
allow customer invoice change value of line property of category in PO to be nonchargeable (if chargeable set it noncharge ) and dis allow customer invoice gets value of line property from category and set it in line property in PO
I tried to debug update in purch line table after changing this values but I got this error I tried to build model and sync database but no thing is working
This is our code in class allow customer invoice :
public class AllowCustomerInvoiceCFM extends RunBase { public static void main(Args args) { if (args) { PurchTable PurchTable, _PurchTable; PurchLine PurchLine, _PurchLine ,_purchLineOrig; AllowCustomerInvoice AllowCustomerInvoice; FormRun PurchForm = args.caller(); FormDataSource PurchLine_DS; DialogButton diagBut; purchLineType purchLineType; str strMessage = "Are you sure you want to allow customer invoice?"; str strTitle = "Allow Customer Invoice"; diagBut = Box::yesNo(strMessage, DialogButton::Yes, strTitle); if(diagBut == DialogButton::No) { //your own code when user click on No button return; } else if(diagBut == DialogButton::Yes) { //your own code when user click on Yes button select * from PurchTable where PurchTable.RecId == args.record().RecId; while select PurchLine where PurchLine.PurchId == PurchTable.PurchId && PurchLine.PurchStatus != PurchStatus::Invoiced && PurchLine.PurchStatus != PurchStatus::Canceled { ttsbegin; select forupdate AllowCustomerInvoice where AllowCustomerInvoice.PurchLine == PurchLine.RecId; if(AllowCustomerInvoice) { AllowCustomerInvoice.AllowInvoice = NoYes::Yes; AllowCustomerInvoice.update(); } else { AllowCustomerInvoice.PurchLine = PurchLine.RecId; AllowCustomerInvoice.AllowInvoice = NoYes::Yes; AllowCustomerInvoice.insert(); } ttscommit; if(PurchTable.DocumentState ==VersioningDocumentState::Draft) { select forupdate _PurchLine where _PurchLine.PurchId == PurchTable.PurchId; if (_PurchLine) { _PurchLine.ProjLinePropertyId = 'Noncharge'; purchLineType = _PurchLine.type(); ttsBegin; _PurchLine.update(); ttsCommit; } } else { select forupdate _PurchTable where _PurchTable.PurchId == PurchTable.PurchId; _PurchTable.DocumentState = VersioningDocumentState::Draft; ttsBegin; _PurchTable.doUpdate(); ttsCommit; select forupdate _PurchLine where _PurchLine.PurchId == PurchTable.PurchId; if (_PurchLine) { _PurchLine.ProjLinePropertyId = 'Noncharge'; purchLineType = _PurchLine.type(); ttsBegin; _PurchLine.update(); ttsCommit; } _PurchTable.DocumentState = PurchTable.DocumentState; ttsBegin; _PurchTable.doUpdate(); ttsCommit; } } } Info("Done"); } } }
How can I fix this issue ? Its a cloud environment with version 33
it is not a custom table I tried to sync and not working , now I am getting this error also
Seems it's a synch error. Is SourceDocumentLineImplementation custom table or standard table. Try a full DB Synchronization and check.
Seems it's a custom table.
Thanks,
Girish S.
I changed code with Girish updated also I got this error
In your code, ttsbegin at Line# 37 is added inside while select statement and ttscommit is added outside the loop at line# 55. You can try moving ttsBegin to line 31.
You need to encapsulate the update method with ttsbegin and ttscommit.
Try the below code and check if it works.
public class AllowCustomerInvoiceCFM extends RunBase { public static void main(Args args) { if (args) { PurchTable PurchTable, _PurchTable; PurchLine PurchLine, _PurchLine ,_purchLineOrig; AllowCustomerInvoice AllowCustomerInvoice; FormRun PurchForm = args.caller(); FormDataSource PurchLine_DS; DialogButton diagBut; purchLineType purchLineType; str strMessage = "Are you sure you want to allow customer invoice?"; str strTitle = "Allow Customer Invoice"; diagBut = Box::yesNo(strMessage, DialogButton::Yes, strTitle); if(diagBut == DialogButton::No) { //your own code when user click on No button return; } else if(diagBut == DialogButton::Yes) { //your own code when user click on Yes button select * from PurchTable where PurchTable.RecId == args.record().RecId; while select PurchLine where PurchLine.PurchId == PurchTable.PurchId && PurchLine.PurchStatus != PurchStatus::Invoiced && PurchLine.PurchStatus != PurchStatus::Canceled { select forupdate AllowCustomerInvoice where AllowCustomerInvoice.PurchLine == PurchLine.RecId; if(AllowCustomerInvoice) { ttsbegin; AllowCustomerInvoice.AllowInvoice = NoYes::Yes; AllowCustomerInvoice.update(); ttscommit; } else { AllowCustomerInvoice.PurchLine = PurchLine.RecId; AllowCustomerInvoice.AllowInvoice = NoYes::Yes; AllowCustomerInvoice.insert(); } if(PurchTable.DocumentState ==VersioningDocumentState::Draft) { select forupdate _PurchLine where _PurchLine.PurchId == PurchTable.PurchId; if (_PurchLine) { _PurchLine.ProjLinePropertyId = 'Noncharge'; purchLineType = _PurchLine.type(); ttsBegin; _PurchLine.update(); ttsCommit; } } else { select forupdate _PurchTable where _PurchTable.PurchId == PurchTable.PurchId; _PurchTable.DocumentState = VersioningDocumentState::Draft; ttsBegin; _PurchTable.doUpdate(); ttsCommit; select forupdate _PurchLine where _PurchLine.PurchId == PurchTable.PurchId; if (_PurchLine) { _PurchLine.ProjLinePropertyId = 'Noncharge'; purchLineType = _PurchLine.type(); ttsBegin; _PurchLine.update(); ttsCommit; } _PurchTable.DocumentState = PurchTable.DocumentState; ttsBegin; _PurchTable.doUpdate(); ttsCommit; } } } Info("Done"); } } }
Thanks,
Girish S.
Hi Mohit , it was one ttsbegin and one ttscommit and still the same error , I saw this solution to put them before and after update of tables so I change them
Hi Menna, Can you try commenting all ttsBegin and ttscommit in your code and add just one ttsBegin in the beginning and ttsCommit in the end of main method of your class.
André Arnaud de Cal...
291,996
Super User 2025 Season 1
Martin Dráb
230,853
Most Valuable Professional
nmaenpaa
101,156