Sage 300 SDK

Hello, I am very new to development with Sage 300 and using the SDK -- in fact I have not started yet, but before I get started I would like to ask a question. First off, I need to clarify that I'm talking about a version of Sage 300 installed on a server (many years ago I think it was called ACCPAC), not the clould version. When I first started looking at this, one of the most confusing parts is knowing what product exactly are you talking about as Sage has so many. 

My question is hopefully simple. I need to import files into Sage from an external client. I have a web api that recieves the files from the client and I have access to the local Sage installation. So the question is simple. Does the Sage 300 SDK support this type of functionality.

Thank you in advance.

Parents
  • Do you know where I can find the SDK. All the documentation I see on GitHub seems to be for Sage 300 Web SDK. Given this is a server installation, I'm guessing that this isn't what I'm looking for.

  • You don't need the Sage SDK, in fact, only specialists use it because the learning curve is so high.  I can give you code samples in VB6, VBA, C#, or VBDotNet.  

  • That would be awesome. All I need to do is import files. C# is what I use, by the way.

    Thanks.

  • You might be better off just ADO and SQL queries to pull your data.

  • I did think of that. I need to take a look at the schema though. My concern would be missing updates to secondary tables or indexes or something along those lines. That said, I might be overthinking it and it could be as simple as that. I will check it out.

  • I'm doing the opposite of extracting. I'm adding files for a specific account.

  • My bad, I read it backwards.  In general, you can't insert directly into Sage tables with SQL because it bypasses business logic.  

    Snippets below which adds a new AR customer with optional field

    using AccpacCOMAPI;

    namespace MyProgram
    {
    class Program
    {

    public static AccpacSession session;

    public static AccpacDBLink a4wLink;
    public static AccpacView ArCustomer;
    public static AccpacView ArCustomerOpt;

    session = new AccpacSession();
    session.Init("", "XY", "XY1000", "62A");
    session.Open(ACCPACUSER, ACCPACPW, Properties.Settings.Default.AccpacCompany, DateTime.Today, 0, "");

    a4wLink = session.OpenDBLink(tagDBLinkTypeEnum.DBLINK_COMPANY, tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE);

    a4wLink.OpenView("AR0024", out ArCustomer);
    a4wLink.OpenView("AR0400", out ArCustomerOpt);

    ArCustomer.Compose(new object[] { ArCustomerOpt });
    ArCustomerOpt.Compose(new object[] { ArCustomer });

    -----------------

    static bool MakeCustomer()
    {

    ArCustomer.Cancel();
    ArCustomer.Fields.FieldByName["idcust"].PutWithoutVerification(sNewCust + i.ToString("000"));
    ArCustomer.Process();

    // Default Group
    //ArCustomer.Fields.FieldByName["idgrp"].PutWithoutVerification("31100");
    ArCustomer.Fields.FieldByName["idgrp"].PutWithoutVerification(sCustGroup);

    ArCustomer.Fields.FieldByName["idacctset"].PutWithoutVerification(sAccountSet);
    ArCustomer.Fields.FieldByName["CODETERM"].PutWithoutVerification(sTerms);

    ArCustomer.Process();
    ArCustomer.Fields.FieldByName["CODESLSP1"].PutWithoutVerification(sAvalaraSalesPerson);
    ArCustomer.Fields.FieldByName["namecust"].PutWithoutVerification(order.ShippingInfo.FirstName + " " + order.ShippingInfo.LastName);
    ArCustomer.Fields.FieldByName["TEXTSTRE1"].PutWithoutVerification(sAdd1);
    ArCustomer.Fields.FieldByName["TEXTSTRE2"].PutWithoutVerification(order.ShippingInfo.AddressLine2);
    ArCustomer.Fields.FieldByName["NAMECITY"].PutWithoutVerification(order.ShippingInfo.City);
    ArCustomer.Fields.FieldByName["codepstl"].PutWithoutVerification(order.ShippingInfo.PostalCode.Replace("-", "").Substring(0, Math.Min(order.ShippingInfo.PostalCode.Length, 9)));
    ArCustomer.Fields.FieldByName["codestte"].PutWithoutVerification(order.ShippingInfo.Region);
    ArCustomer.Fields.FieldByName["codectry"].PutWithoutVerification(order.ShippingInfo.CountryCode);
    ArCustomer.Fields.FieldByName["EMAIL1"].PutWithoutVerification(order.BuyerEmailAddress);
    ArCustomer.Fields.FieldByName["EMAIL2"].PutWithoutVerification(order.BuyerEmailAddress);

    try
    {
    AddCustomerOpt("SALESTERR", "A");
    AddCustomerOpt("VENREP", "HS");
    ArCustomer.Insert();
    Console.WriteLine(ArCustomer.Fields.FieldByName["idcust"].get_Value() + " " + ArCustomer.Fields.FieldByName["namecust"].get_Value());
    }
    catch
    {
    HandleError("MakeCustomer", "");
    }
    return ArCustomer.Fields.FieldByName["idcust"].get_Value().ToString();

    }

    static void AddCustomerOpt(string sOpt, string sValue)
    {
    try
    {
    // Assumes that ArCustomerOpt as been composed
    ArCustomerOpt.Fields.FieldByName["optfield"].PutWithoutVerification(sOpt);
    if (ArCustomerOpt.Read())
    {
    ArCustomerOpt.Fields.FieldByName["value"].PutWithoutVerification(sValue);
    ArCustomerOpt.Update();
    }
    else
    {
    ArCustomerOpt.RecordGenerate(false);
    ArCustomerOpt.Fields.FieldByName["OPTFIELD"].PutWithoutVerification(sOpt);
    ArCustomerOpt.Fields.FieldByName["value"].PutWithoutVerification(sValue);
    ArCustomerOpt.Insert();
    }
    }
    catch
    {
    HandleError("AddCustomerOpt", "");
    }

    }

Reply Children
No Data