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

Former Member
0 Likes
918

I have a list box on selection screen. Problem is that when i select one value from list box its value gets cleared when i hit ENTER. Plz help !!

6 REPLIES 6
Read only

MarcinPciak
Active Contributor
0 Likes
882

AS you didn't share your code, let me send you the one which you can use [Listbox in Sel Screen|http://sap.niraj.tripod.com/id38.html]

Regards

Marcin

Read only

Former Member
0 Likes
882

Hi Vivek,

Check this thread aswell

" Even I have faced the Same problem and solved as below
iN Top Include
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.
" You dont require the following Declaration
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.
On The screen create 2 list box with names
1) SFLIGHT-CARRID " For this assign any dummy Code and it will trigger PBO once you leave select
 
2) SFLIGHT-CONNID
in PBO
 
module status_100.
 
in Program
 
module status_100 output.
  REFRESH CAR.
  WCAR-KEY = 'AA'. " Make sure you enter same value here as text below
  WCAR-TEXT = 'AA'.
  APPEND WCAR TO CAR.
  WCAR-KEY = 'LH'.
  WCAR-TEXT = 'LH'.
  APPEND WCAR TO CAR.
  CID = 'SFLIGHT-CARRID'.
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      ID              = CID
      VALUES          = CAR
    EXCEPTIONS
      ID_ILLEGAL_NAME = 1
      OTHERS          = 2.

Cheerz

Ram

Read only

Former Member
0 Likes
882

As per my understanding you used CLEAR statement at wrong place.

Please check CLEAR in your modules.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
882

Hi,

Refer code:-


TYPE-POOLS: VRM.

TYPES : BEGIN OF MOVIE,
        YR LIKE YTG_MOVIE-YR,
        CATEGORY LIKE YTG_MOVIE-CATEGORY,
        WINNER LIKE YTG_MOVIE-WINNER,
        NOTES LIKE YTG_MOVIE-NOTES,
        END OF MOVIE.

DATA: NAME TYPE VRM_ID,
      LIST TYPE VRM_VALUES,
      VALUE LIKE LINE OF LIST,
      MOVIETAB TYPE STANDARD TABLE OF MOVIE INITIAL SIZE 10 WITH HEADER LINE.

PARAMETERS: CATEGORY(10) AS LISTBOX VISIBLE LENGTH 10.

AT SELECTION-SCREEN.
  IF CATEGORY EQ ''.
    MESSAGE E006.
  ENDIF.

AT SELECTION-SCREEN OUTPUT.

  NAME = 'CATEGORY'.

  VALUE-KEY = 'PIC'.
  VALUE-TEXT = 'PIC'.
  APPEND VALUE TO LIST.

  VALUE-KEY = 'MAL'.
  VALUE-TEXT = 'MAL'.
  APPEND VALUE TO LIST.

  VALUE-KEY = 'FEM'.
  VALUE-TEXT = 'FEM'.
  APPEND VALUE TO LIST.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      ID     = NAME
      VALUES = LIST.

START-OF-SELECTION.

  WRITE : / 'Category Selected :', CATEGORY.

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
882

Hi

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = NAME

VALUES = LIST.

just write "Clear list" after the FM call..

it should be working..as i copied your code...only problem is value is getting multiple tme in the dropdown when you press enter...it again have the same set of values....just write lear statement so that dropdown doesn't have the same value multiple times

regards,

Yadesh

Read only

Former Member
0 Likes
882

Hi Vivek

Please check the below code

TABLES :MARA.

DATA:BEGIN OF ITAB OCCURS 0,
       NUM LIKE MAKT-MAKTX,
       END OF ITAB.

*&---------------------------------------------------------------------*
*&      Module  output  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE OUTPUT OUTPUT.

IF ITAB[] IS INITIAL.
  ITAB-NUM = '1'.      APPEND ITAB.
  ITAB-NUM = '2'.      APPEND ITAB.
  ITAB-NUM = '3'.      APPEND ITAB.
  ITAB-NUM = '4'.      APPEND ITAB.
  ITAB-NUM = '5'.      APPEND ITAB.
  ITAB-NUM = '6'.      APPEND ITAB.
  ITAB-NUM = '7'.      APPEND ITAB.
  ITAB-NUM = '8'.      APPEND ITAB.
  ITAB-NUM = '9'.      APPEND ITAB.
  ITAB-NUM = '10'.      APPEND ITAB.
  CLEAR ITAB.
ENDIF.


*&---------------------------------------------------------------------*
*&      Module  listbox1  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE LISTBOX1 INPUT.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
*   DDIC_STRUCTURE         = ' '
      RETFIELD               = 'NUM'
*   PVALKEY                = ' '
*   DYNPPROG               = ' '
*   DYNPNR                 = ' '
*   DYNPROFIELD            = ' '
*   STEPL                  = 0
*   WINDOW_TITLE           =
*   VALUE                  = ' '
     VALUE_ORG              = 'S'
*   MULTIPLE_CHOICE        = ' '
*   DISPLAY                = ' '
*   CALLBACK_PROGRAM       = ' '
*   CALLBACK_FORM          = ' '
*   MARK_TAB               =
* IMPORTING
*   USER_RESET             =
    TABLES
      VALUE_TAB              = ITAB
*   FIELD_TAB              =
*   RETURN_TAB             =
*   DYNPFLD_MAPPING        =
* EXCEPTIONS
*   PARAMETER_ERROR        = 1
*   NO_VALUES_FOUND        = 2
*   OTHERS                 = 3
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



**Flow Logic**

PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
MODULE OUTPUT.

PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
MODULE INPUT.
PROCESS ON VALUE-REQUEST .
FIELD ITAB-NUM MODULE LISTBOX1.