‎2008 Feb 12 11:19 AM
what is the purpose for select-option.
plz give some simple example with select-option
‎2008 Feb 12 11:22 AM
hi,
Selection variables
Pass sets of values, which ABAP/4 uses in the report to check whether data base field or report-internal fields are within a certain value range. The result of such a check can be used to control the program flow.
You declare selection variables using the SELECT-OPTIONS statement.
DATA SELECT-OPTIONS field1 FOR field2.
Effect
Declares a selection variable field1 for field2. Field1 may be up to 8 characters long.
This statement defines an internal table field1 with a fixed structure, which consists of the fields field1-SIGN, field1-OPTION, field1-LOW, field1-HIGH. While field1-SIGN, field1-OPTION have a fixed format (type character, length 1 and 2 respectively), field1-LOW, field1-HIGH inherit the type and length of the reference field field2.
If the user enters a selection on the selection screen, the internal table field1 is automatically filled. You can use normal ABAP statements to read and manipulate the internal table field1.
the statements select-options and parameters determine the technical interface and the user interface. The parameters and select options you specify are displayed on the selection screen for the user to enter values.
Under Text elements/Selection texts of GOTO (Menu Bar), you can enter a description for each selection criteria like field1. This description is displayed on the selection screen. If no such text exists, the name field1 of the selection option is displayed instead.
example
DATA: BEGIN OF SALES_TABLE OCCURS 5,
P_ITEM(20) TYPE C,
P_QTY TYPE I,
P_RATE TYPE P DECIMALS 2,
P_PRICE TYPE P DECIMALS 2,
END OF SALES_TABLE.
DATA: CNT TYPE I VALUE IS INITIAL,
CNT_QTY TYPE I VALUE IS INITIAL,
CNT_RATE TYPE I VALUE IS INITIAL.
SELECT-OPTIONS SO_ITEM FOR SALES_TABLE-P_ITEM.
SELECT-OPTIONS SO_QTY FOR SALES_TABLE-P_QTY.
SELECT-OPTIONS SO_RATE FOR SALES_TABLE-P_RATE.
LOOP AT SO_ITEM.
CNT = CNT + 1.
ENDLOOP.
LOOP AT SO_QTY.
CNT_QTY = CNT_QTY + 1.
ENDLOOP.
LOOP AT SO_RATE.
CNT_RATE = CNT_RATE + 1.
ENDLOOP.
IF CNT = 0.
MESSAGE 'NO ROW ENTERED' TYPE 'I'.
EXIT.
ENDIF.
IF CNT_QTY < CNT.
MESSAGE 'ENTER SUFFICIENT DATA' TYPE 'I'.
EXIT.
ENDIF.
IF CNT_RATE < CNT.
MESSAGE 'ENTER SUFFICIENT DATA' TYPE 'I'.
EXIT.
ENDIF.
DO CNT TIMES.
READ TABLE SO_ITEM INDEX SY-INDEX.
SALES_TABLE-P_ITEM = SO_ITEM-LOW.
READ TABLE SO_QTY INDEX SY-INDEX.
SALES_TABLE-P_QTY = SO_QTY-LOW.
READ TABLE SO_RATE INDEX SY-INDEX.
SALES_TABLE-P_RATE = SO_RATE-LOW.
SALES_TABLE-P_PRICE = SALES_TABLE-P_ITEM * SALES_TABLE-P_QTY.
APPEND SALES_TABLE.
ENDDO.
SORT SALES_TABLE BY P_PRICE.
WRITE: /(30) 'ITEM CODE',(30) 'QUANTITY',(30) 'RATE',(30) 'PRICE'.
ULINE.
LOOP AT SALES_TABLE.
WRITE: / SALES_TABLE-P_ITEM,SALES_TABLE-P_QTY,SALES_TABLE-P_RATE,SALES_TABLE-P_PRICE.
AT LAST.
SUM.
WRITE : / 'TOTAL : ', SALES_TABLE-P_PRICE.
ENDAT.
ENDLOOP.
ULINE.
reward if its useful
Edited by: prs on Feb 12, 2008 4:56 PM
‎2008 Feb 12 11:22 AM
Hi,
Select-Options is used to give the range of values in the Selection-screen.
select-options:s_matnr for mara-matnr.
Thanks & Regards,
Roja Velagapudi.
‎2008 Feb 12 11:25 AM
If U want to declare a select-option on the screen ..
I mean a field on the selection screen from low to high
we use the select-option.
SELECT-OPTIONS : S_PERNR FOR PA0001-PERNR.
Here s_pernr is a select option and has a following structure(U
need not declare the structure)
s_pernr-low
s_pernr-high
s_pernr-sign
s_pernr-option
select * from pa0001 into itab where
pernr in s_pernr. <-- use 'IN' in where condition ...
‎2008 Feb 12 11:26 AM
Hi surender kumar,
Select-Options is used to give the range of values in the Selection-screen
Select-options:
You use the SELECT-OPTIONS statement to declare selection tables and create corresponding input fields on the associated selection screen. You can modify the associated text as selection text. When the selection screen is processed, the values entered by the user into the input fields are assigned to the header line of the selection table and appended to the table. The position of the statement in the declaration part of the program determines the selection screen to which the input fields belong.
The basic form of the SELECT-OPTIONS statement is as follows:
SELECT-OPTIONS variable FOR field.
Ex:
DATA WA_CARRID TYPE SPFLI-CARRID.
SELECT-OPTIONS AIRLINE FOR WA_CARRID.
LOOP AT AIRLINE.
WRITE: / 'SIGN:', AIRLINE-SIGN,
'OPTION:', AIRLINE-OPTION,
'LOW:', AIRLINE-LOW,
'HIGH:', AIRLINE-HIGH.
ENDLOOP.
See this links:
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba71f35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba74635c111d1829f0000e829fbfe/frameset.htm
Plzz reward if it is useful,
Mahi.
‎2008 Feb 12 11:27 AM
SELECT-OPTIONS
Syntax
SELECT-OPTIONS selcrit FOR {dobj|(name)}
[screen_options]
[value_options]
[ldb_options].
Effect
This declares a selection criterion selcrit for a data object dobj or a type specified in name. Selection criteria are components of a selection screen, to which are assigned a selection table in the ABAP program, as well as two input fields and a pushbutton for multiple selection.
The name of the selection criterion selcrit is limited to a maximum of 8 characters. This statement is allowed in the global declaration part of executable programs, function groups and module-pools. In function groups and module-pools it is only allowed within the definition of an independent selection screen. In executable programs it is otherwise automatically assigned to the standard selection screen.
The statement SELECT-OPTIONS has the following effect:
The statement declares a selection table in the program with the name selcrit. A selection table is an internal standard table with header line and standard key. In selection tables, you can save multiple logical conditions. The content of selection screens can be analyzed in a logical expression and in the expression of a WHERE-condition in Open SQL. Selection tables have the following four columns:
sign of type c and length 1. The content of sign determines for every row whether the result of the condition formulated in the column is included or excluded in the entire resulting set for all rows. Evaluable values are "I" for include and "E" for exclude.
option of type c and length 2. option contains the selection option for the condition of the row in form of logical operators. Analyzable operators are "EQ", "NE", "GE", "GT", "LE", "LT", "CP" and "NP" if column high is initial, and "BT", "NB" if column high is not initial. With the options "CP" and "NP", the data type of the columns low and high must be of the data type c, and special rules apply for entries on the selection screen.
low of the data type defined after FOR. This column is designated for the comparison value or the lower interval limitation.
high of the data type defined after FOR. This column is designated for the upper interval limitation.
Two input fields with the name selscrit-low and selscrit-high are created on the current selection screen using a matching external data type in a new line at positions 35 and 60. The length of the input fields bases upon the length of the data type which is defined after FOR. The maximum length of the input fields is 45. The maximum visible length of the input fields is, depending on the nesting depth, in blocks with frames between 10 and 18. If the length is larger than the maximum visible length, then the content is scrollable.
Before the first input field, an automatically generated output field
is displayed as identifier in the first possible position, whose length is, depending on the nesting depth, in blocks with frames between 20 and 30. The output field either contains the name of the selection criterion selcrit, or the selection text which is assigned to the selection criterion in the text elements of the program. If the user requests a field- or input-help on the output field using the function key F1 resp. F4, the same output is displayed as if one of the input fields is chosen.
A pushbutton multiple selection is created after the second input field. If you select this pushbutton, a dialog screen with four tabstrip control pages appears, in which the input fields are again displayed in tabular form in Table Controls. The tabstrip pages are separated based on individual value comparison, interval limitation, and settings for the column sign.
As a user, you can select an input field with a double-click on the selection screen or use the dialog screen for multiple selection. On the selection screen, you can also choose the value for column sign. On the dialog screen for multiple selection, you can do this by selecting the respective tabstrip page. If the selection option is not equal to "EQ" or "BT", then it is displayed as an icon in front of the first input field. The color of the icon is green if the content of column sign is "I", and red if it is "E".
The selection options "CP" and "NP" can be selected only if the first input field contains one of the wildcard characters "*" or "+". If one of these characters is entered, the selection option is automatically set to "CP". If "CP" is set, and all wildcard characters have been removed, the selection option is automatically set to "EQ" when there is a user action. This limitation does not apply within the program. During evaluation of the selection table, column low can also contain a string without wildcard characters for the selection options "CP" and "NP".
The attributes of the elements on the selection screen can be influenced with the statement screen_options or the statement SELECTION-SCREEN.
The first row of the selection table selcrit is linked with the input fields on the selection screen. All rows are displayed in the dialog box for multiple selection. Each time before the selection screen is sent to the selection screen event ATSELECTION-SCREEN OUTPUT, the content of first row in the selection table is transported to the selection screen, with a conversion routine being executed if required. If the length of columns low and high in the first row of the selection table is over 45, the excessive content is cut off to the right. It is only possible for all rows to be transported if the button for multiple selections is selected. A conversion routine might be executed here, and rows might be cut off. Settings for the content of the input fields can be made in value_options.
After a user action on the selection screen, the contents of the input fields and the chosen settings are transported to the first row and the header row of the selection table.
After a user action on the dialog box for multiple selections, the contents of all input fields and the chosen settings are transported to the rows of the selection table, and the contents of the header are initialized. During these transports, the contents of character-type fields are converted by default into capitals, after which a conversion routine is performed, if required. After each transport, various selection screen events are triggered.
If a value has been entered in the entry field for the upper interval high, the system checks whether this value is greater than the lower interval limit low> following each transport and conversion routine (if performed). If necessary, an error message is sent. This check can be switched off before the selection screen is sent, using the function module
If selection criteria are defined in the selection-include of a logical database, further additions ldb_options are necessary resp. possible.
If in an executable program, a selection criterion is defined for a component of a node of the linked logical database, declared by TABLES or NODES, and the node in question is intended for free selection on the logical database, then the selection table is transferred to the logical database after selection screen processing and is treated there as a free selection. Furthermore, in this case, the input fields for the corresponding free selection are displayed directly on the selection screen, without the necessity for the user having to select them via the function free selection.
Note
If a selection criterion for data types is supplied with data when calling up an executable program with SUBMIT , a conversion routine may be performed for the first row, while the value of the columns low and high will be truncated to the right of position 45 for the first row. No conversion routine or truncation is performed for any other rows. If the selection criterion is declared with the addition NO-DISPLAY, no conversion routine or truncation will be performed for the first row either.
SELECT-OPTIONS - FOR
Syntax
... FOR {dobj|(name)} ... .
Alternatives:
1. ... FOR dobj
2. ... FOR (name)
SELECT-OPTIONS - screen_options
Syntax
... [OBLIGATORY|NO-DISPLAY]
[VISIBLE LENGTH vlen]
[NO-EXTENSION]
[NO INTERVALS]
[MODIF ID modid] ... .
Extras:
1. ... OBLIGATORY
2. ... NO-DISPLAY
3. ... VISIBLE LENGTH vlen
4. ... NO-EXTENSION
5. ... NO INTERVALS
6. ... MODIF ID modid
SELECT-OPTIONS - value_options
Syntax
... [DEFAULT val1 [TO val2] [OPTION opt] [SIGN sgn]]
[LOWER CASE]
[MATCHCODE OBJECT search_help]
[MEMORY ID pid] ... .
Extras:
1. ... DEFAULT val1 [TO val2] [OPTION opt] [SIGN sgn]
2. ... LOWER CASE
3. ... MATCHCODE OBJECT search_help
4. ... MEMORY ID pid
SELECT-OPTIONS - ldb_options
Syntax
... [ HELP-REQUEST [ FOR {LOW|HIGH} ] ]
[ VALUE-REQUEST [ FOR {LOW|HIGH} ] ]
[ NO DATABASE SELECTION ] ... .
Extras:
1. ... HELP-REQUEST [ FOR {LOW|HIGH} ]
2. ... VALUE-REQUEST [ FOR {LOW|HIGH} ]
3. ... NO DATABASE SELECTION
‎2008 Feb 12 11:27 AM
Hi,
select-options are used to specify the range and eliminate some records from the range and even u can
use the wild character while selecting the data.
Plzz reward points if it helps.
‎2008 Feb 12 11:29 AM
hi,
Unlike parameters that are declared as elementary variables in ABAP programs, selection criteria are based on special internal tables, called selection tables. To define a selection criterion, you must declare a selection table in the declaration part using the SELECT-OPTIONSstatement. The relevant possible entries then appear on the selection screen.
You can use the SELECT-OPTIONS statement for both standard and user-defined selection screens.
REPORT demo_sel_screen_select_options.
DATA wa_carrid TYPE spfli-carrid.
SELECT-OPTIONS airline FOR wa_carrid.
LOOP AT airline.
WRITE: / 'SIGN:', airline-sign,
'OPTION:', airline-option,
'LOW:', airline-low,
'HIGH:', airline-high.
ENDLOOP.
After the executable program demo has been started, the following standard selection screen will appear.
Hope this is helpful, Do reward.
‎2008 Feb 12 11:36 AM
Hi Surendar,
We can use select-options instead of parameters. Both are used for creating selection screen,
In select-options, u can set the range,,sign and options for the selection screen.But its not possible in parameters statement
If u use select-options u should use 'in' in the joining condition.
Ex:
select-options: mtrlno for mara-matnr.
****initialization******
**************************
select * from mara where matnr in mtrlno.
if u use parameters instead of select-options.
Ex:
Parameters: mtrlno type mara-matnr.
select * from mara where matnr = mtrlno.
if it is useful reward points.
Thanks.
regards
Subash.
Edited by: subash sundar on Feb 12, 2008 12:37 PM
Edited by: subash sundar on Feb 12, 2008 12:39 PM
‎2008 Feb 12 11:42 AM
Select- option: is used in the report ,for selection screen input fields details .
based on that selection screen input fields desired report will be displayed
‎2008 Feb 12 11:42 AM
Hi,
SELECT-OPTIONS are used when you want to select some records which are lying within a specified range.
Ex.
SELECT-OPTIONS S_VBELN FOR VBAK-VBELN.
Ehis will create a box in the selection screen where you can enter the values of vbeln { a lower value and a higer value } and the selection occurs only for those values that lie within the range.
Reward if helpful.
Regards.
‎2008 Feb 12 1:31 PM
Hi,
select-options are used to specify the range in the input screen.
select-options: s_plant for werks.
s_plant 1000 2000
it will gives us the plants in between 1000 and 2000.
Plzz reward points if it helps.
Thanks & Regards,
Koti