Query regarding OBLIGATORY option in SELECT-OPTIONS

Hi,
The requirement is to have a select-option for any date field(i've used bkpf-budat) and set its HIGH value to SY-DATUM i.e. current system date. The select-option field MUST BE "OBLIGATORY".
On Executing, the current date should be display on the HIGH filed of select-options. Now, what i need here is that the program should execute normally even if the LOW field of select-options field is left BLANK.
The code is as follows.
TABLES: bkpf.
SELECT-OPTIONS:  s_budat FOR bkpf-budat OBLIGATORY.
AT SELECTION-SCREEN OUTPUT.
    s_budat-low    = space.
    s_budat-high   = sy-datum.
    s_budat-sign   = 'I'.
    s_budat-option = 'BT'.
    APPEND s_budat.
Do suggest the methodlogy to achieve this requirement.
Thanks & Regards,
Rajesh

Hi rajesh,
1. directly its not possible.
  we have to use some extra logic.
2. first of all remove OBLIGATORY.
3. THEN USE LIKE THIS.
REPORT abc.
TABLES: bkpf.
SELECT-OPTIONS: s_budat FOR bkpf-budat .
AT SELECTION-SCREEN OUTPUT.
  s_budat-low = space.
  s_budat-high = sy-datum.
  s_budat-sign = 'I'.
  s_budat-option = 'BT'.
  APPEND s_budat.
<b>START-OF-SELECTION.
  IF s_budat-high IS INITIAL.
    MESSAGE s999(yhr) WITH 'Date should not be blank'.
    LEAVE LIST-PROCESSING.
  ENDIF.</b>
regards,
amit m.

Similar Messages

  • Obligatory mark for select options

    Hi experts,
    I have a requirement where both low and high field of select -option should be mandatory.
    Code i have written is :s_period  for cgpl_project-createdon.
    But only the low field is made obligatory.How to make high field as oblogatory too....
    but if we write abap code manually it will work..
    if s_period is intial..
    error mesg like " date is mandatory''
    but user want that obligatory mark only..how can i acheive this....
    can any body plz help me..
    Regards,
    Praveena..

    Hi,
       Write the below code  in Initialization event...
    Initialization.
    loop at screen.
    if screen-name = 'S_BELNR-HIGH'.
      screen-required = 1.
      modify screen.
    endif.
    endloop.
    Regards,
    Srini.

  • "option" in select-options

    what are the different <b>OPTION</b> used in select-options......plz can u give the full forms of those options......

    hi,
    <b>select-options.</b> 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-OPTIONS statement You use the statement SELECT-OPTIONS <seltab> for <f>.
    <b>The row type of a selection table is a structure that consists of the following four components: SIGN, OPTION, LOW and HIGH.</b>
    Each row of a selection table that contains values represents a sub-condition for the complete selection criterion.
    Description of the individual components: SIGN ' The data type of SIGN is C with length 1. The contents of SIGN determine for each row whether the result of the row condition is to be included in or excluded from the resulting set of all rows.
    <b>OPTION The data type of OPTION is C with length 2. OPTION contains the selection operator</b>.
    <b> The following operators are available If HIGH is empty, you can use EQ, NE, GT, LE, LT,CP, and NP. These operators are the same as those that are used for logical expressions.</b>
    <b>If HIGH is filled, you can use BT (BeTween) and NB (Not Between).</b>
    LOW The data type of LOW is the same as the column type of the database table, to which the selection criterion is linked.
    HIGH The data type of HIGH is the same as the column type of the database table, to which the selection criterion is linked. The contents of HIGH specify the upper limit for a range selection.
    To assign default values to a selection criterion, you use the following syntax: SELECT-OPTIONS <seltab> FOR <f> DEFAULT <g> [TO <h>] ....
    To allow the user to process only the first row of the selection table on the selection screen, you use the following syntax SELECT-OPTIONS <seltab> FOR <f> ..... NO-EXTENSION .....
    To allow the user to process only single fields on the selection screen, you use the following syntax: SELECT-OPTIONS <seltab> FOR <f> ..... NO INTERVALS .....
    SPA/GPA parameters as default values SELECT-OPTIONS <seltab> FOR <f> ... MEMORY ID <pid>..........
    Upper and lower case for selection criteria: SELECT-OPTIONS <seltab> FOR <f> ... LOWER CASE ..............
    To make the From field a required field on the selection screen, use: SELECT-OPTIONS <selcrit> FOR <f> ... OBLIGATORY ..............
    To hide input fields on the selection screen, use: SELECT-OPTIONS <selcrit> FOR <f> ... NO DISPLAY ..............
    To modify input fields on the selection screen, use: SELECT-OPTIONS <selcrit> FOR <f> ... MODIF ID
    regards,
    Ashokreddy.

  • Disabling the Ranges option in Select options

    Hi,
    I have a requirement where I have to remove the possibility of entering the ranges for select-options on the selection screen (eg: FROM ‘xyz’ TO ‘xyz’ ).. For this I used SELECT OPTIONS ……… NO INTERVALS.
    Now the range option doesn’t appear on the main selection screen. However, when I click on the ‘Multiple Selection’ screen button next to this field.. here again I find an option to enter the ranges. Is there a way to disable this option on the ‘Multiple Selection’ screen.
    Could anyone please help me in this.
    Regards,
    Harsha

    chk this program
    REPORT TESTREP.
    * Include type pool SSCR
    TYPE-POOLS SSCR.
    * Define the object to be passed to the RESTRICTION parameter
    DATA RESTRICT TYPE SSCR_RESTRICT.
    * Auxiliary objects for filling RESTRICT
    DATA OPT_LIST TYPE SSCR_OPT_LIST.
    DATA ***      TYPE SSCR_***.
    * Define the selection screen objects
    * First block: 3 SELECT-OPTIONS
    SELECTION-SCREEN BEGIN OF BLOCK BLOCK_0 WITH FRAME TITLE TEXT-BL0.
      SELECT-OPTIONS SEL_0_0 FOR SY-TVAR0.
      SELECT-OPTIONS SEL_0_1 FOR SY-TVAR1.
      SELECT-OPTIONS SEL_0_2 FOR SY-TVAR2.
      SELECT-OPTIONS SEL_0_3 FOR SY-TVAR3.
    SELECTION-SCREEN END   OF BLOCK BLOCK_0.
    * Second block: 2 SELECT-OPTIONS
    SELECTION-SCREEN BEGIN OF BLOCK BLOCK_1 WITH FRAME TITLE TEXT-BL1.
      SELECT-OPTIONS SEL_1_0 FOR SY-SUBRC.
      SELECT-OPTIONS SEL_1_1 FOR SY-REPID.
    SELECTION-SCREEN END   OF BLOCK BLOCK_1.
    INITIALIZATION.
    * Define the option list
    * ALL: All options allowed
      MOVE 'ALL'        TO OPT_LIST-NAME.
      MOVE 'X' TO: OPT_LIST-OPTIONS-BT,
                   OPT_LIST-OPTIONS-CP,
                   OPT_LIST-OPTIONS-EQ,
                   OPT_LIST-OPTIONS-GE,
                   OPT_LIST-OPTIONS-GT,
                   OPT_LIST-OPTIONS-LE,
                   OPT_LIST-OPTIONS-LT,
                   OPT_LIST-OPTIONS-NB,
                   OPT_LIST-OPTIONS-NE,
                   OPT_LIST-OPTIONS-NP.
      APPEND OPT_LIST TO RESTRICT-OPT_LIST_TAB.
    * NOPATTERN: CP and NP not allowed
      CLEAR OPT_LIST.
      MOVE 'NOPATTERN'  TO OPT_LIST-NAME.
      MOVE 'X' TO: OPT_LIST-OPTIONS-BT,
                   OPT_LIST-OPTIONS-EQ,
                   OPT_LIST-OPTIONS-GE,
                   OPT_LIST-OPTIONS-GT,
                   OPT_LIST-OPTIONS-LE,
                   OPT_LIST-OPTIONS-LT,
                   OPT_LIST-OPTIONS-NB,
                   OPT_LIST-OPTIONS-NE.
      APPEND OPT_LIST TO RESTRICT-OPT_LIST_TAB.
    * NOINTERVLS: BT and NB not allowed
      CLEAR OPT_LIST.
      MOVE 'NOINTERVLS' TO OPT_LIST-NAME.
      MOVE 'X' TO: OPT_LIST-OPTIONS-CP,
                   OPT_LIST-OPTIONS-EQ,
                   OPT_LIST-OPTIONS-GE,
                   OPT_LIST-OPTIONS-GT,
                   OPT_LIST-OPTIONS-LE,
                   OPT_LIST-OPTIONS-LT,
                   OPT_LIST-OPTIONS-NE,
                   OPT_LIST-OPTIONS-NP.
      APPEND OPT_LIST TO RESTRICT-OPT_LIST_TAB.
    * EQ_AND_CP: only EQ and CP allowed
      CLEAR OPT_LIST.
      MOVE 'EQ_AND_CP'  TO OPT_LIST-NAME.
      MOVE 'X' TO: OPT_LIST-OPTIONS-CP,
                   OPT_LIST-OPTIONS-EQ.
      APPEND OPT_LIST TO RESTRICT-OPT_LIST_TAB.
    * JUST_EQ: Only EQ allowed
      CLEAR OPT_LIST.
      MOVE 'JUST_EQ' TO OPT_LIST-NAME.
      MOVE 'X' TO OPT_LIST-OPTIONS-EQ.
      APPEND OPT_LIST TO RESTRICT-OPT_LIST_TAB.
    * Assign selection screen objects to option list and sign
    * KIND = 'A': applies to all SELECT-OPTIONS
      MOVE: 'A'          TO ***-KIND,
            '*'          TO ***-SG_MAIN,
            'NOPATTERN'  TO ***-OP_MAIN,
            'NOINTERVLS' TO ***-OP_ADDY.
      APPEND *** TO RESTRICT-***_TAB.
    * KIND = 'B': applies to all SELECT-OPTIONS in block BLOCK_0,
    *             that is, SEL_0_0, SEL_0_1, SEL_0_2
      CLEAR ***.
      MOVE: 'B'          TO ***-KIND,
            'BLOCK_0'    TO ***-NAME,
            'I'          TO ***-SG_MAIN,
            '*'          TO ***-SG_ADDY,
            'NOINTERVLS' TO ***-OP_MAIN.
      APPEND *** TO RESTRICT-***_TAB.
    * KIND = 'S': applies to SELECT-OPTION SEL-0-2
      CLEAR ***.
      MOVE: 'S'          TO ***-KIND,
            'SEL_0_2'    TO ***-NAME,
            'I'          TO ***-SG_MAIN,
            '*'          TO ***-SG_ADDY,
            'EQ_AND_CP'  TO ***-OP_MAIN,
            'ALL'        TO ***-OP_ADDY.
      APPEND *** TO RESTRICT-***_TAB.
    * KIND = 'S': Applies to SELECT-OPTION SEL_0_3
      CLEAR ***.
      MOVE: 'S'        TO ***-KIND,
            'SEL_0_3'  TO ***-NAME,
            'I'        TO ***-SG_MAIN,
            'N'        TO ***-SG_ADDY,
            'JUST_EQ'  TO ***-OP_MAIN.
      APPEND *** TO RESTRICT-***_TAB.
    * Call function module
      CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
           EXPORTING
                 RESTRICTION                = RESTRICT
    *           DB                          = ' '
           EXCEPTIONS
                 TOO_LATE                   = 1
                 REPEATED                   = 2
                 NOT_DURING_SUBMIT          = 3
                DB_CALL_AFTER_REPORT_CALL  = 4
                SELOPT_WITHOUT_OPTIONS     = 5
                 SELOPT_WITHOUT_SIGNS       = 6
                 INVALID_SIGN               = 7
                REPORT_CALL_AFTER_DB_ERROR = 8
                  EMPTY_OPTION_LIST          = 9
                 INVALID_KIND               = 10
                 REPEATED_KIND_A            = 11
                 OTHERS                     = 12.
    * Exception handling
      IF SY-SUBRC NE 0.
      ENDIF.
    Message was edited by: Sekhar

  • Three options in Select Options

    Through Selection screen we can give value range through two input box.
    Is their any option of specifing more than two input fields at a time .
    -David Boon.

    Hi,
    Select the extension button for the select-options button..
    Then in the ranges tab..
    You can enter another range..
    Is that what you want??
    Thanks,
    Naren

  • Basic query regarding work-area and select query

    hi
    dear sdn members,
    thanks too all for solving all my query's up till now
    i am stuck in a problem need help
    1)  why basically work-area has been used ? the sole purpose
    2)  different types of select query ? only coding examples
    note: no links pls
    regards,
    virus

    hi,
    Work Area
    Description for a data object that is particularly useful when working with internal tables or database tables as a source for changing operations or a target for reading operations.
    WORKAREA is a structure that can hold only one record at a time. It is a collection of fields. We use workarea as we cannot directly read from a table. In order to interact with a table we need workarea. When a Select Statement is executed on a table then the first record is read and put into the header of the table and from there put into the header or the workarea(of the same structure as that of the table)of the internal table and then transferred top the body of the internal table or directly displayed from the workarea.
    Each row in a table is a record and each column is a field.
    While adding or retrieving records to / from internal table we have to keep the record temporarily.
    The area where this record is kept is called as work area for the internal table. The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.
    Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.
    .g.
    data: begin of itab occurs 10,
    ab type c,
    cd type i,
    end of itab. " this table will have the header line.
    data: wa_itab like itab. " explicit work area for itab
    data: itab1 like itab occurs 10. " table is without header line.
    The header line is a field string with the same structure as a row of the body, but it can only hold a single row.
    It is a buffer used to hold each record before it is added or each record as it is retrieved from the internal table. It is the default work area for the internal table.
    With header line
    SELECT.
    Put the curson on that word and press F1 . You can see the whole documentation for select statements.
    select statements :
    SELECT result
    FROM source
    INTO|APPENDING target
    [[FOR ALL ENTRIES IN itab] WHERE sql_cond]
    Effect
    SELECT is an Open-SQL-statement for reading data from one or several database tables into data objects.
    The select statement reads a result set (whose structure is determined in result ) from the database tables specified in source, and assigns the data from the result set to the data objects specified in target. You can restrict the result set using the WHERE addition. The addition GROUP BY compresses several database rows into a single row of the result set. The addition HAVING restricts the compressed rows. The addition ORDER BY sorts the result set.
    The data objects specified in target must match the result set result. This means that the result set is either assigned to the data objects in one step, or by row, or by packets of rows. In the second and third case, the SELECT statement opens a loop, which which must be closed using ENDSELECT. For every loop pass, the SELECT-statement assigns a row or a packet of rows to the data objects specified in target. If the last row was assigned or if the result set is empty, then SELECT branches to ENDSELECT . A database cursor is opened implicitly to process a SELECT-loop, and is closed again when the loop is ended. You can end the loop using the statements from section leave loops.
    Up to the INTO resp. APPENDING addition, the entries in the SELECTstatement define which data should be read by the database in which form. This requirement is translated in the database interface for the database system´s programming interface and is then passed to the database system. The data are read in packets by the database and are transported to the application server by the database server. On the application server, the data are transferred to the ABAP program´s data objects in accordance with the data specified in the INTO and APPENDING additions.
    System Fields
    The SELECT statement sets the values of the system fields sy-subrc and sy-dbcnt.
    sy-subrc Relevance
    0 The SELECT statement sets sy-subrc to 0 for every pass by value to an ABAP data object. The ENDSELECT statement sets sy-subrc to 0 if at least one row was transferred in the SELECT loop.
    4 The SELECT statement sets sy-subrc to 4 if the result set is empty, that is, if no data was found in the database.
    8 The SELECT statement sets sy-subrc to 8 if the FOR UPDATE addition is used in result, without the primary key being specified fully after WHERE.
    After every value that is transferred to an ABAP data object, the SELECT statement sets sy-dbcnt to the number of rows that were transferred. If the result set is empty, sy-dbcnt is set to 0.
    Notes
    Outside classes, you do not need to specify the target area with INTO or APPENDING if a single database table or a single view is specified statically after FROM, and a table work area dbtab was declared with the TABLES statement for the corresponding database table or view. In this case, the system supplements the SELECT-statement implicitly with the addition INTO dbtab.
    Although the WHERE-condition is optional, you should always specify it for performance reasons, and the result set should not be restricted on the application server.
    SELECT-loops can be nested. For performance reasons, you should check whether a join or a sub-query would be more effective.
    Within a SELECT-loop you cannot execute any statements that lead to a database commit and consequently cause the corresponding database cursor to close.
    SELECT - result
    Syntax
    ... lines columns ... .
    Effect
    The data in result defines whether the resulting set consists of multiple rows (table-like structure) or a single row ( flat structure). It specifies the columns to be read and defines their names in the resulting set. Note that column names from the database table can be changed. For single columns, aggregate expressions can be used to specify aggregates. Identical rows in the resulting set can be excluded, and individual rows can be protected from parallel changes by another program.
    The data in result consists of data for the rows lines and for the columns columns.
    SELECT - lines
    Syntax
    ... { SINGLE }
    | { { } } ... .
    Alternatives:
    1. ... SINGLE
    2. ... { }
    Effect
    The data in lines specifies that the resulting set has either multiple lines or a single line.
    Alternative 1
    ... SINGLE
    Effect
    If SINGLE is specified, the resulting set has a single line. If the remaining additions to the SELECT command select more than one line from the database, the first line that is found is entered into the resulting set. The data objects specified after INTO may not be internal tables, and the APPENDING addition may not be used.
    An exclusive lock can be set for this line using the FOR UPDATE addition when a single line is being read with SINGLE. The SELECT command is used in this case only if all primary key fields in logical expressions linked by AND are checked to make sure they are the same in the WHERE condition. Otherwise, the resulting set is empty and sy-subrc is set to 8. If the lock causes a deadlock, an exception occurs. If the FOR UPDATE addition is used, the SELECT command circumvents SAP buffering.
    Note
    When SINGLE is being specified, the lines to be read should be clearly specified in the WHERE condition, for the sake of efficiency. When the data is read from a database table, the system does this by specifying comparison values for the primary key.
    Alternative 2
    Effect
    If SINGLE is not specified and if columns does not contain only aggregate expressions, the resulting set has multiple lines. All database lines that are selected by the remaining additions of the SELECT command are included in the resulting list. If the ORDER BY addition is not used, the order of the lines in the resulting list is not defined and, if the same SELECT command is executed multiple times, the order may be different each time. A data object specified after INTO can be an internal table and the APPENDING addition can be used. If no internal table is specified after INTO or APPENDING, the SELECT command triggers a loop that has to be closed using ENDSELECT.
    If multiple lines are read without SINGLE, the DISTINCT addition can be used to exclude duplicate lines from the resulting list. If DISTINCT is used, the SELECT command circumvents SAP buffering. DISTINCT cannot be used in the following situations:
    If a column specified in columns has the type STRING, RAWSTRING, LCHAR or LRAW
    If the system tries to access pool or cluster tables and single columns are specified in columns.
    Note
    When specifying DISTINCT, note that you have to carry out sort operations in the database system for this.
    SELECT - columns
    Syntax
    | { {col1|aggregate( col1 )}
    {col2|aggregate( col2 )} ... }
    | (column_syntax) ... .
    Alternatives:
    1. ... *
    2. ... {col1|aggregate( col1 )}
    {col2|aggregate( col2 )} ...
    3. ... (column_syntax)
    Effect
    The input in columns determines which columns are used to build the resulting set.
    Alternative 1
    Effect
    If * is specified, the resulting set is built based on all columns in the database tables or views specified after FROM, in the order given there. The columns in the resulting set take on the name and data type from the database tables or views. Only one data object can be specified after INTO.
    Note
    If multiple database tables are specified after FROM, you cannot prevent multiple columns from getting the same name when you specify *.
    Alternative 2
    ... {col1|aggregate( col1 )}
    {col2|aggregate( col2 )} ...
    Effect
    A list of column labels col1 col2 ... is specified in order to build the resulting list from individual columns. An individual column can be specified directly or as an argument of an aggregate function aggregate. The order in which the column labels are specified is up to you and defines the order of the columns in the resulting list. Only if a column of the type LCHAR or LRAW is listed does the corresponding length field also have to be specified directly before it. An individual column can be specified multiple times.
    The addition AS can be used to define an alternative column name a1 a2 ... with a maximum of fourteen digits in the resulting set for every column label col1 col2 .... The system uses the alternative column name in the additions INTO|APPENDING CORRESPONDING FIELDS and ORDER BY. .
    Column labels
    The following column labels are possible:
    If only a single database table or a single view is specified after FROM, the column labels in the database table - that is, the names of the components comp1 comp2... - can be specified directly for col1 col2 ... in the structure of the ABAP Dictionary.
    If the name of the component occurs in multiple database tables of the FROM addition, but the desired database table or the view dbtab is only specified once after FROM, the names dbtab~comp1 dbtab~comp2 ... have to be specified for col1 col2 .... comp1 comp2 ... are the names of the components in the structure of the ABAP Dictionary.
    If the desired database table or view occurs multiple times after FROM, the names tabalias~comp1 tabalias~comp2 ... have to be specified for col1 col2 .... tabalias is the alternative table name of the database table or view defined after FROM, and comp1 comp2 ... are the names of the components in the structure of the ABAP Dictionary.
    The data type of a single column in the resulting list is the datatype of the corresponding component in the ABAP Dictionary. The corresponding data object after INTO or APPENDING has to be selected accordingly.
    Note
    If multiple database tables are specified after FROM, you can use alternative names when specifying single columns to avoid having multiple columns with the same name.
    Example
    Read specific columns of a single row.
    DATA wa TYPE spfli.
    SELECT SINGLE carrid connid cityfrom cityto
    INTO CORRESPONDING FIELDS OF wa
    FROM spfli
    WHERE carrid EQ 'LH' AND connid EQ '0400'.
    IF sy-subrc EQ 0.
    WRITE: / wa-carrid, wa-connid, wa-cityfrom, wa-cityto.
    ENDIF.
    Alternative 3
    ... (column_syntax)
    Effect
    Instead of static data, a data object column_syntax in brackets can be specified, which, when the command is executed, either contains the syntax shown with the static data, or is initial. The data object column_syntax can be a character-type data object or an internal table with a character-type data type. The syntax in column_syntax, like in the ABAP editor, is not case-sensitive. When specifying an internal table, you can distribute the syntax over multiple rows.
    If column_syntax is initial when the command is executed, columns is implicitly set to * and all columns are read.
    If columns are specificied dynamically without the SINGLE addition, the resulting set is always regarded as having multiple rows.
    Notes
    Before Release 6.10, you could only specify an internal table with a flat character-type row type for column_syntax with a maximum of 72 characters. Also, before Release 6.10, if you used the DISTINCT addition for dynamic access to pool tables or cluster tables, this was ignored, but since release 6.10, this causes a known exception.
    If column_syntax is an internal table with header line, the table body and not the header line is evaluated.
    Example
    Read out how many flights go to and from a city. The SELECT command is implemented only once in a sub-program. The column data, including aggregate function and the data after GROUP BY, is dynamic. Instead of adding the column data to an internal l_columns table, you could just as easily concatenate it in a character-type l_columns field.
    PERFORM my_select USING `CITYFROM`.
    ULINE.
    PERFORM my_select USING `CITYTO`.
    FORM my_select USING l_group TYPE string.
    DATA: l_columns TYPE TABLE OF string,
    l_container TYPE string,
    l_count TYPE i.
    APPEND l_group TO l_columns.
    APPEND `count( * )` TO l_columns.
    SELECT (l_columns)
    FROM spfli
    INTO (l_container, l_count)
    GROUP BY (l_group).
    WRITE: / l_count, l_container.
    ENDSELECT.
    ENDFORM.
    SELECT - aggregate
    Syntax
    ... { MAX( col )
    | MIN( col )
    | AVG( col )
    | SUM( col )
    | COUNT( DISTINCT col )
    | COUNT( * )
    | count(*) } ... .
    Effect
    As many of the specified column labels as you like can be listed in the SELECT command as arguments of the above aggregate expression. In aggregate expressions, a single value is calculated from the values of multiple rows in a column as follows (note that the addition DISTINCT excludes double values from the calculation):
    MAX( col ) Determines the maximum value of the value in the column col in the resulting set or in the current group.
    MIN( col ) Determines the minimum value of the content of the column col in the resulting set or in the current group.
    AVG( col ) Determines the average value of the content of the column col in the resulting set or in the current group. The data type of the column has to be numerical.
    SUM( col ) Determines the sum of the content of the column col in the resulting set or in the current group. The data type of the column has to be numerical.
    COUNT( DISTINCT col ) Determines the number of different values in the column col in the resulting set or in the current group.
    COUNT( * ) (or count(*)) Determines the number of rows in the resulting set or in the current group. No column label is specified in this case.
    If you are using aggregate expressions, all column labels that are not listed as an argument of an aggregate function are listed after the addition GROUP BY. The aggregate functions evaluate the content of the groups defined by GROUP BY in the database system and transfer the result to the combined rows of the resulting set.
    The data type of aggregate expressions with the function MAX, MIN or SUM is the data type of the corresponding column in the ABAP Dictionary. Aggregate expressions with the function AVG have the data type FLTP, and those with COUNT have the data type INT4. The corresponding data object after INTO or APPENDING has to be selected accordingly.
    Note the following points when using aggregate expressions:
    If the addition FOR ALL ENTRIES is used in front of WHERE, or if cluster or pool tables are listed after FROM, no other aggregate expressions apart from COUNT( * ) can be used.
    Columns of the type STRING or RAWSTRING cannot be used with aggregate functions.
    When aggregate expressions are used, the SELECT command makes it unnecessary to use SAP buffering.
    Null values are not included in the calculation for the aggregate functions. The result is a null value only if all the rows in the column in question contain the null value.
    If only aggregate expressions are used after SELECT, the results set has one row and the addition GROUP BY is not necessary. If a non-table type target area is specified after INTO, the command ENDSELECT cannot be used together with the addition SINGLE. If the aggregate expression count( * ) is not being used, an internal table can be specified after INTO, and the first row of this table is filled.
    If aggregate functions are used without GROUP BY being specified at the same time, the resulting set also contains a row if no data is found in the database. If count( * ) is used, the column in question contains the value 0. The columns in the other aggregate functions contain initial values. This row is assigned to the data object specified after INTO, and unless count( * ) is being used exclusively, sy-subrc is set to 0 and sy-dbcnt is set to 1. If count( *) is used exclusively, the addition INTO can be omitted and if no data can be found in the database, sy-subrc is set to 4 and sy-dbcnt is set to 0.
    if helpful reward points

  • How to put Mandatory option for selection screen fields in ABAP Queries

    Hi Experts
    Can anyone tell me how to put mandatory option for the selection screen fields in ABAP Queries.
    Manually I had written code in the At Selection Screen  option in infoset to display error message if that field is blank.
    But I need to display the selection fields with the tick mark (obligatory mark).
    How to do this?
    Appropriate answers will be awarded

    Hi
    For parameter option
    parameters : p_kunnr type kna1-kunnr  obligatory.
    For select option
    select-options: s_date for vbak-erdat obligatory.
    Plz rewards points ,
    Regards ,
    Ganesh.

  • Inner join -select options

    Hi all,
    I have a query, but it doesn't work when i give select-options range table in WHERE clause.
    SELECT-OPTIONS  :
            l_bukrs  FOR  WA_INPUT-bukrs NO INTERVALS ,
      SELECT
                VBAK~BUKRS_VF AS BUKRS   "COMPANY CODE
                PA0001~ENAME     "SALES EMPLOYEE NAME
                KNA1~NAME1       "CLIENT
                VBKD~BSTKD       "PO NO
                VBAK~VBELN       "SO NO
                VBAK~AUDAT       "SO DATE
                VBAP~POSNR       "LINE
                VBAP~KWMENG      "QTY
                VBAP~VRKME       "UNIT
                VBAP~NETPR       "RATE
                VBAP~NETWR       "ORDER VALUE
                VBAP~WAERK       "DOCUEMNT CURRENCY
                VBAP~MATNR       "MATERIAL NO
                VBAP~ARKTX       "MATERIAL NAME
                VBKD~KURSK       "EXCHANGE RATE
                    INTO CORRESPONDING FIELDS OF TABLE IT_OPSALES
                      FROM  VBAP
                                LEFT OUTER JOIN  VBPA ON VBPAVBELN = VBAPVBELN AND VBPA~PARVW = 'AF'
                                INNER JOIN PA0001 ON PA0001PERNR = VBPAPERNR
                                INNER JOIN VBAK ON VBAKVBELN  = VBAPVBELN
                                INNER JOIN KNA1 ON KNA1KUNNR  = VBAKKUNNR
                                INNER JOIN VBKD ON VBKDVBELN = VBAKVBELN AND VBKDPOSNR = VBAPPOSNR
                      WHERE  BUKRS  IN L_BUKRS
    it wont support when i give L_bukrs in inner join clause..!!
    any idea to change the query??
    thaks and regards
    Jose

    Hi,
    Declare the select option as  s_bukrs .
    SELECT-OPTIONS :
    S_bukrs FOR WA_INPUT-bukrs NO INTERVALS ,
    SELECT
    VBAK~BUKRS_VF AS BUKRS "COMPANY CODE
    PA0001~ENAME "SALES EMPLOYEE NAME
    KNA1~NAME1 "CLIENT
    VBKD~BSTKD "PO NO
    VBAK~VBELN "SO NO
    VBAK~AUDAT "SO DATE
    VBAP~POSNR "LINE
    VBAP~KWMENG "QTY
    VBAP~VRKME "UNIT
    VBAP~NETPR "RATE
    VBAP~NETWR "ORDER VALUE
    VBAP~WAERK "DOCUEMNT CURRENCY
    VBAP~MATNR "MATERIAL NO
    VBAP~ARKTX "MATERIAL NAME
    VBKD~KURSK "EXCHANGE RATE
    INTO CORRESPONDING FIELDS OF TABLE IT_OPSALES
    FROM VBAP
    LEFT OUTER JOIN VBPA ON VBPAVBELN = VBAPVBELN AND VBPA~PARVW = 'AF'
    INNER JOIN PA0001 ON PA0001PERNR = VBPAPERNR
    INNER JOIN VBAK ON VBAKVBELN = VBAPVBELN
    INNER JOIN KNA1 ON KNA1KUNNR = VBAKKUNNR
    INNER JOIN VBKD ON VBKDVBELN = VBAKVBELN AND VBKDPOSNR = VBAPPOSNR
    WHERE BUKRS IN S_BUKRS
    Hope this helps you.
    Thanks & Regards,
    Y.R.Prem Kumar

  • How to write Error message for select options?

    Hi
    i have this select option statement
    SELECT-OPTIONS: s_fevor FOR afko-fevor.
    how to write error message for this?
    Regards
    Smitha

    Error messages are displayed for Select-options mostly on two conditions:
    1) You needs to check wether a value is entered or not its done by:
    a)
    Select-options:SELECT-OPTIONS: s_fevor FOR afko-fevor Obligatory.
       In this case error message is automatically throwed by system.
    b) You can do this in Selection Screen events.
    Ex:
    AT SELECTION-SCREEN./AT SELECTION-SCREEN ON S_FEVOR.
    IF S_FEVOR-LOW IS INITIAL.
    MESSAGE 'XXXXX' TYPE 'E'.
    ENDIF.
    2) You need to Validate the entered value:
    You can do this in Selection Screen events.
    Ex:
    AT SELECTION-SCREEN./AT SELECTION-SCREEN ON S_FEVOR.
    SELECT FEVOR
                 FROM AFKO
                 INTO AFKO-FEVOR
                 UP TO 1 ROWS
    ENDSELECT.        
    IF SY-SUBRC NE 0.
    MESSAGE 'XXXXX' TYPE 'E'.
    ENDIF.
    Regards,
    Gurpreet

  • Multiple records in select options-Urgent help

    Hi all,
       Iam using the following function module to get the set values. I need to pass multiple values in select options(ie) select options with no intervals. to the function module parameter Shortname. I have declared the variable which has to be passed as
         S_SETID   FOR  SETHEADER-SETNAME NO INTERVALS.
      The problem is when i use S_SETID-LOW the value is passed to the function module , but if multiple data is entered in the input then how to pass all the data to the function module. Please Help.

    Hi,
    Declare the Range in the Function module , then you can pass that Select-option fields to that ranges and use that in the Function module.
    Or you can use the RANGE_C8 for the Select-optios in the Function module, you can declare the Internal table with the type of RANGE_C8 in the tables parameter, then pass the Select-option to this Internal table
    If you want more length field then search based on RANGE_* then you will get all the Range Structure.
    Regards
    Sudheer

  • How can we pass the select-option value to modulepool program?

    hi,
      how can we pass the select-option value to modulepool program ?
      Because if i declared select-options in executable program and i used SSCRFIELDS to define push buttons in selection screen.
               My requirement if enter the values to select-options and press UPDATE pussbotton then i want call screen which contains tablecontrol.
               How i get select-option values to PAI of call screen for getting the data from database table to my internal table?

    Oh I thought that you have selection-screen and again you are working on dialog programming.
    if you want to use select-option directly in module pool then it is not possible.
    but you can do other way.
    create two varaiables
    data : v_kun_low like kna1-kunnr,
             v_kun_high like kna1-kunnr.
    use these two variables in layout ,let user knows that he can not give options like gt,lt,eq ,it will be always BT.
    and also when you see normal report program,you can use multiple values in either low or high,but here it is not possibel.
    use can enter only low value and high value.
    when you come to program point of view
    declare one range
    ranges r_kunnr for kna1-kunnr.
    do the coding like
    r_kunnr-low = v_kun_low.
    r_kunnr-high = v_kun_high.
    r_kunnr-options = 'BT'.
    r_kunnr-sign = 'I'.
    append r_kunnr.
    now you can use r_kunnr in select query ,it will work like select-option.
    other than this there is no option.
    Thanks
    Seshu

  • Select options in function module

    hi friends, pls help me reg my query.
    I have wERKS select-options
    on the selection screen.
    (This same thing, i want to pass in FM)
    2. So in FM, I have used the
    TABLES parameter (Not import, nor export)
    3. And the type given is
    WERKS_RANG
    i defined it like
    plant type WERKS_RANG
    (This WERKS_RANG has 4 fields,
    just like a select option
    SIGN
    OPTION
    LOW
    HIGH
    4. Then inside fm,
    i used SELECT Query,
    and use IN WERKS.
    below is my code in FM.
    select lgort labst
    from mard
    into table imard1
    where PLANT in werks
    and material1 = matnr.
    but i am getting an error "field plant is unknown". i have defined it under tables parameter..pls help
    how shud i get the values i enter in select option for main program in se38 to function module field 'plant'...

    Hi
    You can define your TABLE parameter WERK without reference and define a range in your fm:
    FUNCTION Z_PROVA_PROVA.
    ""Interfaccia locale:
    *"  IMPORTING
    *"     REFERENCE(MATNR) TYPE  MATNR
    *"  TABLES
    *"      SEL_WERKS
      RANGES R_WERKS FOR MARD-WERKS.
      R_WERKS[] = SEL_WERKS[].
      DATA: BEGIN OF IMARD1 OCCURS 0,
               LGORT LIKE MARD-LGORT,
               LABST LIKE MARD-LABST,
            END   OF IMARD1.
      SELECT LGORT LABST FROM MARD  INTO TABLE IMARD1
      WHERE WERKS IN R_WERKS
      AND MATNR = MATNR.
    Max

  • Select options in madulupool

    Hi Friends,
    I need to add select-option in my modulepool screen.
    the select option is for material Group.
    how to add select options in madulepools?
    thanks,
    Sridhar

    hi
    good
    if you want to use select-option directly in module pool then it is not possible.
    but you can do other way.
    create two varaiables
    data : v_kun_low like kna1-kunnr,
    v_kun_high like kna1-kunnr.
    use these two variables in layout ,let user knows that he can not give options like gt,lt,eq ,it will be always BT.
    and also when you see normal report program,you can use multiple values in either low or high,but here it is not possibel.
    use can enter only low value and high value.
    when you come to program point of view
    declare one range
    ranges r_kunnr for kna1-kunnr.
    do the coding like
    r_kunnr-low = v_kun_low.
    r_kunnr-high = v_kun_high.
    r_kunnr-options = 'BT'.
    r_kunnr-sign = 'I'.
    append r_kunnr.
    now you can use r_kunnr in select query ,it will work like select-option.
    other than this there is no option.
    thanks
    mrutyun^

  • At new, EXIT,STOP and CONTINUE, Select-options Initialization

    Hi Experts,
    I am having the following requirements.
    1) I have design the selection screen by using Select-options statement. In that i have to initialize both low and high values. I don't know how to write and where to write the code for the same.
    2) and another requirement as
    field A  contain values ( 0, 1, 1, 0, 1, 1, 1, 0)
    Field B  contain values (1, 0, 1, 1, 1, 1, 1, 1)
    At new b.
    write:/ b.
    endat.
    In the above case how many times At new statement calls.
    3) How is EXIT differ to STOP and CONTINUE. Please give me the brief idea on this.
    I hope i will get the accurate results for the above soon.
    Regards
    Prabhakar

    Hi,
    1.
    Select-options could be initialised with the command INITIALIZATION.
    Ex :
    tables : MARA.
    select-options : s_matnr for mara-matnr.
    Intialization.
      move : '123456789' to s_matnr-low ,
             'I'         to s_matnr-sign ,
             'EQ'        to s_matnr-option.
      append s_matnr.
    I means  Include, the other possible value is E for exclude.
    EQ means EQual, could be BT BeTween ...
    The structure of a select-options is : Sign, Option, Low and High. (Low and High is the two values you see in screen).
    The commande Initialization could be place anywhere outside the start-of-selection ... end-of-selection.
    2.
    3 times ..  but, depends where are the fields ..
    4.
    The command EXIT leave the current command. Command could be a PERFORM, a DO, a LOOP, a SELECT, ...
    The command STOP go to the end-of-selection. If you put some code after the end-of-selection, the code will be processed.
    Rgd
    Frédéric

  • Select-option.....strange problem.....have ur points.

    Hi all
    pleas see the code...
    SELECT-OPTIONS : dept FOR equz-ingrp DEFAULT 'DG'.
    write : / dept.
    output-> IEQDG
    Now thing is equz is a fields with length 3 character, what ever i select from the drop down in select option.
    IEQ is attached with every value....
    Why? Please assist me...
    <b>Have ur points.</b>
    Regards,
    pradeep phogat

    Hi Pradeep,
    Select option is similar to an internal table & has 4 fields in it.
    SIGN
    OPTION
    LOW
    HIGH
    Inorder to display contents of select option you need to code as follows:
    loop at dept.
    write :/ dept-low, dept-high.
    endloop.
    Best regards,
    Prashant

Maybe you are looking for

  • Can't get SMTP working with SSL on Panther Server

    mail client is mail.app mail server on panther server (ie the default one) all works fine without SSL if i turn on the SSL option for IMAP in mail.app, it works but if I turn on the SSL option for SMTP, it doesn't. Mail.app tells me that "Starting TL

  • Highlighted text in Normal report.

    Hi, My client requirements is that one report has to display in higlighted text for every alternative line items. This is a normal classical report, In alv we can achive this. But in normal report how it can be possilbe. Please suggest me on this.. T

  • Suitable Laptop for PXI-1033

    I am using a PXIe-8360 with a PXI-1033 and am trying to find a laptop that is compatible with this system.  NI states that not all laptops work with this configuration and has a list of laptops that do have been tested at (http://zone.ni.com/devzone/

  • Where is the batchusr.sql location???

    dear all, where is the location of batchusr.sql actually ???? i've searched on my db and oas home, even in oas installer : discoverer\utils directory, but still not found. there are any other source location to find it ??? this is the first time i tr

  • How source data changing synchronize to destination after exp from source?

    Stream creation, how the source data changing synchronize to the destination after exp data from source? Time of Stream creation: a. exp/imp exp erpdev/erpdev owner=erpdevobject_consistent=y file=erpdev.dmp grants=y rows=y indexes=y statistics=none i