Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

F4 help

former_member734916
Participant
0 Likes
643

Hello Abapers,

I have a selection screen with two fields, the first field has search help. If I press f4 on the first field it is showing possible values, in my search help I have two columns, if I double click on a particular row one value is showing in first field, but the problem is 'I want to show other field value in serch help in the second field of the selection screen'.

ex:

selection screen.

p_matn

p_werks

possible values for p_matnr :

matnr werks

001 cp01

002 cp02

003 cp03

if i select second row that is '002' and 'cp02'

i want to display '002' in p_matnr and 'cp02' in p_werks.

Thanks in advance.

points assured.

Regards.

Krishna Yerram.

1 ACCEPTED SOLUTION
Read only

Pawan_Kesari
Active Contributor
0 Likes
566

you will have to use FM DYNP_VALUES_UPDATE in AT SELECTION SCREEN ON VALUE REQUEST FOR p_matnr to set value of other p_werks

You can refer below code .. to see how to use this FM


Get dynamic values of parameters on selecttion screen DYNP_VALUES_UPDATE

REPORT zpwtest .

TABLES tcurt.
DATA   dyfields LIKE dynpread OCCURS 1 WITH HEADER LINE.

DATA: BEGIN OF value_tab OCCURS 0,
               name(10),
             END OF value_tab.
DATA :field_tab LIKE dfies  OCCURS 0 WITH HEADER LINE.
DATA : return_tab LIKE ddshretval OCCURS 0 WITH HEADER LINE. DATA : x
TYPE string.


PARAMETERS: p_waers LIKE tcurt-waers,        "Currency
            p_ltext LIKE tcurt-ltext,        "Long Text
            p_ktext LIKE tcurt-ktext.        "Short Text

PARAMETERS: p_name(10).

*-----------------------------------------------------------------------

*--- Example of updating value of another field on the screen ----------

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_waers.
  CLEAR: dyfields[], dyfields.
*--- select currency
  CALL FUNCTION 'HELP_VALUES_GET'
       EXPORTING
            fieldname    = 'WAERS'
            tabname      = 'TCURT'
       IMPORTING
            select_value = p_waers.
*--- get long text for the selected currency
  SELECT SINGLE ltext FROM tcurt
    INTO dyfields-fieldvalue
    WHERE spras = sy-langu
    AND   waers = p_waers.
  IF sy-subrc <> 0.
    CLEAR dyfields-fieldvalue.
  ENDIF.
*--- update another field
  dyfields-fieldname = 'P_LTEXT'.
  APPEND dyfields.
  CALL FUNCTION 'DYNP_VALUES_UPDATE'
       EXPORTING
            dyname     = sy-cprog
            dynumb     = sy-dynnr
       TABLES
            dynpfields = dyfields.
*-----------------------------------------------------------------------

*--- Example of reading value of another field -------------------------

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ktext.
*--- read another field
  CLEAR: dyfields[], dyfields.
  dyfields-fieldname = 'P_WAERS'.
  APPEND dyfields.
  CALL FUNCTION 'DYNP_VALUES_READ'
       EXPORTING
            dyname     = sy-cprog
            dynumb     = sy-dynnr
       TABLES
            dynpfields = dyfields.
  READ TABLE dyfields INDEX 1.
*--- get short text and update current field
  SELECT SINGLE ktext FROM tcurt
    INTO p_ktext
    WHERE spras EQ sy-langu
    AND   waers EQ dyfields-fieldvalue.
*-----------------------------------------------------------------------


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_name.

  REFRESH value_tab[].
  REFRESH field_tab[].
  REFRESH return_tab[].
  field_tab-fieldname = 'ERNAM'.
  field_tab-tabname = 'VBAK'.
  APPEND field_tab.
  value_tab-name = 'John'.
  APPEND value_tab.
  value_tab-name = 'Abraham'.
  APPEND value_tab.
  value_tab-name = 'Lingam'.
  APPEND value_tab.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
       EXPORTING
            retfield        = field_tab-fieldname
       TABLES
            value_tab       = value_tab
            field_tab       = field_tab
            return_tab      = return_tab
       EXCEPTIONS
            parameter_error = 1
            no_values_found = 2
            OTHERS          = 3.
  IF sy-subrc = 0.
    p_name = return_tab-fieldval.
  ENDIF.

3 REPLIES 3
Read only

Former Member
0 Likes
566

Use DYNP_VALUES_UPDATE to update the second value on the selection screen.

Read only

0 Likes
566

Hello Srinivas,

Thanks for the reply,

with this function module also I am unable to show the value in second field, please send me if you have any sampel code.

Regards.

Krishna Yerram.

Read only

Pawan_Kesari
Active Contributor
0 Likes
567

you will have to use FM DYNP_VALUES_UPDATE in AT SELECTION SCREEN ON VALUE REQUEST FOR p_matnr to set value of other p_werks

You can refer below code .. to see how to use this FM


Get dynamic values of parameters on selecttion screen DYNP_VALUES_UPDATE

REPORT zpwtest .

TABLES tcurt.
DATA   dyfields LIKE dynpread OCCURS 1 WITH HEADER LINE.

DATA: BEGIN OF value_tab OCCURS 0,
               name(10),
             END OF value_tab.
DATA :field_tab LIKE dfies  OCCURS 0 WITH HEADER LINE.
DATA : return_tab LIKE ddshretval OCCURS 0 WITH HEADER LINE. DATA : x
TYPE string.


PARAMETERS: p_waers LIKE tcurt-waers,        "Currency
            p_ltext LIKE tcurt-ltext,        "Long Text
            p_ktext LIKE tcurt-ktext.        "Short Text

PARAMETERS: p_name(10).

*-----------------------------------------------------------------------

*--- Example of updating value of another field on the screen ----------

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_waers.
  CLEAR: dyfields[], dyfields.
*--- select currency
  CALL FUNCTION 'HELP_VALUES_GET'
       EXPORTING
            fieldname    = 'WAERS'
            tabname      = 'TCURT'
       IMPORTING
            select_value = p_waers.
*--- get long text for the selected currency
  SELECT SINGLE ltext FROM tcurt
    INTO dyfields-fieldvalue
    WHERE spras = sy-langu
    AND   waers = p_waers.
  IF sy-subrc <> 0.
    CLEAR dyfields-fieldvalue.
  ENDIF.
*--- update another field
  dyfields-fieldname = 'P_LTEXT'.
  APPEND dyfields.
  CALL FUNCTION 'DYNP_VALUES_UPDATE'
       EXPORTING
            dyname     = sy-cprog
            dynumb     = sy-dynnr
       TABLES
            dynpfields = dyfields.
*-----------------------------------------------------------------------

*--- Example of reading value of another field -------------------------

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ktext.
*--- read another field
  CLEAR: dyfields[], dyfields.
  dyfields-fieldname = 'P_WAERS'.
  APPEND dyfields.
  CALL FUNCTION 'DYNP_VALUES_READ'
       EXPORTING
            dyname     = sy-cprog
            dynumb     = sy-dynnr
       TABLES
            dynpfields = dyfields.
  READ TABLE dyfields INDEX 1.
*--- get short text and update current field
  SELECT SINGLE ktext FROM tcurt
    INTO p_ktext
    WHERE spras EQ sy-langu
    AND   waers EQ dyfields-fieldvalue.
*-----------------------------------------------------------------------


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_name.

  REFRESH value_tab[].
  REFRESH field_tab[].
  REFRESH return_tab[].
  field_tab-fieldname = 'ERNAM'.
  field_tab-tabname = 'VBAK'.
  APPEND field_tab.
  value_tab-name = 'John'.
  APPEND value_tab.
  value_tab-name = 'Abraham'.
  APPEND value_tab.
  value_tab-name = 'Lingam'.
  APPEND value_tab.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
       EXPORTING
            retfield        = field_tab-fieldname
       TABLES
            value_tab       = value_tab
            field_tab       = field_tab
            return_tab      = return_tab
       EXCEPTIONS
            parameter_error = 1
            no_values_found = 2
            OTHERS          = 3.
  IF sy-subrc = 0.
    p_name = return_tab-fieldval.
  ENDIF.