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

Insert value inside a selection screen parameter

Former Member
0 Likes
3,429

Hi all,

I have a selection screen which containes two parameters, these parameters contain values which are linked to each other (they are both fields of the same database table, view). For the first parameter I have a search help.

When I select a value for the first parameter I want to automatically add the corresponding value for the second parameter.

Taking for example the below code:

SELECTION-SCREEN BEGIN OF BLOCK sflight WITH FRAME.

PARAMETERS:

p_carrid TYPE sflights-carrid MATCHCODE OBJECT sflight,

p_cityfr TYPE sflights-cityfrom.

SELECTION-SCREEN END OF BLOCK sflight.

Both carrid and cityfrom are fields of the sflights databse view. Additionally when I open the carrid search help the cityfrom field appears inside the popup restrictions dialog for the sflight search help.

So what I basically want to do, if I restrict the range of the hit list for the sflight search help by inserting a value for the cityfrom field I want the same value of the cityfrom field (from the restrictions dialog) to be automatically added inside the p_cityfr parameter.

Can you please help me with this problem?

Best Regards,

Mihai

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,758

Hi Mihai,

As per your requirement, below code will fulfill 100%. Kindly go through below code.

*********************************************************

TYPES:BEGIN OF t_t001w,

werks       TYPE t001w-werks,

name1       TYPE t001w-name1,

END OF t_t001w,

t_return_tab  TYPE ddshretval.

DATA:w_t001w      TYPE t_t001w,

w_return_tab TYPE t_return_tab.

DATA:i_t001w      TYPE STANDARD TABLE OF t_t001w,

i_return_tab TYPE STANDARD TABLE OF t_return_tab.

DATA:w_dynpfields TYPE dynpread,

i_dynpfields LIKE STANDARD TABLE OF dynpread.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

PARAMETERS :p_werks TYPE t001w-werks,

p_name1 TYPE t001w-name1.

SELECTION-SCREEN END OF BLOCK b1.

"F4 Help for Werks

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_werks.

  IF i_t001w[] IS INITIAL.

    SELECT werks name1

    FROM t001w

    INTO TABLE i_t001w.

  ENDIF.

  "Function module for F4 help

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

      retfield    = 'WERKS'   "field name on f4 help window

      dynpprog    = sy-repid

      dynpnr      = sy-dynnr

      dynprofield = 'P_WERKS' "Screen field name

      value_org   = 'S'

    TABLES

      value_tab   = i_t001w

      return_tab  = i_return_tab.

  READ TABLE i_return_tab INTO w_return_tab INDEX 1.

  p_werks = w_return_tab-fieldval.

  READ TABLE i_t001w INTO w_t001w WITH KEY werks = p_werks.

  IF sy-subrc = 0.

    w_dynpfields-fieldname    = 'P_NAME1'.

    w_dynpfields-fieldvalue   = w_t001w-name1.

    APPEND w_dynpfields TO i_dynpfields.

    CLEAR w_dynpfields.

    "DYNP_VALUES_UPDATE

    CALL FUNCTION 'DYNP_VALUES_UPDATE'

      EXPORTING

        dyname     = sy-repid

        dynumb     = sy-dynnr

      TABLES

        dynpfields = i_dynpfields.

  ENDIF.

***********************************************

Hope it works, Thanks,

Regards,

Praveen Reddy M

2 REPLIES 2
Read only

Former Member
0 Likes
1,759

Hi Mihai,

As per your requirement, below code will fulfill 100%. Kindly go through below code.

*********************************************************

TYPES:BEGIN OF t_t001w,

werks       TYPE t001w-werks,

name1       TYPE t001w-name1,

END OF t_t001w,

t_return_tab  TYPE ddshretval.

DATA:w_t001w      TYPE t_t001w,

w_return_tab TYPE t_return_tab.

DATA:i_t001w      TYPE STANDARD TABLE OF t_t001w,

i_return_tab TYPE STANDARD TABLE OF t_return_tab.

DATA:w_dynpfields TYPE dynpread,

i_dynpfields LIKE STANDARD TABLE OF dynpread.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

PARAMETERS :p_werks TYPE t001w-werks,

p_name1 TYPE t001w-name1.

SELECTION-SCREEN END OF BLOCK b1.

"F4 Help for Werks

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_werks.

  IF i_t001w[] IS INITIAL.

    SELECT werks name1

    FROM t001w

    INTO TABLE i_t001w.

  ENDIF.

  "Function module for F4 help

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

      retfield    = 'WERKS'   "field name on f4 help window

      dynpprog    = sy-repid

      dynpnr      = sy-dynnr

      dynprofield = 'P_WERKS' "Screen field name

      value_org   = 'S'

    TABLES

      value_tab   = i_t001w

      return_tab  = i_return_tab.

  READ TABLE i_return_tab INTO w_return_tab INDEX 1.

  p_werks = w_return_tab-fieldval.

  READ TABLE i_t001w INTO w_t001w WITH KEY werks = p_werks.

  IF sy-subrc = 0.

    w_dynpfields-fieldname    = 'P_NAME1'.

    w_dynpfields-fieldvalue   = w_t001w-name1.

    APPEND w_dynpfields TO i_dynpfields.

    CLEAR w_dynpfields.

    "DYNP_VALUES_UPDATE

    CALL FUNCTION 'DYNP_VALUES_UPDATE'

      EXPORTING

        dyname     = sy-repid

        dynumb     = sy-dynnr

      TABLES

        dynpfields = i_dynpfields.

  ENDIF.

***********************************************

Hope it works, Thanks,

Regards,

Praveen Reddy M

Read only

Former Member
0 Likes
1,758

Hi,

try like this.

SELECTION-SCREEN BEGIN OF BLOCK sflight WITH FRAME.

PARAMETERS:

p_carrid TYPE sflights-carrid MATCHCODE OBJECT sflight,

p_cityfr TYPE sflights-cityfrom.

SELECTION-SCREEN END OF BLOCK sflight.

AT SELECTION-SCREEN.
   SELECT SINGLE cityfrom FROM sflights INTO p_cityfr WHERE carrid = p_carrid.

thanks.