‎2007 Mar 23 4:56 PM
Hi Guys/Dolls
I want to declare a parameter in my program that when the program runs the user can only pick certain values and I can then use the value in my program.
Just like a combo-box or drop down list.
How do I do this - small snippet of code would be useful.
Many thanks in advance.
Raj
‎2007 Mar 23 5:33 PM
Try this.
TYPE-POOLS : vrm. "Value Request Manager
PARAMETERS: p_test AS LISTBOX VISIBLE LENGTH 20 OBLIGATORY.
INITIALIZATION.
PERFORM f4_value_request.
*&--------------------------------------------------------------------*
*& Form f4_value_request
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM f4_value_request.
DATA: l_name TYPE vrm_id,
li_list TYPE vrm_values,
l_value LIKE LINE OF li_list.
l_value-key = '1'.
l_value-text = 'Value 1'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '2'.
l_value-text = 'Value 2'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '3'.
l_value-text = 'Value 3'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '4'.
l_value-text = 'Value 4'.
APPEND l_value TO li_list.
CLEAR l_value.
l_name = 'P_TEST'.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = l_name
values = li_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.
ENDFORM. " f4_value_request
‎2007 Mar 23 5:33 PM
Try this.
TYPE-POOLS : vrm. "Value Request Manager
PARAMETERS: p_test AS LISTBOX VISIBLE LENGTH 20 OBLIGATORY.
INITIALIZATION.
PERFORM f4_value_request.
*&--------------------------------------------------------------------*
*& Form f4_value_request
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM f4_value_request.
DATA: l_name TYPE vrm_id,
li_list TYPE vrm_values,
l_value LIKE LINE OF li_list.
l_value-key = '1'.
l_value-text = 'Value 1'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '2'.
l_value-text = 'Value 2'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '3'.
l_value-text = 'Value 3'.
APPEND l_value TO li_list.
CLEAR l_value.
l_value-key = '4'.
l_value-text = 'Value 4'.
APPEND l_value TO li_list.
CLEAR l_value.
l_name = 'P_TEST'.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = l_name
values = li_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.
ENDFORM. " f4_value_request
‎2007 Mar 26 9:50 AM
Hi Srinivas
This seems exactly what I want but can you tell me how I get my chosen value out? I've ran this through the debugger but can't see it.
Basically I want to print it, after I have selected it.
Raj
‎2007 Mar 26 9:55 AM
Hi...,
parameters p_carrid type spfli-carrid as listbox visible length 10.
start-of-selection.
write p_carrid.
reward helpful answers..
sai ramesh
‎2007 Mar 26 9:56 AM
HI..
try this...
parameters:
p_c(10).
data:
begin of fs_tab,
field type YH642_F4,
end of fs_tab.
data:
t_tab like table of fs_tab.
data:
t_ft like table of dfies with header line.
initialization.
move 'RAM' to fs_tab-field.
append fs_tab to t_tab.
clear fs_tab.
move 'ram' to fs_tab-field.
append fs_tab to t_tab.
clear fs_tab.
move 'ananth_chetta' to fs_tab-field.
append fs_tab to t_tab.
at selection-screen on value-request for p_c.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
retfield = 'FIELD'
PVALKEY = ' '
DYNPPROG = sy-repid
DYNPNR = sy-dynnr
DYNPROFIELD = 'P_C'
STEPL = 0
WINDOW_TITLE =
VALUE =
VALUE_ORG = 'S'
MULTIPLE_CHOICE = ' '
DISPLAY = ' '
CALLBACK_PROGRAM =
CALLBACK_FORM = ' '
MARK_TAB =
IMPORTING
USER_RESET =
tables
value_tab = t_tab
FIELD_TAB =
RETURN_TAB =
DYNPFLD_MAPPING =
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
start-of-selection.
write p_c.
‎2007 Mar 26 10:04 AM
Use LISTBOW
TYPE-POOLS: VRM.
DATA: NAME TYPE VRM_ID,
LIST TYPE VRM_VALUES,
VALUE LIKE LINE OF LIST.
PARAMETERS: PS_PARM(10) AS LISTBOX VISIBLE LENGTH 10.
AT SELECTION-SCREEN OUTPUT.
NAME = 'PS_PARM'.
VALUE-KEY = '1'.
VALUE-TEXT = 'LINE 1'.
APPEND VALUE TO LIST.
VALUE-KEY = '2'.
VALUE-TEXT = 'LINE 2'.
APPEND VALUE TO LIST.
CALL FUNCTION 'VRM_SET_VALUES' EXPORTING ID = NAME VALUES = LIST.
Regards
‎2007 Mar 26 10:20 AM
Hi,
The function module SELECT_OPTIONS_RESTRICT can be used for restricting possible selection options and signs. By calling this function module, we can restrict the number of selection options available for a field. For more information, refer to the function module documentation.
The code was written in 4.6C.
Code
REPORT selectoptionsrestrict.
Include type pool SSCR
TYPE-POOLS sscr.
TABLES :
marc.
defining the selection-screen
select-options :
s_matnr for marc-matnr,
s_werks for marc-werks.
Define the object to be passed to the RESTRICTION parameter
DATA restrict TYPE sscr_restrict.
Auxiliary objects for filling RESTRICT
DATA : optlist TYPE sscr_opt_list,
ass type sscr_ass.
INITIALIZATION.
Restricting the MATNR selection to only EQ and 'BT'.
optlist-name = 'OBJECTKEY1'.
optlist-options-eq = 'X'.
optlist-options-bt = 'X'.
APPEND optlist TO restrict-opt_list_tab.
ass-kind = 'S'.
ass-name = 'S_MATNR'.
ass-sg_main = 'I'.
ass-sg_addy = space.
ass-op_main = 'OBJECTKEY1'.
APPEND ass TO restrict-ass_tab.
Restricting the WERKS selection to CP, GE, LT, NE.
optlist-name = 'OBJECTKEY2'.
optlist-options-cp = 'X'.
optlist-options-ge = 'X'.
optlist-options-lt = 'X'.
optlist-options-ne = 'X'.
APPEND optlist TO restrict-opt_list_tab.
ass-kind = 'S'.
ass-name = 'S_WERKS'.
ass-sg_main = 'I'.
ass-sg_addy = space.
ass-op_main = 'OBJECTKEY2'.
APPEND ass TO restrict-ass_tab.
CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
EXPORTING
restriction = restrict
EXCEPTIONS
TOO_LATE = 1
REPEATED = 2
SELOPT_WITHOUT_OPTIONS = 3
SELOPT_WITHOUT_SIGNS = 4
INVALID_SIGN = 5
EMPTY_OPTION_LIST = 6
INVALID_KIND = 7
REPEATED_KIND_A = 8
OTHERS = 9
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*****************
Reward point if answer found suitable.
Regards,
Irfan