cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting a Warehouse

simonsimonian
Participant
0 Kudos

I am sure this happens a lot and I would like to know if there's a resolution to this.

we've accidentally added an * warehouse (when attempting to Find with *, someone just Added that warehouse). The bad news - new warehouses are automatically assigned to all items in our system which means we have every single item in SAP automatically assigned to this new asterisk warehouse.

An obvious question is how to delete that warehouse without having to go through a painstaking process of unassigning every item from that warehouse one by one?

Please tell me there's an easier way

thanks

Simon

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Expert,

I read this forum discussion and having some comment and appreciate if anyone can post to SAP support to get it correct:

Let me explain my problem:

1) I created a warehouse and set the general settings on Items portion to "ADD WAREHOUSES TO NEW ITEMS ADDED".

2) I created more than 2 thousand over items and therefore there are 2 thousand over * #n warehouse records in AITW (account item warehouse)

3) However, when I realized that some warehouse accounting setup wrongly, by deleting the warehouse, the system will not remove data from AITW, SO I need to go ITEM MASTER to delete item account setting one by one?

4) Actually, there is a shortcut way which I think it works:

DELETE FROM AITW WHERE WAREHOUSE = XX

which I need to remove the warehouse item account table and remove warehouse and re-setup the same warehouse code with different a/c settings.

From here, I would appreciate if someone can post to SAP SUPPORT to do the patches to allow the system to perform "when warehouse is being deleted, the AITW records should be automatically remove".

thank you and regards,

Joan.

simonsimonian
Participant
0 Kudos

Just closing this thread. No answer. Hopefully there will be a way to do that in the next releases

simonsimonian
Participant
0 Kudos

You are correct, SAP will discontinue product support if you start messing with sql tables. So the verdict is that there really is no straightforward way to remove a warehouse

Thank you all though

former_member186095
Active Contributor
0 Kudos

Hi,

In DE localization database (DEMO database), deleting a certain warehouse that has transaction or no transaction is unable except all warehouses have no transaction yet. So, I suggest to make the warehouse unable to use, you must block it using SP_TN, for example blocking the warehouse code 77 using in the transfer order:

IF @transaction_type ='A' AND @object_type = '67'
BEGIN
IF EXISTS (SELECT T0.DOCNUM FROM [DBO].[OWTR] T0 INNER JOIN [DBO].[WTR1] T1 ON T0.DOCENTRY = T1.DOCENTRY AND T0.DOCENTRY = @list_of_cols_val_tab_del
WHERE T0.FILLER = '77' OR T1.WHSCODE = '77')
BEGIN
SELECT @Error = 1, @error_message = 'Inventory transfer can be made only from and to warehouse 77'
END
END

Do not ever delete using query, because it is not recommended by SAP Support. Once they know it, they will not support your SBO installation anymore.

Rgds,

Former Member
0 Kudos

wow that's powerful stuff. our consultant had warned me never to use queries apart from Select, and i only remembered this after I saw this warning.

But fair play Suda that's worked for the three warehouses i needed removing.

simonsimonian
Participant
0 Kudos

Thanks Istvan,

can I do that though? i was told by everyone that under no circumstances we're allowed to manually modify SAP sql tables like that.

former_member583013
Active Contributor
0 Kudos

You need to first delete the items linked to the * warehouse and then delete the warehouse from within SAP.

If you are sure that there is not transactions from this warehouse.

Then do this

DELETE FROM OITW WHERE WhsCode = '*'

Then go to your Warehouse setup and find this warehouse do to Data > Remove

former_member204969
Active Contributor
0 Kudos

I use this code before deleting the warehouse:

if exists
 (SELECT top 1 T0.ItemCode, T0.WhsCode, T0.OnHand
   FROM OITW T0 WHERE T0.OnHand <>0 and  T0.WhsCode ='[%0]')
 SELECT T0.ItemCode, T0.WhsCode, T0.OnHand
   FROM OITW T0 WHERE T0.OnHand <>0 and  T0.WhsCode ='[%0]'
else 
  delete OITW  WHERE WhsCode ='[%0]'

Former Member
0 Kudos

I also have the problem of needing to delete warehouses.

I tried this query and it didnt initially work so i added = where needed, for example WHERE T0.OnHand = 0.

However, surely this just gives us a report, rather than changing any data?

former_member204969
Active Contributor
0 Kudos

I'm sorry, but left two '=' from the code:

if exists 
(SELECT top 1 T0.ItemCode, T0.WhsCode, T0.OnHand 
   FROM OITW T0 WHERE T0.OnHand=0 and  T0.WhsCode ='[%0]') 
SELECT T0.ItemCode, T0.WhsCode, T0.OnHand 
   FROM OITW T0 WHERE T0.OnHand=0 and  T0.WhsCode ='[%0]' 
else 
  delete OITW  WHERE WhsCode ='[%0]'

This query list the items having non zero stock in the warehouse you want to delete. You should not delete the warehouse until there is any item with non zero onhand quantity on them.

After removing this stock, the query will remove the warehouse from every item, and you can delete it.