Friday, August 9, 2013
OVS(Object Value Selection) help is to get F4 help. Previously we discussed about OVS help for Input field and OVS help in Selection Options. Here we will discuss on how to implement OVS Help For Multiple Input Fields in Select-Options.
Steps to achieve OVS Search Help For Multiple Input Fields in Select-Options
- Create Web Dynpro Component with View and Window(Automatically View is embedded into Window) and Save it as local object.
- Define Component Use SELECT_OPT for the Used component WDR_SELECT_OPTIONS under Used Components tab of Web Dynpro Component.
- Go to View SELOPT_V->Properties tab->Define or Include Used Controllers/ Components of Select Options.
- Go to view SELOPT_V ->Layout tab->Create ViewContainerUIElement to hold Select-Option field.
- Go to view SELOPT_V ->Methods tab->Double click on WDDOINIT method and write the following code
- WDDOINIT code
- ADD_SELECTION_FIELD method input fields
1 2 3 4 5 6 7 8 9 10 11 12 | METHOD WDDOINIT . WD_THIS->ADD_SELECTION_FIELD( EXPORTING FIELDNAME = 'PERNR' ROLLNAME = 'PA0001-PERNR' NO_INTEVAL = ABAP_TRUE VALUE_HELP_TYPE = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_OVS ). WD_THIS->ADD_SELECTION_FIELD( EXPORTING FIELDNAME = 'ORGEH' ROLLNAME = 'PA0001-ORGEH' NO_INTEVAL = ABAP_TRUE VALUE_HELP_TYPE = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_OVS ). ENDMETHOD. |
- ADD_SELECTION_FIELD method code.
- Go to view SELOPT_V ->Methods tab->Double click on WDDOINIT method and write the following code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | METHOD ADD_SELECTION_FIELD . "Instantiate Used Component DATA LO_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE. LO_CMP_USAGE = WD_THIS->WD_CPUSE_SELECT_OPT( ). IF LO_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL. LO_CMP_USAGE->CREATE_COMPONENT( ). ENDIF. " Instantiate Used Controller and Call Init_selection_screen method. DATA LO_INTERFACECONTROLLER TYPE REF TO IWCI_WDR_SELECT_OPTIONS . LO_INTERFACECONTROLLER = WD_THIS->WD_CPIFC_SELECT_OPT( ). DATA LV_R_HELPER_CLASS TYPE REF TO IF_WD_SELECT_OPTIONS. LV_R_HELPER_CLASS = LO_INTERFACECONTROLLER->INIT_SELECTION_SCREEN( ). DATA LV_FIELDNAME TYPE STRING. DATA LV_ROLLNAME TYPE STRING. LV_ROLLNAME = ROLLNAME. LV_FIELDNAME = FIELDNAME. "Define RANGE table DATA RT_TABLE TYPE REF TO DATA. CALL METHOD LV_R_HELPER_CLASS->CREATE_RANGE_TABLE EXPORTING I_TYPENAME = LV_ROLLNAME RECEIVING RT_RANGE_TABLE = RT_TABLE. "Disable CANCEL, CHECK, RESET and COPY buttons CALL METHOD LV_R_HELPER_CLASS->SET_GLOBAL_OPTIONS EXPORTING I_DISPLAY_BTN_CANCEL = ABAP_FALSE I_DISPLAY_BTN_CHECK = ABAP_FALSE I_DISPLAY_BTN_RESET = ABAP_FALSE I_DISPLAY_BTN_EXECUTE = ABAP_FALSE. "Add range field to Selection screen CALL METHOD LV_R_HELPER_CLASS->ADD_SELECTION_FIELD EXPORTING I_ID = LV_FIELDNAME IT_RESULT = RT_TABLE I_OBLIGATORY = OBLIGATORY I_NO_EXTENSION = NO_EXTENSION I_DESCRIPTION = DESCRIPTION I_VALUE_HELP_TYPE = VALUE_HELP_TYPE I_VALUE_HELP_ID = SEARCH_HELP I_VALUE_HELP_STRUCTURE = VALUE_HELP_STRUCTURE I_VALUE_HELP_STRUCTURE_FIELD = VALUE_HELP_STRUCTURE_FIELD I_NO_INTERVALS = NO_INTEVAL. ENDMETHOD. |
- Go to view SELOPT_V->Methods tab-> Create one Event Handler method OVS_4_SELECT_OPT -> Select the event ON_OVS of component WDR_SELECT_OPTIONS using F4 help for Event field.
- OVS_4_SELECT_OPT event handler method code.
METHOD OVS_4_SELECT_OPT . IF I_OVS_DATA-M_SELECTION_FIELD_ID = 'ORGEH'. WD_THIS->OVS_DEP( I_OVS_DATA ). ELSEIF I_OVS_DATA-M_SELECTION_FIELD_ID = 'PERNR'. WD_THIS->OVS_PERNR( I_OVS_DATA ). ENDIF. ENDMETHOD.
- OVS_DEP method code.
METHOD OVS_DEP . * declare data structures for the fields to be displayed and * for the table columns of the selection list, if necessary TYPES: BEGIN OF LTY_STRU_INPUT, " Add fields for the display of your search input here ORGEH TYPE PA0001-ORGEH, ORGTX TYPE T527X-ORGTX, END OF LTY_STRU_INPUT. TYPES: BEGIN OF LTY_STRU_LIST, * add fields for the selection list here ORGEH TYPE PA0001-ORGEH, ORGTX TYPE T527X-ORGTX, END OF LTY_STRU_LIST. DATA: LS_SEARCH_INPUT TYPE LTY_STRU_INPUT, LT_SELECT_LIST TYPE STANDARD TABLE OF LTY_STRU_LIST, LS_TEXT TYPE WDR_NAME_VALUE, LT_LABEL_TEXTS TYPE WDR_NAME_VALUE_LIST, LT_COLUMN_TEXTS TYPE WDR_NAME_VALUE_LIST, LRT_DEP TYPE CCHRY_ORGEH_RANGE, LV_WINDOW_TITLE TYPE STRING, LV_TABLE_HEADER TYPE STRING. FIELD-SYMBOLS: <LS_QUERY_PARAMS> TYPE LTY_STRU_INPUT, <LS_SELECTION> TYPE LTY_STRU_LIST. CASE I_OVS_DATA-M_OVS_CALLBACK_OBJECT->PHASE_INDICATOR. WHEN IF_WD_OVS=>CO_PHASE_0. "configuration phase, may be omitted * in this phase you have the possibility to define the texts, * if you do not want to use the defaults (DDIC-texts) LS_TEXT-NAME = 'ORGEH'. "must match a field name of search LS_TEXT-VALUE = 'Org Unit ID'. "wd_assist->get_text( `001` ). INSERT LS_TEXT INTO TABLE LT_LABEL_TEXTS. LS_TEXT-NAME = 'STEXT'. "must match a field in list structure LS_TEXT-VALUE = 'Org Unit Description'. "wd_assist->get_text( `002` ). INSERT LS_TEXT INTO TABLE LT_COLUMN_TEXTS. LV_WINDOW_TITLE = 'Department Selection'. "wd_assist->get_text( `003` ). * lv_table_header = wd_assist->get_text( `004` ). I_OVS_DATA-M_OVS_CALLBACK_OBJECT->SET_CONFIGURATION( LABEL_TEXTS = LT_LABEL_TEXTS COLUMN_TEXTS = LT_COLUMN_TEXTS WINDOW_TITLE = LV_WINDOW_TITLE TABLE_HEADER = LV_TABLE_HEADER ). WHEN IF_WD_OVS=>CO_PHASE_1. "set search structure and defaults * In this phase you can set the structure and default values * of the search structure. If this phase is omitted, the search * fields will not be displayed, but the selection table is * displayed directly. * Read values of the original context (not necessary, but you * may set these as the defaults). A reference to the context * element is available in the callback object. * I_OVS_DATA-M_OVS_CALLBACK_OBJECT->CONTEXT_ELEMENT->GET_STATIC_ATTRIBUTES( * IMPORTING STATIC_ATTRIBUTES = LS_SEARCH_INPUT ). * pass the values to the OVS component * I_OVS_DATA-M_OVS_CALLBACK_OBJECT->SET_INPUT_STRUCTURE( * INPUT = LS_SEARCH_INPUT ). WHEN IF_WD_OVS=>CO_PHASE_2. * If phase 1 is implemented, use the field input for the * selection of the table. * If phase 1 is omitted, use values from your own context. "IF OVS_CALLBACK_OBJECT->QUERY_PARAMETERS IS NOT BOUND. "TODO exception handling "ENDIF. * ASSIGN I_OVS_DATA-M_OVS_CALLBACK_OBJECT->QUERY_PARAMETERS->* * TO <LS_QUERY_PARAMS>. "IF NOT <LS_QUERY_PARAMS> IS ASSIGNED. "TODO exception handling "ENDIF. SELECT * FROM T527X INTO CORRESPONDING FIELDS OF TABLE LT_SELECT_LIST UP TO 50 ROWS WHERE SPRSL = SY-LANGU. * call business logic for a table of possible values * lt_select_list = ??? I_OVS_DATA-M_OVS_CALLBACK_OBJECT->SET_OUTPUT_TABLE( OUTPUT = LT_SELECT_LIST ). WHEN IF_WD_OVS=>CO_PHASE_3. * apply result ASSIGN I_OVS_DATA-M_OVS_CALLBACK_OBJECT->SELECTION->* TO <LS_SELECTION>. IF <LS_SELECTION> IS ASSIGNED. I_OVS_DATA-M_OVS_CALLBACK_OBJECT->CONTEXT_ELEMENT->SET_ATTRIBUTE( NAME = I_OVS_DATA-M_OVS_CALLBACK_OBJECT->CONTEXT_ATTRIBUTE VALUE = <LS_SELECTION>-ORGEH ). ENDIF. ENDCASE. ENDMETHOD.
- OVS_PERNR method code.
- Activate ZOVH_SELECT_OPTIONS_001 component.
- Create Web dynpro Application for the component.
- Run Web Dynpro Application. Check f4 for both fields one by one.
METHOD OVS_PERNR . * declare data structures for the fields to be displayed and * for the table columns of the selection list, if necessary TYPES: BEGIN OF LTY_STRU_INPUT, " Add fields for the display of your search input here PERNR TYPE PA0001-PERNR, ENAME TYPE PA0001-ENAME, END OF LTY_STRU_INPUT. TYPES: BEGIN OF LTY_STRU_LIST, * add fields for the selection list here PERNR TYPE PA0001-PERNR, ENAME TYPE PA0001-ENAME, END OF LTY_STRU_LIST. DATA: LS_SEARCH_INPUT TYPE LTY_STRU_INPUT, LT_SELECT_LIST TYPE STANDARD TABLE OF LTY_STRU_LIST, LS_TEXT TYPE WDR_NAME_VALUE, LT_LABEL_TEXTS TYPE WDR_NAME_VALUE_LIST, LT_COLUMN_TEXTS TYPE WDR_NAME_VALUE_LIST, LRT_DEP TYPE CCHRY_ORGEH_RANGE, LV_WINDOW_TITLE TYPE STRING, LV_TABLE_HEADER TYPE STRING. FIELD-SYMBOLS: <LS_QUERY_PARAMS> TYPE LTY_STRU_INPUT, <LS_SELECTION> TYPE LTY_STRU_LIST. CASE I_OVS_DATA-M_OVS_CALLBACK_OBJECT->PHASE_INDICATOR. WHEN IF_WD_OVS=>CO_PHASE_0. "configuration phase, may be omitted * in this phase you have the possibility to define the texts, * if you do not want to use the defaults (DDIC-texts) LS_TEXT-NAME = `PERNR`. "must match a field name of search LS_TEXT-VALUE = `Employee No.`. "wd_assist->get_text( `001` ). INSERT LS_TEXT INTO TABLE LT_LABEL_TEXTS. LS_TEXT-NAME = `ENAME`. "must match a field in list structure LS_TEXT-VALUE = `Employee Name`. "wd_assist->get_text( `002` ). INSERT LS_TEXT INTO TABLE LT_COLUMN_TEXTS. LV_WINDOW_TITLE = 'Personnel No. Selection'. "wd_assist->get_text( `003` ). * lv_table_header = wd_assist->get_text( `004` ). I_OVS_DATA-M_OVS_CALLBACK_OBJECT->SET_CONFIGURATION( LABEL_TEXTS = LT_LABEL_TEXTS COLUMN_TEXTS = LT_COLUMN_TEXTS WINDOW_TITLE = LV_WINDOW_TITLE TABLE_HEADER = LV_TABLE_HEADER ). WHEN IF_WD_OVS=>CO_PHASE_1. "set search structure and defaults * In this phase you can set the structure and default values * of the search structure. If this phase is omitted, the search * fields will not be displayed, but the selection table is * displayed directly. * Read values of the original context (not necessary, but you * may set these as the defaults). A reference to the context * element is available in the callback object. * I_OVS_DATA-M_OVS_CALLBACK_OBJECT->CONTEXT_ELEMENT->GET_STATIC_ATTRIBUTES( * IMPORTING STATIC_ATTRIBUTES = LS_SEARCH_INPUT ). * pass the values to the OVS component ***** I_OVS_DATA-M_OVS_CALLBACK_OBJECT->SET_INPUT_STRUCTURE( ***** INPUT = LS_SEARCH_INPUT ). WHEN IF_WD_OVS=>CO_PHASE_2. * If phase 1 is implemented, use the field input for the * selection of the table. * If phase 1 is omitted, use values from your own context. "IF OVS_CALLBACK_OBJECT->QUERY_PARAMETERS IS NOT BOUND. "TODO exception handling "ENDIF. ASSIGN I_OVS_DATA-M_OVS_CALLBACK_OBJECT->QUERY_PARAMETERS->* TO <LS_QUERY_PARAMS>. "IF NOT <LS_QUERY_PARAMS> IS ASSIGNED. "TODO exception handling "ENDIF. * CALL METHOD WD_ASSIST->PERNR_4_MGR * EXPORTING * DEPARTMENT = LRT_DEP * QUERY_PARAMS = <LS_QUERY_PARAMS> * IMPORTING * PERNR_4_MGR = LT_SELECT_LIST. * call business logic for a table of possible values * lt_select_list = ??? SELECT PERNR ENAME FROM PA0001 INTO TABLE LT_SELECT_LIST UP TO 50 ROWS. I_OVS_DATA-M_OVS_CALLBACK_OBJECT->SET_OUTPUT_TABLE( OUTPUT = LT_SELECT_LIST ). WHEN IF_WD_OVS=>CO_PHASE_3. * apply result ASSIGN I_OVS_DATA-M_OVS_CALLBACK_OBJECT->SELECTION->* TO <LS_SELECTION>. IF <LS_SELECTION> IS ASSIGNED. I_OVS_DATA-M_OVS_CALLBACK_OBJECT->CONTEXT_ELEMENT->SET_ATTRIBUTE( NAME = I_OVS_DATA-M_OVS_CALLBACK_OBJECT->CONTEXT_ATTRIBUTE VALUE = <LS_SELECTION>-PERNR ). ENDIF. ENDCASE. ENDMETHOD.
Followers
Popular Posts
- ABAP - ALV Report example with steps
- ABAP - Sending email with pdf attachment
- ABAP - Step by step tutorial on Smart Forms - Template Node
- SAP Adobe Form - Steps to create simple ADOBE Form and calling it from ABAP Program
- SAP ABAP - CL_ABAP_CHAR_UTILITIES class usage
- ABAP - Multiple value selection from F4 help for SELECT-OPTIONS
- Execute ABAP Report using SUBMIT statement
- ABAP - Select all or Deselect all in ALV or Check box handling in ALV
- Web Dynpro ABAP ALV - ON_CLICK event
- ABAP - Dynamic WHERE clause
0 comments:
Post a Comment
Your useful comments, suggestions are appreciated.Your comments are moderated.