Professional Documents
Culture Documents
Sap CRM Ui Cookbook Tutorials
Sap CRM Ui Cookbook Tutorials
Business Roles
Definition
The Business role is the central object for controlling the Navigation Bar, the Logical
Links and the authorizations for users
Purpose
The business role determines the different profiles of the UI and
what is visible on the UI
How to define and assign Business Roles
Step1: Go to IMG Path: Customer Relationship Management > Business Roles >
Define Business Roles or to transaction CRMC_UI_PROFILE
Step2: Pick a suitable role which you want to create a copy of and note the PFCG
Role ID
Step3. Go to Transaction PFCG and create a Z copy of the standard PFCG role
Step 4: Once the PFCG Role is created go to IMG Path: Customer Relationship
Management > Business Roles > Define Business Roles and create a new business
role with the above created PFCG Role. (It is convenient to copy the standard role to
Z name space and change the PFCG role ID). Save the changes.
Step 5: IMG Path: Customer Relationship Management > Business Roles > Define
Organizational Assignment or transaction PPOMA_CRM
Users/Business partners are assigned within the Organizational Model to a
Position
User / Business Partners can be assigned to multiple Positions
Each Position can have exactly one Business Role
Step 3: You can save your configuration according to different parameters. If different
configurations for one view have been saved you get an overview, if you press
Choose configuration. With Copy Configuration you can copy an existing
configuration. Make the necessary changes to the config and save the same. Run the
UI and notice the made changes.
The navigation bar can have a two level menu. Each of the last level entry is known as
a Logical Link.
Logical Links can then be grouped as follows depending on whether you want to
include it as a work centre link or a direct Link
Part of work Centre
Step 1. Create a relevant logical link
Step 2: Group different Logical Links as Work Center Link Groups
Step 3: Group related Work Center Link Groups as work centres
Step 4: Assign the work centre to the navigation bar profile
Part of direct link group
Step 1: Create a relevant logical link
Step 2: Group different logical links as Direct Link groups
Step 3: Assign the direct link group to the navigation bar profile
Once the above steps are done, we need to assign the navigation bar profile to the
business roles:
Go to IMG Path: Customer Relationship Management > Business Roles
Assign your navigation bar profile to the business role.
Note: You also need to go into options adjust work centers, adjust work centre groups
and adjust link groups and activate all the links that you need to see on the UI.
4.Transaction Launcher
Purpose
With Transaction Launcher you can integrate Calls of:
1) External URLs which are defined in URL repository
2) Web Gui Transaction of another SAP System with available ITS
Pre-requisites
1) The transaction Launcher can be used to launch URLs and BSPs / BOR
transactions from other systems.
2) To launch a GUI transaction a BOR object type with a method EXECUTE, that
supports synchronous calls is required.
3) A mapping of the logical systems is required. Transaction:
CRMS_IC_CROSS_SYS
4) To launch an URL the URL has to be defined in the URL repository first.
View: CRMV_IC_LTX_URL
Launch GUI transaction
1) To launch a GUI transaction a BOR object type with a method EXECUTE, that
supports synchronous calls is required.
2) Transaction: SE80 > Workbench > Edit object
3) Copy BOR object type TSTC to ZTSTC
b) Enter a description, class name (Z-class, dont give names of existing classes
else the same gets over-written )
If the STATEFUL flag is set, the launch transaction will always be executed in a
new window and will remain open until the agent manually closes it.
The RAISE VETO flag is used to raise a message to inform the agent that launch
transaction is open on a different window and is useful only when the STATEFUL
flag is set.
Launch URL
1) Transaction: SM30 View: CRMV_IC_LTX_URL
Maintain the necessary URL details
c) Select the transaction type as a URL transaction and enter the URL ID
5. MVC Concept
Presentation Layer (BSP)
user
inpu
Request
Controller
set Model
CRM WebClient
data
outpu
Response
View
Business Layer
get
Data flow
Control flow
Business
Engine
(APIs)
Tables
Request
Model
data
output Response
Business
Layer
Controller
View
Business
Engine
API
API
API
BOL (Business Object Layer): The BOL structures hold the data while the UI
session runs. You can treat them as work areas.
GenIL (Generic Interaction Layer): The GenIL layer includes the classes that
connect the BOL with the underlying APIs that fetch the relevant data from the
data base tables.
Note: You can have a look at the underlying GenIL classes as follows:
Go To IMG path: Customer Relationship Management > CRM cross-application
components > Generic interaction layer/object layer > Basic Settings
These GenIL implementation classes connect the BOL to CRM application logic
and database tables APIs
BOL & Genil Tools
Presentation
Controller
Layer
BSP
Model
View
Business
Layer
GenIL
GenIL
IMG: Generic Interaction
Layer/Object Layer
Basic Settings
Business
Engine
AP
I
AP
I
AP
I
Types Of Objects
Root objects: Directly accessible via a distinct key (like Header GUID for
BTOrder) and can be independently locked and maintained.
Query Services (Search Objects): Defined object search by given set of
parameters. Return a well defined root or access object type.
Dependent object: Aggregated by a distinct root objects. Locked and maintained
only via its root object.
Query Result objects (Search Result Objects): Aggregated set of fields from
various root, access, or dependent objects for faster display of result lists. ReadOnly by definition.
Access objects: Directly accessible via a distict key but locked and maintained
only via its root object.
View objects: Alias for a hard coded set of objects.
You can test the data retrieval from the database to the BOL through GenIL using
GENIL_BOL_BROWSER
Using the pushbutton CHILDREN you can navigate to the relations as you see
them on GENIL_MODEL_BROWSER and view the data.
7. Component Workbench:MVC
To work on UI Components SAP provides so called Component Workbench in
CRM system.
Transaction BSP_WD_CMPWB starts this Tool.
You can also launch UI directly from here.
When youre on initial page you can enter component name CRM_UI_FRAME in
input field Test Application and hit Test button to launch UI
Go to the application and pick up one of the views and note the following:
Controller
:
Model:
Context &
Context
Nodes
Controller:
Event Handling & Navigation
View: Layout
The Controller gets implemented within a single ABAP class which follows the
naming convention always to end on suffix _IMPL. Its also called the
Implementation Class.
The Model is represented by a collection of ABAP classes.
One management class administrates several different model accesses classes.
This management class also follows a certain naming convention to always end on
suffix _CTXT. Therefore this class is also called the Context class. It is
responsible for creating and connecting the context nodes.
The sub elements which are managed by the context are the so called Context
nodes.
Each context node refers to a single business object out of SAPs Business Object
Layer (BOL).
Context Nodes are also implemented as ABAP classes. Each context node
provides methods to get access to specific business data within SAP CRM
databases.
The View is implemented as so called business server page (BSP), which is a .htm
file.
Certain layout specific coding can be found in here. The view takes over the data
coming from model and prepares the final html output which is sent back to users
browser for display.
user
inpu
t
Request
Controller
Class
* .DO
_IMPL
Methods:
Before Output
DO_INIT_CONTEXT
PREPARE_OUTPUT
After Input
DO_HANDLE_DATA
DO_HANDLE_EVENT
View
Model
Context
*. HTM
Context
Nodes
*_CN01
e.g. Address
Layout:
data
outpu
t
ABAP/HTMLB-code
describing the view layout
Response
BOL
DB
Tables
8.Controller
In this section, we shall have a look at the basic methods in the controller and the
general architecture.
Each view has a controller which has the naming convention .do. The controller is
implemented through a global class which generally ends with _IMPL.
Attributes
Each implementation class has an attribute called TYPED_CONTEXT which
refers to the type of the Context Class (_CTXT).
Methods
Some of the important methods and for what purpose they are used are listed
below:
a) DO_INIT_CONTEXT
This method is used to initialize the context reference.
b) WD_CREATE_CONTEXT
It instantiates the controller context reference. It calls the method
CREATE_CONTEXT_NODES of the context class.
c) WD_DESTROY_CONTEXT
This method releases the controller context reference.
d) DO_HANDLE_DATA
This is the very first method that the runtime would come to after user has
made inputs on the view or a user action has been triggered. This method has
an importing parameter called FORM_FIELDS. You can check this to see
The context node class has the methods called getters and setters for each
attribute in that BOL relation.
a) GET_<attr_name>
This method fetches the value of the required attribute from the BOL structure
which is then used to be displayed on the view
b) SET_<attr_name>
This method sets the value entered by the user on the view into the BOL
structure.
c) GET_M_<attr_name>
This method is used to get the metadata of the attribute (basically the data type
that the attribute refers to)
d) GET_I_<attr_name>
This method is used to get the input readiness for the attribute. If this method
returns a FALSE then the attribute is displayed as a read-only field on the
view.
e) GET_V_<attr_name>
This method is used to give any value help to the fields on the view. The
implementation of this method will be taken up later
f) GET_P_<attr_name>
This is used to describe the property of the attribute. For example: you want a
link to appear under one of the attributes then you can use this method.
g) ON_NEW_FOCUS
This method defines how the collection for the context node shall be created.
It is usually called in the method CREATE_CONTEXT_NODES of the
context class to initialize the collection.
10.View Layout
The view is the .HTM file of the view.
Each view has a set of page attributes which are used to display the data on the
view.
Various BSP extensions are available for us to code the view layout.
You can have a look at them in SE80 by selecting the option BSP Extensions.
Each of the BSP extensions provides certain tags.
Some of the extensions commonly used are HTMLB, CHTMLB, XHTMLB etc.
11.Config Tool
CRM 2007 provides a very strong config tool in order to define the configuration
of each view without writing much of html code.
In order to use the config tool you need to use a Role Config key(described in
Chapter 2).
The code to be written at the view level for using this tool is as follows:
Once this has been done the runtime understands that the view layout as to be
picked up as defined in the configuration and you would be able to see a
configuration tab in your component workbench.
Note: If you are defining a new configuration for a standard view, copy existing
configuration and save the changed configuration against your Role Config key. This
config would be visible when you launch your UI as the role config key is saved
against your Business role. (Process defined in chapter 2)
If you click on the Button Show Available Fields it would list down all the context
nodes with the attributes in them.
You can then select the required attribute and click the + or buttons to add or
remove fields from the view
.
Click on the button Show Field Properties after selecting a field
You will be able to make changes like, changing the row column positions, changing
labels, making the field mandatory or read-only.
12.Window Concept
Each component must have one or more windows which are hosting
the views.
It defines a root for a hierarchy of viewsets and views in the runtime repository.
Navigation is only possible between views or viewsets which are assigned to the same
single window.
A viewset or view can only be part of exactly one window (still no direct reuse of
views)
The window is not only responsible for managing navigation between own views of
the component but it is also mediating between the embedded and embedding
component during runtime.
It acts as the interface between two single components which are reusing each other.
ViewSet
View
ViewArea
ViewArea
View
ViewSet
In case of over view pages the views are attached to the OVP in the runtime
repository. Each of them appears as one Assignment Block (AB) in the
configuration. You need to select the assignment blocks that you want to display.
As for a loading, we have 3 options:
1) Direct Load
The entire view appears as soon as the UI is started
2) Lazy load
The header text of the view appears as a link and you have to click on it to see the
entire view
3) Hidden
Such views are not displayed on the UI.
Logical Link
Main Component M
Technical
ID =
(Target-ID)
Display
Search
Sub component
Header
IP
OP
Sub component
Search
IP
IP
Window
ViewSet
Window
IP
ViewSet
OP
View
View
OP
OP
Each Main Component consists of all available Sub Components related to one
certain Business Object like One Order etc.
Each Sub Component keeps certain Views. A View represents one UI screen with
a certain collection of fields and data of a Business Object.
Sub Components communicate via Inbound and Outbound Plugs.
These Plugs enable data transfer between components as well as cross component
navigation on UI.
To call such a Main Component from your Navigation Bar a target ID has to be
defined.
This target ID points to a specific so-called work area component together with
a specific inbound plug to use.
Definition of target IDs can be found in Customizing under CRM -> UI
Framework -> Technical Role Definition -> Define Workarea Component
Repository
1) In the runtime repository we can find all necessary definitions how runtime
objects work together during processing of UI Component.
To be able to show a view finally to the end user it has to be assigned to a
Window. This assignment will be done in Runtime Repository editor.
2) Different single views can be combined together in a so-called Viewset to
display them together on a single screen.
How and which views form a viewset can be defined in viewset section of runtime
repository editor.
3) Definition of Navigation between views can be found in description of so
called Navigational Links.
A navigational link contains concrete information about on which source view a
navigation starts and on which target view it ends. Its a kind of a dericted route
description for a single navigation step.
4) To enable an UI component to be reusable a so called Component Interface has
to be defined.
In the Component Interface you define which views of the component can be
reused and which data should be available to the outside.
5) A Component Usage defines which parts of an outside component are reused
within the reusing component.
It gives a detailed description of which parts of an outside Component Interface
are getting used and are available then to the reusing component.
Component Usages are handled like inside views, and can be also used as parts of
a viewset or a Navigational Link.
To display parts of reused components, Component Usage also has to be assigned
to a Window.
6) The Models section is used to add the component set of the GenIL structure. It
is the same component set that you enter in the transaction
GENIL_MODEL_BROWSER.
Controller
Model
Context Node
View 1
Lifespan
Custom
Controller
Model
Context Node
Model
Context Node
View 2
Database
The binding of the custom controller nodes with the nodes of the view happens in
the method CREATE_CONTEXT_NODES of the context class of the view.
Component I
Component H
Component S
View
View
View
View
View
View
View
View
View
View
View
View
Create a new enhancement set. You need to enter only a name and description.
3) When you do that you get an option to enter a new BSP application name (
This should be a new name)
4) Once you have done that in SM34 view BSPWDVC_CMP_EXT you will be
able to see the enhancement definition
5) Right click on the view that you want to make changes to and say enhance
(All objects in Grey have not been enhanced and the ones in Black have been
enhanced) All the classes would be generated in the Z-namespace, so you can
go ahead and redefine methods or create new methods.
7) Once you have done this you shall be able to see the same in SM34 view
BSPWDVC_CMP_EXT under controller replacements against Enhancement
definitions
(Give a name to the view set and the number of rows and columns that you require)
(You need to create view areas and enter the column and row positions and the spans)
Creation of Views
Right click on views and say create
Model nodes are the ones which are picked up from BOL structures. The model nodes
can be created as to be dependent on the higher model nodes as shown in the screen
shot above. The code for creating the collection of the lower end nodes will be
generated by the wizard.
Value nodes are generally used for those data which are not a part of the BOL instead
they could be referring to a DDIC table, etc.
In this step you select the various attributes that you want in your context nodes. The
setters and getters for the same would be generated by the wizard.
Click on the add button and give the DDIC table name and then you can select all the
attributes that you require in your value node.
This step is used link the context nodes of the view with the context nodes of the
custom controller. As covered in chapter 15 the code for binding the context nodes
would be generated.
We shall take up an example of custom controllers later. Let us skip this step for now.
Select the view type that you want to create. You can select an empty view and write
the configuration code or else select the table view in case you want to have the
display in the table format. In case of the table view you shall need to select the
context node which you want to appear in the table format. Form view contains form
for data entry.
All the controller, context and context nodes classes would be generated. Save the
classes.
Next add the configuration code for the view in the .htm as covered in chapter 11 and
create a configuration for the same.
Go to the runtime repository editor of the component and make the following changes
Similarly you can create other views and attach to the different view areas.
In case you want to attach the same to an OVP instead follow the steps shown below:
After this in configuration select the assignment block and make it available.
At the view.htm level, the following code needs to be maintained for displaying
the buttons:
This view has to be a part of an overview page and the button would be available
besides the view header text.
2) In order to create the buttons in the toolbar, you shall need to implement the
interface IF_BSP_WD_TOOLBAR_CALLBACK. The list of the buttons will
be provided in the method
IF_BSP_WD_TOOLBAR_CALLBACK~GET_BUTTONS
If the buttons are in a view which is a part of the view set you shall have to
implement the interface in the view set as well.
The buttons in this case would appear in the tool bar.
3) The last method is to directly create the button using the extensions
In this case the buttons would appear depending on their placement in the .htm
page.
This code is generated by the wizard as follows. Go to the controller class of the
view, then in the event handler right click and say Create
Give the event name. Please note that it is very important to have this user
command entered in the right case else the event handler cannot be determined
correctly.
Navigational Link
Navigational links define the mapping between a specific source with OP and
target with IP. The navigational link name has to be unique.
Create the navigational link with a unique name and provide the IP/OP and the
view details.
Navigation Procedure
The event handler for the event would call the relevant outbound plug.
The outbound plug would then call the Navigational link which would then
navigate to the relevant view.
The steps are illustrated below:
Navigation Request
Calling of OutboundPlug
Starting Navigation
2) In the next step window controllers outbound plug method gives responsibility
for navigation to the outside, by so-called firing an outbound plug to the
framework. Name of fired outbound plug and name of outbound plug method
have to be the same.