Application Development 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: 

hi gurus at selection screen

Former Member
0 Kudos

hi gurus the selection screen has two input fields.

werks 2000

matnr F4

in plant we r filling 2000 plant number. when i press F4 on matnr the 2000 plant material only come , .if we r filling 5000 plant number. when i press F4 on matnr the 5000 plant material only come how we do it.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Vasu,

IN AT SELECTION-SCREEN ON VALUE REQUEST <FIELD>

use DYNP_VALUES_READ Function module..

Check this code...


TABLES :
  mara,
  marc.


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE tit.
SELECT-OPTIONS:
  s_matnr FOR  mara-matnr. "NO INTERVALS.
PARAMETERS:
  p_werks LIKE  dfies-fieldname.
SELECTION-SCREEN END OF BLOCK b1.

DATA:

  t_mara LIKE STANDARD TABLE OF mara WITH HEADER LINE,
  t_marc LIKE STANDARD TABLE OF marc WITH HEADER LINE,
  BEGIN OF t_value OCCURS 0,
     werks TYPE marc-werks,
  END OF t_value,

  dynpro_values TYPE TABLE OF dynpread,
  field_value LIKE LINE OF dynpro_values,
  w_prog LIKE d020s-prog,
  w_dnum LIKE d020s-dnum,
  t_return LIKE TABLE OF ddshretval WITH HEADER LINE,
  w_repid LIKE sy-repid,
  w_dynnr LIKE sy-dynnr,
  w_tabix LIKE sy-tabix,
  w_value(20) TYPE c,
  w_werks LIKE help_info-dynprofld,
 field_tab LIKE  ddshretval OCCURS 0 WITH HEADER LINE.

INITIALIZATION.

  tit = 'Material and plant'.
  w_prog = sy-repid.
  w_dnum = sy-dynnr.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_werks.

  CLEAR: field_value, dynpro_values.
  field_value-fieldname = 'S_MATNR-LOW'.
  APPEND field_value TO dynpro_values.

  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname             = w_prog
      dynumb             = w_dnum
      translate_to_upper = 'X'
    TABLES
      dynpfields         = dynpro_values.

  READ TABLE dynpro_values INDEX 1 INTO field_value.

  WRITE field_value-fieldvalue TO w_value.

  CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
    EXPORTING
      input        = w_value
    IMPORTING
      output       = w_value
    EXCEPTIONS
      length_error = 1
      OTHERS       = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



  REFRESH t_value.
  IF s_matnr-low IS INITIAL AND s_matnr-high IS INITIAL.
    SELECT matnr
           werks
      FROM marc
      INTO CORRESPONDING FIELDS OF TABLE t_value.

  ELSE.
    SELECT matnr
            werks
       FROM marc
       INTO CORRESPONDING FIELDS OF TABLE t_value
      WHERE matnr = w_value.
  ENDIF.
  w_repid = sy-repid.
  w_dynnr = sy-dynnr.

  CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
    EXPORTING
      endpos_col   = 4
      endpos_row   = 25
      startpos_col = 1
      startpos_row = 1
      titletext    = 'PLANT DETAILS'
    IMPORTING
      choise       = w_tabix
    TABLES
      valuetab     = t_value
    EXCEPTIONS
      break_off    = 1
      OTHERS       = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ELSE.
    READ TABLE t_value INTO p_werks INDEX w_tabix.
  ENDIF.

AT SELECTION-SCREEN ON s_matnr.
  SELECT SINGLE matnr
           FROM mara
           INTO CORRESPONDING FIELDS
             OF t_mara
          WHERE matnr IN s_matnr.
  IF sy-subrc NE 0.
*    MESSAGE e706(12) WITH s_matnr-low .
*     message 'No material exists with the given value' type 'I'.
    WRITE : ' No material exists with the given value'.
  ENDIF.

  EXIT.

AT SELECTION-SCREEN ON BLOCK b1.
  SELECT matnr
         werks
    FROM marc
    INTO TABLE t_marc
   WHERE matnr IN s_matnr
     AND werks = p_werks.

  IF sy-subrc NE 0.
    MESSAGE e707(12) WITH s_matnr-low p_werks.
  ENDIF.

START-OF-SELECTION.
  SELECT matnr
         werks
    FROM marc
    INTO CORRESPONDING FIELDS
      OF TABLE t_marc
   WHERE matnr IN s_matnr
     AND werks = p_werks.


END-OF-SELECTION.
  LOOP AT t_marc.
    WRITE : t_marc-matnr,
            t_marc-werks.
  ENDLOOP.

AT LINE-SELECTION.
  IF sy-lsind = 20.
    WRITE : 'This is secondary list', sy-lsind.
    sy-lsind = 1.
  ENDIF.
  WRITE : 'This is secondary list', sy-lsind.

Hope this would help you.

Regards

Narin Nandivada

4 REPLIES 4

Former Member
0 Kudos

Hi

create your own search help on table MARC.

Give only matnr and werks in the fields. Give WRK as default for the werks.

Attach this search help to the select-options of the material.

Regards,

Subramanian

Former Member
0 Kudos

Hi Vasu,

IN AT SELECTION-SCREEN ON VALUE REQUEST <FIELD>

use DYNP_VALUES_READ Function module..

Check this code...


TABLES :
  mara,
  marc.


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE tit.
SELECT-OPTIONS:
  s_matnr FOR  mara-matnr. "NO INTERVALS.
PARAMETERS:
  p_werks LIKE  dfies-fieldname.
SELECTION-SCREEN END OF BLOCK b1.

DATA:

  t_mara LIKE STANDARD TABLE OF mara WITH HEADER LINE,
  t_marc LIKE STANDARD TABLE OF marc WITH HEADER LINE,
  BEGIN OF t_value OCCURS 0,
     werks TYPE marc-werks,
  END OF t_value,

  dynpro_values TYPE TABLE OF dynpread,
  field_value LIKE LINE OF dynpro_values,
  w_prog LIKE d020s-prog,
  w_dnum LIKE d020s-dnum,
  t_return LIKE TABLE OF ddshretval WITH HEADER LINE,
  w_repid LIKE sy-repid,
  w_dynnr LIKE sy-dynnr,
  w_tabix LIKE sy-tabix,
  w_value(20) TYPE c,
  w_werks LIKE help_info-dynprofld,
 field_tab LIKE  ddshretval OCCURS 0 WITH HEADER LINE.

INITIALIZATION.

  tit = 'Material and plant'.
  w_prog = sy-repid.
  w_dnum = sy-dynnr.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_werks.

  CLEAR: field_value, dynpro_values.
  field_value-fieldname = 'S_MATNR-LOW'.
  APPEND field_value TO dynpro_values.

  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname             = w_prog
      dynumb             = w_dnum
      translate_to_upper = 'X'
    TABLES
      dynpfields         = dynpro_values.

  READ TABLE dynpro_values INDEX 1 INTO field_value.

  WRITE field_value-fieldvalue TO w_value.

  CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
    EXPORTING
      input        = w_value
    IMPORTING
      output       = w_value
    EXCEPTIONS
      length_error = 1
      OTHERS       = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



  REFRESH t_value.
  IF s_matnr-low IS INITIAL AND s_matnr-high IS INITIAL.
    SELECT matnr
           werks
      FROM marc
      INTO CORRESPONDING FIELDS OF TABLE t_value.

  ELSE.
    SELECT matnr
            werks
       FROM marc
       INTO CORRESPONDING FIELDS OF TABLE t_value
      WHERE matnr = w_value.
  ENDIF.
  w_repid = sy-repid.
  w_dynnr = sy-dynnr.

  CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
    EXPORTING
      endpos_col   = 4
      endpos_row   = 25
      startpos_col = 1
      startpos_row = 1
      titletext    = 'PLANT DETAILS'
    IMPORTING
      choise       = w_tabix
    TABLES
      valuetab     = t_value
    EXCEPTIONS
      break_off    = 1
      OTHERS       = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ELSE.
    READ TABLE t_value INTO p_werks INDEX w_tabix.
  ENDIF.

AT SELECTION-SCREEN ON s_matnr.
  SELECT SINGLE matnr
           FROM mara
           INTO CORRESPONDING FIELDS
             OF t_mara
          WHERE matnr IN s_matnr.
  IF sy-subrc NE 0.
*    MESSAGE e706(12) WITH s_matnr-low .
*     message 'No material exists with the given value' type 'I'.
    WRITE : ' No material exists with the given value'.
  ENDIF.

  EXIT.

AT SELECTION-SCREEN ON BLOCK b1.
  SELECT matnr
         werks
    FROM marc
    INTO TABLE t_marc
   WHERE matnr IN s_matnr
     AND werks = p_werks.

  IF sy-subrc NE 0.
    MESSAGE e707(12) WITH s_matnr-low p_werks.
  ENDIF.

START-OF-SELECTION.
  SELECT matnr
         werks
    FROM marc
    INTO CORRESPONDING FIELDS
      OF TABLE t_marc
   WHERE matnr IN s_matnr
     AND werks = p_werks.


END-OF-SELECTION.
  LOOP AT t_marc.
    WRITE : t_marc-matnr,
            t_marc-werks.
  ENDLOOP.

AT LINE-SELECTION.
  IF sy-lsind = 20.
    WRITE : 'This is secondary list', sy-lsind.
    sy-lsind = 1.
  ENDIF.
  WRITE : 'This is secondary list', sy-lsind.

Hope this would help you.

Regards

Narin Nandivada

former_member787646
Contributor
0 Kudos

Hi

You can achieve the desired functionality by using the function

module "F4_IF_INT_TABLE_VALUE_REQUEST" for the event

AT SELECTION-SCREEN OUTPUT ON VALUE REQUEST FOR '<material_no_variable>'

Hope this would help you.

Murthy

Edited by: Kalyanam Seetha Rama Murthy on Jul 16, 2008 10:57 AM

Subhankar
Active Contributor
0 Kudos

Hi

Do it in this way.

First fetch the value in palnt variable. Then select material for this plant and display it in the F4 help. To get value of plant use the FM "DYNP_VALUES_READ". It will fetch value dynamically

AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_matnr.

PERFORM sub_pop_matnr .

form sub_pop_matnr .

DATA : l_wa_dynp TYPE dynpread,

l_i_dynp TYPE STANDARD TABLE OF dynpread,

l_wa_temp LIKE LINE OF S_werks.

  • REFRESH s_temp[].

l_wa_dynp-fieldname = 'S_WERKS-LOW'.

APPEND l_wa_dynp TO l_i_dynp.

  • Get the screen values of template

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

dyname = sy-repid

dynumb = sy-dynnr

TABLES

dynpfields = l_i_dynp

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.

IF sy-subrc <> 0.

  • Do Nothing

ENDIF.

  • Put the screen value in the select-options

READ TABLE l_i_dynp INTO l_wa_dynp INDEX 1.

l_wa_temp-sign = 'I'.

l_wa_temp-option = 'EQ'.

l_wa_temp-low = l_wa_dynp-fieldvalue.

  • Now you use l_wa_temp as plant field then get all the related material

endform. " sub_pop_matnr