How to Post the AR or AP Batch using Accpac Advantage.

SUGGESTED

Hi all, I have already created C# program using Accpac Advantage to import AR and AP Batches into sage in Ready to Post Mode. But my client wants it to auto post after import to sage. So, is there any tutorial or example that I can reference for doing this since I am quite new in this area? Thank you for your help and guidance in advance!

Parents Reply Children
  • 0 in reply to Hein Thu
    SUGGESTED

    The easiest way to work this out is to record a macro where you create a new batch, add an invoice, and then post it. Then take the macro code and convert it to C#.

    The code to post an AR batch is here though:

            private bool PostARInvoiceBatch(out string psError)
            {
                // oARIBC = AR0031
                // oARPostInv = AR0048
                bool bSuccess = false;
    
                psError = "";
    
                if (mbDebugMode) { HandleLogRequest($"In {MethodBase.GetCurrentMethod().Name}"); }
    
                try
                {
                    oARIBC.Fields.FieldByName("PROCESSCMD").SetValue("2", false);
                    oARIBC.Process();
                    oARIBC.Fields.FieldByName("BTCHSTTS").SetValue("7", true);
                    oARIBC.Update();
                    oARIBC.Fields.FieldByName("PROCESSCMD").SetValue("0", false);
                    oARIBC.Process();
                    oARPostInv.Fields.FieldByName("BATCHIDFR").SetValue(oARIBC.Fields.FieldByName("CNTBTCH").Value.ToString().Trim(), false);
                    oARPostInv.Fields.FieldByName("BATCHIDTO").SetValue(oARIBC.Fields.FieldByName("CNTBTCH").Value.ToString().Trim(), false);
                    oARPostInv.Process();
    
                    bSuccess = true;
                }
                catch (Exception ex)
                {
                    psError = $"There was a problem posting AR invoice batch: '{ex.Message + Environment.NewLine + WriteSageErrorsToLog()}'";
                    HandleLogRequest(psError);
                }
    
                return bSuccess;
            }
    

    I have added comments telling you which views these are. You will need to know how to compose the views.