Hi all,
as announced, here some further info:
First of all, I have to admit, that this little utility was just created as some sort of "experiment", thus the code has not been cleaned up (several things might be programmed better) and there are some limitations. I just stopped development as this thingy actually fulfilled MY requirements, but I decided to publish it here to give YOU also a basis to start with
So I would like to invite YOU to further improve this "SSRS Helper", please share your comments, advices, fixes, enhancements etc.. As we should not "flood" MIBUSO by posting dozens of different variants of this tool, I kindly ask you to publish your proposals HERE or to send me your code via e-mail: [url]contact@stryk.info[/url] I'll update the "SSRS Helper" then and publish the new versions here (of course, with appropriate acknowledgement of all who participated!)
--------------------------------------------------
OK, so here - briefly - what "SSRS Helper" does:
1.
Option to SQLThe Problem: If you query an option field vie SQL you only retrieve the Option
Value.
For example ...
SELECT [Document Type], [Document No_], [Line No_] FROM [dbo].[Cronus$Sales Line]
... will show a result like:
[Document Type], [Document No_], [Line No_]
1 , 12345 , 10000
Here, "SSRS Helper" is generating the CASE subquery which could be used to fetch the Option Text e.g. of [Document Type]:
Option String:
Quote,Order,Invoice,Credit Memo,Blanket Order,Return Order
CASE [Document Type] WHEN 0 THEN 'Quote' WHEN 1 THEN 'Order' WHEN 2 THEN 'Invoice' WHEN 3 THEN 'Credit Memo' WHEN 4 THEN 'Blanket Order' WHEN 5 THEN 'Return Order' END AS [Document Type]
Hence, when including this CASE in the SELECT statement ...
]SELECT
CASE [Document Type]
WHEN 0 THEN 'Quote'
WHEN 1 THEN 'Order'
WHEN 2 THEN 'Invoice'
WHEN 3 THEN 'Credit Memo'
WHEN 4 THEN 'Blanket Order'
WHEN 5 THEN 'Return Order'
END AS [Document Type],
[Document No_], [Line No_] FROM [dbo].[Cronus$Sales Line]
... will give this:
[Document Type], [Document No_], [Line No_]
Order , 12345 , 10000
Again, "SSRS Helper" creates this CASE part, which could be used in those queries, either by "copy & paste" or via "dynamic SQL" (the download package contains some examples).
--------------------------------------------------
2.
FlowField to SQL"FlowFields" are not really fields within the table, at least not on the SQL server site - "FlowFields" simply do not exist there, hence they cannot be selected.
Actually a FF displays data from a sub-sequent table, thus a subquery is required to get this info.
The "SSRS Helper" reads the CalcFormula of FlowFields from TXT file into table and parses it to generate this subquery.
For example, FlowField [Inventory] of table [Item]:
The CalcFormula ...
Sum("Item Ledger Entry".Quantity WHERE (Item No.=FIELD(No.),Global Dimension 1 Code=FIELD(Global Dimension 1 Filter),Global Dimension 2 Code=FIELD(Global Dimension 2 Filter),Location Code=FIELD(Location Filter),Drop Shipment=FIELD(Drop Shipment Filter),Variant Code=FIELD(Variant Filter),Lot No.=FIELD(Lot No. Filter),Serial No.=FIELD(Serial No. Filter)));
... is "translated" into this SQL query:
(SELECT ISNULL(SUM([Quantity]), 0) FROM [Cronus$Item Ledger Entry] WHERE ([Item No_] = [CRONUS 403$Item].[No_]) AND ([Global Dimension 1 Code] IS NOT NULL) AND ([Global Dimension 2 Code] IS NOT NULL) AND ([Location Code] IS NOT NULL) AND ([Drop Shipment] IS NOT NULL) AND ([Variant Code] IS NOT NULL) AND ([Lot No_] IS NOT NULL) AND ([Serial No_] IS NOT NULL)) AS [Inventory]
This could be included into the "main" query.
--------------------------------------------------
Limitations & Known Issues:
- The NAV OptionStrings, CalcFormulas and the generated TSQL frequently exceeds the max. field length of 250 characters in NAV. I decided NOT to save everything in binary fields, but to split up the strings in up to 4 table fields (like TSQL1, TSQL2, TSQL3, TSQL4). This gives a max. length of 1000 characters, but even that is exceeded in NAV 2009. If this happens, the query contains a '<...>' at the end.
- Some CalcFormulas are really tricky to parse. I didn't care, I just left them incomplete - feel free to enhance.
- FlowFilters are included as "IS NOT NULL" filters; these filters have to be set manually.
So, I hope it helps you with SQL reporting etc.! Enjoy!
Looking forward to getting your most appreciated feedback.
Best regards,
Jörg