Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

How to delete AR Payments from Database

Posted on by 700

Dear All,

We deleted the ACH batch. All of the payments went away except the problem payment  PYMT000000XXXXX.   The AR account XXXXXXX does not show the payment and Dynamics GP says the payment does not exist if you try to search for it. However, the first 12 invoices of the 15 that user applied this payment to originally still show as having zero balance left on them and are applied to this phantom payment.   We can't void this payment because Dynamics doesn't have it to void.

 Using SQL query can we remove the Payments, if so from which tables.

*This post is locked for comments

  • Sureshn07 Profile Picture
    Sureshn07 700 on at
    RE: How to delete AR Payments from Database

    Thank you Richard

  • Richard Wheeler Profile Picture
    Richard Wheeler 75,730 on at
    RE: How to delete AR Payments from Database

    Try using this script to locate all occurrences of the payment. Before doing and deleting perform a backup and then run check links after deleting.

    /*************************************************************************/

    /*         Procedure of search of a phrase on all database               */

    /*            Is developed by Oufimtsev Gleb, MCSE                       */

    /*                                                                       */

    /*            gvu@newmail.ru,  http://www.gvu.newmail.ru                 */

    /*            +7 (095) 178-40-92,  Moscow, Russia                        */

    /*************************************************************************/

    if exists

    (select * from sysobjects where id = object_id('dbo.spSearchOnAllDB') )

    drop procedure dbo.spSearchOnAllDB

    GO

    CREATE PROCEDURE spSearchOnAllDB @phrase varchar(8000), @OutFullRecords bit=0 AS

    /*

      To apply so:

         exec  spSearchOnAllDB 'Sugar%'

         exec  spSearchOnAllDB '%soft%'

         exec  spSearchOnAllDB '_5234_57%', 1

         exec  spSearchOnAllDB M_cro_oft

    */

    declare @sql varchar(8000)

    declare @tbl varchar(128)

    declare @col varchar(128)

    declare @id_present bit

    declare @is_char_phrase bit

    declare @min_len int

    declare @loop_idx int

    declare @loop_chr char(1)

    set nocount on

    if IsNull(@phrase,'')=''

    begin

     raiserror('Phrase is absent',16,-1)

     return

    end

    select @loop_idx=1, @is_char_phrase=0, @min_len=0

    while @loop_idx<=LEN(@phrase)

    begin

     set @loop_chr=SUBSTRING(@phrase,@loop_idx,1)

     if @loop_chr not in ('%','_') set @min_len=@min_len+1

     if @is_char_phrase=0 and @loop_chr not in ('%','_','0','1','2','3','4','5','6','7','8','9','.')  

          set @is_char_phrase=1

     set @loop_idx=@loop_idx+1

    end

    create table #tbl_res

                   (TableName varchar(128) not NULL,

                    ColumnName varchar(128) not NULL,

                    Id int NULL,

                    ColumnValue varchar(7500) not NULL)

    create table #tbl_res2

                   (TableName varchar(128) not NULL,

                    ColumnName varchar(128) not NULL,

                    Id int NULL,

                    ColumnValue varchar(7500) not NULL)

    declare CRR cursor local fast_forward for

     select t.name, c.name, 1

     from sysobjects t, syscolumns c

     where t.type='U'

     and c.id=t.id

     and c.status&0x80=0 -- Not IDENTITY

     and exists (select * from syscolumns c2 where t.id=c2.id and c2.status&0x80=0x80 and c2.xtype in (48,52,56))

     and (   (@is_char_phrase=1 and c.xtype in (175,239,99,231,35,167) and c.length>=@min_len) -- char only

          or (@is_char_phrase=0 and c.xtype not in (34,165,173,189,61,58,36))) -- char and numeric

     union select t.name, c.name, 0

     from sysobjects t, syscolumns c

     where t.type='U'

     and c.id=t.id

     and not exists (select * from syscolumns c2 where t.id=c2.id and c2.status&0x80=0x80 and c2.xtype in (48,52,56))

     and (   (@is_char_phrase=1 and c.xtype in (175,239,99,231,35,167) and c.length>=@min_len) -- char only

          or (@is_char_phrase=0 and c.xtype not in (34,165,173,189,61,58,36))) -- char and numeric

     order by 1,2

    open CRR

    fetch CRR into @tbl, @col, @id_present

    while @@FETCH_STATUS=0

    begin

     if @OutFullRecords=0

     begin

       set @sql='insert into #tbl_res (TableName,ColumnName,Id,ColumnValue) '

               +'select '+char(39)+@tbl+char(39)+', '

                         +char(39)+@col+char(39)+', '

       if @id_present=1 set @sql=@sql+'IDENTITYCOL, '

                   else set @sql=@sql+'NULL, '

       set @sql=@sql+'convert(varchar(7500),'+@col+') '

                    +'from '+@tbl+' (nolock) '

                    +'where convert(varchar(8000),'+@col+') like '+char(39)+@phrase+char(39)

     end

     if @OutFullRecords=1

     begin

       set @sql='if exists (select * from '+@tbl+' (nolock) '

                          +'where convert(varchar(8000),'+@col+') like '+char(39)+@phrase+char(39)+') '

               +'select '+char(39)+@tbl+char(39)+' TableName, '+char(39)+@col+char(39)+' ColumnName, * '

               +'from '+@tbl+' (nolock) where convert(varchar(8000),'+@col+') like '+char(39)+@phrase+char(39)

     end

     exec(@sql)

     fetch CRR into @tbl, @col, @id_present

    end

    close CRR

    deallocate CRR

    if @OutFullRecords=0

    begin

     -- For the clients supporting new types:

     --exec('select * from #tbl_res order by 1,2,3')

     -- For the clients who are not supporting new types:

    INSERT #tbl_res2

    select TableName, ColumnName, Id, convert(varchar(255),ColumnValue) ColumnValue from #tbl_res

    /** exec('select TableName, ColumnName, Id, convert(varchar(255),ColumnValue) ColumnValue from #tbl_res order by 1,2,3')**/

    end

    drop table #tbl_res

    /***Select Statement to show tables***/

    select TableName,ColumnName,ColumnValue from #tbl_res2 group by TableName,ColumnName,ColumnValue

    order by TableName

    GRANT EXECUTE ON dbo.spSearchOnAllDB TO DYNGRP

    truncate table #tbl_res2

    drop table #tbl_res2

  • Suggested answer
    Srnvasan80 Profile Picture
    Srnvasan80 15 on at
    RE: How to delete AR Payments from Database

    Please check in below tables,whether you get any records for the problem payment  PYMT000000XXXXX

    RM00401

    RM30101

    RM30201

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