Skip to Content
0
Former Member
Apr 21, 2006 at 12:16 PM

Validation in DropDown List box

323 Views

Dear Experts,

I am having problem in validating a dropdown boxes on the selection screen.

I have 2 dropdown boxes for choosing values from a database table

<b>Drobdown List1</b> - to choose profile name from database table from z_profile.

<b>Drobdown List2</b> - to choose source name from database table from z_source <b>based on profile selected in the Drobdown List1.</b>

<u><b>My problem is</b></u>

<b>How can I choose only those "source names" depending on the "profile names" that I have chosen in droplist 1 only.</b>

<i>Also find the database tables and their values that need to be there to populate in Listbox 1 and 2</i>.

<b>Table - ZPROFILES</b>

MANDT PROFILE_NAME PROFILE_DESC

324   LOCATION     LOCATION MASTER
324   MATERIAL     MATERIAL MASTER
324   VENDOR       VENDOR MASTER

<b>Table - ZSOURCES</b>

MANDT PROFILE_NAME DBTABLE_NAME SOURCE_NAME

324   LOCATION     T001         PLANTS/BRANCHES
324   LOCATION     T001W        COMPANY CODES
324   MATERIAL     MAKT         MATERIAL DESCRIPTIONS
324   MATERIAL     MARA         GENERAL MATERIAL DATA

.. Please see the code that i have written.

REPORT ZTEST1 .

* Display Options for parameters
SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE T01.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK 3 WITH FRAME TITLE T03.


PARAMETERS: I_PRO LIKE ZPROFILES-PROFILE_NAME
AS LISTBOX VISIBLE LENGTH 15 DEFAULT '' OBLIGATORY..


PARAMETERS: I_SRC LIKE ZSOURCES-SOURCE_NAME
AS LISTBOX VISIBLE LENGTH 15 DEFAULT '' OBLIGATORY.


SELECTION-SCREEN END OF BLOCK 3.
SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN END OF BLOCK 1.
*-----------------------------------------------



*-- Fill the dropdown list boxes before displaying them
AT SELECTION-SCREEN OUTPUT.
  PERFORM FILL_DROPDOWN_LIST USING 'I_PRO'.

  PERFORM FILL_DROPDOWN_LIST_SRC USING 'I_SRC'.


INITIALIZATION.
  T01 = 'Update DB Tables'.
  T03 = 'Browse Profile and Data Source'.

START-OF-SELECTION.

END-OF-SELECTION.


*---------------------------------------------------------------------*
*       FORM fill_dropdown_list                   *
*---------------------------------------------------------------------*
FORM FILL_DROPDOWN_LIST USING VALUE(F_PARAMETER).
  TYPE-POOLS: VRM. " For parameter drop down lists
*-- Definitions for parameter drop down lists
  DATA:
    NAME  TYPE VRM_ID,
    LIST  TYPE VRM_VALUES,
    VALUE LIKE LINE OF LIST.

  DATA : IT_PROFILES LIKE ZPROFILES OCCURS 0 WITH HEADER LINE.


  NAME = F_PARAMETER.
  CASE F_PARAMETER.
    WHEN 'I_PRO'.

      VALUE-KEY = 'TEST_PROFI'.
      VALUE-TEXT = 'TEST_PROFILE'.
      APPEND VALUE TO LIST.


      CLEAR : IT_PROFILES,
              IT_PROFILES[].

      SELECT * FROM ZPROFILES CLIENT SPECIFIED
      INTO TABLE IT_PROFILES
      WHERE MANDT = SY-MANDT .
      IF SY-SUBRC = 0.
        SORT IT_PROFILES BY PROFILE_NAME.

        CLEAR : IT_PROFILES.
        LOOP AT IT_PROFILES.
          VALUE-KEY = IT_PROFILES-PROFILE_NAME.
          VALUE-TEXT = IT_PROFILES-PROFILE_NAME.
          APPEND VALUE TO LIST.
        ENDLOOP.
      ENDIF.

    WHEN OTHERS.
  ENDCASE.
  CALL FUNCTION 'VRM_SET_VALUES'
       EXPORTING
            ID     = NAME
            VALUES = LIST.

ENDFORM." fill_dropdown_list


*&---------------------------------------------------------------------*
*&      Form  FILL_DROPDOWN_LIST_SRC
*&---------------------------------------------------------------------*
FORM FILL_DROPDOWN_LIST_SRC USING   VALUE(F_PARAMETER).

  TYPE-POOLS: VRM. " For parameter drop down lists
*-- Definitions for parameter drop down lists
  DATA:
    NAME  TYPE VRM_ID,
    LIST  TYPE VRM_VALUES,
    VALUE LIKE LINE OF LIST.

  DATA : IT_SOURCES LIKE ZSOURCES OCCURS 0 WITH HEADER LINE.


  NAME = F_PARAMETER.
  CASE F_PARAMETER.
    WHEN 'I_SRC'.

      CLEAR : IT_SOURCES,
              IT_SOURCES[].

      SELECT * FROM ZSOURCES CLIENT SPECIFIED
      INTO TABLE IT_SOURCES
      WHERE MANDT = SY-MANDT.

      IF SY-SUBRC = 0.
        SORT IT_SOURCES BY PROFILE_NAME SOURCE_NAME.

        CLEAR : IT_SOURCES.
        LOOP AT IT_SOURCES.
          VALUE-KEY  = IT_SOURCES-PROFILE_NAME.
          VALUE-TEXT = IT_SOURCES-SOURCE_NAME.
          APPEND VALUE TO LIST.
        ENDLOOP.
      ENDIF.

    WHEN OTHERS.
  ENDCASE.
  CALL FUNCTION 'VRM_SET_VALUES'
       EXPORTING
            ID     = NAME
            VALUES = LIST.

ENDFORM.                    " FILL_DROPDOWN_LIST_SRC

Please help.

Thanks