Essentially,each ABAP class can be used as a model. The particularity of an assistance classes is that we can assign it to a Web Dynpro component and it is automatically instantiated when the proper component is called.
We create an assistance class named YCL_AC_MODEL.
In this assistance class,we create three methods namedSEARCH_CANDIDAT,SELECT_CANDIDATE and INSERT_CANDIDATE. Here, we store the coding required within the WD components to look for a candidate,to select all the candidates and to insert information about a candidate into or from the database table YPERSON.
Methods for the assistance class
Before implementing our methods,we created the lowest level of coding that abstracts the data access.In this case,we choose to implement the simplest data access method by using the classical ABAP tools,respective through the Function Modules,but we can also use other tools,e.g.the Persistent Object Classes,required to benefit of the object oriented programming(OOP).In case we want to use Persistent Objects to access the data from the database table in the Object Oriented mode,we can use for our Web Dynpro project the same structure (by taking the Assistance class as a model). But,in this case,we have to replace the Function Modules with Persistent Classes.tableOne of the created Function Modules will be used later,as the end point for a BAPI.It will be also used to create a Web Service.
A Function Module (FM)is a procedure with public interface, which can be created within a Function Group. To create a Function Group, we select Create--> Function Group from the context menu of our package name. We create a Function Group named YFG_DBACCESS.Here,we implement three FMs,named.
YFM_SELECT_CANDIDATE and YFM_ INSERT_CANDIDATE.
Listing shows the implementation of YFM_SEARCH_CANDIDATE.
The exception class YCX_EXCEPTION_T100_TXT was defined hereinbefore,when we have seen how we can work with the exception classes in WD.
Shows the implementation of YFM_SEARCH_CANDIDATEFUNCTION YFM_SEARCH_CANDIDATE .
Listing Implementation of YFM_SELECT_CANDIDATEFUNCTION YFM_SELECT_CANDIDATE.
This FM selects the information about all the candidates. In this case,we create a new message ID–001“Data cannot be selected!”and a new exception ID YCX_ SELECT_NO_POSSIBLE with the text from the message class – message ID 001
Listing shows the implementation of YFM_INSERT_CANDIDATEFUNCTION YFM_INSERT_CANDIDATE .
This FM inserts in the database table YPERSON the information about a candidate.In this case,we create a new message ID–002 “Candidate insert cannot be done!”and a new exception ID YCX_INSERT_NO_POSSIBLE with the text from the message class – message ID 002.
A FM can be tested by using the Test/Execute Button .In this way,we can check if our created FM works correctly.Then,we implement our first method from the assistance class.
Implementation of the SEARCH_CANDIDATE method
Implementation of the SELECT_CANDIDATE method
Implementation of the INSERT_CANDIDATE method
The Class Builder provides a test environment for classes.We can test our class by using the same test/execute Button.
Testing the assistance class
In this way,we have autonomous units that can be independently tested before we integrate them into bigger applications. If we look backwards to the example that refers to the Exception class with OTR text,we can see that the entire coding was integrated in a method of the view controller.So,we didn’t separate the application layer from the business layer and from the presentation layer.
We create the presentation layer through a WD application. We create a main component named Y_MAIN,in which we will use three secondary elements:
Y_SEARCH,Y_SELECT and Y_INSERT.
WD component’s structure
All the components defined the same assistance class,the YCL_AC_MODEL.Any changes made to the model class in the Framework are available for any other component that has this model class defined as assistance class.In this way,we can share data among components.
As we have mentioned above,each ABAP class can be used as a model class,but the services offered by the Web Dynpro Framework in this respect are available only for an assistance class that inherits the abstract classCL_WD_COMPONENT_ASSISTANCE.
The Y_MAIN component represented the start point of this application;it is the only component that has a Web Dynpro application defined.We assign our assistance class YCL_AC_MODEL for our components.
Assistance class assigned to our components
The V_MAIN layout
By using the ViewContainerUIElement,we show one of the views:
V_SELECT,V_INSERT or V_SEARCH.
To be able to navigate among the three used Views,we have to define three outbound plugs.Figure shows the defined outbound plugs and the window structure.
Before being able to create the instance of the used components,e have to create usages at the V_MAIN View level.
When the user presses the linkToAction UI element–Insert–the Framework triggers the event handler method onactioninsert.
Event handler methodMETHOD onactioninsert .
As we can see,through the statement
lr_cmp_usage--> create_component (assistance_class = me
SAP ABAP Web Dynpro Related Tutorials
|SAP ABAP Tutorial|
SAP ABAP Web Dynpro Related Interview Questions
|SAP ABAP Interview Questions||SAP ABAP Web Dynpro Interview Questions|
|Sap Abap Hr Interview Questions||SAP ABAP Dictionary Interview Questions|
|SAP ABAP Enhancement Interview Questions||SAP ABAP Module Pool Interview Questions|
|SAP ABAP Report Developer Interview Questions||SAP ABAP Data Dictionary Interview Questions|
|SAP ABAP ALV Reports Interview Questions|
Sap Abap Web Dynpro Tutorial
Sap Easy Access
Designing A Web Dynpro Component
Context Nodes And Attributes At Design Time
Data Binding, Context Mapping And Interface Methods
View Controller Methods
Layout Ui Elements
User Interface Elements (ui Elements) Static And Dynamic Programming
Messages, Exceptions And Web Dynpro Abap
Writing Multilanguage Applications
Alv And Select Options
Integrating A Web Dynpro Application Into The Sap Netweaver Portal
Web Dynpro And Authorization
Web Dynpro Mind Map
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.