web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Delete empty Sales Batches

(0) ShareShare
ReportReport
Posted on by

Is there any way to mass delete empty sales batches?  Due to the way that sales orders are invoiced there are many empty batches by the end of the month which will not be reused.  The only method I can think of would be to use a SQL statement on the sy00500 table to delete any batches with 0 as the number of transactions.  Any Utility available that could accomplish this?  Thank you!

*This post is locked for comments

I have the same question (0)
  • Chris Isbell Profile Picture
    on at

    I think deleting from the SY00500 table would be the simplest way.  You could also make a SQL job to do this, perhaps at the end of each month.

  • Richard Wheeler Profile Picture
    75,848 Moderator on at

    If you do create a script to delete sales batches, make sure you check more than just the document count. GP is notorious for incorrect batch counts and totals. Have your script check for any records with the Batch ID you are about to delete. This way you will be sure it will only delete truly empty batches.

  • Tristan Clores Profile Picture
    2,812 on at

    Hi Susan,

    By default, GP should delete the sales batches once all transactions in it are posted/completed and moved to History.  Try using the Reconcile - Remove Sales Documents utility and use the Remove Completed Documents option.

    If it does not work, you can then use SQL.  Make a FULL BACKUP.  Use the NUMOFTRX = 0, BCHSOURC = 'Sales Entry' as part of your delete statement.

    Let me know how this goes.

    Regards,

    Tristan

  • Richard Wheeler Profile Picture
    75,848 Moderator on at

    Don't forget that sales batches can have quotes and orders in them, so when you print the sales batch, nothing prints so you think it is empty. Also, you can move transactions from one batch to another so a zero transaction batch can result from this as well. Just have your script count the number of transactions associated with the batch. If the result is zero, then it is safe to remove the batch.

  • Suggested answer
    Community Member Profile Picture
    on at

    First, make a full backup of the Company Database Affected.

    Use this code to make sure you have selected a Company Database and not the DYNAMICS database:

    SELECT * FROM SY00500 ORDER BY BACHNUMB;

    (I recommend you save these results for easy review)

    Use this code to make the deletion:

    DELETE FROM SY00500 WHERE NUMOFTRX=0 AND BCHSOUR='Sales Entry';

  • Suggested answer
    Redbeard Profile Picture
    12,931 on at

    First, Richard's advice is spot on, be careful.  I am not sure what your root cause of this problem is, but Willoware makes a really cool batch handling application that might make this a moot point. willoware.com/.../gp-powerpack

  • Community Member Profile Picture
    on at

    /*

    Used to reset the Batch Header Sales Transaction Entry Batch Counts

    Execute from the GYP System Database

    */

    DECLARE @Cmd AS VARCHAR(5000)

    DECLARE MyCurrsor CURSOR FOR

    SELECT Cmd = '

    USE ['+RTRIM(INTERID)+'];

    UPDATE SY00500

    SET NUMOFTRX= ISNULL((SELECT COUNT(1) FROM SOP10100 WHERE VOIDSTTS=0 AND BACHNUMB=A.BACHNUMB),0)

    FROM SY00500 A

    WHERE A.BCHSOURC=''Sales Entry''

    AND NUMOFTRX<>ISNULL((SELECT COUNT(1) FROM SOP10100 WHERE VOIDSTTS=0 AND BACHNUMB=A.BACHNUMB),0);

    '

    FROM SY01500

    OPEN MyCurrsor;

    FETCH NEXT FROM MyCurrsor INTO @Cmd;

    WHILE @@FETCH_STATUS = 0

    BEGIN

    EXECUTE(@Cmd);

    FETCH NEXT FROM MyCurrsor INTO @Cmd;

    END

    CLOSE MyCurrsor;

    DEALLOCATE MyCurrsor;

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
mtabor Profile Picture

mtabor 1

#2
Victoria Yudin Profile Picture

Victoria Yudin 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans