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 poulate dropdown(list box) in a Table control Dynamically

Former Member
0 Kudos

Hi,

I have a Table Control in which one of the columns is a listbox(dropdown). Now i need to fill the list box with entries dynamically where the entries of the listbox are different for each row in the table control. I am trying to find some suitable code which i can put in my PBO. Please kindly help.

Regards,

Vinay.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You need to do it as the same way as you do build a static search help for a field in table control. the only catch here i find here is you will have read the screen value based on which you would build your search help internal table using FM

DYNP_VALUES_READ.

13 REPLIES 13

Former Member
0 Kudos

You need to do it as the same way as you do build a static search help for a field in table control. the only catch here i find here is you will have read the screen value based on which you would build your search help internal table using FM

DYNP_VALUES_READ.

Former Member
0 Kudos

Hi Vinayaka,

U can Simply use Event PROCESS ON VALUE-REQUEST for Populating the List Box Values in Screen on which u are going to display Table Control.

Suppose We want only few Customer type for field ( WA_CUST-CustomerType )in Table control. Then I will add following code after PBO.

PROCESS ON VALUE-REQUEST.

 FIELD WA_CUST-CustomerType
 MODULE cust_types.

In Defination of MODULE cust_type

Use the FM 'F4IF_INT_TABLE_VALUE_REQUEST'.

Pass Value_tab to the Above FM which will Contain the Values that you want in Dropdown List.

Please Do Reply for the Further Assistance.

Regards,

Ranjit Thakur.

<b>Please Mark The Helpful Answer.</b>

0 Kudos

Hi Ranjit,

Consider the following senario. I have a table control in whcih one of the columns is list box. Now in run time lets consider that we have 5 rows. Now for each row the list box should contain different values. How can we achieve this.

Regards,

Vinay.

0 Kudos

Hi Vinayaka,

This possible only if you have some criteria for the Row Identification( In Table Control ) . Then you can populate the Value_tab (For FM) as per the requirement.

But Problem here is that, Process On Value Request is called Once only ( not for each column selection (for Diferent Row) ).You Can Confirm this using Degubbing Mode.

<b>Please Mark The Helpful Answer.</b>

Regards,

Ranjit Thakur.

<b>Please Mark The Helpful Answer.</b>

Former Member
0 Kudos

Hi Vinayaka,

Welcome to SDN.

Refer std program - DEMO_DYNPRO_DROPDOWN_LISTBOX

in the PBO use the function module VRM_SET_VALUES

set the attribute of the field in screen painter as Drop down list.

NAME1 is the name of the field.

data: NAME1 type VRM_ID,

LIST1 type VRM_VALUES,

VALUE1 like line of LIST1.

select * from ZES_RFQ_REJECT into table IT_RFQREJ.

NAME1 = 'ZES_RFQ_ITEM-REJ_CODE'.

loop at IT_RFQREJ into IS_RFQREJ.

VALUE1-KEY = IS_RFQREJ-REJ_CODE.

append VALUE1 to LIST1.

clear IS_RFQREJ.

endloop.

call function 'VRM_SET_VALUES'

exporting

ID = NAME1

VALUES = LIST1.

clear LIST1.

Hope this helps.

Manish

0 Kudos

Hi,

You can select the field and convert it to listbox. IF this field is associtaed with any search help then all the possible values get listed autmoatically.

Regards,

Sesh

NAeda
Contributor
0 Kudos

Hi Can any reply to this thread??

I have the same scenario, which needs to be populated dynamically, Lets say one example, In Table control based on the entry in first column, data needs to be pupulated in second column which is a LISTBOX.. how to achieve this?

I have tried with POV which is triggering for only F4 not for list box, and VRM_SET_VALUES will be used to set the predefine values but in my case it should differ from row to row..

Kindly advice.

Thanks,

Aeda N

Hi Ranjit,
Consider the following senario. I have a table control in whcih one of the columns is list box. Now in run time lets consider that we have 5 rows. Now for each row the list box should contain different values. How can we achieve this.

Regards,
Vinay.

Former Member
0 Kudos

Check the code i have pasted below .

Hope it helps you.

0 Kudos

Hi Sampat,

As per your code PBO will trigger and populate the values and which are predefined.. And you know it wil trigger only once during start of the program..

My requirement is when the user click on the list box the event(PBO or PAI) should trigger so that I can poppulate the values.. But as per my observation, no action is getting triggered while clicking the list box and FCODE which is assingned to list box triggers only after selecting the value from list.

Thanks,

N Aeda

Former Member
0 Kudos

Hi Sampat,

>

> As per your code PBO will trigger and populate the values and which are predefined.. And you know it wil trigger only once during start of the program..

>

> My requirement is when the user click on the list box the event(PBO or PAI) should trigger so that I can poppulate the values.. But as per my observation, no action is getting triggered while clicking the list box and FCODE which is assingned to list box triggers only after selecting the value from list.

>

> Thanks,

> N Aeda

If you want it to generate on click of a dropdown box then use the following. Im giving you a code which i have used. I have two list boxes. Based on the selection in the first tlist the second will be populated. For this you will have to place a FCODE in the screen painter for that listbox.

case sy-ucomm.

when 'LSTDESC_TYPE'.
   clear wa_mpp-desc_model.
if wa_mpp-desc_type = 'GENERATOR'.
  refresh l_val.
val-key = 'SAMSUNG'.
val-text = 'SAMSUNG'.
append val to l_val.


val-key = 'AMUVOLT'.
val-text = 'AMUVOLT'.
append val to l_val.

lid = 'WA_MPP-DESC_MODEL'.
"lid= 'WA_MPP-DESC_TYPE'.

call function 'VRM_SET_VALUES'
  exporting
    id                    = lid
    values                = l_val
* 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.

elseif wa_mpp-desc_type = 'LAPTOPS'.
  refresh l_val.
val-key = 'DELL'.
val-text = 'DELL'.
append val to l_val.


val-key = 'HP'.
val-text = 'HP'.
append val to l_val.

lid = 'WA_MPP-DESC_MODEL'.
"lid= 'WA_MPP-DESC_TYPE'.

call function 'VRM_SET_VALUES'
  exporting
    id                    = lid
    values                = l_val
* 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.

elseif wa_mpp-desc_type = 'MOBILES'.
  refresh l_val.
val-key = 'BLACKBERRY'.
val-text = 'BLACKBERRY'.
append val to l_val.


val-key = 'APPLE'.
val-text = 'APPLE'.
append val to l_val.

lid = 'WA_MPP-DESC_MODEL'.
"lid= 'WA_MPP-DESC_TYPE'.

call function 'VRM_SET_VALUES'
  exporting
    id                    = lid
    values                = l_val
* 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.

endif.
endcase.

0 Kudos

Hi Sampath,

Thanks for the reply..

so are you saying FCdoe will trigger when I click on the list box.. No its only trigger after selecting the value..

In your case :

selecting the value from the first list box 
       |
Fcode will trigger
       |
fill the second listbox

In my case its only one list box, so once click on this it should fill.. I hope you clear now.

Thanks,

N Aeda

Former Member
0 Kudos

Yes.

My code triggers when the list box value is selected.

Remove the if condition inside the when loop.

That should do the trick.

Let me know if it helps.

if you want the values in the same list box , use the clear and refresh keywords.

Edited by: devrath.sampat on Feb 15, 2012 5:41 AM

Former Member
0 Kudos

Try this code:

type-pools: vrm.

data: lid type vrm_id,
      l_val type vrm_values,
      val like line of l_val.

module status_0001 output.


    refresh l_val.
val-key = '1234567'.
val-text = '123456'.
append val to l_val.


val-key = '312354'.
val-text = '312354'.
append val to l_val.


val-key = '998700'.
val-text = '998700'.
append val to l_val.


val-key = '302145'.
val-text = '302145'.
append val to l_val.

lid = 'WA_MPP-PO_NO'.

call function 'VRM_SET_VALUES'
  exporting
    id                    = lid
    values                = l_val
* 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.

Here in this code fetch the values you want in a select statement and place it accordingly.

If you want to call from a table then create a seprate search help for that specific field .. That search help should contain only that field

Edited by: devrath.sampat on Feb 14, 2012 11:37 AM