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 in Screen.

Former Member
0 Likes
3,044

Hi,

I have a requirement where i have to select material no from mara and populate in the drop down list based on the mtart entered in a text box.

i have written follwong code but F4 key doesnt fetch any value is enter is not pressed.

screen has got 2 fields.

T_MAT_TYP - Inpu/output field

MARA-MATNR - list box.

PROCESS BEFORE OUTPUT.

MODULE status_0100.

*

PROCESS AFTER INPUT.

MODULE user_command_0100.

PROCESS ON VALUE-REQUEST.

FIELD mara-matnr MODULE generate_mat_drop_down.

MODULE generate_mat_drop_down INPUT.

IF NOT t_mat_typ IS INITIAL.

SELECT matnr mtart FROM mara INTO TABLE itab_mara

WHERE mtart = t_mat_typ.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'MATNR'

value_org = 'S'

TABLES

value_tab = itab_mara

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS = 3.

IF sy-subrc <> 0.

...

ENDIF.

ENDIF.

ENDMODULE. " generate_mat_drop_down INPUT

request you help me..

Thankx in advance

Regards

Vivek

Hi,

I have a requirement where i have to select material no from mara and populate in the drop down list based on the mtart entered in a text box.

i have written follwong code but F4 key doesnt fetch any value is enter is not pressed.

screen has got 2 fields.

T_MAT_TYP - Inpu/output field

MARA-MATNR - list box.

PROCESS BEFORE OUTPUT.

MODULE status_0100.

*

PROCESS AFTER INPUT.

MODULE user_command_0100.

PROCESS ON VALUE-REQUEST.

FIELD mara-matnr MODULE generate_mat_drop_down.

MODULE generate_mat_drop_down INPUT.

IF NOT t_mat_typ IS INITIAL.

SELECT matnr mtart FROM mara INTO TABLE itab_mara

WHERE mtart = t_mat_typ.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'MATNR'

value_org = 'S'

TABLES

value_tab = itab_mara

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS = 3.

IF sy-subrc <> 0.

...

ENDIF.

ENDIF.

ENDMODULE. " generate_mat_drop_down INPUT

request you help me..

Thankx in advance

Regards

Vivek

18 REPLIES 18
Read only

Former Member
0 Likes
2,174

Hi,

You can use it in the process on value request.It will help you to fetch the values as per your wish

Read only

Former Member
0 Likes
2,174

hi ,

Use FM VRM_SET_VALUES

Chck

http://www.sap-img.com/ab012.htm

<b>REWARDS IF USEFUL,</b>

SWATI

Read only

Former Member
0 Likes
2,174

Hi

Debug and see whether the values are coming into internal table itab_mara from MARA?

I doubt it. check

see the sample doc for this type of requirement

For F4 Values on Screen:

PROCESS ON VALUE_REQUEST

using module call starting with FIELD i.e FIELD field MODULE module

There are number of function modules that can be used for the purpose, but these

can fullfill the task easily or combination of them.

DYNP_VALUE_READ

F4IF_FIELD_VALUE_REQUEST

F4IF_INT_TABLE_VALUE_REQUEST

POPUP_WITH_TABLE_DISPLAY

DYNP_VALUE_READ

This function module is used to read values in the screen fields. Use of this

FM causes forced transfer of data from screen fields to ABAP fields.

There are 3 exporting parameters

DYNAME = program name = SY-CPROG

DYNUMB = Screen number = SY-DYNNR

TRANSLATE_TO_UPPER = 'X'

and one importing TABLE parameter

DYNPFIELDS = Table of TYPE DYNPREAD

The DYNPFIELDS parameter is used to pass internal table of type DYNPREAD

to this FM and the values read from the screen will be stored in this table.This

table consists of two fields:

FIELDNAME : Used to pass the name of screen field for which the value is to

be read.

FIELDVALUE : Used to read the value of the field in the screen.

e.g.

DATA: SCREEN_VALUES TYPE TABLE OF DYNPREAD ,

SCREEN_VALUE LIKE LINE OF SCREEN_VALUES.

SCREEN_VALUE-FIELDNAME = 'KUNNR' . * Field to be read

APPEND SCREEN_VALUE TO SCREEN_VALUES. * Fill the table

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

DYNAME = SY-CPROG

DYNUMB = SY-DYNNR

TRANSLATE_TO_UPPER = 'X'

TABLES

DYNPFIELDS = SCREEN_VALUES.

READ TABLE SCREEN_VALUES INDEX 1 INTO SCREEN_VALUE.Now the screen value for field KUNNR is in the SCREEN_VALUE-FIELDVALUE and can be used for further processing like using it to fill the internal table to be used as parameter in F4IF_INT_TABLE_VALUE_REQUEST ETC.

F4IF_FIELD_VALUE_REQUEST

This FM is used to display value help or input from ABAP dictionary.We have to pass the name of the structure or table(TABNAME) along with the field name(FIELDNAME) . The selection can be returned to the specified screen field if three

parameters DYNPNR,DYNPPROG,DYNPROFIELD are also specified or to a table if RETRN_TAB is specified.

CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'

EXPORTING

TABNAME = table/structure

FIELDNAME = 'field name'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNR

DYNPROFIELD = 'screen field'

IMPORTING

RETURN_TAB = table of type DYNPREAD

.

F4IF_INT_TABLE_VALUE_REQUEST

This FM is used to dsiplay values stored in an internal table as input

help.This FM is used to program our own custom help if no such input help

exists in ABAP dictionary for a particular field. The parameter VALUE_TAB is used to pass the internal table containing input values.The parameter RETFIELD

is used to specify the internal table field whose value will be returned to the screen field or RETURN_TAB.

If DYNPNR,DYNPPROG and DYNPROFIELD are specified than the user selection is passed to the screen field specified in the DYNPROFIELD. If RETURN_TAB is specified the selectionis returned in a table.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = field from int table whose value will be returned

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'screen field'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = internal table whose values will be shown.

RETURN_TAB = internal table of type DDSHRETVAL

EXCEPTIONS

parameter_error = 1

no_values_found = 2

others = 3.

POPUP_WITH_TABLE_DISPLAY

This FM is used to display the contents of an internal table in a popup window.The user can select a row and the index of that is returned in the CHOISE

parameter.The VALUETAB is used to pass the internal table.

A suitable title can be set using TITLETEXT parameter. The starting and end position of the popup can be specified by the parameters STARTPOS_COL / ROW and ENDPOS_ROW / COL .

CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'

EXPORTING

ENDPOS_COL =

ENDPOS_ROW =

STARTPOS_COL =

STARTPOS_ROW =

TITLETEXT = 'title text'

IMPORTING

CHOISE =

TABLES

VALUETAB =

EXCEPTIONS

BREAK_OFF = 1

OTHERS = 2.

e.g.

DATA: w_choice TYPE SY-TABIX.

DATA: BEGIN OF i_values OCCURS 0 WITH HEADER LINE,

values TYPE I,

END OF i_values.

PARAMETRS : id TYPE I.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR id

i_values-values = '0001'.

APPEND i_values.

i_values-values = '0002'.

APPEND i_values.

i_values-values = '0003'.

APPEND i_values.

i_values-values = '0004'.

APPEND i_values.

CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'

EXPORTING

ENDPOS_COL = 40

ENDPOS_ROW = 12

STARTPOS_COL = 20

STARTPOS_ROW = 5

TITLETEXT = 'Select an ID'

IMPORTING

CHOISE = w_choice

TABLES

VALUETAB = i_values

EXCEPTIONS

BREAK_OFF = 1

OTHERS = 2.

CHECK w_choice > 0.

READ TABLE i_values INDEX w_choice....now we can process the selection as it is contained

...in the structure i_values.

Other FM that may be used to provide input help is HELP_START .

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

0 Likes
2,174

Hi,

when i am pressing F4 nothing is getting trigerred. I want the data fetch should happen when i press F4. please tell me where i am wrong.

Regards

Vivek

Read only

Former Member
0 Likes
2,174

Give Return Tabv.

DATA t_1 LIKE ddshretval OCCURS 0 WITH HEADER LINE..

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

  • DDIC_STRUCTURE = ' '

retfield = 'KWMENG'

  • PVALKEY = ' '

  • DYNPPROG = SY-

  • DYNPNR = ' '

  • DYNPROFIELD = ' '

  • STEPL = 0

  • WINDOW_TITLE =

  • VALUE = ' '

value_org = 'S'

  • MULTIPLE_CHOICE = ' '

  • DISPLAY = ' '

  • CALLBACK_PROGRAM = ' '

  • CALLBACK_FORM = ' '

  • MARK_TAB =

  • IMPORTING

  • USER_RESET =

TABLES

value_tab = ITAB

  • FIELD_TAB =

return_tab = t_1

  • DYNPFLD_MAPPING =

  • EXCEPTIONS

  • PARAMETER_ERROR = 1

  • NO_VALUES_FOUND = 2

  • OTHERS = 3

.

IF sy-subrc = 0.

T_MAT-KWMENG = t_1-fieldval.

ENDIF.

Read only

Former Member
0 Likes
2,174

Hi Vivek,

INITIALIZATION.

fill your table.

SELECT matnr mtart FROM mara INTO TABLE itab_mara.

AT_SELECTION_SCREEN.

IF T_MAT_TYP is not initial.

DELETE from itab_mara WHERE mtart <> T_MAT_TYP .

ENDIF.

Hope this will help you out.

Regards.

Azad.

Reward if helpful.

Read only

former_member196280
Active Contributor
0 Likes
2,174

Try this,

see the below programs to fill the field with a valid listbox value, for example, in this program, I am building the listbox in the program and just assign P_FIELD a valid value from internal table'ivrm_values' . Create screen 100 and create a field call P_FIELD, make sure to select "ListBox" from the DropDown Field.

report zdrop_list_0001.

type-pools: vrm.

data: p_field(20) type c.

data: ivrm_values type vrm_values.

data: xvrm_values like line of ivrm_values.

data: name type vrm_id.

start-of-selection.

  • Set default value, before calling the screen

p_field = 'DEF'.

call screen 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


module status_0100 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

name = 'P_FIELD'.

xvrm_values-key = 'ABC'.

xvrm_values-text = 'ABC'.

append xvrm_values to ivrm_values.

xvrm_values-key = 'DEF'.

xvrm_values-text = 'DEF'.

append xvrm_values to ivrm_values.

xvrm_values-key = 'GHI'.

xvrm_values-text = 'GHI'.

append xvrm_values to ivrm_values.

call function 'VRM_SET_VALUES'

exporting

id = name

values = ivrm_values.

endmodule. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module user_command_0100 input.

endmodule. " USER_COMMAND_0100 INPUT

<b>Reward points to all useful answers.</b>

Regards,

SaiRam

Read only

0 Likes
2,174

for the first time when the screen is loaded the mtart field is initial. so the the selection doesnt fetch any data. that is correct. but when i press F4 the program should fetch values from mara on basis of value entered in Mtart. after activating debug when i press F4 nothing is triggered. please tell me where i am wrong.

regards

Vivek

Read only

0 Likes
2,174

Hey Vivek,

At selection screen event. when you press f4 before calling that function module.

fill your table based on mtype.

then pass it.

It should work man.

Regards

Azad.

Read only

former_member491305
Active Contributor
0 Likes
2,174

Hi Vivek,

Can you tell me when you press f4 for the material,the module <b>generate_mat_drop_down</b> which you are created is not at all called in debugging mode or not?. If it called,but there is no values in itab,then you have to use 'DYNP_VALUES_READ' statement to read the t_mat_typ value in screen.Then only the latest value in the screen for this field will come in t_mat_typ variable.

Check out the followin code.

DATA:BEGIN OF itab OCCURS 0,

matnr TYPE marc-matnr,

END OF itab.

DATA: it_ret LIKE TABLE OF ddshretval WITH HEADER LINE.

DATA:it_dyfld LIKE TABLE OF dynpread WITH HEADER LINE.

it_dyfld-fieldname = 'P_WERKS'.

APPEND it_dyfld.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

dyname = sy-repid

dynumb = sy-dynnr

TABLES

dynpfields = it_dyfld.

READ TABLE it_dyfld INDEX 1.

p_werks = it_dyfld-fieldvalue.

SELECT matnr

FROM marc

INTO TABLE itab WHERE werks = p_werks .

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'ITAB'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'P_MATNR'

value_org = 'S'

TABLES

value_tab = itab

  • return_tab = it_ret

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS = 3.

Read only

0 Likes
2,174

Hi Vijneswaran,

The module <b>generate_mat_drop_down </b> is not at all called in the debugging mode when i press F4.

Regards

Vivek

Read only

0 Likes
2,174

Hi,

May be you might have given incorrect field name in screen.Just make sure that both screen field name(MARA-MATNR) and variable name(MARA-MATNR) which you have declared should be same.Otherwise this module will not trigger.

Read only

0 Likes
2,174

I have used same field name as in the screen still it is not getting triggered,

please help.

Read only

0 Likes
2,174

data : begin of itab occurs 0,

kwmeng like vbap-kwmeng,

end of itab.

DATA t_1 LIKE ddshretval OCCURS 0 WITH HEADER LINE..

refresh itab.

clear itab.

refresh t_1.

clear t_1.

itab-kwmeng = '1'.

append itab.

itab-kwmeng = '2'.

append itab.

itab-kwmeng = '3'.

append itab.

itab-kwmeng = '4'.

append itab.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

  • DDIC_STRUCTURE = ' '

retfield = 'KWMENG'

  • PVALKEY = ' '

  • DYNPPROG = SY-

  • DYNPNR = ' '

  • DYNPROFIELD = ' '

  • STEPL = 0

  • WINDOW_TITLE =

  • VALUE = ' '

value_org = 'S'

  • MULTIPLE_CHOICE = ' '

  • DISPLAY = ' '

  • CALLBACK_PROGRAM = ' '

  • CALLBACK_FORM = ' '

  • MARK_TAB =

  • IMPORTING

  • USER_RESET =

TABLES

value_tab = ITAB

  • FIELD_TAB =

<b> return_tab = t_1</b>

  • DYNPFLD_MAPPING =

  • EXCEPTIONS

  • PARAMETER_ERROR = 1

  • NO_VALUES_FOUND = 2

  • OTHERS = 3

.

<b> IF sy-subrc = 0.

T_MAT-KWMENG = t_1-fieldval.

ENDIF.</b>

Read only

0 Likes
2,174

HI Sumi,

my problem is that once F4 is pressed no code is getting activated.

Regards

Vivek

Read only

0 Likes
2,174

Hi Vivek,

Dont give it as list box.If it is a list box then that module will trigger only when some event is triggered say 'Enter' or any othe function code(not for F4 or F1).So instead of giving it as list box just leave it as normat i/o field.Then it will work.If you still want listbox,Then you have to press 'ENTER' every time, after you have entered material type to see the updated search help.

Read only

0 Likes
2,174

Hi,

Call the code in a PROCESS ON VALUE REQUEST module.

Not in PROCESS AFTER INPUT module.

Since you want this to execute after F4 you need to assign a module of type Process on value request for this field.

PROCESS ON VALUE-REQUEST.

FIELD CARRIER MODULE VALUE_CARRIER.

MODULE value_carrier INPUT.

CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'

EXPORTING

tabname = 'DEMOF4HELP'

fieldname = 'CARRIER1'

dynpprog = progname

dynpnr = dynnum

dynprofield = 'CARRIER'.

ENDMODULE.

Regards,

Sesh

Read only

Former Member
0 Likes
2,174

Thanx

Changing List box to Input/output

worked.

Regards

Vivek