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

List Box Selection not working

Former Member
0 Likes
2,005

  Hi,

I have used following code for popluating the list box values.

Both Under Initializtion  or At selection screen output options individually.....the problemis the desired values are getting populated but the selected value is not getting picked up for select query to fetch the data...For ex: I7 in parameter...P_nftype is initial for select query.

Select NFTYPE FROM J_1BAA INTO TABLE i_nftype WHERE nftype NE ''.

SORT I_NFTYPE BY NFTYPE.

*REFRESH LIST.

NAME = 'P_NFTYPE'.

v_key = 1.

APPEND VALUE TO LIST.

CLEAR VALUE.

V_key = 2.

LOOP AT i_nftype into wa_nftype.

MOVE: V_KEY TO VALUE-KEY,

       wa_nftype-nftype TO VALUE-TEXT.

APPEND VALUE TO LIST.

v_key = v_key + 1.

CLEAR VALUE.

ENDLOOP.

*SORT LIST BY TEXT ASCENDING.

*VALUE-KEY = '1'.

*VALUE-TEXT = 'LINE 1'.

*APPEND VALUE TO LIST.

*CLEAR VALUE.

*VALUE-KEY = '2'.

*VALUE-TEXT = 'LINE 2'.

*APPEND VALUE TO LIST.

*CLEAR VALUE.

CALL FUNCTION 'VRM_SET_VALUES'

  EXPORTING

     ID = NAME

    VALUES = LIST.

1 ACCEPTED SOLUTION
Read only

alisson_fragozo
Explorer
0 Likes
1,358

Hello Vishnuvardhan,

   Probably when VALUE-KEY receives V-key, it leaves left spaces becouse is a CHAR and the function considers the first places, according to the length of p_nftype, see if the following code works:

REPORT zteste.

TYPE-POOLS : vrm.

DATA: i_nftype  TYPE TABLE OF j_1baa,

       wa_nftype LIKE LINE OF i_nftype.

PARAMETERS: p_nftype(3) AS LISTBOX VISIBLE LENGTH 10 OBLIGATORY.

INITIALIZATION.

   PERFORM f4_value_request.

START-OF-SELECTION.

   WRITE p_nftype.

FORM f4_value_request.

   DATA:   l_name  TYPE vrm_id,

           li_list TYPE vrm_values,

           l_value LIKE LINE OF li_list,

           li_key  TYPE i VALUE 1.

   SELECT nftype FROM j_1baa INTO TABLE i_nftype WHERE nftype NE ' '.

   SORT i_nftype BY nftype.

   LOOP AT i_nftype INTO wa_nftype.

     l_value-key  = li_key.

     SHIFT l_value-key LEFT DELETING LEADING space.

     l_value-text = wa_nftype-nftype.

     APPEND l_value TO li_list.

     ADD 1 TO li_key.

   ENDLOOP.

   l_name = 'P_NFTYPE'.

   p_nftype = '1'. "this is to set the default value of the list box.

   CALL FUNCTION 'VRM_SET_VALUES'

     EXPORTING

       id              = l_name

       values          = li_list

     EXCEPTIONS

       id_illegal_name = 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.

ENDFORM. " f4_value_request

  Hi,

I have used following code for popluating the list box values.

Both Under Initializtion  or At selection screen output options individually.....the problemis the desired values are getting populated but the selected value is not getting picked up for select query to fetch the data...For ex: I7 in parameter...P_nftype is initial for select query.

Select NFTYPE FROM J_1BAA INTO TABLE i_nftype WHERE nftype NE ''.

SORT I_NFTYPE BY NFTYPE.

*REFRESH LIST.

NAME = 'P_NFTYPE'.

v_key = 1.

APPEND VALUE TO LIST.

CLEAR VALUE.

V_key = 2.

LOOP AT i_nftype into wa_nftype.

MOVE: V_KEY TO VALUE-KEY,

       wa_nftype-nftype TO VALUE-TEXT.

APPEND VALUE TO LIST.

v_key = v_key + 1.

CLEAR VALUE.

ENDLOOP.

*SORT LIST BY TEXT ASCENDING.

*VALUE-KEY = '1'.

*VALUE-TEXT = 'LINE 1'.

*APPEND VALUE TO LIST.

*CLEAR VALUE.

*VALUE-KEY = '2'.

*VALUE-TEXT = 'LINE 2'.

*APPEND VALUE TO LIST.

*CLEAR VALUE.

CALL FUNCTION 'VRM_SET_VALUES'

  EXPORTING

     ID = NAME

    VALUES = LIST.

2 REPLIES 2
Read only

alisson_fragozo
Explorer
0 Likes
1,359

Hello Vishnuvardhan,

   Probably when VALUE-KEY receives V-key, it leaves left spaces becouse is a CHAR and the function considers the first places, according to the length of p_nftype, see if the following code works:

REPORT zteste.

TYPE-POOLS : vrm.

DATA: i_nftype  TYPE TABLE OF j_1baa,

       wa_nftype LIKE LINE OF i_nftype.

PARAMETERS: p_nftype(3) AS LISTBOX VISIBLE LENGTH 10 OBLIGATORY.

INITIALIZATION.

   PERFORM f4_value_request.

START-OF-SELECTION.

   WRITE p_nftype.

FORM f4_value_request.

   DATA:   l_name  TYPE vrm_id,

           li_list TYPE vrm_values,

           l_value LIKE LINE OF li_list,

           li_key  TYPE i VALUE 1.

   SELECT nftype FROM j_1baa INTO TABLE i_nftype WHERE nftype NE ' '.

   SORT i_nftype BY nftype.

   LOOP AT i_nftype INTO wa_nftype.

     l_value-key  = li_key.

     SHIFT l_value-key LEFT DELETING LEADING space.

     l_value-text = wa_nftype-nftype.

     APPEND l_value TO li_list.

     ADD 1 TO li_key.

   ENDLOOP.

   l_name = 'P_NFTYPE'.

   p_nftype = '1'. "this is to set the default value of the list box.

   CALL FUNCTION 'VRM_SET_VALUES'

     EXPORTING

       id              = l_name

       values          = li_list

     EXCEPTIONS

       id_illegal_name = 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.

ENDFORM. " f4_value_request

Read only

Former Member
0 Likes
1,358

Hi Vishnuvardhan,

as Ali said, its taking value-key for p_ nftype. I tried reading values table based on the selected key, may be you can try in this fashion.


START-OF-SELECTION.


   CLEAR value.

   READ TABLE list INTO value WITH KEY key = p_nftype.

   IF sy-subrc EQ 0.

     p_nftype = value-text.

   ENDIF.


   SELECT  nftype doctyp FROM j_1baa INTO CORRESPONDING FIELDS OF TABLE i_nftype WHERE nftype EQ p_nftype.


Regards,

CA