SBA environment might not match Dynamics GP environment

David Meego - Click for blog homepageWhile testing Batch Posting Service Toolkit (BPST), a customer identified an issue with Inventory Posting.

When an inventory batch was posted from the Microsoft Dynamics GP client it would post to the General Ledger, however, a similar batch posted via Web Services and Service Based Architecture it would fail to post to GL.

After the initial double checking of my source code, I confirmed that the BPST code was correct and that the Post to GL checkbox on the Batch Header and the Post to GL Posting setting for inventory were being handled correctly.

Reviewing the source code for Dynamics I was able to locate the code in the IV_Post_Batch global procedure which decides if a batch will post to the GL.

if ('Post to General Ledger' of file SY_Posting_Journal_Settings) and
(IN_post_to_gl) and ('Module Loaded'[GL] of globals) and ('Module Registered'[GL] of globals) then
set l_POSTING_TO_GL to true;
end if;

You will note that it checks the IN_post_to_gl variable which is the Post to GL setting from the Batch Header table. It also checks the Post to GL setting from the posting setup table and finally checks that the GL module is loaded and registered.

We knew that the two settings from tables were correctly set as we had checked them and the batch would post to GL when posted from inside Dynamics GP using the BPST testing window.

So we realised that the problem must have been environmental. By that I mean that something was different between being inside Dynamics GP and making a web service call via Service Based Architecture. How could we check the values of the global variables without having to make a special BPST build?

Using GP Power Tools (GPPT) and its ability to create custom web services, we built a script to be called from a web service to return the values for ‘Module Loaded'[GL] of globals and ‘Module Registered'[GL] of globals. What we found was that ‘Module Registered'[GL] of globals was set to true, but ‘Module Loaded'[GL] of globals was false.

Adding the line ‘Module Loaded'[GL] of globals = true; into the BPST inventory posting code fixed the issue. But there is a bigger picture issue to be addressed.

As a developer writing code for Service Based Architecture, you cannot be sure that the SBA environment will match Dynamics GP environment. The environment is set up by the ServiceLogin global procedure and this script might not populate all the variables that would be initialized when the full client is executed.

I logged a bug with Microsoft to get the ‘Module Loaded'[] of globals array initialized in the future.

A final note, it is very unlikely that any of the 3rd party or ISV products have initialized their variables as they probably don’t trigger after the ServiceLogin script.

Hope you find this information useful.


This article was originally posted on

2 thoughts on “SBA environment might not match Dynamics GP environment

Please post feedback or comments

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s