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: 

How to clear contents of list box in abap

Former Member
0 Kudos

Hi All,

I am using AT SELECTION_SCREEN ON VALUE REQUEST FOR PARAMETER for displaying the contents inside list box. i have multiple list box and values are populated when user select that list box.

I have used FM 'VRM_SET_VALUES' to populate data from database. I am clearing Internal Table before each and every AT SELECTION SCREEN.... code meant for each list box.


Problem is suppose i select some value in 1st drop down list,now value in all other dependent listbox gets populated which are dependent values of 1st list box.All these are working fine.

Now when i select all list box and go back to 1st listbox and change the values..corresponding dependent gets new values plus the value selected previously.

I have used debugger..internal table has been cleared..when i choose new value in 1st list box,internal table gets new value. Any other internal table does not contain that previous selected value.. when program control goes ahead. listbox after 1st listbox gets previous selected value automatically.

I would be very pleased to know your answers.

Thanks,

Praveen Nishchal

35 REPLIES 35

Former Member
0 Kudos

code:

  • "SELECT DISTINCT MESTYP
         from EDIMSG
         into CORRESPONDING FIELDS OF TABLE it_list_mes.

       loop at it_list_mes into wa_list_mes.
         VALUEM-KEY wa_list_mes-mestyp.
         VALUEM-TEXT = wa_list_mes-mestyp.
         APPEND VALUEM TO LISTM.
          clear wa_list_mes.
       endloop.


       NAMEM = 'PA_MES'.
       CALL FUNCTION 'VRM_SET_VALUES'
         EXPORTING
           ID     = NAMEM
           VALUES = LISTM.

        CLEAR it_list_mes.
        CLEAR LISTM."

Former Member
0 Kudos

Hi,

I guess you could use FM VRM_DELETE_VALUES...

Kr,

Manu.

0 Kudos

Hi Manu,

I have tried using VRM_DELETE_VALUES but the problem is not in the list. List is not containing previous selected value as i am clearing its contents.

Previous selected value comes automatically at the last even if i use VRM_DELETE_VALUES.

Former Member
0 Kudos

Hi Praveen ,

    Check following code,

Type-pools:VRM.

DATA: l_name TYPE vrm_id,
  it_list TYPE vrm_values,
  wa_value LIKE LINE OF it_list.

  wa_value-key = '1'.
  wa_value-text = 'DEMO'.
  APPEND wa_value TO it_list.
  CLEAR wa_value.

 wa_value-key = '2'.
  wa_value-text = 'DEMO1'.
  APPEND wa_value TO it_list.
  CLEAR wa_value.

     CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = l_name
      values          = it_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.

Regards,

Gurunath Kumar D

Former Member
0 Kudos

Hi praveen,

Please clear your internal tables before the select query itself(for the first list box).

you said,you are using the first list box value for the dependent lists for fetching the respected values.Before fetching the dependent list box entries based on the parent list box value , CLEAR the already existed set of values for the child list box.

you can refer the following code example ,

refresh it_list_main.

SELECT DISTINCT MESTYP
     from EDIMSG
     into CORRESPONDING FIELDS OF TABLE it_list_mes.


CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = namem
      values          = it_list
_main.

*clear the previously existed data for the dependent list box

refresh it_list_sub1.

*fetch data again according to your logic based on the main list box-IT_LIST_MAIN

select *

     from DDIC_TABLE1

     into corresponding fields of IT_LIST_SUB1

     where FIELD1 = NAMEM.

        

Hope this helps to you.

Regards,

Bhaskar

0 Kudos

Hi Bhaskar,

I am already clearing all my internal tables before SELECT query.. sorry as i did not made it visible in my pasted code. I still have values from previous selections

Former Member
0 Kudos

Hi all,

my code goes like this

"

*
*Parameter Selection for Message Type----------------------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR PA_MES.

clear it_list_mes.
clear it_list_idoc.
clear it_list_segnam.
clear LISTM.
clear LISTI.
clear LISTS.
clear LISTF.


   SELECT DISTINCT MESTYP
     from EDIMSG
     into CORRESPONDING FIELDS OF TABLE it_list_mes.

   loop at it_list_mes into wa_list_mes.
     VALUEM-KEY wa_list_mes-mestyp.
     VALUEM-TEXT = wa_list_mes-mestyp.
     APPEND VALUEM TO LISTM.
      clear wa_list_mes.
   endloop.


   NAMEM = 'PA_MES'.
   CALL FUNCTION 'VRM_SET_VALUES'
     EXPORTING
       ID     = NAMEM
       VALUES = LISTM.

    CLEAR it_list_mes.
    CLEAR LISTM.

*end of parameter selection for message type----------------------------------

*parametr selection for idoc type---------------------------------------------

AT SELECTION-SCREEN ON VALUE-REQUEST FOR PA_IDOC.

  
     CLEAR it_list_idoc.
     CLEAR LISTI.
     CLEAR VALUEI.



      SELECT DISTINCT IDOCTYP
      from EDIMSG  INTO CORRESPONDING FIELDS OF TABLE it_list_idoc WHERE MESTYP EQ PA_MES.



   loop at it_list_idoc into wa_list_idoc.
     VALUEI-KEY wa_list_idoc-idoctyp.
     VALUEI-TEXT = wa_list_idoc-idoctyp.
     APPEND VALUEI TO LISTI.
     CLEAR wa_list_idoc.
   endloop.


   NAMEI = 'PA_IDOC'.


   CALL FUNCTION 'VRM_SET_VALUES'
     EXPORTING
       ID     = NAMEI
       VALUES = LISTI.

CLEAR it_list_idoc.


*end of paramter selection for idoc type---------------------------------------

"

There are two more list box of which i am not writing code here. if problem is solved for 2nd list box then other will work fine as well,

Thanks

0 Kudos

Hi,

Please use the following statement to clear you tables:

clear it_list_mes[].

clear it_list_idoc[].

clear it_list_segnam[].

You seemed to only clear the working areas...

Kr,

Manu.

0 Kudos

Had same problem. It worked perfectly.

0 Kudos

Hi,

     Instead of Clear use Refresh to clear values of Internal Table.

refresh it_list_mes[].

refresh it_list_idoc[].

refresh it_list_segnam[].

Former Member
0 Kudos

Halo Praveen ,

First of all you should initialise the list values inside event AT SELECTION-SCREEN OUTPUT.

Suppose P_LIST1 and P_LIST2 are parameter list boxes in the Selection Screen.

AT SELECTION-SCREEN OUTPUT.

Perform clear_list_values.

Perform Initialise_list_values.

Form clear_list_values.

Clear: p_list1,

          p_list2.

Endform.

Form Initialise_list_values.

  TYPE-POOLS: vrm.

  DATA: l_name TYPE vrm_id,

        lt_name TYPE TABLE OF vrm_id,

        lt_list TYPE vrm_values,

         l_list LIKE LINE OF lt_list.

    l_list-key = l_key_list1.

    l_list-text = l_key_list1_descr.

    APPEND l_list TO lt_list.

    l_list-key = l_key_list2.

    l_list-text = l_key_list2_descr.

    APPEND l_list TO lt_list.

CALL FUNCTION 'VRM_SET_VALUES'

      EXPORTING

        id     = 'P_LIST1'

        values = lt_list.

***Setting values for P_LIST2.

if P_LIST1 eq l_key_list1.

**Fill the P_LISt2 values accordingly using VRM_SET_VALUES

elseif P_LIST2 eq l_key_list2.

**Fill the P_LISt2 values accordingly using VRM_SET_VALUES

endif.

Regards

Arshad

0 Kudos

Hi Arshad,

Thanks for your answer and i have followed what you have said me.. I am putting all such code inside AT SELECTION-SCREEN OUTPUT rather than AT SELECTION-SCREEN ON VALUE REQUEST.. but there is no improvement!

Regards

Praveen Nishchal

0 Kudos

Hi Praveen,

Try to not only CLEAR internal tables but also REFRESH  it.

Regards,

Jake

0 Kudos

Hi Jake,

There is no problem with internal table. value is flowing from previous selection.

0 Kudos

Halo Praveen,

You should press enter to trigger the AT SELECTION SCREEN OUTPUT event. Then the list values will be refreshed

Regards

Arshad

0 Kudos

Hi Arshad,

After pressing enter values of internal table plus the previous selection value is displayed in listbox

0 Kudos

You have to refresh the lt_list internal tables everytime

Former Member
0 Kudos

Hi all,

Can anyone tell me how could we refresh contents of listbox. I think that would serve my purpose.

Thanks,

Praveen Nishchal

0 Kudos

Hi,

I think you had the answer... use CLEAR itab[] or REFRESH statement before calling VRM function again...

Kr,

Manu.

0 Kudos

Hi,

Replace the CLEAR statement of your internal tables by REFRESH statement.

Regards,

Jake

0 Kudos

Hi , Try use the FM DYNP_UPDATE_FIELDS in conjunction with VRM_SET_VALUES.

Regards

Raj

0 Kudos

Hi Rajasekhar,

Can u please elaborate a little. What is the use of FM DYNP_UPDATE_FIELDS and how and where it could be used.

Thanks for your response.

Former Member
0 Kudos

Hi Jake and Manu,

Thanks for replying. I have already tried CLEAR itab[] and REFRESH Itab.

0 Kudos

Hi ,

VRM_DELETE_VALUES should resolve your Problem

Thx ,

Dilum

Former Member
0 Kudos

Hi all,

Problem is not in the internal table used by FM 'VRM_SET_VALUES' , Problem is that i have many drop down or list box and all are dependent except 1st listbox like :

2nd listbox dependent on 1st listbox

3rd lsitbox dependent on 1st listbox and 2nd listbox.... and so on..

once i have selected all listbox in order (from top to down) and go back and chage the content of 1st listbox..the values corresponding to that field is reflected to all other listbox but one value that comes alaways is previous value selected in that listbox previous time.

Problem is i am not able to refresh contents of list box.

Thanks

0 Kudos

Is there any way to refresh list box because in this context refreshing itab is not the solution

0 Kudos

Hi Praveen

by using the keyword Clear & Refresh will not work for the FM "VRM_SET_VALUES" & also the FM "VRM_DELETE_VALUES" will also not work better pass empty internal table to the FM "VRM_SET_VALUES" such that we will get empty drill down.

Hope answer your Question

Mohammed Shaik

0 Kudos

Hi Shaik,

I tried your solution but the problem still persists. I appreciate your idea but try to imagine this situation.

Listbox has already one value as a result of previous selection

now i embedded blank internal table..listbox has still that value.it is not cleared

Now embedding listbox with internal table that has values will now result in same thing.

I tried one thing but failed: To CLEAR PARAM at AT SELECTION-SCREEN OUTPUT. but in this way even the selected values were cleared when i pressed enter

Thanks for your reply shaik

0 Kudos

Hi

Try This code. I didnt get the situation you were mentioning about.

Regards

Raj

   *&---------------------------------------------------------------------*
*& Report  YTESTRAJ2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  YTESTRAJ2.

*&--------------------------------------------------------------------&*
*  Includes                                                            *
*&--------------------------------------------------------------------&*
INCLUDE ytestraj2_top.
INCLUDE ytestraj2_form.

*&--------------------------------------------------------------------&*
*  Initialization                                                      *
*&--------------------------------------------------------------------&*
INITIALIZATION.

*// Prepare the F4 input values for Country
  PERFORM f_prepare_base.

*&--------------------------------------------------------------------&*
*  At Selection Screen on value request                                *
*&--------------------------------------------------------------------&*
*// For Country
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_contry.
  PERFORM f_f4help_country.

*// For State
  perform f_f4help_state.

*&--------------------------------------------------------------------&*
*  At Selection Screen                                                 *
*&--------------------------------------------------------------------&*
AT SELECTION-SCREEN.
*// Get the OK Code
  v_ucomm = sy-ucomm.

*&--------------------------------------------------------------------&*
*  At selection screen output                                          *
*&--------------------------------------------------------------------&*
AT SELECTION-SCREEN OUTPUT.
  if 1 = 1.
  endif.
*&--------------------------------------------------------------------&*
*  Start of selection                                                  *
*&--------------------------------------------------------------------&*
START-OF-SELECTION.
  if 1 = 1.
  endif.

*&--------------------------------------------------------------------&*
*  End of selection                                                    *
*&--------------------------------------------------------------------&*

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

   *&---------------------------------------------------------------------*
*&  Include           YTESTRAJ2_TOP
*&---------------------------------------------------------------------*
*&--------------------------------------------------------------------&*
*  Type Pools                                                          *
*&--------------------------------------------------------------------&*
TYPE-POOLS: vrm, sscr.

*&---------------------------------------------------------------&*
*  INFOTYPES
*&---------------------------------------------------------------&*
INFOTYPES: 0000, 0001, 0002.

*&---------------------------------------------------------------&*
*  TABLES
*&---------------------------------------------------------------&*
TABLES: pernr,
        t005,
        t71jpr28,
        t710g,
        sflight,
        hrp1000,
        hrp1001.

*&--------------------------------------------------------------------&*
*  Types                                                               *
*&--------------------------------------------------------------------&*
TYPES: BEGIN OF ty_land1,
         molga TYPE molga,   "Country Key
         ltext TYPE mlgtx,   "Country Name
       END OF ty_land1,

       begin of ty_state,
         regio type regio,     "State
         BEZEI type BEZEI20,   "Text
       end of ty_state.
*&--------------------------------------------------------------------&*
*  Data Declarations                                                   *
*&--------------------------------------------------------------------&*

DATA: t_return_tab TYPE STANDARD TABLE OF ddshretval,
      t_data       TYPE vrm_values,
      gwa_data     LIKE LINE OF t_data,
      t_land1      TYPE STANDARD TABLE OF ty_land1    WITH HEADER LINE,
      t_state      type STANDARD TABLE OF ty_state    WITH HEADER LINE,
      gwa_state    type ty_state.

data: v_ucomm type syst-ucomm.
*&--------------------------------------------------------------------&*
*  Constants                                                           *
*&--------------------------------------------------------------------&*
CONSTANTS: true     VALUE 'X',
           false    VALUE ' ',
           c_en     TYPE spras VALUE 'EN',
           c_can    TYPE molga VALUE '07',
           c_usa    TYPE molga VALUE '10',
           c_usl    TYPE cmp_evtyp VALUE 'USIL',
           c_cal    TYPE cmp_evtyp VALUE 'CAIL'.
*&--------------------------------------------------------------------&*
*  Selection Screen                                                    *
*&--------------------------------------------------------------------&*

SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t01.
PARAMETERS p_contry TYPE t005-land1 AS LISTBOX VISIBLE LENGTH 20 USER-COMMAND usd. "Country
SELECTION-SCREEN SKIP 1.
parameters p_state type t005g-regio as LISTBOX VISIBLE LENGTH 40 USER-COMMAND usd. "States
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK b3.

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

   *&---------------------------------------------------------------------*
*&  Include           YTESTRAJ2_FORM
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  F_PREPARE_BASE
*&---------------------------------------------------------------------*
*       Prepare the F4 input values for Country
*----------------------------------------------------------------------*
FORM f_prepare_base .

  CLEAR: t_land1,   t_land1[].

*// Country
  SELECT molga ltext
    INTO TABLE t_land1
    FROM t500t
    WHERE spras = c_en AND
          molga IN (c_usa, c_can).
  IF sy-subrc = 0.
    SORT t_land1 BY molga.
  ENDIF.
ENDFORM.                    " F_PREPARE_BASE
*&---------------------------------------------------------------------*
*&      Form  F_F4HELP_COUNTRY
*&---------------------------------------------------------------------*
*       F4 Help for Country
*----------------------------------------------------------------------*
FORM f_f4help_country.
  DATA:
        lwa_land1 TYPE ty_land1.

  CLEAR: t_data, t_data[].
  LOOP AT t_land1 INTO lwa_land1.
    CLEAR gwa_data.
    gwa_data-key  = lwa_land1-molga.
    gwa_data-text = lwa_land1-ltext.
    APPEND gwa_data TO t_data.
  ENDLOOP.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = 'P_CONTRY'
      values          = t_data
    EXCEPTIONS
      id_illegal_name = 1
      OTHERS          = 2.
ENDFORM.                    " F_F4HELP_COUNTRY
*&---------------------------------------------------------------------*
*&      Form  F_F4HELP_STATE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM F_F4HELP_STATE .
  CLEAR: t_data, t_data[],
         t_state, t_state[].
  data: lv_land1 type land1.
  if not p_contry is INITIAL.
    if p_contry = '10'.
      lv_land1 = 'US'.
    else.
      lv_land1 = 'CA'.
    endif.
    select regio
           BEZEI
      from t005h
      into table t_state
      where  spras = sy-langu and
             land1 = lv_land1.
    if sy-subrc = 0.
      sort t_state by regio.
    endif.

    loop at t_state into gwa_state.
      CLEAR gwa_data.
      gwa_data-key  = gwa_state-regio.
      gwa_data-text = gwa_state-BEZEI.
      APPEND gwa_data TO t_data.
    endloop.

    CALL FUNCTION 'VRM_SET_VALUES'
      EXPORTING
        id              = 'P_STATE'
        values          = t_data
      EXCEPTIONS
        id_illegal_name = 1
        OTHERS          = 2.
  endif.
ENDFORM.                    " F_F4HELP_STATE

0 Kudos

Hi

Try This code. I didnt get the situation you were mentioning about.

Regards

Raj

   *&---------------------------------------------------------------------*
*& Report  YTESTRAJ2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  YTESTRAJ2.

*&--------------------------------------------------------------------&*
*  Includes                                                            *
*&--------------------------------------------------------------------&*
INCLUDE ytestraj2_top.
INCLUDE ytestraj2_form.

*&--------------------------------------------------------------------&*
*  Initialization                                                      *
*&--------------------------------------------------------------------&*
INITIALIZATION.

*// Prepare the F4 input values for Country
  PERFORM f_prepare_base.

*&--------------------------------------------------------------------&*
*  At Selection Screen on value request                                *
*&--------------------------------------------------------------------&*
*// For Country
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_contry.
  PERFORM f_f4help_country.

*// For State
  perform f_f4help_state.

*&--------------------------------------------------------------------&*
*  At Selection Screen                                                 *
*&--------------------------------------------------------------------&*
AT SELECTION-SCREEN.
*// Get the OK Code
  v_ucomm = sy-ucomm.

*&--------------------------------------------------------------------&*
*  At selection screen output                                          *
*&--------------------------------------------------------------------&*
AT SELECTION-SCREEN OUTPUT.
  if 1 = 1.
  endif.
*&--------------------------------------------------------------------&*
*  Start of selection                                                  *
*&--------------------------------------------------------------------&*
START-OF-SELECTION.
  if 1 = 1.
  endif.

*&--------------------------------------------------------------------&*
*  End of selection                                                    *
*&--------------------------------------------------------------------&*

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

   *&---------------------------------------------------------------------*
*&  Include           YTESTRAJ2_TOP
*&---------------------------------------------------------------------*
*&--------------------------------------------------------------------&*
*  Type Pools                                                          *
*&--------------------------------------------------------------------&*
TYPE-POOLS: vrm, sscr.

*&---------------------------------------------------------------&*
*  INFOTYPES
*&---------------------------------------------------------------&*
INFOTYPES: 0000, 0001, 0002.

*&---------------------------------------------------------------&*
*  TABLES
*&---------------------------------------------------------------&*
TABLES: pernr,
        t005,
        t71jpr28,
        t710g,
        sflight,
        hrp1000,
        hrp1001.

*&--------------------------------------------------------------------&*
*  Types                                                               *
*&--------------------------------------------------------------------&*
TYPES: BEGIN OF ty_land1,
         molga TYPE molga,   "Country Key
         ltext TYPE mlgtx,   "Country Name
       END OF ty_land1,

       begin of ty_state,
         regio type regio,     "State
         BEZEI type BEZEI20,   "Text
       end of ty_state.
*&--------------------------------------------------------------------&*
*  Data Declarations                                                   *
*&--------------------------------------------------------------------&*

DATA: t_return_tab TYPE STANDARD TABLE OF ddshretval,
      t_data       TYPE vrm_values,
      gwa_data     LIKE LINE OF t_data,
      t_land1      TYPE STANDARD TABLE OF ty_land1    WITH HEADER LINE,
      t_state      type STANDARD TABLE OF ty_state    WITH HEADER LINE,
      gwa_state    type ty_state.

data: v_ucomm type syst-ucomm.
*&--------------------------------------------------------------------&*
*  Constants                                                           *
*&--------------------------------------------------------------------&*
CONSTANTS: true     VALUE 'X',
           false    VALUE ' ',
           c_en     TYPE spras VALUE 'EN',
           c_can    TYPE molga VALUE '07',
           c_usa    TYPE molga VALUE '10',
           c_usl    TYPE cmp_evtyp VALUE 'USIL',
           c_cal    TYPE cmp_evtyp VALUE 'CAIL'.
*&--------------------------------------------------------------------&*
*  Selection Screen                                                    *
*&--------------------------------------------------------------------&*

SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t01.
PARAMETERS p_contry TYPE t005-land1 AS LISTBOX VISIBLE LENGTH 20 USER-COMMAND usd. "Country
SELECTION-SCREEN SKIP 1.
parameters p_state type t005g-regio as LISTBOX VISIBLE LENGTH 40 USER-COMMAND usd. "States
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK b3.

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

   *&---------------------------------------------------------------------*
*&  Include           YTESTRAJ2_FORM
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  F_PREPARE_BASE
*&---------------------------------------------------------------------*
*       Prepare the F4 input values for Country
*----------------------------------------------------------------------*
FORM f_prepare_base .

  CLEAR: t_land1,   t_land1[].

*// Country
  SELECT molga ltext
    INTO TABLE t_land1
    FROM t500t
    WHERE spras = c_en AND
          molga IN (c_usa, c_can).
  IF sy-subrc = 0.
    SORT t_land1 BY molga.
  ENDIF.
ENDFORM.                    " F_PREPARE_BASE
*&---------------------------------------------------------------------*
*&      Form  F_F4HELP_COUNTRY
*&---------------------------------------------------------------------*
*       F4 Help for Country
*----------------------------------------------------------------------*
FORM f_f4help_country.
  DATA:
        lwa_land1 TYPE ty_land1.

  CLEAR: t_data, t_data[].
  LOOP AT t_land1 INTO lwa_land1.
    CLEAR gwa_data.
    gwa_data-key  = lwa_land1-molga.
    gwa_data-text = lwa_land1-ltext.
    APPEND gwa_data TO t_data.
  ENDLOOP.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = 'P_CONTRY'
      values          = t_data
    EXCEPTIONS
      id_illegal_name = 1
      OTHERS          = 2.
ENDFORM.                    " F_F4HELP_COUNTRY
*&---------------------------------------------------------------------*
*&      Form  F_F4HELP_STATE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM F_F4HELP_STATE .
  CLEAR: t_data, t_data[],
         t_state, t_state[].
  data: lv_land1 type land1.
  if not p_contry is INITIAL.
    if p_contry = '10'.
      lv_land1 = 'US'.
    else.
      lv_land1 = 'CA'.
    endif.
    select regio
           BEZEI
      from t005h
      into table t_state
      where  spras = sy-langu and
             land1 = lv_land1.
    if sy-subrc = 0.
      sort t_state by regio.
    endif.

    loop at t_state into gwa_state.
      CLEAR gwa_data.
      gwa_data-key  = gwa_state-regio.
      gwa_data-text = gwa_state-BEZEI.
      APPEND gwa_data TO t_data.
    endloop.

    CALL FUNCTION 'VRM_SET_VALUES'
      EXPORTING
        id              = 'P_STATE'
        values          = t_data
      EXCEPTIONS
        id_illegal_name = 1
        OTHERS          = 2.
  endif.
ENDFORM.                    " F_F4HELP_STATE

Former Member
0 Kudos

Hi Praveen,

Please see the below sample code to clear the list box value in selection screen.

in below report we have three list box selection

Message Type

Basic type

Extension

first user will select message type then basic type and if he click on message type again then you can clear the previously selected basic type.

use the user command extension while defining list box and depend on sy-ucomm you can clear the old values of dependent list box.

hopefully this will serve your requirement.

REPORT  ZTEST_LIST_BOX.

tables:EDIMSG.

PARAMETERS:

MESTYP LIKE EDIMSG-MESTYP AS LISTBOX VISIBLE LENGTH 30 USER-COMMAND chx1,

IDOCTYP LIKE EDIMSG-IDOCTYP AS LISTBOX VISIBLE LENGTH 30 USER-COMMAND chx2,

CIMTYP LIKE EDIMSG-CIMTYP AS LISTBOX VISIBLE LENGTH 30.

AT SELECTION-SCREEN..

   if sy-ucomm = 'CHX1'.

     CLEAR: IDOCTYP,CIMTYP.

   ELSEIF sy-ucomm = 'CHX2'.

     CLEAR CIMTYP.

   ENDIF.


Regards

Chudamani Gavel

0 Kudos

Hi Chudamani,

It will clear only selection (as working area). Or I am wrong?

Regards,

Aivaras

0 Kudos

Hi Plockis,

Yes off course. He asked the idea to clear PARAM at AT SELECTION-SCREEN OUTPUT.

he has already cleared the internal tables only problem was that he was not able to clear the previously selected values of selection screen.

Thats why I suggested above code.

Regards

Chudamani

former_member190928
Participant
0 Kudos

HI Praveen,

I have same problem and finally we found it is caused by parameter id assigned on data element.

So for the case that several drop down list box which has dependency one by one.

I will call below code each time:

   CALL FUNCTION 'VRM_SET_VALUES'

     EXPORTING

       id              = iv_fname

       values          = lt_values

     EXCEPTIONS

       id_illegal_name = 1

       OTHERS          = 2.

   SET PARAMETER ID 'POPR' FIELD ''.


It will help clear the UI parameter so that the wrong key value will not be shown in the list box.

Hope it helps.


BR,

Steve

former_member309899
Participant
0 Kudos

Hi,

You can simply clear the parameter value.

For example, p_list2 is your list box. then before populating the list items(internal table), just use:-

clear p_list2.

hope it will solve your issue.

Regards,

Nagarajan S.