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

Dropdown List in Tablecontrol

Former Member
0 Likes
2,229

Hi everyone!

I'm having trouble filling the dropdown lists that I have in a table control.

In the PAI, I'm filling the dropdown lists with the correct information. The problem is, that all of the dropdown lists (rows) are being filled with the same information.

How I'm able to identify an specific field name of a row? (I think that is the problem). Please any help solving this would be greatly appreciated.

Felipe.

This is the code that I have:

-


PROCESS AFTER INPUT.

LOOP AT it_ztac0004.

CHAIN.

FIELD wa_ztac0004-id_tip_comision.

FIELD wa_ztac0004-descripcion.

FIELD wa_ztac0004-grp_comision.

FIELD wa_ztac0004-opcion.

FIELD wa_ztac0004-subscreen.

FIELD wa_ztac0004-met_extraccion.

MODULE tc_ztac0004_modify ON CHAIN-REQUEST.

ENDCHAIN.

FIELD wa_ztac0004-mandt

MODULE tc_ztac0004_mark ON REQUEST.

<b>MODULE set_drops.</b>

ENDLOOP.

-


MODULE set_drops INPUT.

DATA: wa_tabla4 LIKE LINE OF it_ztac0004,

nombre_campo TYPE VRM_ID.

DATA: it_lista1 TYPE VRM_VALUES,

wa_lista1 LIKE LINE OF it_lista1.

DATA: it_ztac0020 TYPE TABLE OF ztac0020,

wa_ztac0020 LIKE LINE OF it_ztac0020.

nombre_campo = 'wa_ztac0004-opcion'.

READ TABLE it_ztac0004 INTO wa_tabla4 INDEX tc_ztac0004-current_line.

IF sy-subrc = 0.

SELECT * FROM ZTAC0020 INTO TABLE it_ztac0020

WHERE grp_comision = wa_tabla4-grp_comision.

if sy-subrc = 0.

LOOP AT it_ztac0020 INTO wa_ztac0020.

wa_lista1-key = wa_ztac0020-opcion.

wa_lista1-text = wa_ztac0020-opcion.

APPEND wa_lista1 TO it_lista1.

ENDLOOP.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = nombre_campo

values = it_lista1.

endif.

ENDIF.

ENDMODULE. " set_drops INPUT

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,168

I think that you need to be filling your drop downs during PBO, not PAI. I'm checking.

Regards,

Rich Heilman

14 REPLIES 14
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,169

I think that you need to be filling your drop downs during PBO, not PAI. I'm checking.

Regards,

Rich Heilman

Read only

0 Likes
2,168

Yes, this needs to be done in the PBO. See the module below. You can see that ITAB-FIELD is a field in the table control. This field will have a listbox, you can do the same for all of your fields of the ITAB.




module status_0100 output.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

data: ivrm_values type vrm_values.
data: xvrm_values like line of ivrm_values.
data: name type vrm_id.


<b>  name = 'ITAB-FIELD'.</b>

  xvrm_values-key = '1234567890'.
  xvrm_values-text = '1234567890'.
  append xvrm_values to ivrm_values.

  xvrm_values-key = '0987654321'.
  xvrm_values-text = '0987654321'.
  append xvrm_values to ivrm_values.

  call function 'VRM_SET_VALUES'
    exporting
      id     = name
      values = ivrm_values.

endmodule.                 " STATUS_0100  OUTPUT

Of course this works for all rows, not specific rows of the table control.

REgards,

Rich Heilman

Read only

0 Likes
2,168

Hi Rich,

First of all thanks for the quick response to all.

I tried Rich's sugestion, in the PBO and it is having the same result. If a put the name attribute with 'ITAB-FIELD' that particular ListBox is not being filled with the information that I want, Or it fills all the fields in each row with the same information.

What I want to do, is that from a particular value of other field in the tablecontrol the listbox will be filled with some data. This initial value, can be different in each row of the table control.

How can identify one field from one row? Because I think that if I can pass the name of the field to the VRM_SET_VALUES FM, will solved the problem

For example:

row1Field1 row1Field2 row1Field3

row2Field1 <b>row2Field2</b> row2Field3

row3Field1 row3Field2 row3Field3

Thanks,

Felipe

Read only

0 Likes
2,168

You can't do this for specific rows of the table control. You do it for a field, it is the same for all rows for that field.

Why is it this way? Well, lets think about it, does it make any sense, to have different default values for the same field in different rows of the table control. In most business cases, I would say no. There are exceptions of course. You may want to re-think your design.

Regards,

Rich Heilman

Read only

former_member186741
Active Contributor
0 Likes
2,168

I don't think it matters too much where you fill the dropdown list (unless the contents change dynamically) the main thing is to get the pf4 to work. You need to associate a help module (pai) pf4 button with the specific field, it doesn't matter if this field is in a table control or not. This module will need to display the contents of the table which you have built earlier.

eg,

PROCESS ON VALUE-REQUEST.

FIELD ZNRW_TC-COL01 MODULE col01_HELP.

Read only

0 Likes
2,168

Neil, this is not a value request, but a listbox, doing a module under PROCESS ON VALUE-REQUEST will not do the job, this is for F4 help, not listbox.

Listboxes should be built in the PBO, before the screen is thrown.

Regards,

Rich Heilman

Read only

0 Likes
2,168

if that's the case then I apologise, but Felipe didn't actually say listbox.... he said dropdown list which could be taken to mean the conventional pf4.

Read only

0 Likes
2,168

Very true, Neil. There is always some confusion about the two. But in his code, he is using.....



CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = nombre_campo
values = it_lista1.

which tells me, that he is trying to use ListBoxes.

Regards,

Rich Heilman

Read only

0 Likes
2,168

Rich,

Thanks, as you sugested, the best thing to do is a change in the application design. I was trying to do an imposible task. Thank you for your help.

And thanks to all for the comments.

Felipe

Read only

0 Likes
2,168

Good Decision. Glad to help.

Regards,

Rich Heilman

Read only

venkat_o
Active Contributor
0 Likes
2,168

Hi Felipe Andres Contreras,

To get Drop Drown Box on screen .

Follow these steps.

<b>1</b>.

Go to T.Code SE51 and Select Laypout for the Screen.

<b>2</b>.

Double click on the field for which u want Dropdown box.

<b>3</b>.

Then U will see Name ,Text ,DROPDOWN.Click on that and select List Box or ListBox with key . Better to to select first one.

<b>4</b>.

Save and Activate ur screen .

<b>5</b>.

Enter the following peice of code in the PBO of the screen.(Change for ur requirement).

<b>TYPE-POOLS :vrm</b>.

DATA:i_natio TYPE vrm_values,

w_natio LIKE LINE OF i_natio.

DATA: BEGIN OF i_t005t OCCURS 0,

land1 TYPE t005t-land1,

natio TYPE t005t-natio,

END OF i_t005t.

IF i_t005t[] IS INITIAL.

SELECT land1 natio

FROM t005t

INTO TABLE i_t005t

WHERE spras = sy-langu.

IF sy-subrc = 0.

LOOP AT i_t005t .

w_natio-key = i_t005t-land1.

w_natio-text = i_t005t-natio.

APPEND w_natio TO i_natio.

CLEAR w_natio.

ENDLOOP.

ENDIF.

ENDIF.

CALL FUNCTION <b>'VRM_SET_VALUES'</b>

EXPORTING

id = 'I_IT0002-NATIO'<b> This is screen field name</b>

values = i_natio

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.

<b>6</b>.

Observe the above code and change as for ur requirement.

I think it helps a lot.

Let me know ,if u have any problem creating Dropdownbox.

<b>Thanks,

Venkat.O</b>

Read only

Former Member
0 Likes
2,168

hi ,

As Rich said the values showing for that will be same for

all the rows in the table control.

List is the internal table holding the values to be displayed in the drop down

z123-kostl is the field in the table control for which you need drop down.

all this has to be in PBO

type-pools : vrm.

DATA: LIST TYPE VRM_VALUES,

VALUE LIKE LINE OF LIST,

  • NAME TYPE VRM_ID.

VRM_ID TYPE VRM_VALUE-TEXT.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = 'z123-kostl'

VALUES = 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.

let me know if you need anything else.

Read only

Former Member
0 Likes
2,168

Hi,

Check the Demo Program <b>RSDEMO_TABLE_CONTROL</b>

Regards

vijay

Read only

Former Member
0 Likes
2,168

I have used the type pool VRM to create the drop down in IW31 using the enhancement IWO10018. The drop down menu comes correctly.The field is a mandatory field.The selected value is also shown in the textbox.But when I click on any other tab of the screen,the selected value is deleted and system again asks to fill the value saying 'Fill in all mandatory fields'.

How to capture the selected value so that it can be used for further processing ?