Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Selection Screen not able to pick from f4 if i make field non editable.

Hi,

I have one small requirement.

I would like to restrict the Users. The person has to give the input values in Selection screen through the only f4 help only,

It might  be possible to enter the values in fields directly.  Plz have a look on below attached image.

In the below code, In selection screen If i make field disabled, Only parameter only it is working. means i can able to pick the value from f4.

but same logic is applicable to 

SELECT-OPTIONS: S_BUKRS FOR MARA-MATNR.   But not working.

Can any body tell me  what is the wrong in my code..

TABLES: MARA.

TYPES: BEGIN OF TY,

          MATNR TYPE MATNR,

         WERKS TYPE WERKS_D,

        END OF TY.

DATA: IT2 TYPE STANDARD TABLE OF DSELC,

       WA2 TYPE DSELC.

DATA: IT TYPE STANDARD TABLE OF TY,

       WA_RETURN TYPE DDSHRETVAL,

       I_RETURN TYPE STANDARD TABLE OF DDSHRETVAL,

       REPID TYPE SY-REPID,

       DYNNR TYPE SY-DYNNR.

PARAMETERS:

          P_MATNR   TYPE MARA-MATNR,

          P_WERKS    TYPE MARC-WERKS.

SELECT-OPTIONS: S_BUKRS FOR MARA-MATNR.

AT SELECTION-SCREEN OUTPUT.

   LOOP AT SCREEN.

     IF SCREEN-NAME = 'P_WERKS'.

       SCREEN-INPUT = 0.

       SCREEN-DISPLAY_3D = 'X'.

       MODIFY SCREEN.

     ENDIF.

   ENDLOOP.

     LOOP AT SCREEN.

     IF SCREEN-NAME = 'P_MATNR'.

       SCREEN-INPUT = 0.

*      SCREEN-DISPLAY_3D = 'X'.

       MODIFY SCREEN.

     ENDIF.

   ENDLOOP.

   LOOP AT SCREEN.

     IF SCREEN-NAME = 'S_BUKRS-HIGH'.

       SCREEN-INPUT = 0.

*      SCREEN-DISPLAY_3D = 'X'.

       MODIFY SCREEN.

     ENDIF.

   ENDLOOP.

     LOOP AT SCREEN.

     IF SCREEN-NAME = 'S_BUKRS-LOW'.

       SCREEN-INPUT = 0.

*      SCREEN-DISPLAY_3D = 'X'.

       MODIFY SCREEN.

     ENDIF.

   ENDLOOP.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MATNR.

   REPID = SY-REPID.

   DYNNR = SY-DYNNR.

   SELECT MATNR WERKS

               FROM MARC UP TO 20 ROWS

               INTO TABLE IT.

   CHECK SY-SUBRC = 0.

   WA2-FLDNAME = 'F0001'.

   WA2-DYFLDNAME = 'P_MATNR'.

   APPEND WA2 TO IT2.

   WA2-FLDNAME = 'F0002'.

   WA2-DYFLDNAME = 'P_WERKS'.

   APPEND WA2 TO IT2.

   CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

     EXPORTING

       RETFIELD        = 'WERKS'

       DYNPPROG        = REPID

       DYNPNR          = DYNNR

       DYNPROFIELD     = 'P_WERKS'

       VALUE_ORG       = 'S'

       DISPLAY         = 'F'

     TABLES

       VALUE_TAB       = IT

       DYNPFLD_MAPPING = IT2

     EXCEPTIONS

       PARAMETER_ERROR = 1

       NO_VALUES_FOUND = 2

       OTHERS          = 3.

f4_selection.png (69638 B)
replied

Hi NewB,

You were on the right lines with the very first code that you posted. I think you got a little confused trying to handle a select-option. You certainly do not need to call DYNP_VALUES_UPDATE.

As you found the key to be able to return a value to display only fields is the following parameter of the function call:

        display         = 'F' "<<<<<< Allow value return to screen in display mode

The following report returns the selected F4 value to a select-option. Frankly it is not really suited to returning a value to a display only select-option, as you are limited to what you can select in the F4 help. It is much more suited to a display only parameter, but the below shows that it can be done for a select-option. Just be careful the input parameters to the function call match your program, e.g. dynpprog, dynprofield, etc:

  REPORT zprac11.

  TABLES:mara.

  SELECT-OPTIONS : s_matnr FOR mara-matnr.

  TYPES: BEGIN OF resb_posnr,

           matnr TYPE mara-matnr,

         END OF resb_posnr.

  DATA: it_rseb TYPE TABLE OF resb_posnr,

        wa_rseb TYPE resb_posnr,

        ls_values TYPE ddshretval.

  DATA : it_return1 LIKE ddshretval OCCURS 0 WITH HEADER LINE,

         it_return2 LIKE ddshretval OCCURS 0 WITH HEADER LINE,

         lt_values TYPE STANDARD TABLE OF ddshretval.

AT SELECTION-SCREEN OUTPUT.

  LOOP AT SCREEN.

    IF screen-name = 'S_MATNR-LOW'

    OR screen-name = 'S_MATNR-HIGH'.

      screen-input = 0.

      MODIFY SCREEN.

    ENDIF.

  ENDLOOP.

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

  SELECT   matnr FROM mara INTO TABLE it_rseb

     UP TO 10 ROWS.

  IF sy-subrc = 0.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

      EXPORTING

        retfield        = 'MATNR'

        dynpprog        = 'ZPRAC11' "<<<<<<< The name of your ABAP program

        dynpnr          = sy-dynnr

        dynprofield     = 'S_MATNR'  "<<<<<<< The name of the select-option

        value_org       = 'S'

        display         = 'F' "<<<<<< Allow value return to screen in display mode

      TABLES

        value_tab       = it_rseb

        return_tab      = lt_values

      EXCEPTIONS

        parameter_error = 1

        no_values_found = 2

        OTHERS          = 3.

    IF sy-subrc <> 0.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

  ENDIF.

The above works when I try it.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question