Skip to Content
avatar image
-6
Former Member

select-options depend on select options

Good morning!

Does anybody know if a select-options match code can depend on another select-options match code? If yes ,please post an example.For example:

SELECT-OPTIONS: s_klart FOR klah-klart.
SELECT-OPTIONS: s_atinn FOR cabn-atinn NO INTERVALS NO-EXTENSION.

The match code of s_atinn need to depend on the match code of s_klart. Until now i`ve seen only dependency between select-option and a parameter.

Have a great day!

Please find below my code:

- code removed by moderator. Only post relevant code, and when you've posted it, make sure it is readable -

Add comment
10|10000 characters needed characters exceeded

  • What makes me think is the information you've given us so far to in this post. Have you indicated that you ran the code through the debugger? Have you shared your findings with us? You think I'm being sarcastic while I'm merely expressing how your own text is perceived:

    "The problem is that immediatly after my report gets blocked,enters in a sort of loop ,it countinuously loading without being able do anything else. Please find below my code:"

    No word about debugging here or trying anything further.

    Kindly refer to this blog if you're expecting to receive assistance from the volunteers on SCN in future.

  • Former Member Jelena Perfiljeva

    Best thing is that all the other people that tried to help me figured out themselves that i did the best i could otherwise i wouldn`t be posting this thread.

  • Please do not keep editing the question (or any other posts). It makes it difficult for others who might want to use the discussion for their own purposes figure out what is going on. I have reverted the original post to the last reasonable version.

    If you want to add information, use comments.

    The text of your last revision is:

    Good morning!

    Thanks to Rashid my code now works.Please see below

    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    
    SELECT-OPTIONS: s_klart FOR klah-klart NO INTERVALS NO-EXTENSION DEFAULT '001'."PARAMETERS: s_klart LIKE klah-klart."
    
    SELECT-OPTIONS: s_class FOR klah-class NO INTERVALS NO-EXTENSION OBLIGATORY MATCHCODE OBJECT clas DEFAULT 'Z_MEDIU'."Nume clasa   NO INTERVALS NO-EXTENSION
    
    SELECT-OPTIONS: s_matkl FOR mara-matkl NO INTERVALS NO-EXTENSION.  "Grup Material
    
    SELECT-OPTIONS: s_mtart FOR t134t-mtart NO INTERVALS NO-EXTENSION.  "Cont Material
    
    SELECT-OPTIONS: s_matnr FOR mara-matnr NO INTERVALS NO-EXTENSION.  "Numar Material
    
    SELECT-OPTIONS: s_atinn FOR cabn-atinn. "PARAMETERS:s_atinn LIKE cabn-atinn. " .  "Caracteristici
    
    SELECTION-SCREEN END OF BLOCK b1.                  " DISPLAY_DATA
    
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_atinn-low.
    
      PERFORM fetch_values_atinn.
    
    FORM fetch_values_atinn.
      DATA: lv_klart LIKE klah-klart.
      DATA: lt_fieldvals TYPE STANDARD TABLE OF rsselread,
            ls_fieldvals TYPE rsselread.
      IF s_klart IS INITIAL.
    
    **may be value not passed to select option yet
    ** fill fieldvals table
        CLEAR ls_fieldvals. REFRESH lt_fieldvals.
        MOVE: 'S_KLART' TO ls_fieldvals-name,
         'S'     TO ls_fieldvals-kind,
         'LOW'   TO ls_fieldvals-position.
        APPEND ls_fieldvals TO lt_fieldvals.
    
    ** call the FM to read selection screen values
        CALL FUNCTION 'RS_SELECTIONSCREEN_READ'
          EXPORTING
            program     = sy-repid
          TABLES
            fieldvalues = lt_fieldvals.
    
    ** check fieldvals tab for values read
        CLEAR lv_klart.
        READ TABLE lt_fieldvals INTO ls_fieldvals WITH KEY name = 'S_KLART'.
        IF sy-subrc = 0.
          CONDENSE ls_fieldvals-fieldvalue NO-GAPS.
          lv_klart = ls_fieldvals-fieldvalue.
          IF lv_klart IS NOT INITIAL.
            SELECT imerk clint klart INTO TABLE i_ksml
           FROM ksml
         WHERE klart = lv_klart.
            CHECK sy-subrc = 0.
            PERFORM show_f4_atinn.
          ENDIF.  "lv_klart not initial
        ENDIF. "subrc read table
      ELSE.  "s_klart has some value
    
        SELECT imerk clint klart INTO TABLE i_ksml
      FROM ksml
    WHERE klart IN s_klart.
        IF sy-subrc = 0.
          PERFORM show_f4_atinn.
        ENDIF.  "subrc 0 check
      ENDIF.   "s_klart check
    ENDFORM.
    *&---------------------------------------------------------------------*
    
    *&      Form  SHOW_F4_EBELP
    
    *&---------------------------------------------------------------------*
    
    FORM show_f4_atinn.
      DATA: lt_return TYPE STANDARD TABLE OF ddshretval.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
        retfield        = 'IMERK'
        dynpprog        = sy-repid
        dynpnr          = sy-dynnr
        dynprofield     = 'S_ATINN-LOW'
        value_org       = 'S'
      TABLES
        value_tab       = i_ksml
        return_tab      = lt_return
      EXCEPTIONS
        parameter_error = 1
        no_values_found = 2
        OTHERS          = 3.
      IF sy-subrc <> 0.
    
    * Implement suitable error handling here
    **** ??
      ENDIF.
    ENDFORM.
Further commenting has been locked.
  • Get RSS Feed

4 Answers

  • Best Answer
    Jul 26, 2017 at 02:52 PM

    If the user has input some value in select-option or parameter and then press "Enter" button, this basically allow selection screen values to be passed to the relevent variables like S_KLART etc. In this case you can simply address this variable (select-option to be more precise) in "AT SELECTION-SCREEN ON VALUE-REQUEST FOR" for other select-options.

    However if user just types the value or select the value from a list and then goes to next select-option/parameter, in this case the selection-screen values are not passed to relevent variables. In this case Sandra Rossi has given you a very good tip to use function module RS_SELECTIONSCREEN_READ to read such value.

    I had a similar requirement in one report. Following code is derived from that report, although i have removed the code not relevant with your issue. This is owrking code. Just copy/paste in your system and it should work. It can give you some baseline to observe and apply similar changes in your report.

    *&---------------------------------------------------------------------*
    *& Report  YYRJ_TEST0080
    *&
    *&---------------------------------------------------------------------*
    *& Read selection screen elements
    *& Working: Enter a valid PO number in s_ebeln. then press F4 for
    *&          s_ebelp-low. Basically it will retreive a list of all
    *&          all line items number for the PO given in s_ebeln.
    *&---------------------------------------------------------------------*
    REPORT yyrj_test0080.
    TABLES: ekko, ekpo.
    
    
    SELECT-OPTIONS :
    s_ebeln FOR ekko-ebeln NO INTERVALS NO-EXTENSION,
    s_ebelp FOR ekpo-ebelp.
    
    
    TYPES: BEGIN OF tt_ebelp,
             ebelp LIKE ekpo-ebelp,
           END OF tt_ebelp.
    DATA: lt_ebelp TYPE STANDARD TABLE OF tt_ebelp,
          ls_ebelp TYPE tt_ebelp.
    
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_ebelp-low.
      PERFORM fetch_values_ebelp.
    
    START-OF-SELECTION.
      WRITE:/ 'What is this'..
    *&---------------------------------------------------------------------*
    *&      Form  FETCH_VALUES_EBELP
    *&---------------------------------------------------------------------*
    FORM fetch_values_ebelp.
    
      DATA: lv_lin   TYPE i,
            lv_ebeln LIKE ekko-ebeln.
      DATA: lt_fieldvals TYPE STANDARD TABLE OF rsselread,
            ls_fieldvals TYPE rsselread.
    
      IF s_ebeln IS INITIAL.
    **may be value not passed to select option yet
    ** fill fieldvals table
        CLEAR ls_fieldvals. REFRESH lt_fieldvals.
        MOVE: 'S_EBELN' TO ls_fieldvals-name,
              'S'     TO ls_fieldvals-kind,
              'LOW'   TO ls_fieldvals-position.
        APPEND ls_fieldvals TO lt_fieldvals.
    ** call the FM to read selection screen values
        CALL FUNCTION 'RS_SELECTIONSCREEN_READ'
          EXPORTING
            program     = sy-repid
          TABLES
            fieldvalues = lt_fieldvals.
    ** check fieldvals tab for values read
        CLEAR lv_ebeln.
        READ TABLE lt_fieldvals INTO ls_fieldvals WITH KEY name = 'S_EBELN'.
        IF sy-subrc = 0.
          CONDENSE ls_fieldvals-fieldvalue NO-GAPS.
          lv_ebeln = ls_fieldvals-fieldvalue.
          IF lv_ebeln IS NOT INITIAL.
            SELECT ebelp INTO TABLE lt_ebelp
              FROM ekpo
            WHERE ebeln = lv_ebeln.
            CHECK sy-subrc = 0.
            PERFORM show_f4_ebelp.
          ENDIF.  "lv_ebeln not initial
        ENDIF. "subrc read table
      ELSE.  "s_ebeln has some value
        SELECT ebelp INTO TABLE lt_ebelp
          FROM ekpo
        WHERE ebeln IN s_ebeln.
        IF sy-subrc = 0.
          PERFORM show_f4_ebelp.
        ENDIF.  "subrc 0 check
      ENDIF.   "s_ebeln check
    ENDFORM.
    *&---------------------------------------------------------------------*
    *&      Form  SHOW_F4_EBELP
    *&---------------------------------------------------------------------*
    FORM show_f4_ebelp .
    
    
      DATA: lt_return TYPE STANDARD TABLE OF ddshretval.
    
    
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield        = 'EBELP'
          dynpprog        = sy-repid
          dynpnr          = sy-dynnr
          dynprofield     = 'S_EBELP-LOW'
          value_org       = 'S'
    * IMPORTING
    *     USER_RESET      =
        TABLES
          value_tab       = lt_ebelp
          return_tab      = lt_return
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.
      IF sy-subrc <> 0.
    * Implement suitable error handling here
    **** ??
      ENDIF.
    ENDFORM.
    
    Add comment
    10|10000 characters needed characters exceeded

  • Jul 19, 2017 at 07:16 AM

    There are lots of examples all around the web how to display your own values, with function module F4IF_INT_TABLE_VALUE_REQUEST for instance. I guess you know how to build the list of S_ATINN possible values according to values in S_KLART, or are you stuck somewhere?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Dear Matthew ,

      I did as you advised me and i thank you for this . When i put a value in s_klart , after i can see in s_atinn the list accordingly to what i put in s_klart,which is good.The problem is that immediatly after my report gets blocked,enters in a sort of loop ,it countinuously loading without being able do anything else. Please find below my code:

      DATA:

      "Internal Tables of Value Table for F4 Help

      * i_class1 TYPE STANDARD TABLE OF type_class1, pentru parametrul : s_klart

      * i_ksml TYPE STANDARD TABLE OF type_ksml, pentru select-options s_atinn

      * it_pspid1 TYPE STANDARD TABLE OF ty_pspid,

      "Internal Tables of Return Table for F4 Help

      wa_return1 TYPE ddshretval,

      wa_return2 TYPE ddshretval,

      wa_return3 TYPE ddshretval,

      it_return1 TYPE STANDARD TABLE OF ddshretval,

      it_return2 TYPE STANDARD TABLE OF ddshretval,

      it_return3 TYPE STANDARD TABLE OF ddshretval.

      CONSTANTS:

      "Constants for F4IF_INT_TABLE_VALUE_REQUEST

      c_klart TYPE dfies-fieldname VALUE 'S_KLART',

      c_pspid_l TYPE dfies-fieldname VALUE 'P_PSPID-LOW',

      c_pspid_h TYPE dfies-fieldname VALUE 'P_PSPID-HIGH',

      c_vorg TYPE char1 VALUE 'S'.

      * ALV data declarations

      data: it_sortcat type slis_sortinfo_alv occurs 1,

      wa_sort like line of it_sortcat.

      DATA: it_filter TYPE slis_t_filter_alv.

      Data: ls_filter TYPE slis_filter_alv.

      *selection screen

      SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

      PARAMETERS: s_klart LIKE klah-klart. "Tip clasa ,SELECT-OPTIONS: s_klart FOR klah-klart NO INTERVALS NO-EXTENSION.

      SELECT-OPTIONS :s_class FOR klah-class OBLIGATORY MATCHCODE OBJECT clas DEFAULT 'Z_MEDIU'."Nume clasa NO INTERVALS NO-EXTENSION

      SELECT-OPTIONS: s_matkl FOR mara-matkl. "Grup Material

      SELECT-OPTIONS: s_mtart FOR t134t-mtart. "NO INTERVALS NO-EXTENSION DEFAULT '3010'. "Grup Material

      SELECT-OPTIONS: s_matnr FOR mara-matnr." NO INTERVALS NO-EXTENSION. "Numar Material

      SELECT-OPTIONS: s_atinn FOR cabn-atinn NO INTERVALS NO-EXTENSION. "Caracteristici

      SELECTION-SCREEN END OF BLOCK b1.

      *SELECTION-SCREEN SKIP 1.

      *

      *

      *START-OF-SELECTION.

      AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_klart.

      SELECT DISTINCT class klart FROM klah INTO TABLE i_class1.

      IF sy-subrc = 0.

      SORT i_class1 BY klart.

      ENDIF.

      "Function Module to create F4 help

      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

      EXPORTING

      retfield = c_klart

      value_org = c_vorg

      TABLES

      value_tab = i_class1

      return_tab = it_return1

      EXCEPTIONS

      parameter_error = 1

      no_values_found = 2

      OTHERS = 3.

      IF it_return1 IS NOT INITIAL.

      LOOP AT it_return1 INTO wa_return1.

      s_klart = wa_return1-fieldval.

      ENDLOOP.

      SELECT imerk clint klart FROM ksml INTO TABLE i_ksml

      WHERE klart = s_klart.

      IF sy-subrc = 0.

      SORT i_ksml BY imerk.

      ENDIF.

      ENDIF.

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

      "Function Module to create F4 help

      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

      EXPORTING

      retfield = c_pspid_l

      value_org = c_vorg

      TABLES

      value_tab = i_ksml

      return_tab = it_return2

      EXCEPTIONS

      parameter_error = 1

      no_values_found = 2

      OTHERS = 3.

      IF it_return2 IS NOT INITIAL.

      LOOP AT it_return2 INTO wa_return2.

      s_atinn-low = wa_return2-fieldval.

      ENDLOOP.

      SELECT imerk clint klart FROM ksml INTO TABLE i_ksml

      WHERE imerk GT s_atinn-low

      AND klart = s_klart.

      IF sy-subrc = 0.

      SORT i_ksml BY imerk.

      ENDIF.

      ENDIF.

  • Jul 19, 2017 at 08:06 AM

    Hello,

    If you know how to perform this selection with one parameter then all you have to do is to loop on every singe values from first select-options.

    Something like :

    AT SELECTION SCREEN ON VALUE REQUEST FOR S_ATINN.
    DATA t_klart type table of khla-klart.
    FIELD-SYMBOLS : <klart> type khla-klart. 
    select distinct klart from khla into table t_klart where klart in s_klart.
    * Create values for s_atinn from t_klart and use F4IF_INT_TABLE_VALUE_REQUEST

    Or :

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_klart.
      SELECT DISTINCT class klart FROM klah INTO TABLE i_class1.
      IF sy-subrc = 0.
        SORT i_class1 BY klart.
      ENDIF.
    
      "Function Module to create F4 help
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield        = 'KLART' " Name of value_tab column to be returned
          dynpprog        = sy-repid 
          dynpnr          = sy-dynnr
          dynprofield     = 'S_KLART' " Name of field to be filled
          value_org       = 'S'       " I don't know why but it's mandatory
        TABLES
          value_tab       = i_class1
    *     return_tab      = it_return1
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.
    
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_atinn-low.
      CHECK s_klart IS NOT INITIAL.
    
      SELECT imerk clint klart FROM ksml INTO TABLE i_ksml
      WHERE klart = s_klart.
      IF sy-subrc = 0.
        SORT i_ksml BY imerk.
      ENDIF.
    
      DATA t_field_tab TYPE TABLE OF dfies.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield        = 'IMERK'
          dynpprog        = sy-repid
          dynpnr          = sy-dynnr
          dynprofield     = 'S_ATINN-LOW'
          value_org       = 'S'       
        TABLES
          value_tab       = i_ksml
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.
    

    Best regards

    Bertrand

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Bertrand DELVALLEE

      Hi Bertrand,

      I have used that parameter,still not working,i`v got four days since i am working on this :(.

      Thank you for your support...

  • Jul 20, 2017 at 06:06 AM

    PS: you may also need to call RS_SELECTIONSCREEN_READ when you process F4 on S_ATINN, to retrieve the last entered value of S_KLART, because all screen values are not automatically transferred when you press F4.

    Add comment
    10|10000 characters needed characters exceeded