Important Coding for Dynamic Programming in Webdynpro ABAP
*&-------------------------------------------------------------*
* Create a Dynamic Text View *
*&-------------------------------------------------------------*
data : root type ref to cl_wd_uielement_container.
data : textview type ref to cl_wd_text_view.
**** Getting reference of Dynamic Programming
root ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
**** Create Element and set appropriate property
textview = cl_wd_text_view=>new_text_view( text = 'SAP Webdynpro ABAP' ).
**** Define the layout
cl_wd_flow_data=>new_flow_data( element = textview ).
**** Add created element to the root
root->add_child_node( textview ).
*&-------------------------------------------------------------*
* Create a Dynamic Button *
*&-------------------------------------------------------------*
data : bt type ref to cl_wd_button.
**** Creating element button and set appropriate property
bt = cl_wd_button=>new_button( text = 'Save'
on_click = 'Save_act' ).
**** Define the layout
cl_wd_matrix_data =>new_matrix_data( element = bt ).
**** Add created element to the root
root->add_child_node( bt ).
*&-------------------------------------------------------------*
* Create a Dynamic Input Filed *
*&-------------------------------------------------------------*
data : inp type ref to cl_wd_input_field.
**** Creating element button and set appropriate property
inp = cl_wd_input_field=>new_input_filed( bind_value = 'EMP.SALARY' ).
**** Define the layout
cl_wd_row_data=>new_row_data( element = inp ).
**** Add created element to the root
root->add_child_node( inp ).
*&-------------------------------------------------------------*
* Create a Dynamic Page Header *
*&-------------------------------------------------------------*
data : pg type ref to cl_wd_page_header.
**** Creating element button and set appropriate property
pg = cl_wd_page_header=>new_page_header( title = 'Welcome to Webdynpro ABAP' ).
**** Define the layout
cl_wd_flow_data=>new_flow_data( element = pg ).
**** Add created element to the root
root->add_child_node( pg ).
------------------------------------------------------------------------------------------------------------------------
|| CHANGING THE PROPERTIES OF THE EXISTING SCREEN ELEMENTS DYNAMICALLY ||
------------------------------------------------------------------------------------------------------------------------
*&-------------------------------------------------------------*
* Change a Dynamic Page Header *
*&-------------------------------------------------------------*
data : ph type ref to cl_wd_page_header.
**** Get the reference of the element that you want to change
ph ?= view->get_element( 'PH' ).
**** Change the properties
ph->set_title( 'Welcome to Webdynpro JAVA' ).
NOTE : 1) Use the parameter FIRST_TIME and set the property to ABAP_TRUE to avoid dynamic program calling every time whenever action is triggered.
i,e., IF FIRST_TIME = abap_true.
---------<code>------------
---------<code>------------
ENDIF.
2) Always implement the dynamic code in the method WDDOMODIFYVIEW( ).
*&-------------------------------------------------------------*
* Create a Dynamic Text View *
*&-------------------------------------------------------------*
data : root type ref to cl_wd_uielement_container.
data : textview type ref to cl_wd_text_view.
**** Getting reference of Dynamic Programming
root ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
**** Create Element and set appropriate property
textview = cl_wd_text_view=>new_text_view( text = 'SAP Webdynpro ABAP' ).
**** Define the layout
cl_wd_flow_data=>new_flow_data( element = textview ).
**** Add created element to the root
root->add_child_node( textview ).
*&-------------------------------------------------------------*
* Create a Dynamic Button *
*&-------------------------------------------------------------*
data : bt type ref to cl_wd_button.
**** Creating element button and set appropriate property
bt = cl_wd_button=>new_button( text = 'Save'
on_click = 'Save_act' ).
**** Define the layout
cl_wd_matrix_data =>new_matrix_data( element = bt ).
**** Add created element to the root
root->add_child_node( bt ).
*&-------------------------------------------------------------*
* Create a Dynamic Input Filed *
*&-------------------------------------------------------------*
data : inp type ref to cl_wd_input_field.
**** Creating element button and set appropriate property
inp = cl_wd_input_field=>new_input_filed( bind_value = 'EMP.SALARY' ).
**** Define the layout
cl_wd_row_data=>new_row_data( element = inp ).
**** Add created element to the root
root->add_child_node( inp ).
*&-------------------------------------------------------------*
* Create a Dynamic Page Header *
*&-------------------------------------------------------------*
data : pg type ref to cl_wd_page_header.
**** Creating element button and set appropriate property
pg = cl_wd_page_header=>new_page_header( title = 'Welcome to Webdynpro ABAP' ).
**** Define the layout
cl_wd_flow_data=>new_flow_data( element = pg ).
**** Add created element to the root
root->add_child_node( pg ).
------------------------------------------------------------------------------------------------------------------------
|| CHANGING THE PROPERTIES OF THE EXISTING SCREEN ELEMENTS DYNAMICALLY ||
------------------------------------------------------------------------------------------------------------------------
*&-------------------------------------------------------------*
* Change a Dynamic Page Header *
*&-------------------------------------------------------------*
data : ph type ref to cl_wd_page_header.
**** Get the reference of the element that you want to change
ph ?= view->get_element( 'PH' ).
**** Change the properties
ph->set_title( 'Welcome to Webdynpro JAVA' ).
NOTE : 1) Use the parameter FIRST_TIME and set the property to ABAP_TRUE to avoid dynamic program calling every time whenever action is triggered.
i,e., IF FIRST_TIME = abap_true.
---------<code>------------
---------<code>------------
ENDIF.
2) Always implement the dynamic code in the method WDDOMODIFYVIEW( ).
Thanks
ReplyDeleteAre you looking to enhance your skills in SAP WebDynpro? Look no further! ERP TRAINING GURGAON offers comprehensive and industry-focused SAP WebDynpro Training in Gurgaon . With our expert trainers and cutting-edge curriculum, we provide you with the knowledge and practical experience to excel in the field of SAP WebDynpro development.
ReplyDelete