Skip to Content
0

​ How to Create a drop down list for 3 or more tables & update other lists based on selection

Nov 01, 2016 at 12:22 PM

75

avatar image
Former Member

Hi Experts,

I am new to SAP ABAP, My requirement is to create a drop down list for 3 or more db tables, where on selection of one value in first drop down list the second list should be updated based on first selection and same for third list, as all are dependent on each other.

Ex: 3 tables Tab1 Tab2 Tab3.

Tab1 has values A, B, C. when A is selected from list, all the values related to A in Tab2 list should be Populated and same for 3rd.

Can any expert please help me with some code for the same.

Thanks in Advance.

Thanveer

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Kali Charan Nov 01, 2016 at 12:30 PM
0

I hope i understood.

Selection For Field 1: Create F4(Static nothing but fixed) From the Reference parameter of the table 1
For Selection For Field 2: Here Create f4(dynamic) Using Query.

Refer in Forum how to create f4.(By using Query, using Where Condition Which values you selected for First F4 you need pass it
dynpro Values Get For getting the selecting screen values.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

For Selection For Field 3:Same logic apply

Hope you understood.

Show 4 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks NewB To Abap for reply

But i didn't get it clearly, Could you please give me some code snippers to better understand it.

0

Can you please Wait for Some time, Actually it will take some time to give the code, Almost we have to develop it.
mean while You have to check it in forum like

How to create F4 using F4IF_INT_TABLE_VALUE_REQUEST'. check it, and also Dynpro values Get, else How to Get dynpro values you need to check it.

Hope you understood.I will try to give the suggestions. But you need to understood.If you does not know any thing about
abap coding. Everything will be wasted.

0

Have a look below attached images. By using the below code, First you need to write the logic for first Selection field F4
next you need to Fetch the records based on the First selection screen values, For this you need to get dynpro values read and show the values to the F4_help.

Hope you understood.

PARAMETERS:s_table1 TYPE ztab1-zmatnr,
           s_table2 TYPE ztab2-zmatnr.


DATA : lt_values TYPE STANDARD TABLE OF ddshretval.

TYPES:BEGIN OF st_table1.
        INCLUDE STRUCTURE ztab1.
TYPES:END OF st_table1.

DATA:it_tab1 TYPE TABLE OF st_table1,
     wa_tab1 TYPE st_table1.

TYPES:BEGIN OF st_table2.
        INCLUDE STRUCTURE ztab2.
TYPES:END OF st_table2.

DATA:it_tab2 TYPE TABLE OF st_table2,
     wa_tab2 TYPE st_table2.

DATA:repid TYPE sy-repid,
dynnr TYPE sy-dynnr.

DATA :
t_prueba TYPE STANDARD TABLE OF dynpread,
s_prueba TYPE dynpread.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_table1.
  "BREAK-POINT .
  repid = sy-repid.
  dynnr = sy-dynnr.
  REFRESH:it_tab1.
  CLEAR:wa_tab1.

SELECT * FROM ztab1 INTO TABLE it_tab1.
IF NOT it_tab1 IS INITIAL.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
        retfield        = 'ZMATNR'
        dynpprog        = 'ZPRAC3'
        dynpnr          = sy-dynnr
        dynprofield     = 'S_TOOL'
        value_org       = 'S'  "Mandatory
        display         = 'F'
      TABLES
        value_tab       = it_tab1
        return_tab      = lt_values
      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.
  ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_table2.
  "BREAK-POINT .
  repid = sy-repid.
  dynnr = sy-dynnr.
  REFRESH:it_tab1.
  CLEAR:wa_tab1.

  CLEAR:s_prueba,t_prueba.
  MOVE 'S_TABLE1' TO s_prueba-fieldname.
  APPEND s_prueba TO t_prueba.
  "APPEND dynpfields.          FIELDNAME

 CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname     = sy-repid
      dynumb     = sy-dynnr
    TABLES
      dynpfields = t_prueba.

 CLEAR:s_prueba.
  READ TABLE t_prueba INTO s_prueba INDEX 1.
  IF sy-subrc EQ 0.
    MOVE:  s_prueba-fieldvalue TO s_table1.
  ENDIF.
 SELECT * FROM ztab2 INTO TABLE it_tab2 WHERE zmatnr EQ  s_table1.
 IF NOT it_tab2 IS INITIAL.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
        retfield        = 'ZMATNR'
        dynpprog        = 'ZPRAC3'
        dynpnr          = sy-dynnr
        dynprofield     = 'S_TOOL'
        value_org       = 'S'  "Mandatory
        display         = 'F'
      TABLES
        value_tab       = it_tab2
        return_tab      = lt_values
      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.
  ENDIF.

example1.png (25.1 kB)
example2.png (74.5 kB)
0
Former Member
Kali Charan

Thanks a lot NewB To Abap..

Being a new comer, this has helped me in a great way,

I truly appreciate the effort from an expert.

Regards,

Tanveer

0
Renato Parise Nov 01, 2016 at 03:30 PM
0

Hi,

Also, you can try this code:

BR,

Parise

SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S32 {
color: #3399FF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}

TABLES: t001w, t001l.



DATA: lw_vrm TYPE vrm_values,

      ls_vrm TYPE vrm_value,

      lc_id  TYPE vrm_id.



PARAMETERS p_werks  TYPE t001w-werks AS LISTBOX VISIBLE LENGTH 10

                                     USER-COMMAND fcode.



PARAMETERS p_lgort  TYPE t001l-lgort AS LISTBOX VISIBLE LENGTH 20

                                     USER-COMMAND fcode.





AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_werks.



  REFRESH lw_vrm.



  SELECT *

    FROM t001w.

    CLEAR ls_vrm.

    ls_vrm-key  = t001w-werks.

    ls_vrm-text = t001w-werks.

    APPEND ls_vrm TO lw_vrm.

  ENDSELECT.



  lc_id  = 'P_WERKS'.



  CALL FUNCTION 'VRM_SET_VALUES'

    EXPORTING

      id              = lc_id

      values          = lw_vrm

    EXCEPTIONS

      id_illegal_name = 1

      OTHERS          = 2.





AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_lgort.



  REFRESH lw_vrm.



  SELECT *

    FROM t001l

      WHERE werks EQ p_werks.

    CLEAR ls_vrm.

    ls_vrm-key  = t001l-lgort.

    ls_vrm-text = t001l-lgort.

    APPEND ls_vrm TO lw_vrm.

  ENDSELECT.



  lc_id  = 'P_LGORT'.



  CALL FUNCTION 'VRM_SET_VALUES'

    EXPORTING

      id              = lc_id

      values          = lw_vrm

    EXCEPTIONS

      id_illegal_name = 1

      OTHERS          = 2.



START-OF-SELECTION.
Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks Renato Parise..

Even this solves my issue..

Great help.

Thanks & Regards,

Tanveer

0