Item and memo tables

Hi there, 

I am having issues correlating item and memo tables together to get user text by item number. The tables i am using in the SQL database are [timitem] and [tcimemo]. I tried to find a middle table between the 2 tables but there is no table in the entire database to do the trick. I am getting stuck and need some help. Thanks! 

Parents
  • 0
    Suggested

    Hi Ibrahim,

    For this kind of puzzle, I always use SQL Profiler. In this case, I trace the save event on the memo screen, from a specific item. Then I run the relevant queries and find the tciMemo.MemoOwnerKey is a key that links to the entity the memo is created from.  Below is an example where a memo is tied to 1.44 floppy in SOA company:

    Thus, you can adopt your own query to find all the key values in timItem that are linked as a MemoOwnerKey in tciMemo.

  • 0 in reply to Phil K

    Thanks for the quick response, Phil. I tried that solution initially but did not have any luck. The result does not make sense to what the interface shows. I get a MemoText that is not the same as Sage interface or the MemoText is blank and the database returns value that is incorrect. Here is a screenshot of one example. I tried multiple keys and none of them is correct... 

    I tried to filter on MemoID to "Item" but there were only a handful of lines...

  • +1 in reply to Ibrahim Alayidi
    Verified Answer

    You also need to filter on the EntityType. This is a metadata value defined in tciEntity for document and entity data stored in the system.

    As a general rule, the entity value ranges correspond to the module number (ModuleNo) defined in the tsmModule table that contains other metadata components (denormalized in tsmModuleStrDef). If you add 100, that is your entity range, so tsmModule indicates Inventory Management has a ModuleNo of 7. This in turn means the entity range is between 700-799, so looking in tciEntity indicates the 701 EntityType is associated with the Item domain, the timItem table and ModuleNo = 7 (you could also filter tciEntity values using the ModuleNo but the + 100 rule usually does the trick). The explanation actually gets more complex from there, so to put it succinctly, a properly formatted query against data in tciMemo needs to include the EntityType and ItemKey in your scenario.

    Below is one way to form that query using the vdvItem view (replace <x> with your values), but you could also replace vdvItem with timItem and build out your object relationships from there.

    SELECT 
    		[vdvItem].[CompanyID],
    		[vdvItem].[ItemID],
    		[tciMemo].*
    	FROM
    		[dbo].[vdvItem] WITH (NOLOCK)
    		INNER JOIN [dbo].[tciMemo] WITH (NOLOCK)
    			ON [vdvItem].[ItemKey] = [tciMemo].[MemoOwnerKey]
    			AND [tciMemo].[EntityType] = 701
    	WHERE
    		[vdvItem].[CompanyID] = '<x>'
    		AND [vdvItem].[ItemID] = '<x>';

  • 0 in reply to Contefication

    Looks like a winner, Ibrahim, be sure to select 'Verified Answer' on the reply from Contefication.

  • 0 in reply to Contefication

    This works PERFECT! Thank you so much! 

Reply Children
No Data