Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

How to get the NextPaymentNumber using [taGetPMNextPaymentNumber] stored Procedure

(0) ShareShare
ReportReport
Posted on by 790

I am trying to get next Payment number from GP 2013 .

First i am trying form  SQL  side :


DECLARE @return_value int,
@O_iPMNPYNBR varchar(21),
@O_iErrorState int

EXEC @return_value = [dbo].[taGetPMNextPaymentNumber]
@I_vInc_Dec = 255, // What value i have t pass to this parameter.... 
@O_iPMNPYNBR = @O_iPMNPYNBR OUTPUT,
@O_iErrorState = @O_iErrorState OUTPUT

SELECT @O_iPMNPYNBR as N'@O_iPMNPYNBR',
@O_iErrorState as N'@O_iErrorState'

SELECT 'Return Value' = @return_value

Output  :  99999999999999989 

But in GP 2013  my Payment number is :   00000000000000449

Let me know how can i get correct Payment number. 

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to get the NextPaymentNumber using [taGetPMNextPaymentNumber] stored Procedure

    Hi Kavitha,

    The Above SQL code work for us,

    my assumption is : you can count the number of records from the external table and use to decrement the loop while processing.

    please make sure you must make another loop to increment the Payment number based on the record count.

    or

    you can follow the suggested steps from Soma using econnect methods(GetNextDocNumbers).  

  • Verified answer
    soma Profile Picture
    soma 24,410 on at
    RE: How to get the NextPaymentNumber using [taGetPMNextPaymentNumber] stored Procedure

    You need to pass the value 1 for the parameter @I_vInc_Dec. By default this should be 1, but you code has passing the value rather than 1 for this parameter. So, try to pass the value 1 and let me know.

    Your reply is much appreciated.

    Note: If you using c# to get the next document number, I would not recommend for getting next number from the SQL stored procedure. Because, there is default function available for getting the same. Have a look on my c# code from my previous post. This will handle the multi user document number accessibility and strink your code.

    Hope this helps!!!

  • kavitha B Profile Picture
    kavitha B 790 on at
    RE: How to get the NextPaymentNumber using [taGetPMNextPaymentNumber] stored Procedure

    I have to use stored procedure   instead of using econnect  methods..

    this is my c# code ;

        SqlCommand NextPaymentNumber = new SqlCommand("taGetPMNextPaymentNumber", myConnection);

                                       NextPaymentNumber.CommandType = CommandType.StoredProcedure;

                                       NextPaymentNumber.CommandText = "taGetPMNextPaymentNumber";

              SqlParameter mobjSqlParameter = new SqlParameter("@I_vInc_Dec", SqlDbType.TinyInt);

                                       mobjSqlParameter.IsNullable = true;

                                       mobjSqlParameter.Direction = ParameterDirection.Input;

                                       mobjSqlParameter.Value =100; // here i have passed 100 value

                                       NextPaymentNumber.Parameters.Add(mobjSqlParameter);

                                       NextPaymentNumber.Parameters.Add("@O_iPMNPYNBR", SqlDbType.Char, 21);

                                       NextPaymentNumber.Parameters["@O_iPMNPYNBR"].Direction = ParameterDirection.Output;

                                       NextPaymentNumber.Parameters.Add("@O_iErrorState", SqlDbType.Int, 250);

                                       NextPaymentNumber.Parameters["@O_iErrorState"].Direction = ParameterDirection.Output;

                                       if (myConnection == null || myConnection.State == ConnectionState.Closed)

                                       {

                                           myConnection.Open();

                                       }

                                       NextPaymentNumber.CommandTimeout = 3600;

                                       try

                                       {

                                           NextPaymentNumber.ExecuteNonQuery();

                                       }

                                       catch (Exception exe)

                                       {

                                           MessageBox.Show(exe.Message);

                                       }

                                       string PaymentNumber = (NextPaymentNumber.Parameters["@O_iPMNPYNBR"].Value).ToString();

                                       int PaymentNumberError = (int)NextPaymentNumber.Parameters["@O_iErrorState"].Value;

    this logic i kepted in loop. when loop is running my Payment value is decrementing by 1

    Like : 00000000000000449

              00000000000000448

               00000000000000447

    Let me know why it is drecreming by 1 and what  value i have to pass this parameter : @I_vInc_Dec

  • Suggested answer
    soma Profile Picture
    soma 24,410 on at
    RE: How to get the NextPaymentNumber using [taGetPMNextPaymentNumber] stored Procedure

    The above mentioned SQL coding is correct. This is worked for me with getting the correct next payment number.

    I guess are you trying to get the next payment number from your C# coding. If yes, use the below coding to get the next payment number from GP.

    try

               {

                   string cnString = @"Data Source=MYSERVER;initial catalog=TWO;integrated security=SSPI;

                   persist security info=False;packet size=4096";

                   GetNextDocNumbers oNextDoc = new GetNextDocNumbers();

                   string nextPMPaymentNumber = "";

                   nextPMPaymentNumber = oNextDoc.GetNextPMPaymentNumber(GetNextDocNumbers.IncrementDecrement.Increment, cnString);

                   Console.WriteLine("The next PM Payment Number is " + nextPMPaymentNumber);

                   Console.WriteLine("Press <Enter> to close...");

                   Console.Read();

               }

               catch (Exception ex)

               {

                   Console.WriteLine(ex.ToString());

                   Console.WriteLine("Press <Enter> to close...");

                   Console.Read();

               }

    Hope this helps!!!

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans