
I have been meaning to write this article for quite a while. The Batch Posting Service Toolkit (BPST) is a product created by Winthrop Development Consultants to provide a variety of methods for posting, maintaining, transferring batches, etc.
The API’s (Application Programming Interface) can be called externally as a Service Based Architecture (SBA) Web Service (for GP 2015 or later), or from inside the Microsoft Dynamics GP application using Dexterity, Visual Studio Tools (via C# or VB.Net) or via GP Power Tools.
The Batch Posting Service Toolkit is exactly that, a toolkit designed to be called by a developer and so it does not have an interface (except for testing the API). However, you can use the Scheduling functionality in GP Power Tools to post batches on a scheduled basis, read on for more details ….
Following on from the earlier article (below) we can use the same scheduling concepts to post batches using Batch Posting Service Toolkit and Dexterity calls to the global service procedures.
The approaches that can be used to execute Batch Posting Service Toolkit are described below:
- Only launch GP when desired, so a user license is not being used up. You can launch GP with the Windows Scheduler at the desired time and use the options to remember user and company, or use a macro to login. A trigger can be written to run automatically after login for the specified user (and company), and start the automations.
- If you already have a GP session that is always logged in for other tasks or are willing to have a session always logged in, you can use that session to run the trigger scheduled for a specified time. The trigger can be limited to only register for the user (and company) for that session.
- If you already have a GP session that is always logged in for other tasks or are willing to have a session always logged in, you can use that session to run the trigger on a timed basis with the trigger firing every X minutes. The trigger can be limited to only register for the user (and company) for that session.
Below is a screenshot of the BPST TEST project showing the components. There are components for both testing the BPST calls from both Dexterity and .Net (C#) and also components for starting BPST posting (as controlled by a SQL table) using the three approaches mentioned above (Scheduled, Timed and on Login).
NOTE: The triggers in the project archive are currently disabled. You must create the table with the BPST_BATCH_TABLE SQL Execute script and set the User (and Company) the project should be active for with the Users Button before enabling them (select them, right click and Enable Trigger).
Here are the Testing Batch Posting Service Toolkit components of the project:
Runtime Execute Script BPST TEST GETLIST
This Dexterity script uses the BPST TEST Parameter to get a Batch Source and calls ServiceGetBatchList to get a list of batches that are ready and available to be posted from that Batch Source.
Runtime Execute Script BPST TEST POST
This Dexterity script uses the BPST TEST Parameter to get the Batch Source and Batch and calls ServicePostBatch to post the selected batch.
.Net Execute Script BPST TEST GETLIST
This C# script uses the BPST TEST Parameter to get a Batch Source and invokes PostingServices.Procedures.ServiceGetBatchList.Invoke() to get a list of batches that are ready and available to be posted from that Batch Source.
.Net Execute Script BPST TEST POST
This C# script uses the BPST TEST Parameter to get the Batch Source and Batch and invokes PostingServices.Procedures.ServicePostBatch.Invoke() to post the selected batch.
SQL Execute Script BPST TEST LOOKUP
This SQL script displays a list of batches for a specified Batch Source (if provided) and is used by the BPST TEST Parameter List.
Parameter List BPST TEST
This Parameter List is used for both parts of the project to either request Batch Source and Batch Number details from the user as needed, or to pass parameters into the SQL Execute scripts to insert or update table records in the GPPT_AutoBatchList.
Here are the Automatic Posting components of the project:
Trigger BPST LOGIN
This trigger runs after logging into Microsoft Dynamics GP once all foreground scripts have completed. It will load and execute the BPST LOGIN Runtime Execute script in the background to queue up the posting process once all foreground and background processes have completed.
Trigger BPST SCHEDULED
This trigger is set up to run daily at 09:00 and calls the BPST BATCH QUERY Runtime Execute Script to start the posting process on a scheduled basis. You can change the timing as desired.
Trigger BPST TIMED
This trigger is set up to run every 5 minutes and calls the BPST BATCH QUERY Runtime Execute Script to start the posting process on a timed basis. You can change the frequency as desired.
Runtime Execute Script BPST BATCH QUERY
This Dexterity script is the Main workhorse of the automatic posting process. It will use the BPST BATCH QUERY SQL Execute script to obtain a list of batches (Batch Source and Batch Number) to be processed from the GPPT_AutoBatchList SQL Table. It moves the data to l_Batch_Data text variable so that it can call other scripts without interfering with the batch data obtained.
It will parse the Batch Source and Batch Number for each batch to be posted and call the ServicePostBatch service procedure. After requesting the batch to post, it will use the BATCH TEST Parameter List and the BPST BATCH UPDATE SQL Execute script to mark the batch status as posted in the GPPT_AutoBatchList SQL Table.
Runtime Execute Script BPST BATCH QUERY OLD
This Dexterity script performs the same functions as the BPST BATCH QUERY Runtime Execute script, but uses methods from before the MBS_Script_Load_SQL_DB, MBS_SQL_Execute and MBS_SQL_Parse_Data_String Helper Functions were added to GP Power Tools.
Runtime Execute Script BPST LOGIN
This script is called in the background by the BPST LOGIN trigger. It calls the BPST BATCH QUERY Runtime Execute Script to start the posting process after login and will call MBS_Exit_After_Processes to exit GP once posting has completed.
SQL Execute Script BPST BATCH INSERT
This SQL script uses the BPST TEST Parameter List and can be used to populate batches into the GPPT_AutoBatchList table. It can be called manually, or it could be used from another script as desired.
SQL Execute Script BPST BATCH QUERY
This SQL script returns a list of batches from the GPPT_AutoBatchList table for the batches awaiting posting. It is called from the BPST BATCH QUERY (and BPST BATCH QUERY OLD) Runtime Execute script.
SQL Execute Script BPST BATCH TABLE
This SQL script must be executed before using the automatic processing triggers to create the GPPT_AutoBatchList table in the company database.
SQL Execute Script BPST BATCH UPDATE
This SQL script uses the BPST TEST Parameter List and is used to update the Status flag in the GPPT_AutoBatchList table. It can also be called manually.
Downloading and Installing
Download the example code, import using the Project Setup window (without any project showing, select the path to the xml file and click Import):
The code will be active on next login or after switching companies, or you can start the triggers manually from the Project Setup window.
More Information
For more information see:
- GP Power Tools Portal: http://winthropdc.com/GPPT
- GP Power Tools Samples: http://winthropdc.com/GPPT/Samples
- GP Power Tools Videos: http://winthropdc.com/GPPT/Videos
- Batch Posting Service Toolkit: https://winthropdc.com/BPST
Hope you the techniques demonstrated in this article helpful.
David
This article was originally posted on http://www.winthropdc.com/blog.
