Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Discontinue thousands of items

Posted on by 300

I have 10's of thousands of items that I want to set the type to "Discontinued" in GP2010. Obviously, I don't want to do this one-by-one by hand!? Can I simply use SQL to update a table/field and be done with it?

*This post is locked for comments

  • Jason Cagle Profile Picture
    Jason Cagle 300 on at
    RE: Discontinue thousands of items

    Is that triggered off the change? So, if I were to update the field via SQL, would all this still happen based off a trigger?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Discontinue thousands of items

    Here is profiler trace  when an item is discontinued from GP

    declare @p1 int

    set @p1=10

    exec sp_prepexec @p1 output,N'@P1 smallint,@P2 datetime2,@P3 smallint,@P4 datetime2,@P5 char(32)',N'BEGIN UPDATE TWO.dbo.IV00101 SET ITEMTYPE = @P1, MODIFDT = @P2 WHERE ITEMTYPE = @P3 AND MODIFDT = @P4 AND ITEMNMBR = @P5 SELECT @@rowcount END ',2,'2013-11-15 00:00:00',1,'2017-01-15 00:00:00','1-A3261A                        '

    select @p1

    exec TWO.dbo.zDP_IV00400SS_1 '1-A3261A'

    exec TWO.dbo.zDP_IV00400SS_1 '1-A3261A'

    BEGIN DECLARE @num int EXEC TWO.dbo.zDP_IV00400SI '1-A3261A', 1, 1, 1, 1, @num OUT SELECT @num END

    BEGIN DECLARE @num int EXEC TWO.dbo.zDP_IV00400SI '1-A3261A', 1, 1, 1, 1, @num OUT SELECT @num END

    exec TWO.dbo.zDP_IV00401L_2 '1-A3261A',-2147483648,'1-A3261A',2147483647

    exec TWO.dbo.zDP_IV00401L_2 '1-A3261A',-2147483648,'1-A3261A',2147483647

    exec ##zDP_1972403F_2 '1-A3261A',-2147483648,'1-A3261A',2147483647

    Opps - lot more is going on than update to one field on IV00101

    Cheers!

    Sanjay

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Discontinue thousands of items

    Galina,

    You are missing the point,  by the way  I will be having a beer!!!

    Cheers!

    Sanjay

  • Jason Cagle Profile Picture
    Jason Cagle 300 on at
    RE: Discontinue thousands of items

    I totally agree that it would be nice to do it through "recommended practices". But, if I can be assured that doing this update via SQL is "good enough", that would save me a LOT of time. I'm leaning towards doing it the SQL way...I guess I'll be prepared to do an undo if things get out of sync... Thanks everyone for your insight!

  • Galina Profile Picture
    Galina 1,075 on at
    RE: Discontinue thousands of items

    Well, Sanjay, it is true, you need to do things proper way.

    If it wasn't for a fact that Jason needs to update 10's of thousands of items, I wouldn't recommend direct SQL update. I would expect the macro to run for a day ot two, if not three. IM will take several hours.

    It could be fun watching, though, you right there!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Discontinue thousands of items

    My take on updating with direct TSQL statements

    1)  Are you sure it the only table updated ?

    2)  When there are relatively simple options to do it right way, why do it the wrong way

    3)  Always ask the question  - is it the supported method

    Finally - What is the fun in just executing a TSQL  :).

    Any way TGIF , Happy Friday!

    Cheers!

    Sanjay

  • Suggested answer
    Mahmoud Saadi Profile Picture
    Mahmoud Saadi 32,738 on at
    RE: Discontinue thousands of items

    Mr. Jason

    I have personally changed the Item Type on the database level several times with no negative ramifications at all. Especially that the case is just to turn the flag of Item Type field as previously mentioned by Galina.

    Although, the point that is made is not to go on SQL and work around with the tables unless you are quite aware of what's being done.

    The bottom line is, you got many options to take depending on your experience. So as Galina said above, if you are comfortable with SQL, go ahead with the update statement. Be aware of the "WHERE" in your update, since you said thousands of items, then you shall be quite cautious not to update any other records by mistake, you could use the Dex_Row_Id in order to be quite precise.

  • Jason Cagle Profile Picture
    Jason Cagle 300 on at
    RE: Discontinue thousands of items

    Galina, that's exactly what my original question was...can I just change the item type? I was concerned that there might be other things that needed to be changed as well. By using the GP interface, econnect or integration service, I was assuming that any "other stuff" would be taken care of. Can you confirm that nothing else occurs? If so, then I can easily just change the itemtype...

  • Galina Profile Picture
    Galina 1,075 on at
    RE: Discontinue thousands of items

    Changing item type to Discontinued is literally just changing a ITEMTYPE field named in IV00101 table. If I was tasked with the update, I'd use SSIS to upload the item list from Excel or a text file in a table and run the statement:

    UPDATE IV00101 SET ITEMTYPE = 2 FROM IV00101 I INNER JOIN T ON I.ITEMNMBR = T.ITEM

    Done!

    I"m assuming, you comfortable with SQL...

  • Suggested answer
    Mahmoud Saadi Profile Picture
    Mahmoud Saadi 32,738 on at
    RE: Discontinue thousands of items

    When it comes to knowledge workers who are not quite accustomed to using SQL, any update statement on key tables such as (IV00101) might be risky. In this essence, I would highly recommend using the Macro.

    To use a Macro, you consider one of the following methods;

    • Using Mail Merge, simple and straight forward steps which are all performed on the same way with no conditions, such as your case. Check the following reference to see how the Mail Merge is to be used: Mail Merge to record Macro
    • When there is a logic in the code, with condition, you might need to use Excel in order to make use of the Excel Functionality in considering "If cases" The following explains how to use Excel in your case

    6813.COPY.png

    -  Under the First Column (Item Number), list down you Item list to be discontinued.

    -  Under Macro Header, copy the following;

    ="# DEXVERSION=12.00.0270.000 2 2
    CheckActiveWin dictionary 'default'  form 'IV_Item_Maintenance' window 'IV_Item_Maintenance' "

    -  Under Macro Detail, copy the following:

    ="MoveTo field 'Item Number'
      TypeTo field 'Item Number' , '"&TRIM(A2)&"'
      MoveTo field Inactive  # 'FALSE'
      MoveTo field 'Item Type' item 1  # 'Sales Inventory'
      ClickHit field 'Item Type' item 2  # 'Discontinued'
      MoveTo field 'Save Button'
      ClickHit field 'Save Button'
    "

    -  Drag and drop the Macro Detail cell to include all the item list.

    - Copy the whole column (Macro Header and Detail), into Word document, to paste the format.


    -  Finally, copy the the Code from the word document into text notepad, the extension of the text file is (.txt)

    -  Change the extension to be (.mac)

    -  Now you have the file ready to be played from the Screen.

    Helping note:

    If you are not quite accustomed with the steps above, I would recommend applying either scenarios (Mail merge or Excel) on a test environment.


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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans