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

Drop down list for fields in table control

Former Member
0 Likes
7,406

Hi,

I have drop down list box on table control screen on particular field . i have displayed data on table control screen.i need to have possible entries in that list box.

These list box values needs to be added manually ( They do not come from any table)

I have 6 values to be displayed in this list, which the users must select for this field.

Please let me know how i can do this

10 REPLIES 10
Read only

former_member194669
Active Contributor
0 Likes
4,098

Hi,

Follow these steps.

1.

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

2.

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

3.

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

4.

Save and Activate ur screen .

5.

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


TYPE-POOLS :vrm.
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 'VRM_SET_VALUES'
EXPORTING
id = 'I_IT0002-NATIO'
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.

Please check the program RSDEMO_TABLE_CONTROL

a®

Read only

0 Likes
4,098

I have seen this code previously. It is valid if u have data in some table.

Here i have 6 records that aren't in any table

Read only

0 Likes
4,098

Hi,

Please check the modified code


TYPE-POOLS :vrm.
DATA:i_natio TYPE vrm_values,
w_natio LIKE LINE OF i_natio.
 
w_natio-key = 'ABC'.     "<< Append your 6 values here
w_natio-text = 'TEST ABC'.
APPEND w_natio TO i_natio.

w_natio-key = 'CDE'.
w_natio-text = 'TEST CDE'.
APPEND w_natio TO i_natio.

CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'I_IT0002-NATIO'
values = i_natio
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
IF sy-subrc <> 0.

ENDIF.

a®

Read only

0 Likes
4,098

Hi,

Thanks for your detailed response.

I tried implementing your code. But it doesnt show the drop down list.

I am not sure where i am making a mistake.

Read only

0 Likes
4,098

Please try below code ,use the code within loop ,here use field statement.

PROCESS AFTER INPUT.

LOOP AT t_tcdata. -> t_tcdata is the internal table for your table control

FIELD table-field MODULE validate_value.

endloop.

MODULE validate_value INPUT.

tables: tvdir.

type-pools: vrm.

data: name type vrm_id,

list type vrm_values,

value like line of list.

name = 'P_TABNM'.

refresh list.

value-key = 'V_024'.

value-text = text-002. "'V_024-Purchasing Groups'.

append value to list.

value-key = 'V_T024D'.

value-text = text-003. "'V_T024D-MRP Controllers'.

append value to list.

value-key = 'ZT604'.

value-text = text-004. "'T604-Commodity Codes'.

append value to list.

value-key = 'T179'.

value-text = text-005. "'T179-Product Hierarchies'.

append value to list.

value-key = 'TVM1T'.

value-text = text-006. "'TVM1T-Business Manager'.

append value to list.

value-key = 'TVM2T'.

value-text = text-007. "'TVM2T-Division manager'.

append value to list.

value-key = 'TVM3T'.

value-text = text-008. "'TVM3T-Director'.

append value to list.

value-key = 'V_TVV2'.

value-text = text-009. "'V_TVV2-Customer Group 2'.

append value to list.

call function 'VRM_SET_VALUES'

exporting

id = name

values = list.

ENDMODULE.

Thanks

Seshu

Read only

0 Likes
4,098

Hi,

Have you enabled the list box property of this field. ie in layout double click in the field and there you can find dropdown property for the field , and make it as listbox

aRs

Read only

0 Likes
4,098

Hi,

I tried your code and it still doesnt work.

In the previous posts some one said , we need to put this code in PBO. You were saying PAI.

Please let me know how do i relate this code to my field in table control.

Here is the code that i have in my program.

Please do correct and let me know

---I need this list for activity field....

LOOP AT T_PM013_DISCONNECT.

CHAIN.

FIELD WA_PM013_DISCONNECT-ORDER#.

FIELD WA_PM013_DISCONNECT-COMP_DATE.

FIELD WA_PM013_DISCONNECT-METER_READ.

FIELD WA_PM013_DISCONNECT-ACTIVITY MODULE VALIDATE_VALUE.

FIELD WA_PM013_DISCONNECT-FILED_NOTES.

ENDCHAIN.

Data:i_name type vrm_id,

i_atype TYPE vrm_values,

w_atype like line of i_atype.

i_name = 'T_PM013_DISCONNECT'.

Refresh I_atype.

w_atype-key = '1'.

w_atype-text = 'Leave ON'.

append w_atype to i_atype.

w_atype-key = '2'.

w_atype-text = 'Regular'.

append w_atype to i_atype.

w_atype-key = '3'.

w_atype-text = 'Pulled'.

append w_atype to i_atype.

w_atype-key = '4'.

w_atype-text = 'Plugged'.

append w_atype to i_atype.

w_atype-key = '5'.

w_atype-text = 'Padlocked'.

append w_atype to i_atype.

w_atype-key = '6'.

w_atype-text = 'Canceled'.

append w_atype to i_atype.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = i_name

values = i_atype

EXCEPTIONS

id_illegal_name = 1

OTHERS = 2.

IF sy-subrc <> 0.

ENDIF.

Read only

0 Likes
4,098

I have enabled it as list box. But how do i relate that field to the code that you have given me...

Read only

0 Likes
4,098

Hello Narendra,

Check the below code ,i have tested and it works great..

I have taken work area for table control fields

data : begin of i_data ,

matnr(10) type c,

maktx(10) type c,

end of i_data.

PROCESS BEFORE OUTPUT.

loop with control tc.

module modify. -> I written the code here

endloop.

MODULE STATUS_9000.

*

PROCESS AFTER INPUT.

loop with control tc."at i_data.

endloop.

MODULE USER_COMMAND_9000.

MODULE modify OUTPUT.

tables: tvdir.

type-pools: vrm.

data: name type vrm_id,

list type vrm_values,

value like line of list.

name = 'I_DATA-MAKTX'. -> field name

refresh list.

value-key = 'V_024'.

value-text = text-002. "'V_024-Purchasing Groups'.

append value to list.

value-key = 'V_T024D'.

value-text = text-003. "'V_T024D-MRP Controllers'.

append value to list.

value-key = 'ZT604'.

value-text = text-004. "'T604-Commodity Codes'.

append value to list.

value-key = 'T179'.

value-text = text-005. "'T179-Product Hierarchies'.

append value to list.

value-key = 'TVM1T'.

value-text = text-006. "'TVM1T-Business Manager'.

append value to list.

value-key = 'TVM2T'.

value-text = text-007. "'TVM2T-Division manager'.

append value to list.

value-key = 'TVM3T'.

value-text = text-008. "'TVM3T-Director'.

append value to list.

value-key = 'V_TVV2'.

value-text = text-009. "'V_TVV2-Customer Group 2'.

append value to list.

call function 'VRM_SET_VALUES'

exporting

id = name

values = list.

Please enable list box in table control field

Thanks

Seshu

ENDMODULE. " modify OUTPUT

Read only

Former Member
0 Likes
4,098

done