Vous êtes sur la page 1sur 13

RSDEMO_DROPDOWN_LISTBOX SAP Report - Demo program for drop down list boxes

RSDEMO_DROPDOWN_LISTBOX is a standard ABAP report available within your SAP system (depending on your version and release level). Below is the standard documentation available for this report and a few details of other objects it interacts with such as tables, function modules, includes etc. If you would like to see the full code listing simply enter the object name( RSDEMO_DROPDOWN_LISTBOX ) into the relevant SAP transaction such as SE38 or SE80 Within the comments section below there is also an opportunity for anyone to be able add useful hints and information specific to this SAP object. This means that you and other users will be able to find these details quickly by simply searching on the object name.

TRANSACTION CODE: N/A


Includes used within report:
No INCLUDES are used within this report code!

Tables used within report and the associated select statement:


SCARR

SELECT carrid carrname

FROM scarr

INTO CORRESPONDING FIELDS OF TABLE itab_carrid. scarr.

SELECT * FROM scarr.

Function Modules used within report and the associated call statement:
F4IF_INT_TABLE_VALUE_REQUEST

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield

= 'CARRID'

value_org

= 'S'

TABLES

value_tab

= itab_carrid

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS VRM_SET_VALUES

= 3.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id

= 'SBOOK-CARRID'

values

= values[]

EXCEPTIONS

id_illegal_name = 1

OTHERS

= 2.

Text pool values

Title: Demo program for drop down list boxes

Dropdown Boxes
As well as input help, which appears in separate dialog boxes, you can also define input/output fields as dropdown boxes. A dropdown box offers the user a predefined set of input values from which to choose. It is not possible to type a entry into a dropdown box, instead, the user must use one of the values from the list. When the user chooses a value, the PAI event can be triggered simultaneously. If you use a dropdown box for a field, you cannot at the same time use the input help button. List boxes are currently the only type of dropdown box supported. A list box is a value list containing a single text column of up to 80 characters. Internally, each text field has a key of up to 40 characters. When the user chooses a line, the contents of the text field are placed in the input field on the screen, and the contents of the key are placed in the screen field. The contents and length of the input/output field and the screen field are not necessarily the same. To make an input/output field into a list box, you must set the value L or LISTBOX in the Dropdown attribute in the Screen Painter. The visLg attribute determines the output width of the list box and the field. You can assign a function code to a list box field. In this case, the PAI event is triggered as soon as the user chooses a value from the list, and the function code is placed in the SY-UCOMM and OK_CODE fields. If you do not assign a function code, the PAI event must be triggered in the usual way that is, when the user chooses a pushbutton or an element from the GUI status. If you have assigned a list box to an input/output field, you can use the Value list attribute of the screen element to determine how the value list should be compiled. There are two options: y Value list from input help (recommended) If you do not enter anything in the value list attribute, the text field uses the first column displayed in the input help assigned to the screen field. The input help can be defined in the ABAP Dictionary, the screen, or a POV dialog module. It should be laid out in two columns. The key is automatically filled. Value list from PBO modules (not recommended).

If you enter A in the value list attribute, you must fill the value list yourself before the screen is sent (for example, in the PBO event) using the function module VRM_SET_VALUES. When you do this, you must pass an internal table with the type VRM_VALUES to the import parameter VALUES of the function module. VRM_VALUES belongs to the type group VRM. The line type is a structure consisting of the two text fields KEY (length 40) and TEXT (length 80). In the table, you can combine possible user entries from the KEY field with any texts from the TEXT component. You specify the corresponding input/output field in the import parameter ID.

Examples
Dropdown box with a value list from input help (recommended) *&---------------------------------------------------------------* *& Report DEMO_DROPDOWN_LIST_BOX * *&---------------------------------------------------------------* REPORT demo_dropdown_list_box. *&---------------------------------------------------------------* *& Global Declarations * *&---------------------------------------------------------------* * Screen Interfaces TABLES sdyn_conn. DATA ok_code TYPE sy-ucomm. * Global data TYPES: BEGIN OF type_carrid, carrid type spfli-carrid, carrname type scarr-carrname, END OF type_carrid. DATA itab_carrid TYPE STANDARD TABLE OF type_carrid WITH HEADER LINE. *&---------------------------------------------------------------* *& Processing Blocks called by the Runtime Environment * *&---------------------------------------------------------------* * Event Block START-OF-SELECTION START-OF-SELECTION. CALL SCREEN 100. * Dialog Module PBO MODULE status_0100 OUTPUT. SET PF-STATUS 'SCREEN_100'. ENDMODULE. * Dialog Modules PAI MODULE cancel INPUT. LEAVE PROGRAM. ENDMODULE. * MODULE user_command_0100 INPUT. CASE ok_code. WHEN 'SELECTED'. MESSAGE i888(sabapdocu) WITH sdyn_conn-carrid. ENDCASE. ENDMODULE. * Dialog Module POV

MODULE create_dropdown_box INPUT. SELECT carrid carrname FROM scarr INTO CORRESPONDING FIELDS OF TABLE itab_carrid. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'CARRID' value_org = 'S' TABLES value_tab = itab_carrid EXCEPTIONS parameter_error = 1 no_values_found = 2 OTHERS = 3. IF sy-subrc <> 0. ... ENDIF. ENDMODULE. The next screen (statically defined) for screen 100 is 100. The only input field on the screen is the component SDYN_CONN-CARRID. Its Dropdown attribute is set to L, and it has the output length 20. The Value list attribute is empty, and it has the function code SELECTED. The function codes of the buttons EXECUTE and CANCEL. CANCEL are defined in the GUI status as having the function type E. The screen flow logic is as follows: PROCESS BEFORE OUTPUT. MODULE status_0100. PROCESS AFTER INPUT. MODULE cancel AT EXIT-COMMAND. MODULE user_command_0100. PROCESS ON VALUE-REQUEST. FIELD sdyn_conn-carrid MODULE create_dropdown_box. Users cannot enter any values into the screen fields. When they choose the input field on screen 100, the system displays a list box. The Value list attribute is empty, so the system launches the input mechanism. In this case, the event block PROCESS ON VALUEREQUEST is created in the screen flow logic. This event block controls all other mechanisms. A two-column internal table is filled in the appropriate dialog module and passed to the input help using the F4IF_INT_TABLE_VALUE_REQUEST function module. The system inserts the two columns of the table into the list box. When the user chooses a line in the list box, the PAI event is triggered using the function code SELECTED and the value in the first column of the internal table is copied to the input field.

Dropdown box with a value list from the PBO module for screen 200 (not recommended) REPORT demo_dynpro_dropdown_listbox. TYPE-POOLS vrm. DATA: name TYPE vrm_id, list TYPE vrm_values, value LIKE LINE OF list.

DATA: wa_spfli TYPE spfli, ok_code TYPE sy-ucomm, save_ok TYPE sy-ucomm. TABLES demof4help. name = 'DEMOF4HELP-CONNID'. CALL SCREEN 100. MODULE cancel INPUT. LEAVE PROGRAM. ENDMODULE. MODULE init_listbox OUTPUT. CLEAR demof4help-connid. SELECT connid cityfrom cityto deptime FROM spfli INTO CORRESPONDING FIELDS OF wa_spfli WHERE carrid = demof4help-carrier2. value-key = wa_spfli-connid. WRITE wa_spfli-deptime TO value-text USING EDIT MASK '__:__:__'. CONCATENATE value-text wa_spfli-cityfrom wa_spfli-cityto INTO value-text SEPARATED BY space. APPEND value TO list. ENDSELECT. CALL FUNCTION 'VRM_SET_VALUES' EXPORTING id = name values = list. ENDMODULE. MODULE user_command_100. save_ok = ok_code. CLEAR ok_code. IF save_ok = 'CARRIER' AND NOT demof4help-carrier2 IS INITIAL. LEAVE TO SCREEN 200. ELSE. SET SCREEN 100. ENDIF. ENDMODULE. MODULE user_command_200. save_ok = ok_code. CLEAR ok_code. IF save_ok = 'SELECTED'. MESSAGE i888(sabapdocu) WITH text-001 demof4help-carrier2 demof4help-connid. ENDIF. ENDMODULE. The next screen (statically defined) for screen 100 is 200. It has the following layout:

The component CARRIER2 of the ABAP Dictionary structure DEMOF4HELP is assigned to the input field. Its Dropdown attribute is set to L, and it has the output length 15. The Value list attribute is empty, and it has the function code CARRIER. The pushbutton has the function code CANCEL with function type E. The screen flow logic is as follows: PROCESS BEFORE OUTPUT. PROCESS AFTER INPUT. MODULE cancel AT EXIT-COMMAND. MODULE user_command_0100. The next screen (statically defined) for screen 200 is 100. It has the following layout:

The component CONNID of the ABAP Dictionary structure DEMOF4HELP is assigned to the input field. Its Dropdown attribute is set to L, and it has the output length 30. The Value list attribute is set to A, and it has the function code SELECTED. The pushbutton has the function code CANCEL with function type E. The screen flow logic is as follows: PROCESS BEFORE OUTPUT. MODULE init_listbox. PROCESS AFTER INPUT. MODULE cancel AT EXIT-COMMAND. MODULE user_command_200. The user cannot type any values into the screen fields. When he or she chooses the input field on screen 100, a value list appears in the list box, compiled from the input help for the

field DEMOF4HELP-CARRIER2. This is the search help H_SCARR, which is assigned to the check table SCARR. The value list contains the names of the airlines. When the user chooses an entry, the screen field is filled with the airline code, and the PAI event is triggered. The module USER_COMMAND_100 checks the OK_CODE field and calls screen 200. In the PBO event of screen 200, an internal table LIST is filled with values from the database table SPFLI. The KEY field is filled with the flight numbers, and other relevant information is placed in the TEXT field. The table LIST is then passed to the function module VRM_SET_VALUES. When the user chooses the input field on screen 200, the TEXT column of the internal table is displayed in the list box. When the user chooses an entry, the screen field is filled with the corresponding entry from the KEY field, and the PAI event is triggered. The module USER_COMMAND_200 checks and processes the OK_CODE field.

using FM 'F4IF INT TABLE VALUE REQUEST'


Asked by Unknown User | posted Oct 20, 2003 | Replies (7)

Hi All,

I'am using a function module 'F4IF_INT_TABLE_VALUE_REQUEST' to get a drop down list on a transaction screen.I have a internal table of two columns and i want both of them to be shown on the screen in the drop down.if any one from u has worked with this FM please let me know how to show all fields of an IT by using it.

regards

Vishwas
Popular White Paper On This Topic

Increase Application Performance With Solid State Disk

7 Replies
0

Puneet Gupta Replied Oct 20, 2003

Hi,

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD =3D <name of return field in internal table>

DYNPPROG =3D <Report Name i.e sy-repid>

DYNPNR =3D <Screen number e.g. 1000 incase of sel. screen)

DYNPROFIELD =3D <screen field name>

VALUE_ORG =3D 'S'

TABLES

VALUE_TAB =3D <internal Table with values>

EXCEPTIONS

PARAMETER_ERROR =3D 1

NO_VALUES_FOUND =3D 2

OTHERS =3D 3.

Regds Puneet
0

Rosie Brent Replied Oct 20, 2003

Vishwas

Have you looked at the documentation of the function module - it's pretty clear about populating the VALUE_TAB and FIELD_TAB for internal tables not defined in the DDIC.

Have a good look at the online documentation and come back if you are still experiencing difficulties.

Kind Regards / Mit freundlichen Gru?en

Rosie Brent Business Analyst / ABAP Programmer

ThyssenKrupp Automotive Tallent Chassis Newton Aycliffe, Co. Durham, England DL5 6EP.

Reception Phone +44 (0)1325 313232 Ext. 263 Mobile +44 (0)7748 982938 Email email@removed
0

Rosie Brent Replied Oct 20, 2003

Puneet

SY-REPID cannot be passed as DYNPPROG since the field is accessed by the Function Module itself and then will not contain the name of the report calling the function module.

VALUE_ORG = 'S' can only be used (as far as I can tell) if the internal table is defined as a DDIC Structure rather than programmatically designed in the calling program.

VALUE_TAB alone doesn't define the internal table, just the values to be assigned to the popup, the FIELD_TAB is necessary to give the definitions of each field within the internal table being passed.

This is precisely why I refered the original message poster to the documentation. This function is a complex one to use (you can find examples of it's implementation by using the 'where used' functionality in SAP), but it is further complicated by the variety of ways in which it can be used. Instead of us guessing what exactly Vishwas is trying to do it would be better if he attempted this himself, and came back with specific problems if

/ when he encounters them.

Kind Regards / Mit freundlichen Gru?en

Rosie Brent Business Analyst / ABAP Programmer

ThyssenKrupp Automotive Tallent Chassis Newton Aycliffe, Co. Durham, England DL5 6EP.

Reception Phone +44 (0)1325 313232 Ext. 263 Mobile +44 (0)7748 982938 Email email@removed

Top 0

Unknown User Replied Oct 20, 2003

He Brent,

I'am having problem with displaying two fields of an internal table at atime on the dropdownlist.

My fields are [NAME like knvk-namev(40)] and [E_MAIL like adr6-smtp_addr(241)].i'am calling the function module and defining it as : -

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING RETFIELD = 'E_MAIL' VALUE_ORG = 'S' TABLES VALUE_TAB = it_knvk2[internal table name] * FIELD_TAB EXCEPTIONS PARAMETER_ERROR = 1 NO_VALUES_FOUND = 2

OTHERS = 3

i'am getting only first field in output i.e NAME but i want both to be shown.

please let me know where i'am going wrong.

regards

vishwas

White Papers and Webcasts


Popular

y y y y

Increase Application Performance With Solid State Disk Related

Compliance and Data Governance for Google Docs with ... What PAS 55 Means for Enterprise Asset Management (EAM) ... Always-On Storage with Five-Nines Reliability More White Papers 0

Rosie Brent Replied Oct 20, 2003

If you populate FIELD_TAB with the technical descriptions of your two table fields in it_knvk2 it should work fine.

Pass the data-dictionary references to FIELD_TAB in TABNAME and FIELDNAME and the FM will understand what is being passed to it in it_knvk2.

Kind Regards / Mit freundlichen Gru?en

Rosie Brent Business Analyst / ABAP Programmer

ThyssenKrupp Automotive Tallent Chassis Newton Aycliffe, Co. Durham, England DL5 6EP.

Reception Phone +44 (0)1325 313232 Ext. 263 Mobile +44 (0)7748 982938 Email email@removed

Puneet Gupta Replied Oct 20, 2003

Hi Rosie, You are right we cannot use sy-repid instead we have to pass the repid via a variable to the FM or you can use sy-cprog.

VALUE_ORG =3D 'S' means that the data is being passes in the form of flat data structure this need not necessarily be a DDIC structure, it can also be an internal table. But here if we are using a DDIC structure we need to pass the parameter 'DDIC_STRUCUTRE'.

Also, in the internal table if the fields are defined like a DDIC field/data element then we do not need to pass the FIELD_TAB.

Quoting from the Documentation : "If all the fields have an explicit reference to a DDIC field (mit LIKE) or to a data element (with TYPE), the module itself can determine the structure of VALUE_TAB. In this case do not pass either DDIC_STRUCTURE or FIELD_TAB."

:) Let us wait for Vishwas to come back with the exact problem he's facing....

Regds Puneet
0

Puneet Gupta Replied Oct 20, 2003

Vishwas, Try this sample prog it works

REPORT ZTEST_F4 .

DATA : BEGIN OF ITAB OCCURS 0, NAME LIKE KNVK-NAMEV,

E_MAIL LIKE ADR6-SMTP_ADDR, END OF ITAB. PARAMETER : P_EMAIL LIKE ADR6-SMTP_ADDR.

INITIALIZATION. ITAB-NAME =3D 'A'. ITAB-E_MAIL =3D email@removed'. APPEND ITAB.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_EMAIL. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING RETFIELD =3D 'E_MAIL' DYNPPROG =3D 'ZTEST_F4' DYNPNR =3D '1000' DYNPROFIELD =3D 'P_EMAIL' VALUE_ORG =3D 'S' TABLES VALUE_TAB =3D ITAB EXCEPTIONS PARAMETER_ERROR =3D 1 NO_VALUES_FOUND =3D 2 OTHERS =3D 3 .

Vous aimerez peut-être aussi