Skip to Content
author's profile photo Former Member
Former Member

select query

Hi all,

Plz tell me how to write select query .

I have 5 inputs in selection screen, 2 are obligatory , 3aro not.

In my first select qyery of my report how how can i write the conditions in where clause for this.

select ekgrp matnr werks lgort r menge meins badat

frgdt ebeln ebelp

into table itab_eban from eban

where ( ekgrp eq p_ekgrp ) and

( matnr in s_matnr ) and

werks eq p_werks and

( lgort eq p_lgort ) and

badat in s_badat.

endif.

I knew that if the input field is not obligatory, then we write the condition in brackets.

Plz tell me.

Savita

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 07:43 AM

    Hi Savita,

    You can make all selection screen parameters as select-options, as select-options work fine even we donot give any value.

    That is all the obligatory and optional fields you need to make them as select-options without intervals and extensions.

    SELECT-OPTIONS: p_date FOR SY-DATUM NO-EXTENSION NO INTERVALS.

    Plz reward if useful.

    Thanks,

    Dhanashri.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 07:04 AM

    hi savita,

    ur select stmt should be like this.

    SELECT FIELD1 FIELD2.... FROM <TABLE> INTO TABLE <INTERNAL TABLE> WHERE COND1 AND

    COND2 AND

    COND3.

    DO NOT BOTHER ABOUT OBLIGATORY.

    Rgds.,

    subash

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 07:07 AM

    Hi Savitha,

    If the Selection Screen Filed is mandatory or not, No need to write in BRACKETS. Remove the brackets in your code and check it.

    Reward if it Helps.

    Regards,

    Viji.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 07:08 AM

    Hi,

    There is no need to give in brackets. There is nothing like that if the input field is not obligatory, then we write the condition in brackets.

    Regards

    Susheel

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 07:08 AM

    HI,

    Obligatory fields are the mandatory fields on the selection screen, These fields will not make difference in fetching the data. Write the select according to your requirement, don't bother about the mandatory fields on the selection screen.

    Functionality: Obligatory fields will not allow to leave the selection screen until these fields are filled properly.

    Reward points if it is helpful.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Dear,

      Try like this,

      if p_ekgrp is initial and

      p_werks is intial and

      s_badat is initial.

      select ekgrp matnr werks lgort r menge meins badat

      frgdt ebeln ebelp

      into table itab_eban from eban

      matnr in s_matnr and

      lgort eq p_lgort .

      elseif p_ekgrp is not initial and

      p_werks is intial and

      s_badat is initial.

      select ekgrp matnr werks lgort r menge meins badat

      frgdt ebeln ebelp

      into table itab_eban from eban

      matnr in s_matnr and

      ekgrp eq p_ekgrp and

      lgort eq p_lgort .

      elseif

      ......................

      ......................

      elseif

      ......................

      else.

      select ekgrp matnr werks lgort r menge meins badat

      frgdt ebeln ebelp

      into table itab_eban from eban

      where ekgrp eq p_ekgrp and

      matnr in s_matnr and

      werks eq p_werks and

      lgort eq p_lgort and

      badat in s_badat.

      endif.

      Regards,

  • Posted on Jun 18, 2008 at 07:10 AM

    Hi Savita,

    No need to bother about weather input field is obligatory or not, if the input field is blank the select query does not consider that input field.

    select ekgrp matnr werks lgort r menge meins badat

    frgdt ebeln ebelp

    into table itab_eban from eban

    where ekgrp eq p_ekgrp and

    matnr in s_matnr and

    werks eq p_werks and

    lgort eq p_lgort and

    badat in s_badat.

    Regards,

    Sachin M M

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.