Skip to Content
author's profile photo Former Member
Former Member

F4 HELP IN SELECTION SCREEN

In selection screen I have TWO Fields Plant and Material No.

If I input Plant, how do I get the Material No: based on the Plant dynamically?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Apr 28, 2008 at 09:54 AM

    You have to use the function module DYNP_VALUES_READ to read the selection screen data after u enter the field value in Plant . Based on that, then call the function module F4_INT_VALUE_REQUEST. And this function module will

    retrive based on the value enter on the field1.

    Have a look at below sample code:

    If you have two parameters, you want to display values(f4) in parameter 2 depending on the values entered in parameter 1.

    REPORT Z_SRI_HELP_VALUE_FOR_TABLES .

    tables tcurt.

    DATA DYFIELDS LIKE DYNPREAD OCCURS 1 WITH HEADER LINE.

    PARAMETERS: P_WAERS LIKE TCURT-WAERS, "Currency

    P_LTEXT LIKE TCURT-LTEXT, "Long Text

    P_KTEXT LIKE TCURT-KTEXT. "Short Text

    • 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.

    Hope this will solve the problem.

    Thanks,

    Vibha

    Please mark all the useful answers

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      You read the values using FM DYNP_VALUES_READ. The value of plant that you have got from this should be used in the select statement to get values of material in where clause. Pass that internal table to FM F4IF_INT_TABLE_VALUE_REQUEST.

      Have a look at below code snippet.

      CALL FUNCTION 'DYNP_VALUES_READ'

      EXPORTING

      DYNAME = PROGNAME

      DYNUMB = DYNNUM

      TRANSLATE_TO_UPPER = 'X'

      TABLES

      DYNPFIELDS = DYNPRO_VALUES.

      READ TABLE DYNPRO_VALUES INDEX 1 INTO FIELD_VALUE.

      SELECT CARRID CONNID

      FROM SPFLI

      INTO CORRESPONDING FIELDS OF TABLE VALUES_TAB

      WHERE CARRID = FIELD_VALUE-FIELDVALUE.

      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

      EXPORTING

      RETFIELD = 'CONNID'

      DYNPPROG = PROGNAME

      DYNPNR = DYNNUM

      DYNPROFIELD = 'CONNECTION'

      VALUE_ORG = 'S'

      TABLES

      VALUE_TAB = VALUES_TAB.

      I hope it helps.

      Thanks,

      Vibha

      Please mark all the useful answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 28, 2008 at 10:07 AM

    Hi,

    Use the below logic.

    tables: t001k.

    • For Identification Number

    DATA: BEGIN OF it_bwkey OCCURS 0,

    bwkey LIKE t001k-bwkey,

    END OF it_bwkey.

    data: v_bukrs(4).

    • For Run date

    DATA: BEGIN OF it_bukrs OCCURS 0,

    bukrs LIKE t001k-bukrs,

    END OF it_bukrs.

    DATA it_ret LIKE ddshretval OCCURS 0 WITH HEADER LINE.

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

    SELECTION-SCREEN SKIP.

    PARAMETERS: p_bukrs(4) TYPE c.

    SELECT-OPTIONS s_bwkey FOR t001k-bwkey NO INTERVALS.

    SELECTION-SCREEN END OF BLOCK main.

    *----


    • Validation Section

    *----


    INITIALIZATION.

    SELECT DISTINCT bukrs FROM t001k INTO TABLE it_bukrs.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_bukrs.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    retfield = 'BUKRS'

    dynpprog = sy-repid

    dynpnr = sy-dynnr

    dynprofield = 'P_BUKRS'

    value_org = 'S'

    TABLES

    value_tab = it_bukrs

    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.

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

    TABLES: t130r.

    DATA: BEGIN OF dynpfields OCCURS 0. "Hilfsstruktur zum auslesen des

    INCLUDE STRUCTURE dynpread. "Feldwertes vom Dynpro bei >F4<

    DATA: END OF dynpfields.

    DATA : sy_repid LIKE sy-repid,

    sy_dynnr LIKE sy-dynnr.

    CLEAR dynpfields.

    REFRESH dynpfields.

    dynpfields-fieldname = 'P_BUKRS'.

    APPEND dynpfields.

      • Lesen des akt. Wertes von Dynpro

      sy_repid = sy-repid.

      sy_dynnr = sy-dynnr.

      CALL FUNCTION 'DYNP_VALUES_READ'

      EXPORTING

      dyname = sy_repid

      dynumb = sy_dynnr

      TABLES

      dynpfields = dynpfields

      EXCEPTIONS

      OTHERS = 01.

      IF sy-subrc = 0.

      READ TABLE dynpfields WITH KEY fieldname = 'P_BUKRS'.

      IF sy-subrc = 0.

      v_bukrs = dynpfields-fieldvalue.

      ENDIF.

      ENDIF.

      SELECT bwkey FROM t001k

      INTO TABLE it_bwkey

      WHERE bukrs = v_bukrs.

      DELETE ADJACENT DUPLICATES FROM it_bwkey.

      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

      EXPORTING

      retfield = 'BWKEY'

      dynpprog = sy-repid

      dynpnr = sy-dynnr

      dynprofield = 'S_BWKEY'

      value_org = 'S'

      TABLES

      value_tab = it_bwkey

      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.

      Note: For BWKEY field use Plant

      For BUKRS field use Material.

      Add a comment
      10|10000 characters needed characters exceeded

    Before answering

    You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
    You must be Logged in to submit an answer.

    Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.