You can try this code where you can send in the item you want to check.
codeunit 50100 ItemTools
{
procedure CountLocations(Item: Record Item)
var
loaction: Record Location;
NoOfLocations: Integer;
LocationString: Text;
begin
NoOfLocations := 0;
LocationString := '';
if loaction.FindSet(false, false) then
repeat
Item.Setfilter(Item."Location Filter", loaction.Code);
Item.CalcFields(Inventory);
If Item.Inventory > 0 then begin
NoOfLocations = 1;
if NoOfLocations = 1 then LocationString := loaction.Code;
If NoOfLocations > 1 then LocationString := LocationString ' ' loaction.Code;
end;
until loaction.Next() = 0;
if NoOfLocations >1 then Message('Item %1 is avalible on these %2 locations %3',Item."No.",NoOfLocations,LocationString);
end;