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)

Update Sales Invoice number After invoice has been posted

(0) ShareShare
ReportReport
Posted on by

Hello Everyone,


We have integrated 140K+ Sales invoices from old system to GP.
Cash Receipts applied against invoices.
SOP to POP link is also done.
Now, we got to know we have wrongly mapped the Invoice number.
Does anyone here have an idea how we can update the Invoice number?

Thanks,
Brian

*This post is locked for comments

I have the same question (0)
  • Tim W Profile Picture
    2,925 on at

    I would add the cross reference number in one of the user defined fields in SOP10106 and move on.  In this way you could easily expose the right number in smartlists and reports.  You'd be taking on a high wire act that would update 10 or more tables and that's just off top of my head.

  • Community Member Profile Picture
    on at

    You are absolutely right Tim.  These will affect several tables. But I am still trying to figure out how I can update.

    Basically Source system team was not sure about which invoice number should be taken for integration.  

  • Community Member Profile Picture
    on at

    Additional Info :

    I am having one ref. table for old & new invoice number.

    Sample:

    OLD NEW
    3478653 2039854
    3753096 2398543
    4593243 2909372
    3798742 3478653
    3687543 3714396
    3987529 3753096
    3714396 3273098
  • Tim W Profile Picture
    2,925 on at

    You might be able to update a subset of tables if you are not that concerned about referential integrity so that basic reporting functions work but I don't see it and I'm a pretty big risk taking cowboy on this stuff.  

    You need the SOP history tables including the distributions and user defined tables, commission and tax tables are in play perhaps, sop-pop for sure.  The RM open and apply tables, distribution table, RM keys table.  GL Open.  

    Invoice Number morphs around as 'SOP Number' 'Document Number' 'Control Number' 'Originating Control Number' (I think something like that in GL).

    Seems like a lot of pain, good luck.

  • Community Member Profile Picture
    on at

    We are not having GL.

    Yes we have to update all subset table. Another pain, we are getting round trip between OLD and New Number.

    e.g.

    OLD Number: 1, 2,3,4,5

    New Number: 1=3, 2=7, 3=11, 4=1 and so on.

  • Community Member Profile Picture
    on at

    Brian,

    Looks like it requires to update more than 15 tables.

  • Verified answer
    Community Member Profile Picture
    on at

    Brian,

    Add unique post fix to new Invoice number to resolve round trip between OLD n new numbers.

    Update below list of tables with new invoice number (Added unique post fix) based on your reference table.

    Again update all tables with SOPNUMBE = SOPNUMBE - Remove Post fix .

    Below SQL script may be helps you. I have update the each record one by one. You can use single update statement for each table instead.

    Try to execute below SQL routine on TEST environment.

    Let me know if I missed to add any subset tables.

    USE DBNAME

    DECLARE @OLD_SOPNUMBE CHAR(21), @NEW_SOPNUMBE CHAR(21)--,@CUSTNMBR CHAR(15)

    DECLARE GETSOPNUMBE CURSOR  FOR --GET  OLD & NEW SOPNUMBER

    SELECT DISTINCT LTRIM(RTRIM(OLD)) AS OLD ,LTRIM(RTRIM(NEW)) AS NEW FROM REF_TABLE

    OPEN GETSOPNUMBE

    FETCH NEXT FROM GETSOPNUMBE INTO @OLD_SOPNUMBE ,@NEW_SOPNUMBE

    WHILE @@FETCH_STATUS = 0    

    BEGIN

    SET @NEW_SOPNUMBE = LTRIM(RTRIM(@NEW_SOPNUMBE))  + '-9' /*Add Unique Post Fix  '-9' */    

    UPDATE SOP30200  SET SOPNUMBE = @NEW_SOPNUMBE WHERE SOPTYPE = 3 AND SOPNUMBE = @OLD_SOPNUMBE  /* Historical Transactions (header) */

    UPDATE SOP30300  SET SOPNUMBE = @NEW_SOPNUMBE WHERE SOPTYPE = 3 AND SOPNUMBE = @OLD_SOPNUMBE  /*Historical Transactions (line detail) */

    UPDATE SOP10102  SET SOPNUMBE = @NEW_SOPNUMBE WHERE SOPTYPE = 3 AND SOPNUMBE = @OLD_SOPNUMBE  /* GL Distributions Work and History */

    UPDATE SOP60100  SET SOPNUMBE = @NEW_SOPNUMBE WHERE SOPTYPE = 3 AND SOPNUMBE = @OLD_SOPNUMBE  /* SOP-POP Link */

    UPDATE RM20201  SET APTODCNM = @NEW_SOPNUMBE WHERE APTODCTY = 1 AND APTODCNM = @OLD_SOPNUMBE  /* Open Transactions Apply */

    UPDATE RM30201  SET APTODCNM = @NEW_SOPNUMBE WHERE APTODCTY = 1 AND APTODCNM = @OLD_SOPNUMBE  /* Historical Transactions Apply */

    UPDATE RM30101  SET DOCNUMBR = @NEW_SOPNUMBE,TRXDSCRN=@NEW_SOPNUMBE WHERE RMDTYPAL = 1 AND DOCNUMBR = @OLD_SOPNUMBE  /*Historical Transactions */

    UPDATE SOP10106  SET SOPNUMBE = @NEW_SOPNUMBE WHERE SOPTYPE = 3 AND SOPNUMBE = @OLD_SOPNUMBE  /* User Defined Work and History */

    UPDATE SOP10202  SET SOPNUMBE = @NEW_SOPNUMBE WHERE SOPTYPE = 3 AND SOPNUMBE = @OLD_SOPNUMBE /* Line Comment Work and History */

    UPDATE SOP10105  SET SOPNUMBE = @NEW_SOPNUMBE WHERE SOPTYPE = 3 AND SOPNUMBE = @OLD_SOPNUMBE  /* Sales Taxes Work and History */

    UPDATE RM10601  SET DOCNUMBR = @NEW_SOPNUMBE WHERE RMDTYPAL = 1 AND DOCNUMBR = @OLD_SOPNUMBE  /* RM Tax Work File */

    UPDATE RM30301  SET DOCNUMBR = @NEW_SOPNUMBE WHERE RMDTYPAL = 1 AND DOCNUMBR = @OLD_SOPNUMBE  /* Distribution History */

    UPDATE RM30601  SET DOCNUMBR = @NEW_SOPNUMBE WHERE RMDTYPAL = 1 AND DOCNUMBR = @OLD_SOPNUMBE  /* RM Tax History File */

    UPDATE RM00401  SET DOCNUMBR = @NEW_SOPNUMBE WHERE RMDTYPAL = 1 AND DOCNUMBR = @OLD_SOPNUMBE  /* RM Key File */

    UPDATE RM20101  SET DOCNUMBR = @NEW_SOPNUMBE,TRXDSCRN=@NEW_SOPNUMBE WHERE RMDTYPAL = 1 AND DOCNUMBR = @OLD_SOPNUMBE  /* Open Transactions */

    FETCH NEXT FROM GETSOPNUMBE INTO @OLD_SOPNUMBE ,@NEW_SOPNUMBE

    END

    CLOSE GETSOPNUMBE

    DEALLOCATE GETSOPNUMBE

    /*Update Invoice number (Remove post fix) */

    DECLARE GETSOPNUMBE1 CURSOR  FOR --GET ALL NEW SOPNUMBER which have Post fix '-9'

    SELECT LTRIM(RTRIM(SOPNUMBE)) AS SOPNUMBE ,REPLACE(LTRIM(RTRIM(SOPNUMBE)),'-9','') AS SOPNUMBE_NEW  /*Remove Post fix*/ FROM SOP30200 where LTRIM(RTRIM(SOPNUMBE)) like  '%-9%'

    OPEN GETSOPNUMBE1

    FETCH NEXT FROM GETSOPNUMBE1 INTO @OLD_SOPNUMBE ,@NEW_SOPNUMBE

    WHILE @@FETCH_STATUS = 0

    BEGIN

    UPDATE SOP30200  SET SOPNUMBE = @NEW_SOPNUMBE WHERE SOPTYPE = 3 AND SOPNUMBE = @OLD_SOPNUMBE

    UPDATE SOP30300  SET SOPNUMBE = @NEW_SOPNUMBE WHERE SOPTYPE = 3 AND SOPNUMBE = @OLD_SOPNUMBE  

    UPDATE SOP10102  SET SOPNUMBE = @NEW_SOPNUMBE WHERE SOPTYPE = 3 AND SOPNUMBE = @OLD_SOPNUMBE  

    UPDATE SOP60100  SET SOPNUMBE = @NEW_SOPNUMBE WHERE SOPTYPE = 3 AND SOPNUMBE = @OLD_SOPNUMBE

    UPDATE RM20201  SET APTODCNM = @NEW_SOPNUMBE WHERE APTODCTY = 1 AND APTODCNM = @OLD_SOPNUMBE  

    UPDATE RM30201  SET APTODCNM = @NEW_SOPNUMBE WHERE APTODCTY = 1 AND APTODCNM = @OLD_SOPNUMBE  

    UPDATE RM30101  SET DOCNUMBR = @NEW_SOPNUMBE,TRXDSCRN=@NEW_SOPNUMBE WHERE RMDTYPAL = 1 AND DOCNUMBR = @OLD_SOPNUMBE

    UPDATE SOP10106  SET SOPNUMBE = @NEW_SOPNUMBE WHERE SOPTYPE = 3 AND SOPNUMBE = @OLD_SOPNUMBE  

    UPDATE SOP10202  SET SOPNUMBE = @NEW_SOPNUMBE WHERE SOPTYPE = 3 AND SOPNUMBE = @OLD_SOPNUMBE

    UPDATE SOP10105  SET SOPNUMBE = @NEW_SOPNUMBE WHERE SOPTYPE = 3 AND SOPNUMBE = @OLD_SOPNUMBE  

    UPDATE RM10601  SET DOCNUMBR = @NEW_SOPNUMBE WHERE RMDTYPAL = 1 AND DOCNUMBR = @OLD_SOPNUMBE

    UPDATE RM30301  SET DOCNUMBR = @NEW_SOPNUMBE WHERE RMDTYPAL = 1 AND DOCNUMBR = @OLD_SOPNUMBE

    UPDATE RM30601  SET DOCNUMBR = @NEW_SOPNUMBE WHERE RMDTYPAL = 1 AND DOCNUMBR = @OLD_SOPNUMBE

    UPDATE RM00401  SET DOCNUMBR = @NEW_SOPNUMBE WHERE RMDTYPAL = 1 AND DOCNUMBR = @OLD_SOPNUMBE

    UPDATE RM20101  SET DOCNUMBR = @NEW_SOPNUMBE,TRXDSCRN=@NEW_SOPNUMBE WHERE RMDTYPAL = 1 AND DOCNUMBR = @OLD_SOPNUMBE

    END

    FETCH NEXT FROM GETSOPNUMBE1 INTO @OLD_SOPNUMBE ,@NEW_SOPNUMBE

    END

    CLOSE GETSOPNUMBE1

    DEALLOCATE GETSOPNUMBE1

    Regards,

    Vinod Agrawal

    www.flovianit.com

  • Community Member Profile Picture
    on at

    Excellent!!

    Thanks Vinod.

    Let me try with test company first.

    Regards,

    Brian

  • Community Member Profile Picture
    on at

    Vinod,

    Script is just working fine and resolved my issue.

    Regards,

    Brian

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 4

#2
Victoria Yudin Profile Picture

Victoria Yudin 1

#2
mtabor Profile Picture

mtabor 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans