To disable ALV Output in Webdynpro.
Purpose of this document : To Run webDynpro application by accepting
Some
input entries from selection screen, incase if there is any valid
output records are exits,webdynpro application displays those in ALV
else it disables ALV Output and displays some message i,e“No Records
exists for given input”.
1. First create webdynpro componet as shown below.Go to TCODE : SE80 select Webdynpro Comp./Intf and click on display button .
2.Give some name to component with short description and click on
3.Whatever
the components user want to reuse ,can mention those components as
shown below .Here components mentioned are “SALV_WD_TABLE’ and
WDR_SELECT_OPTIONS.
4.By
default at the time of creation of component MAIN view will be created
automatically and if user wants to create more views ,create as shown
below.Just give right click on “view”
6.To create View UI Container elements in layout just give right click on “Rootuielementcontainer”as shown below.
7.Create ViewcontainerUIElement to display required select–options by using component : WDR_SELECT_OPTIONS as shown below.
10.whenever user clicks on Create button it gives pop-up as shown below ,fill all details as shown below.
15.To Perform BACK Action user need to create event as shown below in second view.
16.Create node in context of “Componentcontroller” to display required output structure in ALV s in as shown below.
17.Give required Dictionary structure as shown below.
20.Create Navigation between Views in window as shown below and embedded user required components in view.
21 .To test component user need to create webdynpro application for it as shown below.
22. Save application in some package .
22. Save application in some package .
Write below code in Main View method : WDDOINIT
Reference variable used instantiate the select-options component
DATA
lr_cmp_usage TYPE REF TO if_wd_component_usage .
* Instantiate the select-options component
lr_cmp_usage = wd_this->wd_cpuse_select( ).
IF lr_cmp_usage->has_active_component( ) IS INITIAL.
lr_cmp_usage->create_component( ).
ENDIF.
* Sets the helper reference
wd_this->w_select = wd_this->wd_cpifc_select( ).
wd_this->w_handler = wd_this->w_select->init_selection_screen( ).
* wd_this->w_handler = wd_this->w_handler->init_selection_screen( ).
* Declaration for internal tables
data : t_select_table type IF_WD_SELECT_OPTIONS=>tT_SELECTION_SCREEN_ITEM,
WA_SELECT_TABLE type IF_WD_SELECT_OPTIONS=>T_SELECTION_SCREEN_ITEM,
t_range_table TYPE REF TO data.
*Building selction screen
**Adding the block to the selectio options
wd_this->w_handler->add_block(
i_id = 'BL01'
i_block_type = if_wd_select_options=>mc_block_type_tray
i_title = 'Personal Number' ).
WA_select_table-m_id = 'PERSNO'.
wa_select_table-m_within_block = 'BL01'."if_wd_select_options=>mc_block_type_tray."if_wd_select_options=>mc_id_main_block.
wa_select_table-m_value_help_type = if_wd_value_help_handler=>co_prefix_searchhelp.
wa_select_table-M_value_help_id = 'YPERNR_HELP'.
wa_select_table-m_value_help_mode = '0'.
wa_select_table-m_value_help_structure = 'PA0000'.
wa_select_table-m_value_help_structure_field = 'PERNR'.
CALL METHOD wd_this->w_handler->create_range_table
EXPORTING
i_typename = 'PERSNO'
receiving
rt_range_table = t_range_table.
WA_select_table-mt_range_table = t_range_table.
APPEND WA_SELECT_TABLE TO T_SELECT_TABLE.
clear : t_range_table,wa_select_table.
*********************begda*******
**Adding the block to the selectio options
*wd_this->w_handler->add_block(
* i_id = 'BL02'
* i_block_type = if_wd_select_options=>mc_block_type_tray
* i_title = 'Begin Date' ).
WA_select_table-m_id = 'BEGDA'.
wa_select_table-m_within_block = 'BL01'."if_wd_select_options=>mc_block_type_tray.
CALL METHOD wd_this->w_handler->create_range_table
EXPORTING
i_typename = 'BEGDA'
receiving
rt_range_table = t_range_table.
WA_select_table-mt_range_table = t_range_table.
APPEND WA_SELECT_TABLE TO T_SELECT_TABLE.
clear : t_range_table,wa_select_table.
*************endda***********
**Adding the block to the selectio options
*wd_this->w_handler->add_block(
* i_id = 'BL03'
* i_block_type = if_wd_select_options=>mc_block_type_tray
* i_title = 'End date' ).
WA_select_table-m_id = 'ENDDA'.
wa_select_table-m_within_block = 'BL01'."if_wd_select_options=>mc_block_type_tray.
CALL METHOD wd_this->w_handler->create_range_table
EXPORTING
i_typename = 'ENDDA'
receiving
rt_range_table = t_range_table.
WA_select_table-mt_range_table = t_range_table.
APPEND WA_SELECT_TABLE TO T_SELECT_TABLE.
clear : t_range_table,wa_select_table.
CALL METHOD WD_THIS->W_HANDLER->ADD_SELECTION_FIELDS
exporting
it_fields = t_select_table.
DATA
lr_cmp_usage TYPE REF TO if_wd_component_usage .
* Instantiate the select-options component
lr_cmp_usage = wd_this->wd_cpuse_select( ).
IF lr_cmp_usage->has_active_component( ) IS INITIAL.
lr_cmp_usage->create_component( ).
ENDIF.
* Sets the helper reference
wd_this->w_select = wd_this->wd_cpifc_select( ).
wd_this->w_handler = wd_this->w_select->init_selection_screen( ).
* wd_this->w_handler = wd_this->w_handler->init_selection_screen( ).
* Declaration for internal tables
data : t_select_table type IF_WD_SELECT_OPTIONS=>tT_SELECTION_SCREEN_ITEM,
WA_SELECT_TABLE type IF_WD_SELECT_OPTIONS=>T_SELECTION_SCREEN_ITEM,
t_range_table TYPE REF TO data.
*Building selction screen
**Adding the block to the selectio options
wd_this->w_handler->add_block(
i_id = 'BL01'
i_block_type = if_wd_select_options=>mc_block_type_tray
i_title = 'Personal Number' ).
WA_select_table-m_id = 'PERSNO'.
wa_select_table-m_within_block = 'BL01'."if_wd_select_options=>mc_block_type_tray."if_wd_select_options=>mc_id_main_block.
wa_select_table-m_value_help_type = if_wd_value_help_handler=>co_prefix_searchhelp.
wa_select_table-M_value_help_id = 'YPERNR_HELP'.
wa_select_table-m_value_help_mode = '0'.
wa_select_table-m_value_help_structure = 'PA0000'.
wa_select_table-m_value_help_structure_field = 'PERNR'.
CALL METHOD wd_this->w_handler->create_range_table
EXPORTING
i_typename = 'PERSNO'
receiving
rt_range_table = t_range_table.
WA_select_table-mt_range_table = t_range_table.
APPEND WA_SELECT_TABLE TO T_SELECT_TABLE.
clear : t_range_table,wa_select_table.
*********************begda*******
**Adding the block to the selectio options
*wd_this->w_handler->add_block(
* i_id = 'BL02'
* i_block_type = if_wd_select_options=>mc_block_type_tray
* i_title = 'Begin Date' ).
WA_select_table-m_id = 'BEGDA'.
wa_select_table-m_within_block = 'BL01'."if_wd_select_options=>mc_block_type_tray.
CALL METHOD wd_this->w_handler->create_range_table
EXPORTING
i_typename = 'BEGDA'
receiving
rt_range_table = t_range_table.
WA_select_table-mt_range_table = t_range_table.
APPEND WA_SELECT_TABLE TO T_SELECT_TABLE.
clear : t_range_table,wa_select_table.
*************endda***********
**Adding the block to the selectio options
*wd_this->w_handler->add_block(
* i_id = 'BL03'
* i_block_type = if_wd_select_options=>mc_block_type_tray
* i_title = 'End date' ).
WA_select_table-m_id = 'ENDDA'.
wa_select_table-m_within_block = 'BL01'."if_wd_select_options=>mc_block_type_tray.
CALL METHOD wd_this->w_handler->create_range_table
EXPORTING
i_typename = 'ENDDA'
receiving
rt_range_table = t_range_table.
WA_select_table-mt_range_table = t_range_table.
APPEND WA_SELECT_TABLE TO T_SELECT_TABLE.
clear : t_range_table,wa_select_table.
CALL METHOD WD_THIS->W_HANDLER->ADD_SELECTION_FIELDS
exporting
it_fields = t_select_table.
And in ONACTIONFETCH_DATA write below code :
DATA : lo_nd_emp_deatils TYPE REF TO if_wd_context_node,
lo_config_model_value TYPE REF TO cl_salv_wd_config_table,
lo_interfacecontroller TYPE REF TO iwci_salv_wd_table,
lo_el_emp_deatils TYPE REF TO if_wd_context_element,
ls_emp_deatils TYPE wd_this->element_emp_deatils,
text_error type string,
text_error1 type c length 200,
iref_msg type ref to IF_WD_COMPONENT_ASSISTANCE,
lt_sel_item TYPE if_wd_select_options=>tt_selection_screen_item,
itab type standard table of pa0000,
fs_low type c length 30,
fs_high type c length 10,
dref type ref to data, " data referecnce
rt_emp TYPE REF TO data,
fs_sel_item LIKE LINE OF lt_sel_item.
DATA : W_EMP TYPE C LENGTH 10.
data : l_f_low(5) type c value 'LOW'.
types: range_pernr TYPE RANGE OF persno,
range_begda TYPE RANGE OF begda,
range_endda TYPE RANGE OF endda.
data: wa_pernr type line of range_pernr.
FIELD-SYMBOLS :
<fs1> type any,
<fs_emp> type any ,
<FS_PERNR> TYPE range_pernr,
<fs_temp> type str,
<fs_begda> TYPE range_begda,
<fs_endda> TYPE range_endda.
data: ALV_CONFIG_TABLE type REF TO CL_SALV_WD_CONFIG_TABLE.
DATA: wd_table_usage TYPE REF TO if_wd_component_usage.
* Create an instance of ALV component created ALV_COMP is usage name
wd_table_usage = wd_this->wd_cpuse_alv( ).
IF wd_table_usage->has_active_component( ) IS INITIAL.
wd_table_usage->create_component( ).
ENDIF.
*Reading selection screen data
wd_this->w_handler->get_selection_screen_items(
IMPORTING ET_SELECTION_SCREEN_ITEMS = lt_sel_item ).
*Creating ALV COMponent object
lo_interfacecontroller = wd_this->wd_cpifc_alv( ).
lo_config_model_value = lo_interfacecontroller->get_model( ).
*Getting error message
text_error = wd_assist->if_wd_component_assistance~get_text( key =
'001').
text_error1 = wd_assist->if_wd_component_assistance~get_text( key =
'000').
DATA lr_api_controller TYPE REF TO if_wd_controller.
DATA lr_message_manager TYPE REF TO if_wd_message_manager.
lr_api_controller ?= wd_this->wd_get_api( ).
lr_message_manager = lr_api_controller->get_message_manager( ).
loop at lt_sel_item into fs_sel_item.
case fs_sel_item-M_ID.
when 'PERSNO'.
WD_THIS->W_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD(
EXPORTING
i_id = fs_sel_item-m_id
RECEIVING
rt_range_table = rt_emp ).
ASSIGN RT_EMP->* TO <FS_pernr>.
LOOP AT <fs_pernr> into wa_pernr.
fs_low = wa_pernr-low.
fs_high = wa_pernr-high.
ENDLOOP.
CLEAR : rt_emp.
when 'BEGDA'.
WD_THIS->W_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD(
EXPORTING
i_id = fs_sel_item-m_id
RECEIVING
rt_range_table = rt_emp ).
ASSIGN RT_EMP->* TO <FS_BEGDA>.
clear :rt_emp.
when 'ENDDA'.
WD_THIS->W_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD(
EXPORTING
i_id = fs_sel_item-m_id
RECEIVING
rt_range_table = rt_emp ).
ASSIGN RT_EMP->* TO <FS_ENDDA>.
clear :rt_emp.
ENDCASE.
endloop. " ENDLOOP AT it_sel_item
if <fs_pernr> is initial or <fs_begda> is initial or <fs_endda> is initial.
lr_message_manager->report_error_message( message_text = text_error ).
else.
*Fetching data from PA0000
select * from pa0000 into table itab where pernr in <fs_pernr>
and begda in <fs_begda>
and endda in <fs_endda>.
if sy-subrc is initial .
* navigate from <CONTEXT> to <EMP_DEATILS> via lead selection
lo_nd_emp_deatils = wd_context->get_child_node( name = wd_this->wdctx_emp_deatils ).
lo_nd_emp_deatils->bind_table( new_items = itab ).
lo_config_model_value->if_salv_wd_table_settings~set_visible( cl_wd_uielement=>e_visible-visible )..
else.
concatenate text_error1 'for employees :' fs_low ',' fs_high into text_error1.
lr_message_manager->report_error_message( message_text = text_error1 ).
lo_config_model_value->if_salv_wd_table_settings~set_visible( cl_wd_uielement=>e_visible-none ).
endif. "if data is initial
wd_this->fire_out_main_plg( ) .
endif.
lo_config_model_value TYPE REF TO cl_salv_wd_config_table,
lo_interfacecontroller TYPE REF TO iwci_salv_wd_table,
lo_el_emp_deatils TYPE REF TO if_wd_context_element,
ls_emp_deatils TYPE wd_this->element_emp_deatils,
text_error type string,
text_error1 type c length 200,
iref_msg type ref to IF_WD_COMPONENT_ASSISTANCE,
lt_sel_item TYPE if_wd_select_options=>tt_selection_screen_item,
itab type standard table of pa0000,
fs_low type c length 30,
fs_high type c length 10,
dref type ref to data, " data referecnce
rt_emp TYPE REF TO data,
fs_sel_item LIKE LINE OF lt_sel_item.
DATA : W_EMP TYPE C LENGTH 10.
data : l_f_low(5) type c value 'LOW'.
types: range_pernr TYPE RANGE OF persno,
range_begda TYPE RANGE OF begda,
range_endda TYPE RANGE OF endda.
data: wa_pernr type line of range_pernr.
FIELD-SYMBOLS :
<fs1> type any,
<fs_emp> type any ,
<FS_PERNR> TYPE range_pernr,
<fs_temp> type str,
<fs_begda> TYPE range_begda,
<fs_endda> TYPE range_endda.
data: ALV_CONFIG_TABLE type REF TO CL_SALV_WD_CONFIG_TABLE.
DATA: wd_table_usage TYPE REF TO if_wd_component_usage.
* Create an instance of ALV component created ALV_COMP is usage name
wd_table_usage = wd_this->wd_cpuse_alv( ).
IF wd_table_usage->has_active_component( ) IS INITIAL.
wd_table_usage->create_component( ).
ENDIF.
*Reading selection screen data
wd_this->w_handler->get_selection_screen_items(
IMPORTING ET_SELECTION_SCREEN_ITEMS = lt_sel_item ).
*Creating ALV COMponent object
lo_interfacecontroller = wd_this->wd_cpifc_alv( ).
lo_config_model_value = lo_interfacecontroller->get_model( ).
*Getting error message
text_error = wd_assist->if_wd_component_assistance~get_text( key =
'001').
text_error1 = wd_assist->if_wd_component_assistance~get_text( key =
'000').
DATA lr_api_controller TYPE REF TO if_wd_controller.
DATA lr_message_manager TYPE REF TO if_wd_message_manager.
lr_api_controller ?= wd_this->wd_get_api( ).
lr_message_manager = lr_api_controller->get_message_manager( ).
loop at lt_sel_item into fs_sel_item.
case fs_sel_item-M_ID.
when 'PERSNO'.
WD_THIS->W_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD(
EXPORTING
i_id = fs_sel_item-m_id
RECEIVING
rt_range_table = rt_emp ).
ASSIGN RT_EMP->* TO <FS_pernr>.
LOOP AT <fs_pernr> into wa_pernr.
fs_low = wa_pernr-low.
fs_high = wa_pernr-high.
ENDLOOP.
CLEAR : rt_emp.
when 'BEGDA'.
WD_THIS->W_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD(
EXPORTING
i_id = fs_sel_item-m_id
RECEIVING
rt_range_table = rt_emp ).
ASSIGN RT_EMP->* TO <FS_BEGDA>.
clear :rt_emp.
when 'ENDDA'.
WD_THIS->W_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD(
EXPORTING
i_id = fs_sel_item-m_id
RECEIVING
rt_range_table = rt_emp ).
ASSIGN RT_EMP->* TO <FS_ENDDA>.
clear :rt_emp.
ENDCASE.
endloop. " ENDLOOP AT it_sel_item
if <fs_pernr> is initial or <fs_begda> is initial or <fs_endda> is initial.
lr_message_manager->report_error_message( message_text = text_error ).
else.
*Fetching data from PA0000
select * from pa0000 into table itab where pernr in <fs_pernr>
and begda in <fs_begda>
and endda in <fs_endda>.
if sy-subrc is initial .
* navigate from <CONTEXT> to <EMP_DEATILS> via lead selection
lo_nd_emp_deatils = wd_context->get_child_node( name = wd_this->wdctx_emp_deatils ).
lo_nd_emp_deatils->bind_table( new_items = itab ).
lo_config_model_value->if_salv_wd_table_settings~set_visible( cl_wd_uielement=>e_visible-visible )..
else.
concatenate text_error1 'for employees :' fs_low ',' fs_high into text_error1.
lr_message_manager->report_error_message( message_text = text_error1 ).
lo_config_model_value->if_salv_wd_table_settings~set_visible( cl_wd_uielement=>e_visible-none ).
endif. "if data is initial
wd_this->fire_out_main_plg( ) .
endif.
23.Finally Activate the component and to test the application give right click on component name as shown below.
24.Application
componnet selection screen as shown below .Enter some input on it and
click on fetch data if there is any valid records for it, it displays in
ALV else ,it hides ALV output and dispalys message
Thanks for sharing this blog. This is so informative blog
ReplyDeleteLearned a lot of new things from your post! Good creation .
SAP Web DynPro training institutes in Noida
Wonderful post on ABAP Course.
ReplyDeleteSAP Training
SAP Training in Chennai
SAP Training in Bangalore
SAP Training in Hyderabad
SAP Training in Coimbatore
SAP Training in Ameerpet
SAP Training in India
Thanks for sharing this Information. SAP Dynpro Training in Gurgaon
ReplyDeleteSAP WebDynpro Institute in Delhi
ReplyDelete