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 field

Former Member
0 Likes
851

New ABAPer here (as will be evident by my question). I need to put a drop-down field tied to a list of valid values on a selection screen. I'm using a SELECT to put the valid values (not all the values in the table are valid) in an internal table along with their literal translations. It's the literal translations I need in the drop down list.

My gut tells me there must be a function or method or something to tie the internal table to the selection field. I found F4IF_INT_TABLE_VALUE_REQUEST although I'm not sure this is what I want.

Any suggestions?

1 ACCEPTED SOLUTION
Read only

vinod_gunaware2
Active Contributor
0 Likes
815

report z.

type-pools: vrm.

data: it_val type vrm_values,

w_line like line of it_val.

parameters p_bukrs like t001-bukrs as listbox

visible length 25 obligatory.

initialization.

select bukrs butxt from t001 into (w_line-key, w_line-text).

append w_line to it_val.

check p_bukrs is initial.

p_bukrs = w_line-key.

endselect.

at selection-screen output.

call function 'VRM_SET_VALUES'

exporting

id = 'P_BUKRS'

values = it_val.

end-of-selection.

write: / 'Company Code:', p_bukrs.

regards

vinod

6 REPLIES 6
Read only

Former Member
0 Likes
815

u can use FM VRM_SET_VALUES

Read only

Former Member
0 Likes
815

Hi Jane,

You will have to program a AT SELECTION-SCREEN ON VALUE-REQUEST FOR <selection field> in your program.

Regards,

John.

Read only

vinod_gunaware2
Active Contributor
0 Likes
816

report z.

type-pools: vrm.

data: it_val type vrm_values,

w_line like line of it_val.

parameters p_bukrs like t001-bukrs as listbox

visible length 25 obligatory.

initialization.

select bukrs butxt from t001 into (w_line-key, w_line-text).

append w_line to it_val.

check p_bukrs is initial.

p_bukrs = w_line-key.

endselect.

at selection-screen output.

call function 'VRM_SET_VALUES'

exporting

id = 'P_BUKRS'

values = it_val.

end-of-selection.

write: / 'Company Code:', p_bukrs.

regards

vinod

Read only

Former Member
0 Likes
815

Hi Jane,

Have a look at the following code in which I am displaying a list of values from an internal table into a Drop Down. I am picking all the values from the database.

Please reward some appropriate points if it helps you.

Feel free to ask any other query regarding the same.

Data: gv_dynpro TYPE sy-repid,

gv_dynnr TYPE sy-dynnr,

gv_status TYPE crm_j_status.

DATA: gv_screen_field TYPE help_info-dynprofld.

*Global internal table declaration.

DATA: git_returntab TYPE TABLE OF ddshretval.

*Global work areas.

DATA: wa_returntab LIKE LINE OF git_returntab.

  • Parameter for the Status

PARAMETERS: p_status TYPE crm_j_status AS LISTBOX VISIBLE LENGTH 18.

*F4 Help for Status

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_status.

gv_screen_field = gc_screen_field_status.

PERFORM fa000_f4help_status TABLES git_returntab

USING gv_screen_field.

READ TABLE git_returntab INTO wa_returntab INDEX 1.

p_status = wa_returntab-fieldval.

&----


*& Form fa000_f4help_status

&----


  • F4 Help for transaction type

----


  • -->xv_screen_fields Return field

  • <--yt_returntab Return value table

----


FORM fa000_f4help_status TABLES yt_returntab STRUCTURE ddshretval

USING xv_screen_fields TYPE help_info-dynprofld.

*Local constants.

CONSTANTS: lc_status TYPE dfies-fieldname

VALUE 'STATUS'.

IF git_status1 IS INITIAL.

*Retrieve All the status and the status text

SELECT estat txt30

INTO TABLE git_status1

FROM tj30t

WHERE stsma = gc_stsma

AND spras = sy-langu.

CHECK sy-subrc EQ 0.

gv_dynpro = sy-repid.

gv_dynnr = sy-dynnr.

*Display the F4 Help

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = lc_status

dynpprog = gv_dynpro

dynpnr = gv_dynnr

dynprofield = xv_screen_fields

value_org = gc_value_org

TABLES

value_tab = git_status1

return_tab = yt_returntab

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS = 3.

*Error message if F4 help not found

IF sy-subrc <> 0.

MESSAGE ID gc_msg_class

TYPE gc_error

NUMBER gc_msgno_057

DISPLAY LIKE 'E'.

flg_err = gc_x.

EXIT.

ENDIF.

ENDIF.

ENDFORM. " fa000_f4help_status

Read only

Former Member
0 Likes
815

Hi,

check this demo..

<b>DEMO_SELECTION_SCREEN_F4</b>

Regards

Vijay

Read only

Former Member
0 Likes
815

Hi Jane,

You just copy the following code and execute it , you will get dropdown list as you have asked. There you can select the values in first list box . Automatically, the second listbox will contain the corresopnding values which is also in the form of dropdown list.

********Start of Program

REPORT ZKUNAL_LISTBOX1 .

type-pools : vrm.

tables : sflight.

data : begin of itab occurs 0 ,

carrid like sflight-carrid,

connid like sflight-connid,

end of itab.

data : name type vrm_id,

list type vrm_values,

value like line of list.

parameters : p_carrid like sflight-carrid as listbox visible length 12 user-command LIST,

p_connid like sflight-connid as listbox visible length 12 user-command box.

name = p_carrid. " it is character, so code is not needed.

clear itab[].

CLEAR LIST[].

select carrid from sflight into table itab.

loop at itab.

value-key = itab-carrid .

value-text = itab-carrid.

append value to list.

endloop.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = name

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.

at selection-screen.

case sy-ucomm.

when 'LIST'.

clear itab[].

clear list[].

name = 'p_connid'. " it is numeric so code is needed.

p_connid = ''.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = name

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.

select distinct carrid connid from sflight into table itab where carrid = p_carrid.

loop at itab.

value-key = itab-connid.

value-text = itab-connid.

append value to list.

endloop.

endcase.

name = 'p_connid'.

at selection-screen output.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = name

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.

clear list[].

clear itab[].

*******End of Program

Regards,

Kunal.

Message was edited by: Kunal Kumar