Skip to Content
author's profile photo
Former Member

Is this select statement okay?

Hi,

COuld you just check this:

This is the current code:

SELECT SINGLE * FROM v_anlhz

WHERE bukrs = '3166'

AND anlkl = 'GB060'

AND aktiv = sy-datum

AND erdat = sy-datum

AND txt50 = bdc_inrec-txt50

AND kostl = v_kostl.

Sometimes the value for anlkl can be XXX, so is the following code okay?

SELECT SINGLE * FROM v_anlhz

WHERE bukrs = '3166'

AND anlkl = 'GB060'

OR anlkl = 'GB060'

AND aktiv = sy-datum

AND erdat = sy-datum

AND txt50 = bdc_inrec-txt50

AND kostl = v_kostl.

Many Thanks!

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    author's profile photo
    Former Member
    Sep 29, 2005 at 01:04 PM

    hi,

    both the select statments into statement are missing

    you change like that

    data temp like v_anlhz

    SELECT SINGLE * FROM v_anlhz into temp

    WHERE bukrs = '3166'

    AND anlkl = 'GB060'

    AND aktiv = sy-datum

    AND erdat = sy-datum

    AND txt50 = bdc_inrec-txt50

    AND kostl = v_kostl.

    Sometimes the value for anlkl can be XXX, so is the following code okay?

    SELECT SINGLE * FROM v_anlhz into temp

    WHERE bukrs = '3166'

    AND anlkl = 'GB060'

    OR anlkl = 'GB060'

    AND aktiv = sy-datum

    AND erdat = sy-datum

    AND txt50 = bdc_inrec-txt50

    AND kostl = v_kostl.

    so the result will be available in temp.

    cheers,

    sasi

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 29, 2005 at 01:08 PM

    this is just the addition of '(' ')' in sasi's solution -

    SELECT SINGLE * FROM v_anlhz into temp

    WHERE bukrs = '3166'

    AND anlkl = 'GB060'

    AND aktiv = sy-datum

    AND erdat = sy-datum

    AND txt50 = bdc_inrec-txt50

    AND kostl = v_kostl.

    Sometimes the value for anlkl can be XXX, so is the following code okay?

    SELECT SINGLE * FROM v_anlhz into temp

    WHERE bukrs = '3166'

    AND ( anlkl = 'GB060'

    OR anlkl = 'GB060' ) "<<< change

    AND aktiv = sy-datum

    AND erdat = sy-datum

    AND txt50 = bdc_inrec-txt50

    AND kostl = v_kostl.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      I think into clause is not mandatory in case you are selecting all the fields. If you are selection particular no of fields then you need to specify the into clause. also when you have two/more possible values for one field in the data base table then put the brackets before and last of the values.

      Best way is you can assign that value to any variable and use that variable to that select condition.

      Hope this will solve your problem.

      Regards,

      Amit

  • author's profile photo
    Former Member
    Sep 29, 2005 at 10:50 PM

    Robert,

    If you have a list of Asset Classes, you can also use a RANGE.

    eg.

    RANGES: ra_anlkl for anla-anlkl.
    
    perform add_anlkl using 'GB060'.
    perform add_anlkl using 'GB070'.
    
    form add_anlkl using pa_anlkl.
      clear ra_anlkl.
      ra_anlkl-sign   = 'EQ'.
      ra_anlkl-option = 'I'.
      ra_anlkl-low    = pa_anlkl.
      append ra_anlkl.
    endform.
    
    SELECT SINGLE * FROM v_anlhz
           WHERE bukrs = '3166'          AND
                 anlkl IN ra_anlkl       AND
                 aktiv = sy-datum        AND
                 erdat = sy-datum        AND
                 txt50 = bdc_inrec-txt50 AND
                 kostl = v_kostl.
    

    This makes your SELECT statement neater and easier to read if you want to select for multiple Asset Classes.

    Hope this helps.

    Cheers,

    Pat.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 29, 2005 at 11:03 PM

    Robert,

    Insert INTO or INTO CORRESPONDING FIELDS in the select statement.

    If you have multiplea entries for ANLKL, then it is always better to build a range will all the possible values and use that in the WHERE condition of the SELECT statement using IN operator like

    anlkl IN r_anlkl

    Thanks,

    Add comment
    10|10000 characters needed characters exceeded