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

Populate value for listbox

Former Member
0 Likes
1,138

Here is my listbox (ZDROPDOWNLIST).

http://img156.imageshack.us/img156/6797/screenwk1.png

How can I populate the value of my listbox according to the values of this SQL statement.

-


Select distinct PROGRAM_ID from ZPROGRAM_TABLE

-


Please give me codes example that retrieve value from SQL statement for listbox as I am bad in ABAP. Thank you. I shall reward points to all relevant answers.

Here is my listbox (ZDROPDOWNLIST).

http://img156.imageshack.us/img156/6797/screenwk1.png

How can I populate the value of my listbox according to the values of this SQL statement.

-


Select distinct PROGRAM_ID from ZPROGRAM_TABLE

-


Please give me codes example that retrieve value from SQL statement for listbox as I am bad in ABAP. Thank you. I shall reward points to all relevant answers.

3 REPLIES 3
Read only

Former Member
0 Likes
756

Hi JuzMe,

If you have the sql query ready then you assign it to the edit text box as formatted search.

first save sql query in Query generator(Query Manager)

place the cursor in the required edit text box.

then press CtrlShiftF2

choose the option Search by saved query.

Then select the saved query.

Then press Shift + F2 on that edit text(it will list the query results in a form)

or,

If your Sql query is based on one object(like items,Partners) You can use conditions while creating CFL.But if you are getting the data from multiple tables,Conditions object will not be useful.it seems like there is no way we can connect a sql Query to a CFL,But with Some workaround we can still have it(creating our own form for listing the query values).

kindly reward if found helpful.

cheers,

Hema.

Read only

Former Member
0 Likes
756

Hi JuzMe, check this code for declaring a listbox and to add options to that list box.

PARAMETERS - screen_options

Syntax

... { {NO-DISPLAY VISIBLE LENGTH vlen}

| {AS CHECKBOX USER-COMMAND fcode}

| {RADIOBUTTON GROUP group USER-COMMAND fcode}

| {AS LISTBOX VISIBLE LENGTH vlen USER-COMMAND fcode

OBLIGATORY} }

MODIF ID modid ... .

Extras:

1. ... OBLIGATORY

2. ... NO-DISPLAY

3. ... VISIBLE LENGTH vlen

4. ... AS CHECKBOX USER-COMMAND fcode

5. ... RADIOBUTTON GROUP group USER-COMMAND fcode

6. ... AS LISTBOX VISIBLE LENGTH vlen USER-COMMAND fcode

7. ... MODIF ID modid

Effect:

These additions can be used to declare the input field as a required field, hide the input field on the selection screen, and determine the visible length of the field. The input field can be displayed as a checkbox, radio button, or dropdown list box. All screen elements of the parameter can be assigned to a modification group.

Note:

The additions cannot be combined in just any combinations. The syntax above shows the permitted combinations.

Addition 1

... OBLIGATORY

Effect:

This addition defines the input field of the parameter on the selection screen as a required field. If no entry is made in this field, the user cannot use the Execute function (F8) to exit the selection screen, the user can only use the functions Back, Exit, or Cancel.

Addition 2

... NO-DISPLAY

Effect:

This addition means that no screen elements are generated for the parameter on the selection screen. In an executable program, a parameter of this type is exclusively a part of the interface defined by the selection screen. It can be supplied with a value by the calling program when called with SUBMIT.

If the addition NO-DISPLAY is specified, a parameter can have any data types except for reference types. These parameters can only be populated using the WITH addition to the SUBMIT statement. In this case, in contrast to the general conversion rule for deep types, the same rules apply as when importing data from a data cluster.

Note:

The length of a value transferred to a parameter for which there is no input field, is not subject to the 132 character restriction that applies for parameters with input fields.

Addition 3

... VISIBLE LENGTH vlen

Effect:

This addition defines the visible length of the input field as vlen, whereby vlen is entered directly as a positive number. If vlen is smaller than the length of the parameter and smaller than the maximum visible length, the input field is displayed in the length defined in vlen, with movable content. Otherwise, the addition is ignored.

Addition 4

... AS CHECKBOX USER-COMMAND fcode

Effect:

This addition specifies that the input field in the first position of the selection screen is displayed as a checkbox with the corresponding description next to it on the right. The checkbox is selected if the value of para is "X" or r "x". Otherwise, it is not selected.

The parameter must be created with the type c and length 1. An explicit length len is not permitted. If the addition TYPE is used, this can only be followed by the generic type c or a non-generic data type of type c and length 1.

The addition USER-COMMAND can be used to assign a function code fcode to the parameter. The function code fcode must be directly specified and may have a maximum length of 20 characters. To evaluate the function code, an interface work area of the structure SSCRFIELDS from the ABAP Dictionary must be declared using the statement TABLES. When the user selects the checkbox on the selection screen, the runtime environment triggers the event AT SELECTION-SCREEN and transfers the function code fcode to the component ucomm of the interface work area sscrfields. If a function code used in the GUI status of the selection screen is specified for fcode, the selection screen processing is affected accordingly.

Notes

If the TYPE addition is used to make a reference to a data type in the ABAP Dictionary of type CHAR and length 1, and for which t the valid values in the domain are defined as "X" and " ", the parameter is automatically displayed as a checkbox on the selection screen.

If the addition USER-COMMAND is specified without the addition AS CHECKBOX, and the parameter is of type c with length 1, it is also displayed as a checkbox.

The addition USER-COMMAND can, for example, be used for screen modifications with the addition MODIF ID (see example).

Addition 5

... RADIOBUTTON GROUP group USER-COMMAND fcode

Effect:

This addition specifies that the input field is displayed as a radio button in the first position on the selection screen, and the output field is displayed next to it on the right. The radio button is selected if the value of para is "X" or "x". Otherwise, it is not selected.

group is used to define the radio button group for the parameter. The name group is entered directly as a character string with a maximum of 4 characters. Within a selection screen, there must be a minimum of two parameters in the same radio button group. There cannot be more than one radio button group with the same name in one program, even if they are defined in different selection screens.

The parameter must be specified with the type c and length 1. Explicit length specification using len is not permitted. If the addition TYPE is used, it can only be followed by the generic type c or a non-generic data type of type

In a radio button group, only one parameter can be defined with the addition DEFAULT, and the specified value must be "X". By default, the first parameter in a radio button group is set to the value "X", and the rest are set to " ".

The addition USER-COMMAND can be used to assign a function code fcode to the first parameter in a radio button group. The function code fcode must be specified directly, and have a maximum length of 20 characters. To evaluate the function code, an interface work area of the structure SSCRFIELDS from the ABAP Dictionary must be declared using the statement TABLES. When the user selects any radio button of the radio button group on the selection screen, the runtime environment triggers the event AT SELECTION-SCREEN and transfers the function code fcode to the component ucomm of the interface work area sscrfields. If a function code used in the GUI status of the selection screen is specified for fcode, the selection screen processing is affected accordingly.

Note:

It is recommended to define the radio buttons of a radio button group directly underneath each other. If the selection screen also contains other elements, it is recommended to define each radio button group within a block surrounded by a frame.

Addition 6

... AS LISTBOX VISIBLE LENGTH vlen USER-COMMAND fcode

Effect:

This addition generates a dropdown list box for an input field on the selection screen. If the parameter is created with a data type from the ABAP Dictionary, and the data type is linked to the input help in the Dictionary, the first column of the input help is displayed in the list box. Otherwise, a single-line list box is displayed containing the current value of the parameter.

The addition VISIBLE LENGTH must be used to specify the visible length of the input field. The explicit specification of the length is necessary as the length of the entries in the list box is usually different to the actual length of the parameter.

The addition USER-COMMAND can be used to assign a function code fcode to the dropdown list box. The function code fcode must be specified directly and can have a maximum length of 20 characters. To evaluate the function code, an interface work area of the structure SSCRFIELDS from the ABAP Dictionary must be declared using the statement TABLES. When the user selects a line of the list box on the selection screen, the runtime environment triggers the event AT SELECTION-SCREEN and transfers the function code fcode to the component ucomm of the interface work area sscrfields. If a function code used in the GUI status of the selection screen is specified for fcode, the selection screen processing is affected accordingly.

Note:

Without the addition USER-COMMAND, selecting a line in the dropdown list box does not lead to the event AT SELECTION-SCREEN.

Example:

The parameter p_carrid is displayed with length 20 and with the name "Lufthansa" already entered. The user can select a different airline carrier, in which case a three-character abbreviation is assigned to the parameter. When assigning the function code onli which is assigned to the function Execute in the GUI status of the default selection screen, the events AT SELECTION-SCREEN and START-OF-SELECTION are triggered.

PARAMETERS p_carrid TYPE spfli-carrid

AS LISTBOX VISIBLE LENGTH 20

USER-COMMAND onli

DEFAULT 'LH'.

AT SELECTION-SCREEN.

...

START-OF-SELECTION.

...

Addition 7

... MODIF ID modid

Effect

The addition MODIF ID assigns all the screen elements of the parameter to the modification group modid, which is assigned to the column group1 of the system table screen. This enables them to be modified before the selection screen is displayed, using the statement MODIFY SCREEN. The name of the modification group modid must be directly specified and can have a maximum length of three characters.

Note

The modification groups that are assigned to columns group2 and group3 of the system table screen are set when the system generates a selection screen and are described in the screen elements of a selection screen.

Example:

The elements of block b2 are assigned to the modification group bl2. A checkbox show_all allows the user to select whether or not these elements are displayed. The display is changed immediately, as selecting the checkbox triggers the event AT SELECTION-SCREEN. The function code is not required. Instead, the content of show_all is evaluated during PBO.

PARAMETERS show_all AS CHECKBOX USER-COMMAND flag.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

PARAMETERS: p1 TYPE c LENGTH 10,

p2 TYPE c LENGTH 10,

p3 TYPE c LENGTH 10.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.

PARAMETERS: p4 TYPE c LENGTH 10 MODIF ID bl2,

p5 TYPE c LENGTH 10 MODIF ID bl2,

p6 TYPE c LENGTH 10 MODIF ID bl2.

SELECTION-SCREEN END OF BLOCK b2.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF show_all 'X' AND

screen-group1 = 'BL2'.

screen-active = '0'.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

kindly reward if found helpful.

cheers,

Hema.

Read only

0 Likes
756

Use the below code.

TYPE-POOLS : VRM.

DATA : VAL TYPE VRM_VALUES.

DATA : DROPDOWN LIKE LINE OF VAL.

DROPDOWN-TEXT = 'Ticket Booking'.

APPEND DROPDOWN TO VAL.

DROPDOWN-TEXT = 'Electricity Bill Payment'.

APPEND DROPDOWN TO VAL.

DROPDOWN-TEXT = 'Telephone Bill Payment'.

APPEND DROPDOWN TO VAL.

DROPDOWN-TEXT = 'E-Shop'.

APPEND DROPDOWN TO VAL.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

ID = 'CREDITUSAGE' /////// Your list box name.....

VALUES = VAL

EXCEPTIONS

ID_ILLEGAL_NAME = 1

OTHERS = 2.

Thanks

Anand D