You are on page 1of 16

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

© 2011 SAP AG. All rights reserved. 2


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.

© 2011 SAP AG. All rights reserved. 3


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

© 2011 SAP AG. All rights reserved. 4


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

© 2011 SAP AG. All rights reserved. 5


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
Allow range values True

© 2011 SAP AG. All rights reserved. 6


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

© 2011 SAP AG. All rights reserved. 7


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

© 2011 SAP AG. All rights reserved. 8


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 Setting
Allow multiple values False
Allow discrete values False
Allow range values True

Remember: almost all date fields in SAP Business


One are date/time format

© 2011 SAP AG. All rights reserved. 9


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 <Parameter Name>@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 BPType@SELECT Distinct CardType from OCRD
o SelectBPs@SELECT CardCode, CardName from OCRD WHERE (CardType ='@BPType')

© 2011 SAP AG. All rights reserved. 10


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 Setting
<parameter_name>@title Prompt Text This is Title 1

Separators: Separators are horizontal lines that span the width of a selection
criteria window
<parameter_name>@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.

© 2011 SAP AG. All rights reserved. 11


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 Edit Parameter window,
 <parameter_name>@

Value Options Setting


Allow multiple values False
Allow discrete values True
Allow range values False

© 2011 SAP AG. All rights reserved. 12


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

© 2011 SAP AG. All rights reserved. 13


Special Tokens
Tokens for Layouts

UserCode@
 The UserCode@ token contains the current user code for Business 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.

© 2011 SAP AG. All rights reserved. 14


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

© 2011 SAP AG. All rights reserved. 15


Thank You!

Dan Love

Customer Relations and Solution Advisor


SAP Business One, North America
Ecosystem & Channels Readiness

+1 503-758-0457
dan.love@sap.com

You might also like