Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
amy_king
Active Contributor
0 Kudos
The series Web Dynpro Selection Screen Variants continues from Part 2 with creation of the Web Dynpro Component and its component controller.

Part 3: Component and Controller


Create new Web Dynpro component ZWDR_SELECT_OPTIONS_VARI with assistance class ZCL_WD_SELECT_OPTIONS_VARIANT. Next, add the following Context, Attributes and Methods to the Component Controller.

Context


Create context node VARIANT with the following properties then add to it attributes VARIANT and VTEXT from dictionary structure ZWDVARI.
























Node Name
VARIANT
Dictionary Structure
ZWDVARI
Cardinality 1..1
Selection 0..1
Initialization Lead Selection checked


 

Create context node CONFIRM with the following properties then add to it attribute VARIANT from dictionary structure ZWDVARI.
























Node Name
CONFIRM
Dictionary Structure
ZWDVARI
Cardinality 0..n
Selection 0..n
Initialization Lead Selection checked


 

Attributes


Create the following four public attributes.


Methods


Create four custom methods and implement hook method WDDOPOSTPROCESSING.

INITIALIZE


Mark method initialize as an interface method. It is this method callers will use to connect the variants functionality with the other component's selection screen.


method INITIALIZE .

wd_this->mv_application = application_name.
wd_this->mv_component = component_name.
wd_this->mt_select_options_ref = select_options_set.

endmethod.

VARIANT_DELETE



METHOD variant_delete .

CHECK wd_this->mv_component IS NOT INITIAL AND
wd_this->mv_application IS NOT INITIAL.

* -- Delete variants

LOOP AT variant_tab ASSIGNING FIELD-SYMBOL(<variant>).

DATA(ls_return) = wd_assist->variant_delete(
component = wd_this->mv_component
application = wd_this->mv_application
variant = <variant>-variant
).

wd_this->wd_get_api( )->get_message_manager( )->report_t100_message(
msgid = ls_return-msgid
msgno = ls_return-msgno
msgty = ls_return-msgty
p1 = ls_return-msgv1
p2 = ls_return-msgv2
p3 = ls_return-msgv3
p4 = ls_return-msgv4
).

ENDLOOP. " <variant>

ENDMETHOD.

VARIANT_GET



method VARIANT_GET .

CHECK wd_this->mv_component IS NOT INITIAL AND
wd_this->mv_application IS NOT INITIAL.

* -- Fetch variant contents into select-options references

wd_assist->variant_get(
EXPORTING
component = wd_this->mv_component
application = wd_this->mv_application
variant = variant-variant
CHANGING
select_options_ref = wd_this->mt_select_options_ref
).

endmethod.

VARIANT_SAVE



METHOD variant_save .

CHECK wd_this->mv_component IS NOT INITIAL AND
wd_this->mv_application IS NOT INITIAL.

* -- Save variant

DATA(ls_return) = wd_assist->variant_save(
component = wd_this->mv_component
application = wd_this->mv_application
variant = variant-variant
short_text = variant-vtext
select_options_ref = wd_this->mt_select_options_ref
).

wd_this->wd_get_api( )->get_message_manager( )->report_t100_message(
msgid = ls_return-msgid
msgno = ls_return-msgno
msgty = ls_return-msgty
p1 = ls_return-msgv1
p2 = ls_return-msgv2
p3 = ls_return-msgv3
p4 = ls_return-msgv4
).

ENDMETHOD.

WDDOPOSTPROCESSING



method WDDOPOSTPROCESSING .

* -- If component was not properly initialized, issue error message

CHECK wd_this->mv_component IS INITIAL OR
wd_this->mv_application IS INITIAL OR
wd_this->mt_select_options_ref IS INITIAL.

wd_this->wd_get_api( )->get_message_manager( )->report_error_message(
message_text = 'ZWDR_SELECT_OPTIONS_VARI was improperly initialized'
).

endmethod.

Up Next


In Part 4, the series continues with creation of the views and windows.
Labels in this area