Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Stored procedures called to post batches

Posted on by 75,730

I finished an import routine that imports bank transfers and creates a resulting ledger transaction batch. The final piece is the client wants this batch to automatically post.

Running SQL Profiler, I found what I think are the three stored procedures involved. These are:

1) DYNAMICS.dbo.zDP_SY00800SI

2) dbo.glpCreatePostingActivity

3) SCHLD.dbo.glpBatchCleanup

Will calling these three stored procedures be all that is needed?

Categories:
  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,926 Most Valuable Professional on at
    RE: Stored procedures called to post batches

    All Winthrop products are sold as annual subscription to the customer for the system (no affected by user or company counts).

    David

  • Richard Wheeler Profile Picture
    Richard Wheeler 75,730 on at
    RE: Stored procedures called to post batches

    David, I am already over budget on this project and the thought of incurring an additional cost was just too much. It is not often I get asked to post GP batches programmatically. In the future I will consider it. How does the licensing work. Is each customer using this toolkit getting charged or is it an annual fee to the developer?

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,926 Most Valuable Professional on at
    RE: Stored procedures called to post batches

    You could have saved so much time and effort just using Batch Posting Service Toolkit (BPST) with the following code:

    using Microsoft.Dexterity.Applications.PostingServicesDictionary;

    PostingServices.Procedures.ServicePostBatch.Invoke(BatchSource, BatchNumber);

    David

  • Richard Wheeler Profile Picture
    Richard Wheeler 75,730 on at
    RE: Stored procedures called to post batches

    After much research I have gotten this code to work. I need to experiment more to stop the print dialog box popping up.

           public static bool PostBatch(string batchNumber)

           {

               //clear posting destid's array.

               string[] DestID = new string[] { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" };

               string BatchSource = "GL_Normal";                                               /* BATCH_SOURCE_GL_ENTRY                    */

               Int16 nWindowType = 2;                                                          /* BATCH_WINDOW                             */

               Int16 nActivityType = 2;                                                        /* SY_BA_EDITLIST = 3, SY_BA_POSTING = 2    */

               bool EditList = false;

               //inout nStatus in posting call

               Microsoft.Dexterity.Bridge.Field<short> nStatus = new Field<short>(0);

               Field<string> reportDestination = new Field<string>("");

               Microsoft.Dexterity.Applications.Dynamics.Procedures.PostingRptDestWdw.Invoke("", "GENERAL POSTING JOURNAL", "GENERAL POSTING JOURNAL", "GENERAL POSTING JOURNAL", 3, ref reportDestination);

               DestID[0] = reportDestination.Value;                                            /* copy our read/write destid from above to our array */

               //Initialize it with our array above

               FieldArray<string> DestIDArray = DestID;

               //for GL Posting, there is 1 report.

               //Send reports to screen only

               DestID[0] = String.Format("TF{0}{1}{2}{3}{4}", "T", "F", "F", ((int)FILEOUTPUT.NONE).ToString().PadLeft(4).ToString(), "");

               //Dynamics.Forms.Batch.Procedures.Post.Invoke(BatchSource, batchNumber, nWindowType, nActivityType, DestID, ref nStatus);             /* call posting, edit list routine */

               //Dynamics.Forms.GlBatchEntry.Procedures.PostBatch.Invoke(EditList, nWindowType, batchNumber, BatchSource, DestID, ref nStatus);

               Dynamics.Forms.GlBatchEntry.Procedures.PostBatch.Invoke(EditList, nWindowType, batchNumber, BatchSource, DestID);

               if (nStatus != 0)

               {

                   MessageBox.Show("Posting failed");

               }

               return true;

           }

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,926 Most Valuable Professional on at
    RE: Stored procedures called to post batches

    Thanks Andrew for the insight.

    To be honest, you would probably have a more stable solution just driving the UI on the Batch Entry window.

    or (of course) BPST.

    Regards

    David

  • Suggested answer
    Andrew John Dean Profile Picture
    Andrew John Dean 1,337 on at
    RE: Stored procedures called to post batches

    Hi Richard

    I have been monitoring your discussion with David and see that you have figured out how to use VST to post batches.

    There is just one area of VST logic that I need to make you aware of. If you are simply calling the posting function as a one-shot routine after importing transactions from a spreadsheet, then your code will work successfully  

    If however, you are running in a continuous timer loop, GP will eventually crash after about 10-20 batches being posted. Hope this information doesn’t come as “rain-on-your-parade”

    Regards
    Andrew Dean

  • Richard Wheeler Profile Picture
    Richard Wheeler 75,730 on at
    RE: Stored procedures called to post batches

    David, I just successfully posted my first ledger batch without any edit list appearing on the screen or printing. It was quite the challenge not only finding the method but the parameters to pass to it. I cannot believe there is no documentation for this. I am going to do some routine testing over the weekend and submit this to user acceptance testing. I may or may not need BPST. It is good to know that it is there.

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,926 Most Valuable Professional on at
    RE: Stored procedures called to post batches

    Hi Richard

    If you only want to call Batch Posting Service Toolkit from a VS Tools Addin. You don't need IIS and SBA set up.

    You only need IIS and SBA if you want to call it via a web service.

    You can call BPST from Dexterity, C#, VB.Net or GP Power Tools just by installing it.

    Regards

    David 

  • Richard Wheeler Profile Picture
    Richard Wheeler 75,730 on at
    RE: Stored procedures called to post batches

    By the way, the sample code does successfully post the SOP batch so it can be done. I just need to figure out the correct parameter values to send down to

               Dynamics.Forms.Batch.Procedures.Post.Invoke(BatchSource, batchNumber, nWindowType, nActivityType, DestID, ref nStatus);    

    I have BatchSource = "GL_Entry"

    batchnumber is the batch ID

    nWindowType 2 or 3

    nActivityType 2 or 3.

    I can live with the journal printing to the screen.

  • Richard Wheeler Profile Picture
    Richard Wheeler 75,730 on at
    RE: Stored procedures called to post batches

    Yes, but then I need to install Web Services and run IIS on the server. Too much over head just to post batches.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans