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: 

Changing value of select-options according to list box value select

former_member242512
Participant
0 Kudos

Hi all,

I have a requirement ..... i hav a list box and select-option. when ever user will select a value from (parameter) list box the correspoding value from a z-table should be set and should get displayed in the select-option . The select-options get set in initialization but the list box values are populated in at selection-screen output .....

So How can i do this ? Thanks in advance..

1 ACCEPTED SOLUTION

former_member1245113
Active Contributor
0 Kudos

Hi

Take the help of below thread

once you get the First List Box value, then fetch the data from Z table then follow as below

this should also be in AT SELECTION-SCREEN OUTPUT

REFRESH sel_option.

sel_option-sign = 'I'.
sel_option-option = 'EQ'.
loop at itab. " Which you populated from Z table.
sel_option-low = itab-value.
append sel_option.  " If you want only Min and Max to displayed then sort ASCENDING and take First Record and append to "LOW and sort DESCENDING and take First Record and append to High of SEL_OPTION.
" In this case you need to pass SIGN and OPTION system fills them with I and BT
" One More Issue if the values are very Complex Like CASE sensitive and others you need to be more care ful.
" Based on your requirement you can also use EXCLUDE 'E' etc
Hope this is clear to you and Solves your Issue
endloop

Cheerz

Ram

Ram

4 REPLIES 4

former_member1245113
Active Contributor
0 Kudos

Hi

Take the help of below thread

once you get the First List Box value, then fetch the data from Z table then follow as below

this should also be in AT SELECTION-SCREEN OUTPUT

REFRESH sel_option.

sel_option-sign = 'I'.
sel_option-option = 'EQ'.
loop at itab. " Which you populated from Z table.
sel_option-low = itab-value.
append sel_option.  " If you want only Min and Max to displayed then sort ASCENDING and take First Record and append to "LOW and sort DESCENDING and take First Record and append to High of SEL_OPTION.
" In this case you need to pass SIGN and OPTION system fills them with I and BT
" One More Issue if the values are very Complex Like CASE sensitive and others you need to be more care ful.
" Based on your requirement you can also use EXCLUDE 'E' etc
Hope this is clear to you and Solves your Issue
endloop

Cheerz

Ram

Ram

0 Kudos

Hi ,

i have such selection-screen .

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

* Parameter declaration as listbox
PARAMETERS:    p_output TYPE zpersondata-zextapp AS LISTBOX
               VISIBLE LENGTH 6 .

SELECT-OPTIONS : s_date FOR zpersondata-zchdate OBLIGATORY.
SELECTION-SCREEN END OF BLOCK a1.

Then rest code is as follows : .

INITIALIZATION.

 name = 'p_output'.

 SELECT * FROM zpersondata INTO TABLE it_zpersondataout.

LOOP AT it_zpersondata INTO gwa_zpersondata .
    value-key = ch_cnt.
    value-text = gwa_zpersondata-zextapp.
    ch_cnt = ch_cnt + 1.
    APPEND value TO list.
    CLEAR value.
  ENDLOOP.

* Calling function module to populate values on dropdown
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     = name  " Field name
      values = list. "Dropdown values

START-OF-SELECTION.

  READ TABLE list INTO value WITH KEY key = p_output.

  READ TABLE it_zpersondata
                     INTO gwa_zpersondata
                     WITH KEY zextapp = value-text.

Im getting the value selected from list box in event start-of-selection .

Im not able to get it before that so how can i put the code you mentioned in

at selection-screen output......

0 Kudos

Hi,

Report  Z_UJJWAL.
TYPE-POOLS vrm.
TABLES : sflight.
DATA : cid TYPE vrm_id, " For List Box
       car TYPE vrm_values,
       wcar LIKE LINE OF car,
       carrid TYPE spfli-carrid,
       ok TYPE sy-ucomm.
DATA : itab TYPE TABLE OF sflight WITH HEADER LINE, " For Second List Box
       conid TYPE vrm_id,
       con TYPE vrm_values,
       wcon LIKE LINE OF con.

PARAMETERS : p_carrid TYPE sflight-carrid AS LISTBOX VISIBLE LENGTH 4 USER-COMMAND aa.
SELECT-OPTIONS : s_connid FOR sflight-connid.

AT SELECTION-SCREEN OUTPUT.

  REFRESH car.
  wcar-key = 'AA'.
  wcar-text = 'AA'.
  APPEND wcar TO car.
  wcar-key = 'LH'.
  wcar-text = 'LH'.
  APPEND wcar TO car.
  cid = 'P_CARRID'.
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = cid
      values          = car
    EXCEPTIONS
      id_illegal_name = 1
      OTHERS          = 2.

  IF NOT p_carrid IS INITIAL.
    REFRESH itab.
    REFRESH s_connid.
    SELECT * FROM sflight INTO TABLE itab WHERE carrid = p_carrid.
    IF sy-subrc = 0.
      SORT itab BY connid ASCENDING.
       s_connid-sign = 'I'.
       s_connid-option = 'BT'.
      READ TABLE itab INDEX 1.
      MOVE itab-connid TO s_connid-low.
      SORT itab BY connid DESCENDING.
      READ TABLE itab INDEX 1.
      MOVE itab-connid TO s_connid-high.
      APPEND s_connid. "Or to pass all the Values 
*       s_connid-sign = 'I'.
*       s_connid-option = 'EQ'.
* loop at itab.
*      MOVE itab-connid TO s_connid-low.
*     APPEND S_CONNID.
*endloop.
    ENDIF. " Just copy this and Execute I have tested it and working perfect
  ENDIF.

Cheerz

Ram

0 Kudos

Hi Ram ......thanks for reply.............. i have another query related to this .I have im using this statement

parameters :  p_output TYPE zpersondata-zextapp as list-box user-command abc default 'AA'.

Then when i select from the list box then i get values for example : AA,CA,BA,AA,GA .

The value AA is repeating as one coming from default value and other from list passed to set_vrm FM......

How can i have only one entry but the default should be there as 'AA'...