Example: Report without arguments
The query below will show all messages and notifications waiting to be sent.
Begin
@[Messages waiting to be processed]
§Name [Waiting notifications]
§Company []
§Description [All configurations including @ tab data]
§Version [1]
§Arguments []
§Sql
[
select *
from DocumentActionInfo
]
End
Reports with arguments
This section is for reports that will need additional information at run time. Perhaps the logged in user’s name will be needed or some file names. I will give some examples below but for a complete list of all the possible arguments and how to use them please refer to the “Administration Guide” as described in the “Additional Information” section. Note there are many more possible combinations than what I am covering here. They are in the section “Report Query Arguments” in the “Administration Guide”.
In the example below I am using simple substitution – I replace the argument in the SQL script with the variable enclosed in {}. Please note that it is also possible to use an “OR” for multiple values in the argument. Please refer to the documentation in the “Administration Guide” on how to use that.
The section below is copied from the “Administration Guide” on “Arguments”:
§Arguments
[
§type name[count] [instruct]
]
Where:
- type is a predefined argument type. The possible types are described in the Administration Guide
- name is a variable used in the WHERE element of the SQL query
- [count] defines how values are returned to the SQL query
- [instruct] appears in the Report Generator as a user instruction
A report query can have multiple arguments.
All components of the argument must be on one line.
Example:
In the example argument below, the number of groups to be selected is open. The user can choose as many groups as he likes from the list of groups in PDM. When the report is run a dialog will appear and the user can choose the groups to be added to the selection list.
Begin section
§Arguments
[
GroupID TheGroupID[N] [Select groups]
]
End section
Report example with an argument
In the example below, the argument is a single text entry – the filename. The variable is called “theFileName”. Note that the variable is enclosed in curly braces when it is used in the query: {theFileName}
Begin query
@[Find Referencing Checked Out files]
§Name [Files that reference this file that are currently checked out]
§Company [SolidWorks]
§Description
[This query will find all files that reference the target file and are checked out]
§Version [1.2]
§Arguments
[
String theFileName[1] [Enter filename]
]
§Sql
[
select b.DocumentID, a.Filename as ref_File
from documents a
join XRefs b on a.DocumentID=b.DocumentID
where b.XRefDocument=(select DocumentID from documents where Filename={theFileName})
and a.LockPath !=”
End query
Template: Report with arguments
In the “template” below the argument is a single string value that is assigned to the variable “theFileName”. You are welcome to change the name of the variable to whatever you desire. If you want more than one value then change the [1] to the desired number. You can also change the user prompt from “Enter filename” to whatever you like – just keep the brackets.
Begin query
@[Unique name for Query]
§Name [Name displayed in “Queries” box]
§Company [Optional]
§Description
[Optional]
§Version [1.0]
§Arguments
[
String theFileName[1] [Enter filename]
]
§Sql
[
SQL query goes here
]
End query
Conclusion
This has been an introduction into using and modifying the SOLIDWORKS PDM Report Generator tool. Hopefully, you will have found the article informative and the templates of use. If you wish to investigate this issue in more detail please examine the “Administration Guide”
This link will provide 13 sample reports. You may need to modify some of the settings so it matches your environment. The provided reports do the following: