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: 

Reading Select Options from DYNP_VALUES_READ

Former Member
0 Kudos

Hi Experts,

I am faced with this perssiting issue where my requirement is to fetch plants based on the matnr entered in the selection screen , matnr in this case being a select options field.

I have gone through similar threads in sdn and have used the same , but my issue is if i pass S_MATNR

as the field name as in the below case i do not get any values from the FM DYNP_VALUES_READ, even though there are values entered in the selection screen and if i pass S_MATNR-LOW and S_MATNR-HIGH to the column field name i donot get the "SIGN" and "OPTION" values from the SS for s_matnr Please suggest me a correct solution.


*My Code:*
.....................
.....................
select-options: s_matnr type matnr,
                      s_werks type werks_d.

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

  PERFORM get_plant_list        CHANGING  i_plant_help
                                                                  i_dynpfields.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_werks-high.

  PERFORM get_plant_list       CHANGING  i_plant_help
                                                                 i_dynpfields.


FORM get_plant_list  CHANGING fp_i_plant_help  TYPE ty_t_plant_help
                                                 fp_i_dynfields   TYPE ty_i_dynfields.

*LOCAL DECLARATIONS
*Constants Declarations
  CONSTANTS:
     l_c_value_org_s  TYPE ddbool_d      VALUE 'S',              "Select all
     l_c_plant        TYPE fieldname     VALUE 'WERKS',         "Field Name
     l_c_fieldname    TYPE dynfnam       VALUE 'MARC-WERKS',
     l_c_matnr_low    TYPE dynfnam       VALUE 'S_MATNR-LOW',
     l_c_matnr_high   TYPE dynfnam       VALUE 'S_MATNR-HIGH',
     l_c_matnr_sign   type dynfnam       value 'S_MATNR-SIGN',
     l_c_matnr_option type dynfnam       value 'S_MATNR-OPTION'.

*Internal table declarations
  DATA: l_i_return    TYPE STANDARD TABLE OF ddshretval. "Interface Structure Search Help

*Variable Declaration
  DATA: l_v_dynnr      TYPE sy-dynnr,      "Screen Number
        l_v_repid      TYPE syrepid,       "Report ID
        l_v_fieldname  TYPE dynfnam.       "Select option

* Local data
  l_v_dynnr = sy-dynnr.
  l_v_repid = sy-repid.


*>>  Capturing Data
  wa_dynpfields-fieldname = 'S_MATNR'.
  APPEND wa_dynpfields TO fp_i_dynfields.
  CLEAR wa_dynpfields.

* Get field value from selection-screen
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname               = l_v_repid
      dynumb               = l_v_dynnr
    TABLES
      dynpfields           = fp_i_dynfields
    EXCEPTIONS
      invalid_abapworkarea = 0
      invalid_dynprofield  = 0
      invalid_dynproname   = 0
      invalid_dynpronummer = 0
      invalid_request      = 0
      no_fielddescription  = 0
      invalid_parameter    = 0
      undefind_error       = 0
      double_conversion    = 0
      OTHERS               = 0.


Here  fp_i_dynfields is coming out without any values.

---------------- -------------------------

---------------- -------------------------

---------------- -------------------------


code for 
'F4IF_INT_TABLE_VALUE_REQUEST'


ENDFORM.                    " GET_PLANT_LIST

Your Replies Are Appreciated,

Chaitanya

Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:37 AM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

If S_MATNR is given directly, the code in the function module - DYNP_VALUES_READ


call  'HELP_GET_FIELDS'  id 'DYNAME'    field dyname
                           id 'DYNUMB'    field dynumb
                           id 'REQUEST'   field request
                           id 'DPOVNAME'  field syst-repid
                           id 'DPOVNUMB'  field syst-dynnr
                           id 'SSF'       field ssf
                           id 'PROOT'     field <startdynpro>
                           id 'STACKPOS'  field start_search_on_scr_stackpos
                           id 'PATH'      field searchpath_of_subscreen_areas
                           id 'DPOV'      field <dpovtab>."#EC CI_CCALL

gives SY_SUBRC value as '4'.


    when 4.
      raise  invalid_dynprofield.

Parameters would be the best option to be used here.

If Selection-Options has to be used for sure, try to restrict the user not to enter multiple options by using 'NO EXTENSION'. In that case you can get the values of the LOW and HIGH fields and populate then in a ranges with SIGN and Option values I and EQ.

If multiple options are required, then the multiple values will not get captured.

Sample Code:-


TABLES: marc.

DATA: BEGIN OF it_tab OCCURS 1,
            matnr TYPE marc-matnr,
            werks TYPE marc-werks,
           END OF it_tab.

DATA : it_dynp TYPE STANDARD TABLE OF dynpread WITH HEADER LINE.

SELECTION-SCREEN : BEGIN OF BLOCK b1.
SELECT-OPTIONS : s_matnr FOR marc-matnr NO-EXTENSION,
             s_werks FOR marc-werks.
SELECTION-SCREEN : END OF BLOCK b1.
ranges: r_matnr for marc-matnr.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_werks-low.



  REFRESH it_dynp.
  it_dynp-fieldname = 'S_MATNR-LOW'.
  APPEND it_dynp.
  it_dynp-fieldname = 'S_MATNR-HIGH'.
  APPEND it_dynp.

  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname               = sy-cprog
      dynumb               = sy-dynnr
    TABLES
      dynpfields           = it_dynp
    EXCEPTIONS
      invalid_abapworkarea = 0
      invalid_dynprofield  = 0
      invalid_dynproname   = 0
      invalid_dynpronummer = 0
      invalid_request      = 0
      no_fielddescription  = 0
      invalid_parameter    = 0
      undefind_error       = 0
      double_conversion    = 0
      OTHERS               = 0.

  IF sy-subrc = 0.
    READ TABLE it_dynp WITH KEY fieldname = 'S_MATNR-LOW'.
    IF sy-subrc = 0.
      r_matnr-sign = 'I'.
      r_matnr-option = 'EQ'.
      r_matnr-low = it_dynp-fieldvalue.
    READ TABLE it_dynp WITH KEY fieldname = 'S_MATNR-HIGH'.
    IF sy-subrc = 0.
      r_matnr-high = it_dynp-fieldvalue.
    ENDIF.
    APPEND r_matnr.
    ENDIF.
  ENDIF.

There after you can code for getting the plants and show then in the output using the function module 'F4IF_INT_TABLE_VALUE_REQUEST'

Edited by: Krishna Adabala on Jan 8, 2009 4:36 PM

Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:38 AM

1 REPLY 1

Former Member
0 Kudos

If S_MATNR is given directly, the code in the function module - DYNP_VALUES_READ


call  'HELP_GET_FIELDS'  id 'DYNAME'    field dyname
                           id 'DYNUMB'    field dynumb
                           id 'REQUEST'   field request
                           id 'DPOVNAME'  field syst-repid
                           id 'DPOVNUMB'  field syst-dynnr
                           id 'SSF'       field ssf
                           id 'PROOT'     field <startdynpro>
                           id 'STACKPOS'  field start_search_on_scr_stackpos
                           id 'PATH'      field searchpath_of_subscreen_areas
                           id 'DPOV'      field <dpovtab>."#EC CI_CCALL

gives SY_SUBRC value as '4'.


    when 4.
      raise  invalid_dynprofield.

Parameters would be the best option to be used here.

If Selection-Options has to be used for sure, try to restrict the user not to enter multiple options by using 'NO EXTENSION'. In that case you can get the values of the LOW and HIGH fields and populate then in a ranges with SIGN and Option values I and EQ.

If multiple options are required, then the multiple values will not get captured.

Sample Code:-


TABLES: marc.

DATA: BEGIN OF it_tab OCCURS 1,
            matnr TYPE marc-matnr,
            werks TYPE marc-werks,
           END OF it_tab.

DATA : it_dynp TYPE STANDARD TABLE OF dynpread WITH HEADER LINE.

SELECTION-SCREEN : BEGIN OF BLOCK b1.
SELECT-OPTIONS : s_matnr FOR marc-matnr NO-EXTENSION,
             s_werks FOR marc-werks.
SELECTION-SCREEN : END OF BLOCK b1.
ranges: r_matnr for marc-matnr.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_werks-low.



  REFRESH it_dynp.
  it_dynp-fieldname = 'S_MATNR-LOW'.
  APPEND it_dynp.
  it_dynp-fieldname = 'S_MATNR-HIGH'.
  APPEND it_dynp.

  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname               = sy-cprog
      dynumb               = sy-dynnr
    TABLES
      dynpfields           = it_dynp
    EXCEPTIONS
      invalid_abapworkarea = 0
      invalid_dynprofield  = 0
      invalid_dynproname   = 0
      invalid_dynpronummer = 0
      invalid_request      = 0
      no_fielddescription  = 0
      invalid_parameter    = 0
      undefind_error       = 0
      double_conversion    = 0
      OTHERS               = 0.

  IF sy-subrc = 0.
    READ TABLE it_dynp WITH KEY fieldname = 'S_MATNR-LOW'.
    IF sy-subrc = 0.
      r_matnr-sign = 'I'.
      r_matnr-option = 'EQ'.
      r_matnr-low = it_dynp-fieldvalue.
    READ TABLE it_dynp WITH KEY fieldname = 'S_MATNR-HIGH'.
    IF sy-subrc = 0.
      r_matnr-high = it_dynp-fieldvalue.
    ENDIF.
    APPEND r_matnr.
    ENDIF.
  ENDIF.

There after you can code for getting the plants and show then in the output using the function module 'F4IF_INT_TABLE_VALUE_REQUEST'

Edited by: Krishna Adabala on Jan 8, 2009 4:36 PM

Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:38 AM