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
  • 0

    Are you using the .NET API, COM API, or the web API?

  • 0 in reply to Vega

    I am Using accpac advantage dll to open the view and import. But any reference would be fine. I just want to know how to post the batches in C# using this dll.

     

  • 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.

Reply
  • 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.

Children
No Data