07-24-2008 7:03 PM
hi guys, I'm kind of lost, can anybody tellme the steps to create a dropdown listbox? I need to now, how to set its values and where I decide the next step after certain option was selected.
Thank you.
07-24-2008 7:07 PM
Hi,
Check the demo program DEMO_DYNPRO_DROPDOWN_LISTBOX
Thanks
Naren
07-25-2008 4:29 AM
Hi Euclides,
Check this link for creation of drop down list box:
http://sap.niraj.tripod.com/id38.html
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbabe435c111d1829f0000e829fbfe/content.htm
Hope this helps you.
Regards,
Chandra Sekhar
07-25-2008 4:51 AM
Hi Euclides,
You can create a list box according to ur need in the following way...
LIST BOX
Drop down list box can be created in a dialog screen(SE51) as well as selection screen.
The sap list box allows to select a value from the list but we cannot enter our own value in the list box .The value list that will be displayed consists of two
fields TEXT field of TYPE 80(C) and internal KEY field of TYPE 40(C).
In screen painter to create a input/output field into list box we use
'L" as a value for dropdown attribute for the i/o field.
In screen painter to determine the type of method that will be used to fill the value
list we use the attribute value list.
If it is blank the value list will be filled by the first column of the input help assigned to the screen field.This input help can be defined in the ABAP Dictionary, on screen using SELECT,VALUES screen statements or in event POV (PROCESS ON VALUE-REQUEST ) and the input help that will be passed to the field should consists of 2 columns ,the key column is filled automatically by the system.SAP recommends value list field should be blank.
or
The value can be 'A' meaning that the value list will be filled in the event PBO(PROCESS BEFORE OUTPUT) or before the screen is displayed.In this method we use function module VRM_SET_VALUES to fill the values and pass it to the i/o field.
If a function code is attached to the list box the selection of a value triggers a PAI
otherwise PAI will not trigger.
LIST BOX in SELECTION SCREEN
List Box is created in selection screen using PARAMETERS staement
with AS LISTBOX addition other attributes like VISIBLE LENGTH (width of listbox)
can be specified with the declaration.
PARAMETERS name(n) AS LISTBOX VISIBLE LENGTH n.
Here n is an integer and name is the name of parameter.
To populate the value list we use the FM VRM_SET_VALUES and the
selection screen event AT SELECTION-SCREEN OUTPUT is used to write the code to fill it.
VRM_SET_VALUES
The function module VRM_SET_VALUES is used to fill the value list associated with a List Box .This FM uses types which are declared in type group VRM. So
we should declare TYPE-POOLS VRM before using this FM.
Some important types declared in the VRM type group are
VRM_ID
It refers to the name of the input/output field associated with list box
VRM_VALUES
It refers to the internal table consisting of two fields TEXT(80C) and KEY(40)C
that will be used to create the list values.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = name of screen element ,it is of TYPE VRM_ID
VALUES = internal table containing values,of TYPE VRM_VALUES
LIST BOX with value list from input help
In this example the screen element attribute value list is set to blank as such the value list will be filled with the 1st column of the input help,We use PROCESS ON VALUE-REQUEST event to pass the value list to the listbox.In the MODULE call used to fill the value list we can use FM like F4IF_INT_TABLE_VALUE_REQUEST to create input help as explained in the input help.The value of first column will be shown in the field when selected.
PROCESS ON VALUE-REQUEST
FIELD list MODULE fill_list_100
FIELD list MODULE fill_list_100 INPUT
SELECT f1 f2 FROM table INTO int
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'input/output screen field'
value_org = 'S'
TABLES
value_tab = itab "it contains 2 fields that will be shown in the list box
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
...
ENDIF.
ENDMODULE.
VALUE LIST CREATED IN PBO
In this method we set the value list attribute to 'A'.The value list will be filled in the PBO by using FM VRM_SET_VALUES .
TYPE-POOLS : VRM
DATA : field_id TYPE VRM_ID ,
values TYPE VRM_VALUES,
value LIKE LINE OF values.
PROCESS BEFORE OUTPUT
MODULE list_fill_100
MODULE list_fill_100 OUTPUT
SELECT f1 f2 f3 FROM tab WHERE condition.
value-KEY = f1.
value-TEXT = f2
APPEND value TO VALUES
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'i/o screen field'
values = values.
ENDMODULE.
LIST BOX with Selection Screen
For this the FM VRM_SET_VALUES is used to fill the value table and is passed to the parameter created with TYPE LISTBOX in the selection screen event
AT SELECTION-SCREEN.
PROGRAM zlist
TYPE-POOLS : VRM.
DATA: param TYPE vrm_id,
values TYPE vrm_values,
value LIKE LINE OF values.
PARAMETERS: p_name(10) AS LISTBOX VISIBLE LENGTH 10.
AT SELECTION-SCREEN OUTPUT.
param = 'P_NAME'.
value-key = '1'.
value-text = 'JOHN'.
APPEND value TO values.
value-key = '2'.
value-text = 'PETER'.
APPEND value TO values.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING id = param
values = values.
Thanks & Regards
Ashu Singh.
07-25-2008 6:16 AM
Hi
Declare the LISTBOX on the selection screen as follows..
PARAMETERS: P1 AS LISTBOX VISIBLE LENGTH <n>.
Set the values in the LISTBOX In the INITIALIZATION EVENT using the
Function Module "VRM_GET_VALUES" .
Hope this would help you.
Murthy
07-25-2008 6:33 AM
Hi Euclides Lopez,
Try the following code
*----------------------------------------------------------------------*
* Type pool declarations *
*----------------------------------------------------------------------*
TYPE-POOLS:
slis, " Global types for generic list
vrm. " Value Request Manager
*----------------------------------------------------------------------*
* Tables declaration *
*----------------------------------------------------------------------*
TABLES:
ekko. " Purchasing Document Header
*----------------------------------------------------------------------*
* Field strings declaration *
*----------------------------------------------------------------------*
DATA:
fs_event TYPE slis_alv_event, " Used to trigger top-of-page
* To capture return values of ZWOODWARDPO function module
fs_return TYPE bapiret2,
* To fill fieldcatlog
fs_fieldcat TYPE LINE OF slis_t_fieldcat_alv.
*----------------------------------------------------------------------*
* Internal tables declaration *
*----------------------------------------------------------------------*
DATA:
* To hold the purchase order related data
t_podata TYPE STANDARD TABLE
OF zwoodwardpo,
* To hold event names for ALV list display
t_events TYPE slis_t_event,
* To hold field catlog information
t_fieldcat TYPE slis_t_fieldcat_alv,
t_materials TYPE STANDARD TABLE " To hold material numbers
OF zmaterialnum,
t_phierars TYPE STANDARD TABLE " To hold product hierarchies
OF zphierarchy,
t_accounts TYPE vrm_values. " To hold bank accounts
*----------------------------------------------------------------------*
* Constants *
*----------------------------------------------------------------------*
CONSTANTS:
c_msgtyp_e TYPE bapiret2-type
VALUE 'E', " Message type : E
c_msgtyp_s TYPE bapiret2-type
VALUE 'S', " Message type : S
c_tabname LIKE fs_fieldcat-tabname
VALUE 'T_PODATA', " Table name : T_PODATA
c_onli TYPE sy-ucomm
VALUE 'ONLI', " Function code : ONLI
c_bacc_a TYPE c
VALUE 'A', " Baccount account : A
c_bacc_b TYPE c
VALUE 'B', " Baccount account : B
c_bacc_c TYPE c
VALUE 'C'. " Baccount account : C
PARAMETERS:
p_bacc TYPE char35 " Bank account
AS LISTBOX VISIBLE LENGTH 30
LOWER CASE.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON VALUE-REQUEST *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_bacc.
PERFORM fill_accounts.
PERFORM display_accounts.
*----------------------------------------------------------------------*
* FORM FILL_ACCOUNTS *
*----------------------------------------------------------------------*
* This subroutine is used to fill accounts for the drop down facility *
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine. *
*----------------------------------------------------------------------*
FORM fill_accounts .
DATA:
* Field string to fill bank accounts
lfs_accounts TYPE LINE OF vrm_values.
REFRESH t_accounts.
lfs_accounts-key = c_bacc_a.
lfs_accounts-text = text-baa.
APPEND lfs_accounts TO t_accounts.
lfs_accounts-key = c_bacc_b.
lfs_accounts-text = text-bab.
APPEND lfs_accounts TO t_accounts.
lfs_accounts-key = c_bacc_c.
lfs_accounts-text = text-bac.
APPEND lfs_accounts TO t_accounts.
ENDFORM. " FILL_ACCOUNTS
*----------------------------------------------------------------------*
* FORM DISPLAY_ACCOUNTS *
*----------------------------------------------------------------------*
* This subroutine is used to display list box in Bank account field. *
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine. *
*----------------------------------------------------------------------*
FORM display_accounts .
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_BACC'
values = t_accounts[]
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF SY-SUBRC NE 0
ENDFORM. " DISPLAY_ACCOUNTS
Regards,
Mahi.