Skip to Content
avatar image
Former Member

Retrieving Values from Select-Options without Executing

Hi,

I'm trying to get the values from a select-options into a search help function module without executing the program. How would this be done? I tried using 'f4if_int_table_value_request' and 'rs_refresh_from_selectoptions'. I need to be able to filter the search help values that are dependent on a certain select-option value without having to press the enter/execute button.

Thanks for the help

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 15, 2013 at 09:32 PM

    You can to use this FM DYNP_VALUES_READ, look at this example

    REPORT ytest.

    TABLES: t005u.

    PARAMETERS: p_land1 TYPE t005-land1.

    SELECT-OPTIONS: s_bland FOR t005u-bland.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_bland-low.

    * Local Variables

       DATA: lt_t005u  TYPE TABLE OF t005u,

             lt_dynp   TYPE TABLE OF dynpread,

             lt_return TYPE TABLE OF ddshretval.

       FIELD-SYMBOLS: <fs_dynp>   TYPE dynpread,

                      <fs_return> TYPE ddshretval.

    * Fill parameters to get values

       APPEND INITIAL LINE TO lt_dynp ASSIGNING <fs_dynp>.

       <fs_dynp>-fieldname = 'P_LAND1'.

    * Get value

       CALL FUNCTION 'DYNP_VALUES_READ'

         EXPORTING

           dyname                  = sy-repid

           dynumb                  = sy-dynnr

         TABLES

           dynpfields              = lt_dynp

         EXCEPTIONS

           invalid_abapworkarea    = 1

           invalid_dynprofield     = 2

           invalid_dynproname      = 3

           invalid_dynpronummer    = 4

           invalid_request         = 5

           no_fielddescription     = 6

           invalid_parameter       = 7

           undefind_error          = 8

           double_conversion       = 9

           stepl_not_found         = 10

           others                  = 11.

       IF sy-subrc = 0.

    * Get Country

         READ TABLE lt_dynp ASSIGNING <fs_dynp> WITH KEY fieldname = 'P_LAND1'.

         IF sy-subrc = 0.

           IF <fs_dynp>-fieldvalue IS NOT INITIAL.

    * Get Regions

             SELECT *

               INTO TABLE lt_t005u

                 FROM t005u

                   WHERE spras = sy-langu

                     AND land1 = <fs_dynp>-fieldvalue.

             IF sy-subrc = 0.

    * Show Help

               CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

                 EXPORTING

                   retfield         = 'BLAND'

                   dynpprog         = sy-repid

                   dynpnr           = sy-dynnr

                   value_org        = 'S'

                 TABLES

                   value_tab        = lt_t005u

                   return_tab       = lt_return

                 EXCEPTIONS

                   parameter_error  = 1

                   no_values_found  = 2

                   others           = 3.

               IF sy-subrc = 0.

                 READ TABLE lt_return ASSIGNING <fs_return> INDEX 1.

                 IF sy-subrc = 0.

                   s_bland-low = <fs_return>-fieldval.

                 ENDIF.

               ENDIF.

             ELSE.

               MESSAGE s888(sabapdocu) WITH 'There is not any region of country' <fs_dynp>-fieldvalue.

             ENDIF.

           ELSE.

             MESSAGE s888(sabapdocu) WITH 'Enter a country'.

           ENDIF.

         ENDIF.

       ENDIF.

    START-OF-SELECTION.

       WRITE: p_land1.

    I hope this help you

    Regards

    David Carballido


    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 16, 2013 at 03:09 AM

    HI Victoria,

    Get the values in select-options

    The select option values will be available in the at selection screen output or at selection screen event, when some event like F4 help is triggered. You don't have too implement a function module for that or execute the report.

    A small correction. It will be available if user had pressed enter after inputting the values.

    Otherwise, the header line is only filled. The above happens only when you press 'Enter' after entering the select-options or have inputted multiple values using button. In that case, it will be available in the select-options.

    To get the values entered in select options if the user has not pressed enter, use the FM module , RS_REFRESH_FROM_SELECTOPTIONS.

    FM DYNP_VALUES_READ can be used only for parameters

    To use that for select-options, check this thread

    http://scn.sap.com/thread/1191156

    (or of course you can also prompt him to press enter!). ( I personally feel the FMs are too much work for what can be obtained for something as simple as pressing Enter key on your keyboard.)

    To filter the search help for a paramter based on the select options already entered, you can do something like this.

    The following code has two select options - year and document number. If the year has been entered, the search help for document number will be filtered based on the year select options.

    This is captured at the at selection screen on value request for the second select options.

    DATA: it_ret TYPE ddshretval OCCURS 0 WITH HEADER LINE.

    DATA: BEGIN OF value_tab OCCURS 0,
               YEAR TYPE GJAHR,
               BELNR TYPE BELNR,
           END OF value_tab.


    select-options:

    s_year for ztable-year ,

    s_belnr for ztable-belnr.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_belnr-low.

    CLEAR it_ret.


    * Here capture the values in the other select options field, if it is not empty, filter the values for the F4 help in the select options based on it

    if s_year is initial.
       SELECT year belnr  FROM ztable INTO CORRESPONDING FIELDS OF TABLE value_tab .

    else
    SELECT year belnr  FROM ztable INTO CORRESPONDING FIELDS OF TABLE value_tab where year in s_year.

    endif .

       CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
         EXPORTING
           retfield   = 'BELNR'  field name in your value tab
           value_org  = 'S'
         TABLES
           value_tab  = value_tab[]
           return_tab = it_ret[].

    IF sy-subrc EQ 0.
         READ TABLE it_ret INDEX 1.
         s_belnr-low = it_ret-fieldval.
       ENDIF.

    Kindly revert in case of any doubt..

    Message was edited by: Susmitha Susan Thomas


    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 16, 2013 at 05:28 AM

    Hi Victoria,

    Please use the function module 'DYNP_VALUES_READ' to get the values entered in a select-options field in the screen without executing the complete program.

    Here you need to pass the current program name and the selection screen number to get the results of all entered values. Once you get the result, you can read the returned table using the fieldname for which you want the values.

    Once you get the results, you can use this result in the FM "F4IF_INT_TABLE_VALUE_REQUEST" to populate the F4 help of other fields.

    Please note that you need to call the 1st FM in the AT SELECTION SCREEN ON VALUE REQUEST event of the field, for which you need you need to populate the F4 help.

    Hope this helps. Please let me know if you need any further clarifications.

    Thanks

    Arnab

    Add comment
    10|10000 characters needed characters exceeded