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

Selection Screen isuue

Former Member
0 Likes
982

Dear Experts,

I have Plant (WERKS) and Material(MATNR) on the selection screen as a select-options for multiple entries.

Now my issue is, when i am passing a plant in first selection then I should get only those material in the search help for the plant which I have passed.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
964

Hi,

Check this code...


TABLES : mara.
TYPES : BEGIN OF t_mtart,
         mtart TYPE mara-mtart,
        END   OF t_mtart,

        BEGIN OF t_matnr,
         matnr TYPE mara-matnr,
        END OF t_matnr.
DATA : it_mtart TYPE STANDARD TABLE OF t_mtart WITH HEADER LINE,
       it_matnr type STANDARD TABLE OF t_matnr WITH HEADER LINE.


SELECT-OPTIONS : s_mtart FOR mara-mtart,
                 s_matnr FOR mara-matnr.

AT SELECTION-SCREEN ON  VALUE-REQUEST FOR s_mtart-low.
  PERFORM get_value USING 'S_MTART'.

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

*&---------------------------------------------------------------------*
*&      Form  GET_VALUE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0022   text
*----------------------------------------------------------------------*
FORM get_value  USING    name.
  IF it_mtart[] IS INITIAL.
    SELECT DISTINCT mtart
                    FROM mara
                   INTO TABLE it_mtart.
  ENDIF.




  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield        = 'S_MTART'
      dynpprog        = sy-repid
      dynpnr          = sy-dynnr
      dynprofield     = name
      stepl           = 0
      window_title    = 'Material type'
      value_org       = 'S'
    TABLES
      value_tab       = it_mtart
    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.

ENDFORM.                    " GET_VALUE
*&---------------------------------------------------------------------*
*&      Form  GETVALUE_COMP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM getvalue_comp .
   DATA it_dynfield TYPE STANDARD TABLE OF dynpread WITH HEADER LINE.
   DATA : s_comp1 LIKE it_mtart-mtart.
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname               = sy-repid
      dynumb               = sy-dynnr
      request              = 'A'
      translate_to_upper   = 'X'
    TABLES
      dynpfields           = it_dynfield
    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.
  READ TABLE it_dynfield WITH KEY fieldname = 'S_MTART-LOW'.

  s_comp1 = it_dynfield-fieldvalue.



  REFRESH it_MATNR[].
  IF it_MATNR[] IS INITIAL.
    SELECT DISTINCT MATNR
    FROM MARA
   INTO TABLE it_MATNR
   WHERE MTART = s_comp1.
  ENDIF.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
*   DDIC_STRUCTURE         = ' '
      retfield               = 'S1'
*   PVALKEY                = ' '
     dynpprog               = sy-repid
     dynpnr                 = sy-dynnr
     dynprofield            = 'S_COMP-LOW'
     stepl                  = 0
*   WINDOW_TITLE           =
*   VALUE                  = ' '
   value_org              = 'S'
*   MULTIPLE_CHOICE        = ' '
*   DISPLAY                = ' '
*   CALLBACK_PROGRAM       = ' '
*   CALLBACK_FORM          = ' '
*   MARK_TAB               =
* IMPORTING
*   USER_RESET             =
    TABLES
      value_tab              = it_MATNR
*   FIELD_TAB              =
*   RETURN_TAB             =
*   DYNPFLD_MAPPING        =
   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.

ENDFORM.                    " GETVALUE_COMP

Regards

Debarshi

Dear Experts,

I have Plant (WERKS) and Material(MATNR) on the selection screen as a select-options for multiple entries.

Now my issue is, when i am passing a plant in first selection then I should get only those material in the search help for the plant which I have passed.

Thanks

7 REPLIES 7
Read only

Former Member
0 Likes
964

Pass the plant valule in LOW value of the select-options, Then it will fetch data releated to that plant.

Read only

0 Likes
964

Hi Poorna,

My proble is, on which event should i pass this value. Because I am using selection-screen output event but while debugging i am not able to get the plant no.

Read only

Former Member
0 Likes
964

Hi,

Write a select query selecting Material from the internal table

based on the value range u have put in Plant and then read the internal table into the select-option

hope it will help.

Regards

Rajesh Kumar

Read only

Former Member
0 Likes
964

Hi Sam,

You can use this function module,

DYNP_VALUES_READ,

it dynamically reads the corresponding values of second field with respect

to the value entered in the first field on the selection screen.

You can further serch for this function module on sdn or

check its parameters through se37.

Hope it helps you

Regrds

Mansi

Read only

0 Likes
964

Thanks Mansi

Read only

Former Member
0 Likes
965

Hi,

Check this code...


TABLES : mara.
TYPES : BEGIN OF t_mtart,
         mtart TYPE mara-mtart,
        END   OF t_mtart,

        BEGIN OF t_matnr,
         matnr TYPE mara-matnr,
        END OF t_matnr.
DATA : it_mtart TYPE STANDARD TABLE OF t_mtart WITH HEADER LINE,
       it_matnr type STANDARD TABLE OF t_matnr WITH HEADER LINE.


SELECT-OPTIONS : s_mtart FOR mara-mtart,
                 s_matnr FOR mara-matnr.

AT SELECTION-SCREEN ON  VALUE-REQUEST FOR s_mtart-low.
  PERFORM get_value USING 'S_MTART'.

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

*&---------------------------------------------------------------------*
*&      Form  GET_VALUE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0022   text
*----------------------------------------------------------------------*
FORM get_value  USING    name.
  IF it_mtart[] IS INITIAL.
    SELECT DISTINCT mtart
                    FROM mara
                   INTO TABLE it_mtart.
  ENDIF.




  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield        = 'S_MTART'
      dynpprog        = sy-repid
      dynpnr          = sy-dynnr
      dynprofield     = name
      stepl           = 0
      window_title    = 'Material type'
      value_org       = 'S'
    TABLES
      value_tab       = it_mtart
    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.

ENDFORM.                    " GET_VALUE
*&---------------------------------------------------------------------*
*&      Form  GETVALUE_COMP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM getvalue_comp .
   DATA it_dynfield TYPE STANDARD TABLE OF dynpread WITH HEADER LINE.
   DATA : s_comp1 LIKE it_mtart-mtart.
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname               = sy-repid
      dynumb               = sy-dynnr
      request              = 'A'
      translate_to_upper   = 'X'
    TABLES
      dynpfields           = it_dynfield
    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.
  READ TABLE it_dynfield WITH KEY fieldname = 'S_MTART-LOW'.

  s_comp1 = it_dynfield-fieldvalue.



  REFRESH it_MATNR[].
  IF it_MATNR[] IS INITIAL.
    SELECT DISTINCT MATNR
    FROM MARA
   INTO TABLE it_MATNR
   WHERE MTART = s_comp1.
  ENDIF.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
*   DDIC_STRUCTURE         = ' '
      retfield               = 'S1'
*   PVALKEY                = ' '
     dynpprog               = sy-repid
     dynpnr                 = sy-dynnr
     dynprofield            = 'S_COMP-LOW'
     stepl                  = 0
*   WINDOW_TITLE           =
*   VALUE                  = ' '
   value_org              = 'S'
*   MULTIPLE_CHOICE        = ' '
*   DISPLAY                = ' '
*   CALLBACK_PROGRAM       = ' '
*   CALLBACK_FORM          = ' '
*   MARK_TAB               =
* IMPORTING
*   USER_RESET             =
    TABLES
      value_tab              = it_MATNR
*   FIELD_TAB              =
*   RETURN_TAB             =
*   DYNPFLD_MAPPING        =
   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.

ENDFORM.                    " GETVALUE_COMP

Regards

Debarshi

Read only

0 Likes
964

Thanks Debarshi.