Defining Tokens in SAP Business One Partner Enablement Session
May 24th 2011
Agenda
Tokens in Crystal Reports for SAP Business One 8.8
Overview and Differences
Creating Parameters and Syntax Rules
Examples
Special Tokens
Modifying Existing Parameters
Parameters in Crystal Reports Software
Parameters prompt the user of a report to enter information. That information can determine what appears in the report or how the report processes. By using parameter fields in formulas and selection formulas in the report itself, you can create a single report that you can change as your user reporting needs change. A parameter field can be identified by curly brackets and a question mark before the parameter name. o
For example {?parameter_name}
Parameter setup and usage in release 8.8 of the SAP Business One application significantly differs from that of earlier releases of SAP Business One.
How Parameters Work in SAP Business One 8.8
Dialog creation during runtime that has the same look and feel as system reports in SAP Business One A parameter defined in reports and run in SAP Business One will display familiar UI controls of SAP Business One The UI control displayed will vary based on your parameter definition
Creating Parameters Enabled for Business One
Right-click Parameter Fields in the field explorer
Select New…
Enter your “token” in the Name field – Tokens consist of three components: o Unique name + “@” + “SQL Select Statement” o There is no space between your name and the @ symbol or the SELECT keyword o SQL Select Statement is any valid SQL Statement
Choose your parameter data type (string, Boolean, number, date, currency, and so on)
Keep the default List of Values setting as Static
Select the value options you desire. The key ones for parameters in SAP Business One are: – Prompt text – Allow multiple values – Allow discrete values – Allow range of values
Report Tokens in Business One Examples – 1 SelectItem@Select * from OITM Value Options
Setting
Allow multiple values
False
Allow discrete values
True
Allow range values
False
SelectAccount@Select * from OACT Value Options
Setting
Allow multiple values
True
Allow discrete values
True
Allow range values
False
SelectBPCode@Select CardCode from OCRD Value Options
Setting
Allow multiple values
False
Allow discrete values
False
Report Tokens in SAP Business One Examples – 2 SelectAccount@Select * from OACT Value Options
Setting
Allow multiple values
False
Allow discrete values
True
Allow range values
False
SelectBPCode@Select * from OCRD Value Options
Setting
Allow multiple values
True
Allow discrete values
True
Allow range values
False
Report Tokens in SAP Business One Examples – Where and Imbedded Tokens SelectVendors@SELECT * from OCRD where CardType = ‘S’ Value Options
Setting
Allow multiple values
False
Allow discrete values
True
Allow range values
False
Country@SELECT distinct Country FROM OCST State@SELECT code, name FROM OCST WHERE (Country = '@Country') Value Options
Setting
Allow multiple values
False
Allow discrete values
True
Allow range values
False
Report Tokens in SAP Business One Date Tokens MyDate@
Parameter type “Date” Value Options
Setting
Allow multiple values
False
Allow discrete values
True
Allow range values
False
OFPRDate@SELECT * FROM OFPR
Parameter type “Date” Value Options
R
Setting
Allow multiple values
False
Allow discrete values
False
Allow range values
True
be
lm
t all date fields in S A P B
iness
Syntax and Rules for Defining Tokens Recap
Parameter names must start with an alphanumeric character or an underscore (_)
The at-sign (@) must follow the parameter name with no space between them
An SQL statement usually follows the at sign (@), with no space after the at sign @ The general syntax for creating tokens in SAP Business One: o
@SELECT … FROM … WHERE
The SELECT command is not always mandatory for all tables in SAP Business One, but be consistent – using them is a good rule A token may include another parameter name; a second parameter may depend on a first parameter: o o
BPType@SELECT Distinct CardType from OCRD SelectBPs@SELECT CardCode, CardName from OCRD WHERE (CardType ='@BPType')
Special Tokens Separators Titles: You can assign a “title” token to label a group of selection criteria. Place the text that you want to appear in the title in the Prompt Text field of Value Options Value Options
@title
Prompt Text
Setting This is Title 1
Separators: Separators are horizontal lines that span the width of a selection criteria window @separator
To define the parameter order, select a parameter in the field explorer, right-click, and select Set Parameter Order . Use the up and down arrows to position each parameter.
Special Tokens Value Lists Value lists: Build your own list of static values for user selection Enter a list of valid values in the value list of the E dit P arameter window,
@
Value Options
Setting
Allow multiple values
False
Allow discrete values
True
Allow range values
False
Special Tokens Tokens for Layouts
DocKey@ The DocKey@ token contains the current active document number in SAP Business One. Use this token in your Select Expert report to restrict the data to just this document. Example for a invoice layout: {OINV.DocEntry}={DocKey@} If the DocKey@ token does not exist, create a new parameter with the following settings: – Enter DocKey@ in the Name field – Select Number in the Type dropdown list – Leave the default settings in all other fields
ObjectId@ The ObjectId@ token is recommended when you want to use the layout as a master layout for multiple marketing documents. The ObjectId@ token will contain a numeric value that identifies the current document type (13 = invoices; 17 = sales orders) See BoObjectTypes enumeration in the help files of the software development kit (SDK) If the ObjectId@ token does not exist, create a new parameter with the following settings: – Enter ObjectId@ in the Name field – Select Number in the Type dropdown list Leave the default settings in all other fields
Special Tokens Tokens for Layouts
UserCode@
The UserCode@ token contains the current user code for Busi ness One that is currently logged on, such as “manager.” The parameter type is String. This token is available only for layouts; you cannot use it in reports.
Modifying Parameter Tokens Rename Not Edit You cannot edit a parameter name from the Edit Parameter window once it has been added To edit the parameter name, select the parameter name in the field explorer and right-click Select Rename F2 from the pop-up menu
Edit the token here
Thank You! Dan Love Customer Relations and Solution Advisor SAP Business One, North America Ecosystem & Channels Readiness +1 503-758-0457 [email protected]