Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Apply payables documents programmatically

Posted on by Microsoft Employee

Dear Microsoft Dynamics GP Community,

We want to programmatically apply payables documents in Microsoft Dynamics GP.  We want to do this programmatically because we are automating creating payables documents and we also want to automatically apply them to eliminate the chance for human error and because there might be a large number of these documents.

Also, during the apply process, in order to satisfy certain business rules, we want to have control over which documents are applied with each other.  For example, for a given vendor, we might want to apply a credit memo to one invoice, but not to another invoice.  We also want to specify the apply amount.  This is the functionality that is available in the Apply Payables Documents window.

Has anyone programmatically applied payables documents?  I haven't found much information on this in the GP SDK, or in web searches.  I want to make sure that I'm inserting and updating tables correctly, running the correct procedures, etc.  I also want to make sure that I set correct field values in the apply tables and correctly move documents to history.

We have already tried some things.  We first tried to programmatically access the Apply Payables Documents window with .NET and with Modifier, but ran into difficulties when trying to interact with the scrolling window.  We haven't tried this with Dexterity yet.  We wanted to take this approach because we could be more sure that the correct processes would be run in the background to set field values and move documents to history.  Also, this would be a more resilient solution when it comes to upgrades because there would be less customization.

We then tried to programmatically apply records by inserting into the PM20100 table and the PM10200 table, updating amounts in the PM20000 table, and then running the following script (This script runs a routine that, as I understand, is used during Check Links):

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

declare @FuncCurr varchar(15)

declare @ErrorState int

select @FuncCurr = FUNLCURR from MC40000

create table #CNTRLNUMTEMP

(

CNTRLNUM VARCHAR(21) NOT NULL,

DOCTYPE SMALLINT NOT NULL,

VENDORID VARCHAR(15) NOT NULL

)

exec pmclmovefullyapplied

'sa', @FuncCurr, 'PM_Transaction_OPEN', '%1', @ErrorState output

select * from SY03400

delete SY03400

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

We are evaluating this approach, but the script didn't seem to move documents to history when we ran it.  We might be able to get it to work, but in the meantime, instead of the above script, we are trying to move the applied documents to history programmatically with information from another script that we found that moves documents from PM20000 to PM30200, from PM10200 to PM30300, from PM10100 to PM30600, and updates PM00400 (tables PM10500 and PM30700 were also mentioned, but it looks like we're not using those).

This seems to be working, but were not sure that were setting the correct values in the apply work tables, or moving everything to history correctly.

Does anyone know if there is any documentation related to this?

Thank you very much for your assistance.

Sincerely,

Jacob Shukert

*This post is locked for comments

  • Alaa Ramadan Profile Picture
    Alaa Ramadan 4,084 on at
    RE: Apply payables documents programmatically

    Hi,

    I'm also trying to populate those 2 tables programmatically but in my case it's unposted credit memo applied against posted invoice.

    The table PM20100 has the KEYSOURC field which is typically system generated number . it does not seem to be a sequential number. What's the rule to  populate it without violating the system logic?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Apply payables documents programmatically

    We have the same problem, but we made a Macro. This macro goes to "Search" button over the header of the windows, and the "Type" the document number to apply, and then clic on "Search" button.

    If the document exist, then GP, show that document on line 1, so the macro, check "true" in the checkbox and thats all.

    But the problem is when doesn´t exist that document number, becouse, GP show the "most similar number". (if doesn´t exist, GP should not allow to show any document number)

    If someone knows how to modify that logic of searching, please let me know.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Apply payables documents programmatically

    Is it possible this solution can be discussed in more detail? I am looking to do this exactly.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Apply payables documents programmatically

    Hello Frank,

    We have updated an automation which creates Select Check Batch for Selected Check book IDs. We are facing issue when we do Select Check process in Dynamic GP. Some time Check Batch is printing Correctly as per the table PM20000 but sometime No transactions batches got created while sometime only few transactions are get selected. Is there any idea so that all transactions/Invoices of PM20000 should calculated and make the payment  correctly?

    Regards,

    Sanjay Parab.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Apply payables documents programmatically

    Hello Frank,

    Thank you for your response.

    I have since been given some guidance by our consulting partner to use the following procedure using Visual Studio Tools for Microsoft Dynamics GP:

    Microsoft.Dexterity.Applications.Dynamics.Procedures.PmUpdateRealTimeApply

    In order for this to work, I have to first insert records into the PM10200 and PM20100 tables, and then call this procedure.

    It appears that this is accomplishing my objective.

    Thank you.

  • Frank Hamelly | MVP, MCP, CSA Profile Picture
    Frank Hamelly | MVP... 4,029 Super User 2024 Season 2 on at
    RE: Apply payables documents programmatically

    Have you considered using any of the Integration tools that are available that utilize GP's transaction validation rules such as Integration Manager, Scribe, or SmartConnect (eConnect)?

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans