SlideShare a Scribd company logo
1
Controllers
and Context
Programming
2
© SAP AG 2005, ABAP Web Dynpro
The Context At Runtime
Understand the controller methods that are available
to you for application coding
The Context API
Contents:
Controller and Context Programming
3
© SAP AG 2005, ABAP Web Dynpro
After completing this lesson, you will be able to:
Understand how to access nodes and attributes in
the context using the context API.
The Context API: Objectives
4
Code Implementation
Each Web Dynpro controller is a separate ABAP program. The definition of these
programs is generated automatically when a new component or controller is
declared. The source code, that implements these controllers is generated
automatically. You are provided with various points within the controller code
where you may add your own coding.
Any attempt to entering coding outside the designated areas will result in that code
being lost when the controller is regenerated.
Every time the controller is activated the code is regenerated.
Standard Hook Methods
In every controller, there are certain standard methods that are always present. At
controller creation time, these methods are empty and can hold any coding the
developer wishes to place within them.
The application developer is not permitted to deleted or rename any of these
standard hook methods. If any attempt is made to do this, the changes will be lost
when the coding is regenerated.
© SAP AG 2005, ABAP Web Dynpro
Common Controller Features:
Standard Controller Hook Methods
Controller
Implementation
Standard
Hook
Methods
Instance
Methods
Context
Root Node
Required
Controllers
Controller
Interface
Other WD
Controllers
Custom
Controller
Business
Logic
(Models)
Created by explicit declaration or coding Created by the Web Dynpro Framework (WDF)
Component
Usage
Other WD
Components
5
WDDOINIT
Standard hook method for all Web Dynpro controllers. This method is only called
once during the lifecycle of a controller. All your initialization code should go here
since this method is called immediately after the controller has been instantiated.
WDDOEXIT
Standard hook method called at the end of a controller’s life cycle. All your
cleanup code should go here.
This method is called immediately before the controller’s lifecycle comes to an
end.
© SAP AG 2005, ABAP Web Dynpro
Standard Hook Methods for all controllers
All controllers have these two standard hook methods.
The method will only be called during the controller’s lifecycle if they
contain coding.
method WDDOINIT.
endmethod.
method WDDOEXIT.
endmethod.
6
Controller instance methods
This information applies to both view and custom controllers.
For all controllers, you can create an instance method by declaring the method
name and its parameters in the “methods” tab of the controller editor window.
© SAP AG 2005, ABAP Web Dynpro
Common Controller Features: Controller Instance Methods
Controller
Implementation
Standard
Hook
Methods
Instance
Methods
Context
Root Node
Required
Controllers
Controller
Interface
Other WD
Controllers
Custom
Controller
Business
Logic
(Models)
Created by explicit declaration or coding Created by the Web Dynpro Framework (WDF)
Component
Usage
Other WD
Components
7
Attributes:
Attributes can be public or private.
Attributes can not be directly used inside the controller. The attributes can be
accessed by using the controller attribute WD_THIS which provides a
reference to the local controller interface.
Methods:
All methods are public and can be used by any other controllers. Prerequisite
is that the controller which will call the method has defined a use relation to the
used controller in his properties.
© SAP AG 2005, ABAP Web Dynpro
Controller Attributes and Utility methods
Attributes for the controller can be created (public or private)
Arbitrary methods can be created - …….
8
WD_THIS
wdThis is the Web Dynpro specific self reference and should be used in
preference to the standard ABAP self reference of me. WD_THIS is a reference to
the current controller’s interface IF<controller name> and represents all the
functionality implemented in the generated class. This gives you access to
standard Web Dynpro functionality such as logging, validation, and parameter
mapping.
WD_CONTEXT
WD_CONTEXT is the reference to the controller’s context root node, and thus to the
entire context.
© SAP AG 2005, ABAP Web Dynpro
Standard Controller Attributes WD_CONTEXT and WD_THIS
WD_CONTEXT and WD_THIS
present in any WD controller (excepted interface and interface view
controller).
WD_THIS - self reference of the local interface, type depends on the
controller type.
WD_CONTEXT - reference to the context of associated controller.
9
© SAP AG 2005, ABAP Web Dynpro
Standard Controller Attribute WD_COMP_CONTROLLER
WD_COMP_CONTROLLER
present in any WD controller.
reference to the component controller with access to all public methods
and attributes.
Attribute will automatically assigned to all view controllers when a view
is created.
For all other controller the WD_COMP_CONTROLLER attribute will
be assigned, when the properties of the controller the component
controller is used.
10
wdDoBeforeNavigation()
This standard hook method is found only in the component controller.
Whenever an outbound plug is fired from a view controller, a navigation event is
raised. It is perfectly possible for each view in a view set to fire an outbound plug;
therefore, all navigation events are placed into a queue and are only processed
once all the views in the current view assembly have been processed. The
wdDoBeforeNavigation() method is called just before the Web Dynpro
Framework processes the events in the navigation queue. This allows you to
implement your own coding to do such things a navigation event prioritisation etc.
wdDoPostProcessing()
This standard hook method is found only in the component controller.
In complex Web Dynpro applications, it is possible that the data from multiple
components must be validated before the next step in the business process can
be taken. This method has been implemented in order for cross component
validation to take place.
© SAP AG 2005, ABAP Web Dynpro
Standard Hook Methods – Component Controller
Note: Only a component controller has these hook methods.
WDDOBEFORENAVIGATION
It is executed before the navigation stack is processed
WDDOPOSTPROCESSING
Data from multiple components can be validated before the next step is
execute
11
To access a context node element, the following steps must be performed:
1.Use the get_Child_Node() method to get a reference of If_Wd_Context_Node node
instance. This method requires the name of the node and optional the index of the element in
the parent node the desired node instance belongs to. In this case, the parent node is the
context root which only ever has one element, therefore the index parameter is 1.
© SAP AG 2005, ABAP Web Dynpro
Access to Attribute of Node Element I
Flights
..nCARRID
CONNID2CARRID
CONNID1CARRID
CONNID
Context Root
0Default
Element
data: Node_Flights type ref to If_Wd_Context_Node.
* navigate from <CONTEXT> to <FLIGHTS> via lead selection
Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ).
* @TODO handle not set lead selection
if ( Node_Flights is initial ).
endif.
Note: Node and attribute
names must be
used in upper case
12
To access a context node element, the following steps must be performed:
1.Use the get_Child_Node() method to get a reference of If_Wd_Context_Node node
instance. This method requires the name of the node and optional the index of the element in
the parent node the desired node instance belongs to. In this case, the parent node is the
context root which only ever has one element, therefore the index parameter is 1.
2.Calling method get_Element() to get the element with the lead selection. This returns a
reference of If_Wd_Context_Element element instance.
© SAP AG 2005, ABAP Web Dynpro
Access to Attribute of Node Element II
Flights
..nCARRID
CONNID2CARRID
CONNID1CARRID
CONNID
Context Root
0Default
Element
data: Node_Flights type ref to If_Wd_Context_Node,
Elem_Flights type ref to If_Wd_Context_Element.
* navigate from <CONTEXT> to <FLIGHTS> via lead selection
Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ).
* get element via lead selection
Elem_Flights = Node_Flights->get_Element( ).
* @TODO handle not set lead selection
if ( Elem_Flights is initial ).
endif.
13
To access a context node element, the following steps must be performed:
1.Use the get_Child_Node() method to get a reference of If_Wd_Context_Node node
instance. This method requires the name of the node and optional the index of the element in
the parent node the desired node instance belongs to. In this case, the parent node is the
context root which only ever has one element, therefore the index parameter is 1.
2.Calling method get_Element() to get the element with the lead selection. This returns a
reference of If_Wd_Context_Element element instance.
3.Calling method get_Attribute() to get the value of the attribute.
© SAP AG 2005, ABAP Web Dynpro
Access to Attribute of Node Element III
Flights
..nCARRID
CONNID2CARRID
CONNID1CARRID
CONNID
Context Root
0Default
Element
data: Node_Flights type ref to If_Wd_Context_Node,
Elem_Flights type ref to If_Wd_Context_Element,
Stru_Flights type If_Componentcontroller=>Element_Flights,
Item_CARRID like Stru_Flights-CARRID.
* navigate from <CONTEXT> to <FLIGHTS> via lead selection
Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ).
* get element via lead selection
Elem_Flights = Node_Flights->get_Element( ).
* get single attribute
Elem_Flights->get_Attribute(
exporting
Name = `CARRID`
importing
Value = Item_Carrid ).
14
With the method get_Static_Attributes all static attributes of a context node can be
retrieved as a structure.
The method get_Static_Attributes will provide the values of the attributes by using
a move-corresponding. So the target structure can be different to the node
structure.
© SAP AG 2005, ABAP Web Dynpro
Access to all Static Attributes of a Node Element
Flights
..nCARRID
CONNID2CARRID
CONNID1CARRID
CONNID
Context Root
0Default
Element
data: Node_Flights type ref to If_Wd_Context_Node,
Elem_Flights type ref to If_Wd_Context_Element,
Stru_Flights type If_Componentcontroller=>Element_Flights.
* navigate from <CONTEXT> to <FLIGHTS> via lead selection
Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ).
* get element via lead selection
Elem_Flights = Node_Flights->get_Element( ).
* get all declared attributes
Elem_Flights->get_Static_Attributes(
importing
Static_Attributes = Stru_Flights ).
15
With the method get_Static_Attributes_Table the attributes of all elements can be
retrieved as a internal table.
© SAP AG 2005, ABAP Web Dynpro
Access to all Elements of a Node
Flights
..nCARRID
CONNID2CARRID
CONNID1CARRID
CONNID
Context Root
0Default
Element
data: Node_Flights type ref to If_Wd_Context_Node,
Elem_Flights type ref to If_Wd_Context_Element,
lt_Flights type If_Main_View=>Elements_Flights .
* navigate from <CONTEXT> to <FLIGHTS> via lead selection
Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ).
* @TODO handle not set lead selection
if ( Node_Flights is initial ).
endif.
* get all node element
Node_Flights->GET_STATIC_ATTRIBUTES_TABLE( importing
table = lt_Flights ).
Itab
16
Addition of elements to a node
The process of adding an element to a node requires the following steps:
1.Access the relevant context node. Use the get_Child_Node() method to get a reference of
If_Wd_Context_Node node instance.
© SAP AG 2005, ABAP Web Dynpro
Binding of an Element to a Node I
FLIGHTSContext Root
0Default
Element
data:
Node_Flights type ref to If_Wd_Context_Node.
* navigate from <CONTEXT> to <FLIGHTS> via lead selection
node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ).
17
Addition of elements to a node
The process of adding an element to a node requires the following steps:
1.Access the relevant context node. Use the get_Child_Node() method to get a reference of
If_Wd_Context_Node node instance.
2.Create a new elements with the method create_element().
© SAP AG 2005, ABAP Web Dynpro
Binding of an Element to a Node II
FLIGHTSContext Root
0Default
Element
data:
Node_Flights type ref to If_Wd_Context_Node,
First_flight_Elem type ref to If_Wd_Context_Element.
* navigate from <CONTEXT> to <FLIGHTS> via lead selection
node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ).
* create new element for node FLIGHTS
First_flight_Elem = Node_Flights->create_element( ).
18
Addition of elements to a node
The process of adding an element to a node requires the following steps:
1.Access the relevant context node. Use the get_Child_Node() method to get a reference of
If_Wd_Context_Node node instance.
2.Create a new elements with the method create_element().
3.Set the corresponding attributes to the element.
© SAP AG 2005, ABAP Web Dynpro
Binding of an Element to a Node III
FLIGHTSContext Root
0Default
Element
CARRID
CONNID
data:
Node_Flights type ref to If_Wd_Context_Node,
First_flight_Elem type ref to If_Wd_Context_Element.
* navigate from <CONTEXT> to <FLIGHTS> via lead selection
node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ).
* create new element for node FLIGHTS
First_flight_Elem = Node_Flights->create_element( ).
* set attributes
First_flight_Elem->set_attribute( name = 'CARRID' value = 'LH' ).
First_flight_Elem->set_attribute( name = 'CONNID' value = '400' ).
19
Addition of element as a structure to a node
The process of adding an element as a structure to a node requires the following
steps:
1.Access the relevant context node. Use the get_Child_Node() method to get a reference of
If_Wd_Context_Node node instance.
2.Fill the required structure elements.
3.Set the corresponding attributes to the element.
4.Bind the element to the node. The parameter SET_INITIAL_ELEMENTS allows to delete all
existing elements of a node and bind only the actual element to the node. In this case the
parameter must be set to abap_true (default value). If the element should be added to the node
as an additional element then the parameter must be set to abap_false.
© SAP AG 2005, ABAP Web Dynpro
FLIGHTSContext Root
0Default
Element
CARRID
CONNID
1
Binding of an Element to a Node IV
data:
Node_Flights type ref to If_Wd_Context_Node,
First_flight_Elem type ref to If_Wd_Context_Element.
* navigate from <CONTEXT> to <FLIGHTS> via lead selection
node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ).
* create new element for node FLIGHTS
First_flight_Elem = Node_Flights->create_element( ).
* set attributes
First_flight_Elem->set_attribute( name = 'CARRID' value = 'LH' ).
First_flight_Elem->set_attribute( name = 'CONNID' value = '400' ).
* bind first element to node
Node_Flights->bind_element( new_item = First_flight_Elem
SET_INITIAL_ELEMENTS = abap_false ).
20
Addition of element as a structure to a node
The process of adding an element as a structure to a node requires the following
steps:
1.Access the relevant context node. Use the get_Child_Node() method to get a reference of
If_Wd_Context_Node node instance.
2.Fill the required structure elements.
3.Set the corresponding attributes to the element.
4.Bind the structure to the node. The parameter SET_INITIAL_ELEMENTS allows to delete all
existing elements of a node and bind only the actual element to the node. In this case the
parameter must be set to abap_true (default value). If the structure should be added to the
node as an additional element then the parameter must be set to abap_false.
© SAP AG 2005, ABAP Web Dynpro
Static Attributes and Binding of a Element to a Node
data:
Node_Flights type ref to If_Wd_Context_Node,
Stru_flights type If_Componentcontroller=>Element_flights.
* navigate from <CONTEXT> to <FLIGHTS> via lead selection
node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ).
* set values to node->attributes
Stru_flights-carrid = 'AA'.
Stru_flights-connid = '017'.
* bind new element to node
Node_flights->bind_structure( new_item = Stru_flights
SET_INITIAL_ELEMENTS = abap_false ).
21
Addition of multiple elements as a internal table to a node
The process of multiple elements as a internal table to a node requires the
following steps:
1.Define an internal table of the node type.
2.Define a structure of the table type.
3.Append values to the table.
4.Bind the internal table to the node.
© SAP AG 2005, ABAP Web Dynpro
FLIGHTSContext Root
0Default
Element
Binding of a Table to a Node
data:
Node_Flights type ref to If_Wd_Context_Node,
lt_flights type If_Componentcontroller=>Elements_flights,
Stru_flights like line of lt_flights.
* append values to local table
Stru_flights-carrid = 'LH'.
Stru_flights-connid = '400'.
append Stru_flights to lt_flights.
Stru_flights-carrid = 'AA'.
Stru_flights-connid = '017'.
append Stru_flights to lt_flights.
* get node reference
Node_Flights = wd_context->get_child_node( 'FLIGHTS' ).
* bind local table
Node_Flights->bind_table( lt_flights ).
CARRID
CONNID
1
Itab
CARRID
22
© SAP AG 2005, ABAP Web Dynpro
You should now be able to:
Understand how to access nodes and attributes in
the context using the context API
Controller and Context Programming: Summary
Ad

More Related Content

What's hot (20)

Angular Best Practices - Perfomatix
Angular Best Practices - PerfomatixAngular Best Practices - Perfomatix
Angular Best Practices - Perfomatix
Perfomatix Solutions
 
Get rid of controllers in angular 1.5.x start using component directives
Get rid of controllers in angular 1.5.x start using component directivesGet rid of controllers in angular 1.5.x start using component directives
Get rid of controllers in angular 1.5.x start using component directives
Marios Fakiolas
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
Rohit Gupta
 
Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
Christoffer Noring
 
Go swagger tutorial how to create golang api documentation using go swagger (1)
Go swagger tutorial how to create golang api documentation using go swagger (1)Go swagger tutorial how to create golang api documentation using go swagger (1)
Go swagger tutorial how to create golang api documentation using go swagger (1)
Katy Slemon
 
Angularjs2 presentation
Angularjs2 presentationAngularjs2 presentation
Angularjs2 presentation
dharisk
 
Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web
MahmoudOHassouna
 
Murach: An introduction to web programming with ASP.NET Core MVC
Murach: An introduction to web programming with ASP.NET Core MVCMurach: An introduction to web programming with ASP.NET Core MVC
Murach: An introduction to web programming with ASP.NET Core MVC
MahmoudOHassouna
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
Eugene Fidelin
 
Angular 8
Angular 8 Angular 8
Angular 8
Sunil OS
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
Hussain Behestee
 
Dialog programming ABAP
Dialog programming ABAPDialog programming ABAP
Dialog programming ABAP
Jefferson Mutuva
 
Maven
MavenMaven
Maven
Harshit Choudhary
 
Oracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning TutorialOracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning Tutorial
Rakesh Gujjarlapudi
 
React table tutorial use filter (part 2)
React table tutorial use filter (part 2)React table tutorial use filter (part 2)
React table tutorial use filter (part 2)
Katy Slemon
 
Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2
Christoffer Noring
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
Christoffer Noring
 
Angular from Scratch
Angular from ScratchAngular from Scratch
Angular from Scratch
Christian Lilley
 
Working with oro crm entities
Working with oro crm entitiesWorking with oro crm entities
Working with oro crm entities
Oro Inc.
 
Angular interview questions
Angular interview questionsAngular interview questions
Angular interview questions
Goa App
 
Angular Best Practices - Perfomatix
Angular Best Practices - PerfomatixAngular Best Practices - Perfomatix
Angular Best Practices - Perfomatix
Perfomatix Solutions
 
Get rid of controllers in angular 1.5.x start using component directives
Get rid of controllers in angular 1.5.x start using component directivesGet rid of controllers in angular 1.5.x start using component directives
Get rid of controllers in angular 1.5.x start using component directives
Marios Fakiolas
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
Rohit Gupta
 
Go swagger tutorial how to create golang api documentation using go swagger (1)
Go swagger tutorial how to create golang api documentation using go swagger (1)Go swagger tutorial how to create golang api documentation using go swagger (1)
Go swagger tutorial how to create golang api documentation using go swagger (1)
Katy Slemon
 
Angularjs2 presentation
Angularjs2 presentationAngularjs2 presentation
Angularjs2 presentation
dharisk
 
Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web
MahmoudOHassouna
 
Murach: An introduction to web programming with ASP.NET Core MVC
Murach: An introduction to web programming with ASP.NET Core MVCMurach: An introduction to web programming with ASP.NET Core MVC
Murach: An introduction to web programming with ASP.NET Core MVC
MahmoudOHassouna
 
Angular 8
Angular 8 Angular 8
Angular 8
Sunil OS
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
Hussain Behestee
 
Oracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning TutorialOracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning Tutorial
Rakesh Gujjarlapudi
 
React table tutorial use filter (part 2)
React table tutorial use filter (part 2)React table tutorial use filter (part 2)
React table tutorial use filter (part 2)
Katy Slemon
 
Working with oro crm entities
Working with oro crm entitiesWorking with oro crm entities
Working with oro crm entities
Oro Inc.
 
Angular interview questions
Angular interview questionsAngular interview questions
Angular interview questions
Goa App
 

Viewers also liked (20)

E mail eft remittance using bte
E mail eft remittance using bteE mail eft remittance using bte
E mail eft remittance using bte
Kranthi Kumar
 
Webdynpro by vijayender_reddy
Webdynpro by vijayender_reddyWebdynpro by vijayender_reddy
Webdynpro by vijayender_reddy
Kranthi Kumar
 
Adding custom fields to the fi report fbl5 n using bt es
Adding custom fields to the fi report fbl5 n using bt esAdding custom fields to the fi report fbl5 n using bt es
Adding custom fields to the fi report fbl5 n using bt es
Kranthi Kumar
 
Crm technical
Crm technicalCrm technical
Crm technical
Kranthi Kumar
 
IGROWSOFT abap material
IGROWSOFT abap materialIGROWSOFT abap material
IGROWSOFT abap material
Kranthi Kumar
 
Sap script made easy
Sap script made easySap script made easy
Sap script made easy
Kranthi Kumar
 
Scenario on business transaction events
Scenario on business transaction eventsScenario on business transaction events
Scenario on business transaction events
Kranthi Kumar
 
Sap sapscripts tips and tricks
Sap sapscripts tips and tricksSap sapscripts tips and tricks
Sap sapscripts tips and tricks
Kranthi Kumar
 
Exercise in alv
Exercise in alvExercise in alv
Exercise in alv
Kranthi Kumar
 
Sp rao abap
Sp rao abapSp rao abap
Sp rao abap
Kranthi Kumar
 
Ooabap notes with_programs
Ooabap notes with_programsOoabap notes with_programs
Ooabap notes with_programs
Kranthi Kumar
 
Step by step guide to basic web dynpro abap
Step by step guide to basic web dynpro abapStep by step guide to basic web dynpro abap
Step by step guide to basic web dynpro abap
Kranthi Kumar
 
Epic abap
Epic  abapEpic  abap
Epic abap
Kranthi Kumar
 
Sap abap material
Sap abap materialSap abap material
Sap abap material
Kranthi Kumar
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
Kranthi Kumar
 
WEBDYPRO ABAP WITH DETAILED NOTES
WEBDYPRO ABAP WITH DETAILED NOTESWEBDYPRO ABAP WITH DETAILED NOTES
WEBDYPRO ABAP WITH DETAILED NOTES
Kranthi Kumar
 
Bapi programming
Bapi programmingBapi programming
Bapi programming
Samannaya Roy
 
Bapi jco[1]
Bapi jco[1]Bapi jco[1]
Bapi jco[1]
mateenjambagi
 
Abap function module help
Abap function module helpAbap function module help
Abap function module help
Kranthi Kumar
 
Bdc details
Bdc detailsBdc details
Bdc details
Syam Sasi
 
E mail eft remittance using bte
E mail eft remittance using bteE mail eft remittance using bte
E mail eft remittance using bte
Kranthi Kumar
 
Webdynpro by vijayender_reddy
Webdynpro by vijayender_reddyWebdynpro by vijayender_reddy
Webdynpro by vijayender_reddy
Kranthi Kumar
 
Adding custom fields to the fi report fbl5 n using bt es
Adding custom fields to the fi report fbl5 n using bt esAdding custom fields to the fi report fbl5 n using bt es
Adding custom fields to the fi report fbl5 n using bt es
Kranthi Kumar
 
IGROWSOFT abap material
IGROWSOFT abap materialIGROWSOFT abap material
IGROWSOFT abap material
Kranthi Kumar
 
Sap script made easy
Sap script made easySap script made easy
Sap script made easy
Kranthi Kumar
 
Scenario on business transaction events
Scenario on business transaction eventsScenario on business transaction events
Scenario on business transaction events
Kranthi Kumar
 
Sap sapscripts tips and tricks
Sap sapscripts tips and tricksSap sapscripts tips and tricks
Sap sapscripts tips and tricks
Kranthi Kumar
 
Ooabap notes with_programs
Ooabap notes with_programsOoabap notes with_programs
Ooabap notes with_programs
Kranthi Kumar
 
Step by step guide to basic web dynpro abap
Step by step guide to basic web dynpro abapStep by step guide to basic web dynpro abap
Step by step guide to basic web dynpro abap
Kranthi Kumar
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
Kranthi Kumar
 
WEBDYPRO ABAP WITH DETAILED NOTES
WEBDYPRO ABAP WITH DETAILED NOTESWEBDYPRO ABAP WITH DETAILED NOTES
WEBDYPRO ABAP WITH DETAILED NOTES
Kranthi Kumar
 
Abap function module help
Abap function module helpAbap function module help
Abap function module help
Kranthi Kumar
 
Ad

Similar to Controllers and context programming (20)

2007 Zend Con Mvc
2007 Zend Con Mvc2007 Zend Con Mvc
2007 Zend Con Mvc
Pablo Morales
 
Web dynpro
Web dynproWeb dynpro
Web dynpro
Chinmoy Chiranjivi
 
Foundations of Zend Framework
Foundations of Zend FrameworkFoundations of Zend Framework
Foundations of Zend Framework
Adam Culp
 
2007 Zend Con Mvc Edited Irmantas
2007 Zend Con Mvc Edited Irmantas2007 Zend Con Mvc Edited Irmantas
2007 Zend Con Mvc Edited Irmantas
Irmantas Šiupšinskas
 
Conductor vs Fragments
Conductor vs FragmentsConductor vs Fragments
Conductor vs Fragments
Константин Николаевич
 
Container Runtime Security with Falco
Container Runtime Security with FalcoContainer Runtime Security with Falco
Container Runtime Security with Falco
Michael Ducy
 
SAP Inside Track 2010 - Thomas Jung Intro to WDA
SAP Inside Track 2010 - Thomas Jung Intro to WDASAP Inside Track 2010 - Thomas Jung Intro to WDA
SAP Inside Track 2010 - Thomas Jung Intro to WDA
sjohannes
 
ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]
Mohamed Abdeen
 
AngularJs Style Guide
AngularJs Style GuideAngularJs Style Guide
AngularJs Style Guide
Chiew Carol
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design PatternAsp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Pattern
maddinapudi
 
Zend framework
Zend frameworkZend framework
Zend framework
Prem Shankar
 
Symfony2 for Midgard Developers
Symfony2 for Midgard DevelopersSymfony2 for Midgard Developers
Symfony2 for Midgard Developers
Henri Bergius
 
Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2
Adam Culp
 
Angular Course.pptx
Angular Course.pptxAngular Course.pptx
Angular Course.pptx
Imdad Ullah
 
Angular js-crash-course
Angular js-crash-courseAngular js-crash-course
Angular js-crash-course
Keith Bloomfield
 
.NET Core, ASP.NET Core Course, Session 9
.NET Core, ASP.NET Core Course, Session 9.NET Core, ASP.NET Core Course, Session 9
.NET Core, ASP.NET Core Course, Session 9
Amin Mesbahi
 
Aura Framework Overview
Aura Framework OverviewAura Framework Overview
Aura Framework Overview
rajdeep
 
Web(abap introduction)
Web(abap introduction)Web(abap introduction)
Web(abap introduction)
Kranthi Kumar
 
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
ZFConf Conference
 
Zend Framework 2 quick start
Zend Framework 2 quick startZend Framework 2 quick start
Zend Framework 2 quick start
Enrico Zimuel
 
Foundations of Zend Framework
Foundations of Zend FrameworkFoundations of Zend Framework
Foundations of Zend Framework
Adam Culp
 
Container Runtime Security with Falco
Container Runtime Security with FalcoContainer Runtime Security with Falco
Container Runtime Security with Falco
Michael Ducy
 
SAP Inside Track 2010 - Thomas Jung Intro to WDA
SAP Inside Track 2010 - Thomas Jung Intro to WDASAP Inside Track 2010 - Thomas Jung Intro to WDA
SAP Inside Track 2010 - Thomas Jung Intro to WDA
sjohannes
 
ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]ASP.Net MVC 4 [Part - 2]
ASP.Net MVC 4 [Part - 2]
Mohamed Abdeen
 
AngularJs Style Guide
AngularJs Style GuideAngularJs Style Guide
AngularJs Style Guide
Chiew Carol
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design PatternAsp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Pattern
maddinapudi
 
Symfony2 for Midgard Developers
Symfony2 for Midgard DevelopersSymfony2 for Midgard Developers
Symfony2 for Midgard Developers
Henri Bergius
 
Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2
Adam Culp
 
Angular Course.pptx
Angular Course.pptxAngular Course.pptx
Angular Course.pptx
Imdad Ullah
 
.NET Core, ASP.NET Core Course, Session 9
.NET Core, ASP.NET Core Course, Session 9.NET Core, ASP.NET Core Course, Session 9
.NET Core, ASP.NET Core Course, Session 9
Amin Mesbahi
 
Aura Framework Overview
Aura Framework OverviewAura Framework Overview
Aura Framework Overview
rajdeep
 
Web(abap introduction)
Web(abap introduction)Web(abap introduction)
Web(abap introduction)
Kranthi Kumar
 
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
ZFConf Conference
 
Zend Framework 2 quick start
Zend Framework 2 quick startZend Framework 2 quick start
Zend Framework 2 quick start
Enrico Zimuel
 
Ad

More from Kranthi Kumar (19)

Data binding
Data bindingData binding
Data binding
Kranthi Kumar
 
Creating simple comp
Creating simple compCreating simple comp
Creating simple comp
Kranthi Kumar
 
Binding,context mapping,navigation exercise
Binding,context mapping,navigation exerciseBinding,context mapping,navigation exercise
Binding,context mapping,navigation exercise
Kranthi Kumar
 
Abap faq
Abap faqAbap faq
Abap faq
Kranthi Kumar
 
control techniques
control techniquescontrol techniques
control techniques
Kranthi Kumar
 
Chapter 07 debugging sap scripts
Chapter 07 debugging sap scriptsChapter 07 debugging sap scripts
Chapter 07 debugging sap scripts
Kranthi Kumar
 
Chapter 06 printing sap script forms
Chapter 06 printing sap script formsChapter 06 printing sap script forms
Chapter 06 printing sap script forms
Kranthi Kumar
 
Chapter 05 sap script - configuration
Chapter 05 sap script - configurationChapter 05 sap script - configuration
Chapter 05 sap script - configuration
Kranthi Kumar
 
Chapter 04 sap script - output program
Chapter 04 sap script - output programChapter 04 sap script - output program
Chapter 04 sap script - output program
Kranthi Kumar
 
Chapter 02 sap script forms
Chapter 02 sap script formsChapter 02 sap script forms
Chapter 02 sap script forms
Kranthi Kumar
 
sap script overview
sap script overviewsap script overview
sap script overview
Kranthi Kumar
 
Batch input session
Batch input sessionBatch input session
Batch input session
Kranthi Kumar
 
BATCH DATA COMMUNICATION
BATCH DATA COMMUNICATIONBATCH DATA COMMUNICATION
BATCH DATA COMMUNICATION
Kranthi Kumar
 
Call transaction method
Call transaction methodCall transaction method
Call transaction method
Kranthi Kumar
 
Using folder options for page protection
Using folder options for page protectionUsing folder options for page protection
Using folder options for page protection
Kranthi Kumar
 
Business workflow
Business workflowBusiness workflow
Business workflow
Kranthi Kumar
 
Version it satya_dev
Version it satya_devVersion it satya_dev
Version it satya_dev
Kranthi Kumar
 
07 sap scripts
07 sap scripts07 sap scripts
07 sap scripts
Kranthi Kumar
 
abap list viewer (alv)
abap list viewer (alv)abap list viewer (alv)
abap list viewer (alv)
Kranthi Kumar
 
Creating simple comp
Creating simple compCreating simple comp
Creating simple comp
Kranthi Kumar
 
Binding,context mapping,navigation exercise
Binding,context mapping,navigation exerciseBinding,context mapping,navigation exercise
Binding,context mapping,navigation exercise
Kranthi Kumar
 
Chapter 07 debugging sap scripts
Chapter 07 debugging sap scriptsChapter 07 debugging sap scripts
Chapter 07 debugging sap scripts
Kranthi Kumar
 
Chapter 06 printing sap script forms
Chapter 06 printing sap script formsChapter 06 printing sap script forms
Chapter 06 printing sap script forms
Kranthi Kumar
 
Chapter 05 sap script - configuration
Chapter 05 sap script - configurationChapter 05 sap script - configuration
Chapter 05 sap script - configuration
Kranthi Kumar
 
Chapter 04 sap script - output program
Chapter 04 sap script - output programChapter 04 sap script - output program
Chapter 04 sap script - output program
Kranthi Kumar
 
Chapter 02 sap script forms
Chapter 02 sap script formsChapter 02 sap script forms
Chapter 02 sap script forms
Kranthi Kumar
 
BATCH DATA COMMUNICATION
BATCH DATA COMMUNICATIONBATCH DATA COMMUNICATION
BATCH DATA COMMUNICATION
Kranthi Kumar
 
Call transaction method
Call transaction methodCall transaction method
Call transaction method
Kranthi Kumar
 
Using folder options for page protection
Using folder options for page protectionUsing folder options for page protection
Using folder options for page protection
Kranthi Kumar
 
Version it satya_dev
Version it satya_devVersion it satya_dev
Version it satya_dev
Kranthi Kumar
 
abap list viewer (alv)
abap list viewer (alv)abap list viewer (alv)
abap list viewer (alv)
Kranthi Kumar
 

Controllers and context programming

  • 2. 2 © SAP AG 2005, ABAP Web Dynpro The Context At Runtime Understand the controller methods that are available to you for application coding The Context API Contents: Controller and Context Programming
  • 3. 3 © SAP AG 2005, ABAP Web Dynpro After completing this lesson, you will be able to: Understand how to access nodes and attributes in the context using the context API. The Context API: Objectives
  • 4. 4 Code Implementation Each Web Dynpro controller is a separate ABAP program. The definition of these programs is generated automatically when a new component or controller is declared. The source code, that implements these controllers is generated automatically. You are provided with various points within the controller code where you may add your own coding. Any attempt to entering coding outside the designated areas will result in that code being lost when the controller is regenerated. Every time the controller is activated the code is regenerated. Standard Hook Methods In every controller, there are certain standard methods that are always present. At controller creation time, these methods are empty and can hold any coding the developer wishes to place within them. The application developer is not permitted to deleted or rename any of these standard hook methods. If any attempt is made to do this, the changes will be lost when the coding is regenerated. © SAP AG 2005, ABAP Web Dynpro Common Controller Features: Standard Controller Hook Methods Controller Implementation Standard Hook Methods Instance Methods Context Root Node Required Controllers Controller Interface Other WD Controllers Custom Controller Business Logic (Models) Created by explicit declaration or coding Created by the Web Dynpro Framework (WDF) Component Usage Other WD Components
  • 5. 5 WDDOINIT Standard hook method for all Web Dynpro controllers. This method is only called once during the lifecycle of a controller. All your initialization code should go here since this method is called immediately after the controller has been instantiated. WDDOEXIT Standard hook method called at the end of a controller’s life cycle. All your cleanup code should go here. This method is called immediately before the controller’s lifecycle comes to an end. © SAP AG 2005, ABAP Web Dynpro Standard Hook Methods for all controllers All controllers have these two standard hook methods. The method will only be called during the controller’s lifecycle if they contain coding. method WDDOINIT. endmethod. method WDDOEXIT. endmethod.
  • 6. 6 Controller instance methods This information applies to both view and custom controllers. For all controllers, you can create an instance method by declaring the method name and its parameters in the “methods” tab of the controller editor window. © SAP AG 2005, ABAP Web Dynpro Common Controller Features: Controller Instance Methods Controller Implementation Standard Hook Methods Instance Methods Context Root Node Required Controllers Controller Interface Other WD Controllers Custom Controller Business Logic (Models) Created by explicit declaration or coding Created by the Web Dynpro Framework (WDF) Component Usage Other WD Components
  • 7. 7 Attributes: Attributes can be public or private. Attributes can not be directly used inside the controller. The attributes can be accessed by using the controller attribute WD_THIS which provides a reference to the local controller interface. Methods: All methods are public and can be used by any other controllers. Prerequisite is that the controller which will call the method has defined a use relation to the used controller in his properties. © SAP AG 2005, ABAP Web Dynpro Controller Attributes and Utility methods Attributes for the controller can be created (public or private) Arbitrary methods can be created - …….
  • 8. 8 WD_THIS wdThis is the Web Dynpro specific self reference and should be used in preference to the standard ABAP self reference of me. WD_THIS is a reference to the current controller’s interface IF<controller name> and represents all the functionality implemented in the generated class. This gives you access to standard Web Dynpro functionality such as logging, validation, and parameter mapping. WD_CONTEXT WD_CONTEXT is the reference to the controller’s context root node, and thus to the entire context. © SAP AG 2005, ABAP Web Dynpro Standard Controller Attributes WD_CONTEXT and WD_THIS WD_CONTEXT and WD_THIS present in any WD controller (excepted interface and interface view controller). WD_THIS - self reference of the local interface, type depends on the controller type. WD_CONTEXT - reference to the context of associated controller.
  • 9. 9 © SAP AG 2005, ABAP Web Dynpro Standard Controller Attribute WD_COMP_CONTROLLER WD_COMP_CONTROLLER present in any WD controller. reference to the component controller with access to all public methods and attributes. Attribute will automatically assigned to all view controllers when a view is created. For all other controller the WD_COMP_CONTROLLER attribute will be assigned, when the properties of the controller the component controller is used.
  • 10. 10 wdDoBeforeNavigation() This standard hook method is found only in the component controller. Whenever an outbound plug is fired from a view controller, a navigation event is raised. It is perfectly possible for each view in a view set to fire an outbound plug; therefore, all navigation events are placed into a queue and are only processed once all the views in the current view assembly have been processed. The wdDoBeforeNavigation() method is called just before the Web Dynpro Framework processes the events in the navigation queue. This allows you to implement your own coding to do such things a navigation event prioritisation etc. wdDoPostProcessing() This standard hook method is found only in the component controller. In complex Web Dynpro applications, it is possible that the data from multiple components must be validated before the next step in the business process can be taken. This method has been implemented in order for cross component validation to take place. © SAP AG 2005, ABAP Web Dynpro Standard Hook Methods – Component Controller Note: Only a component controller has these hook methods. WDDOBEFORENAVIGATION It is executed before the navigation stack is processed WDDOPOSTPROCESSING Data from multiple components can be validated before the next step is execute
  • 11. 11 To access a context node element, the following steps must be performed: 1.Use the get_Child_Node() method to get a reference of If_Wd_Context_Node node instance. This method requires the name of the node and optional the index of the element in the parent node the desired node instance belongs to. In this case, the parent node is the context root which only ever has one element, therefore the index parameter is 1. © SAP AG 2005, ABAP Web Dynpro Access to Attribute of Node Element I Flights ..nCARRID CONNID2CARRID CONNID1CARRID CONNID Context Root 0Default Element data: Node_Flights type ref to If_Wd_Context_Node. * navigate from <CONTEXT> to <FLIGHTS> via lead selection Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ). * @TODO handle not set lead selection if ( Node_Flights is initial ). endif. Note: Node and attribute names must be used in upper case
  • 12. 12 To access a context node element, the following steps must be performed: 1.Use the get_Child_Node() method to get a reference of If_Wd_Context_Node node instance. This method requires the name of the node and optional the index of the element in the parent node the desired node instance belongs to. In this case, the parent node is the context root which only ever has one element, therefore the index parameter is 1. 2.Calling method get_Element() to get the element with the lead selection. This returns a reference of If_Wd_Context_Element element instance. © SAP AG 2005, ABAP Web Dynpro Access to Attribute of Node Element II Flights ..nCARRID CONNID2CARRID CONNID1CARRID CONNID Context Root 0Default Element data: Node_Flights type ref to If_Wd_Context_Node, Elem_Flights type ref to If_Wd_Context_Element. * navigate from <CONTEXT> to <FLIGHTS> via lead selection Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ). * get element via lead selection Elem_Flights = Node_Flights->get_Element( ). * @TODO handle not set lead selection if ( Elem_Flights is initial ). endif.
  • 13. 13 To access a context node element, the following steps must be performed: 1.Use the get_Child_Node() method to get a reference of If_Wd_Context_Node node instance. This method requires the name of the node and optional the index of the element in the parent node the desired node instance belongs to. In this case, the parent node is the context root which only ever has one element, therefore the index parameter is 1. 2.Calling method get_Element() to get the element with the lead selection. This returns a reference of If_Wd_Context_Element element instance. 3.Calling method get_Attribute() to get the value of the attribute. © SAP AG 2005, ABAP Web Dynpro Access to Attribute of Node Element III Flights ..nCARRID CONNID2CARRID CONNID1CARRID CONNID Context Root 0Default Element data: Node_Flights type ref to If_Wd_Context_Node, Elem_Flights type ref to If_Wd_Context_Element, Stru_Flights type If_Componentcontroller=>Element_Flights, Item_CARRID like Stru_Flights-CARRID. * navigate from <CONTEXT> to <FLIGHTS> via lead selection Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ). * get element via lead selection Elem_Flights = Node_Flights->get_Element( ). * get single attribute Elem_Flights->get_Attribute( exporting Name = `CARRID` importing Value = Item_Carrid ).
  • 14. 14 With the method get_Static_Attributes all static attributes of a context node can be retrieved as a structure. The method get_Static_Attributes will provide the values of the attributes by using a move-corresponding. So the target structure can be different to the node structure. © SAP AG 2005, ABAP Web Dynpro Access to all Static Attributes of a Node Element Flights ..nCARRID CONNID2CARRID CONNID1CARRID CONNID Context Root 0Default Element data: Node_Flights type ref to If_Wd_Context_Node, Elem_Flights type ref to If_Wd_Context_Element, Stru_Flights type If_Componentcontroller=>Element_Flights. * navigate from <CONTEXT> to <FLIGHTS> via lead selection Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ). * get element via lead selection Elem_Flights = Node_Flights->get_Element( ). * get all declared attributes Elem_Flights->get_Static_Attributes( importing Static_Attributes = Stru_Flights ).
  • 15. 15 With the method get_Static_Attributes_Table the attributes of all elements can be retrieved as a internal table. © SAP AG 2005, ABAP Web Dynpro Access to all Elements of a Node Flights ..nCARRID CONNID2CARRID CONNID1CARRID CONNID Context Root 0Default Element data: Node_Flights type ref to If_Wd_Context_Node, Elem_Flights type ref to If_Wd_Context_Element, lt_Flights type If_Main_View=>Elements_Flights . * navigate from <CONTEXT> to <FLIGHTS> via lead selection Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ). * @TODO handle not set lead selection if ( Node_Flights is initial ). endif. * get all node element Node_Flights->GET_STATIC_ATTRIBUTES_TABLE( importing table = lt_Flights ). Itab
  • 16. 16 Addition of elements to a node The process of adding an element to a node requires the following steps: 1.Access the relevant context node. Use the get_Child_Node() method to get a reference of If_Wd_Context_Node node instance. © SAP AG 2005, ABAP Web Dynpro Binding of an Element to a Node I FLIGHTSContext Root 0Default Element data: Node_Flights type ref to If_Wd_Context_Node. * navigate from <CONTEXT> to <FLIGHTS> via lead selection node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ).
  • 17. 17 Addition of elements to a node The process of adding an element to a node requires the following steps: 1.Access the relevant context node. Use the get_Child_Node() method to get a reference of If_Wd_Context_Node node instance. 2.Create a new elements with the method create_element(). © SAP AG 2005, ABAP Web Dynpro Binding of an Element to a Node II FLIGHTSContext Root 0Default Element data: Node_Flights type ref to If_Wd_Context_Node, First_flight_Elem type ref to If_Wd_Context_Element. * navigate from <CONTEXT> to <FLIGHTS> via lead selection node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ). * create new element for node FLIGHTS First_flight_Elem = Node_Flights->create_element( ).
  • 18. 18 Addition of elements to a node The process of adding an element to a node requires the following steps: 1.Access the relevant context node. Use the get_Child_Node() method to get a reference of If_Wd_Context_Node node instance. 2.Create a new elements with the method create_element(). 3.Set the corresponding attributes to the element. © SAP AG 2005, ABAP Web Dynpro Binding of an Element to a Node III FLIGHTSContext Root 0Default Element CARRID CONNID data: Node_Flights type ref to If_Wd_Context_Node, First_flight_Elem type ref to If_Wd_Context_Element. * navigate from <CONTEXT> to <FLIGHTS> via lead selection node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ). * create new element for node FLIGHTS First_flight_Elem = Node_Flights->create_element( ). * set attributes First_flight_Elem->set_attribute( name = 'CARRID' value = 'LH' ). First_flight_Elem->set_attribute( name = 'CONNID' value = '400' ).
  • 19. 19 Addition of element as a structure to a node The process of adding an element as a structure to a node requires the following steps: 1.Access the relevant context node. Use the get_Child_Node() method to get a reference of If_Wd_Context_Node node instance. 2.Fill the required structure elements. 3.Set the corresponding attributes to the element. 4.Bind the element to the node. The parameter SET_INITIAL_ELEMENTS allows to delete all existing elements of a node and bind only the actual element to the node. In this case the parameter must be set to abap_true (default value). If the element should be added to the node as an additional element then the parameter must be set to abap_false. © SAP AG 2005, ABAP Web Dynpro FLIGHTSContext Root 0Default Element CARRID CONNID 1 Binding of an Element to a Node IV data: Node_Flights type ref to If_Wd_Context_Node, First_flight_Elem type ref to If_Wd_Context_Element. * navigate from <CONTEXT> to <FLIGHTS> via lead selection node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ). * create new element for node FLIGHTS First_flight_Elem = Node_Flights->create_element( ). * set attributes First_flight_Elem->set_attribute( name = 'CARRID' value = 'LH' ). First_flight_Elem->set_attribute( name = 'CONNID' value = '400' ). * bind first element to node Node_Flights->bind_element( new_item = First_flight_Elem SET_INITIAL_ELEMENTS = abap_false ).
  • 20. 20 Addition of element as a structure to a node The process of adding an element as a structure to a node requires the following steps: 1.Access the relevant context node. Use the get_Child_Node() method to get a reference of If_Wd_Context_Node node instance. 2.Fill the required structure elements. 3.Set the corresponding attributes to the element. 4.Bind the structure to the node. The parameter SET_INITIAL_ELEMENTS allows to delete all existing elements of a node and bind only the actual element to the node. In this case the parameter must be set to abap_true (default value). If the structure should be added to the node as an additional element then the parameter must be set to abap_false. © SAP AG 2005, ABAP Web Dynpro Static Attributes and Binding of a Element to a Node data: Node_Flights type ref to If_Wd_Context_Node, Stru_flights type If_Componentcontroller=>Element_flights. * navigate from <CONTEXT> to <FLIGHTS> via lead selection node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ). * set values to node->attributes Stru_flights-carrid = 'AA'. Stru_flights-connid = '017'. * bind new element to node Node_flights->bind_structure( new_item = Stru_flights SET_INITIAL_ELEMENTS = abap_false ).
  • 21. 21 Addition of multiple elements as a internal table to a node The process of multiple elements as a internal table to a node requires the following steps: 1.Define an internal table of the node type. 2.Define a structure of the table type. 3.Append values to the table. 4.Bind the internal table to the node. © SAP AG 2005, ABAP Web Dynpro FLIGHTSContext Root 0Default Element Binding of a Table to a Node data: Node_Flights type ref to If_Wd_Context_Node, lt_flights type If_Componentcontroller=>Elements_flights, Stru_flights like line of lt_flights. * append values to local table Stru_flights-carrid = 'LH'. Stru_flights-connid = '400'. append Stru_flights to lt_flights. Stru_flights-carrid = 'AA'. Stru_flights-connid = '017'. append Stru_flights to lt_flights. * get node reference Node_Flights = wd_context->get_child_node( 'FLIGHTS' ). * bind local table Node_Flights->bind_table( lt_flights ). CARRID CONNID 1 Itab CARRID
  • 22. 22 © SAP AG 2005, ABAP Web Dynpro You should now be able to: Understand how to access nodes and attributes in the context using the context API Controller and Context Programming: Summary
  翻译: