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

How to combinate the select options using 'when........(.....or......) '

Dears,

I used select statement like

select rnn
         pucustctycode
    into table gt_zgrrnnh
         from zgrrnnh
         where rnn           in s_rnn
         and   lrcdate       gt gv_update
         and   deleteind     eq space.

and

select rnn
         pucustctycode
  appending table gt_zgrrnnh
         from zgrrnnh
         where rnn           in s_rnn
         and   lrcdate       eq gv_update
         and   lrctime       gt gv_uptime
         and   deleteind     eq space.

in my program. and now i want to combinate them using just one select.

and the different select conditions is lrdate and lrtime. and the firest selections has no limit to lrtime, but just limit to lrdate.

Anyone could help me how to use select ............when ..........(...........or............)?

Thanks a lot.

Julie.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Aug 10, 2009 at 07:58 PM

    Hi,

    Try like this.

    
    select rnn pucustctycode lrcdate lrctime
     into table gt_zgrrnnh
             from zgrrnnh
             where rnn           in s_rnn
             and   lrcdate  >= gv_update
             and   deleteind     eq space.
    
    sort gt_zgrrnnh by lrcdate lrctime
    
    loop at gt_zgrrnnh.
    if gt_zgrrnnh-lrcdate < gv_update or gt_zgrrnnh-lrcdate > gv_update and lrctime  < gv_uptime.
    delete gt_zgrrnh index sy-tabix.
    endif.
    endloop.
    
    

    Regards,

    vik

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi,

      good way to solve the problem, and still i get another way

      select rnn
               frcdate
               frctime
          into table gt_zgrrnnh
               from zgrrnnh
               where rnn           in s_rnn
               and   ibmoccode     in s_owning
               and   rnntype       eq p_typrtn
               and   ( ( lrcdate     gt gv_update ) or
                       ( lrcdate     eq gv_update and
                         lrctime     ge gv_uptime ) )
               and   deleteind     eq space.

  • author's profile photo Former Member
    Former Member
    Posted on Aug 10, 2009 at 08:03 PM

    Change your select query like this:

    Select time also, u have to change your internal table Strucutre.

    SELECT   rnn
                   pucustctycode
                   lrctime
        INTO TABLE gt_zgrrnnh
        FROM zgrrnnh
             WHERE  rnn               IN   s_rnn
             AND      lrcdate         GE  gv_update
             AND      deleteind      EQ  space.
    
    

    from this you will all the data irrespective of time , but you have time field in your internal table .

    Now Loop at your internal table and delete those records whoes LRCTIME is less than GV_UPTIME.

    This is one way, i am sure there can be many ways to do this.

    One has to keep trying...

    Let me know ,if you face further issue..

    Regards,

    Mayank

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 10, 2009 at 07:37 PM

    Try this way

    select rnn
           lrcdate
           lrctime
           pucustctycode
           into table gt_zgrrnnh
             from zgrrnnh
             where rnn           in s_rnn
             and   lrcdate       ge gv_update
             and   lrctime       ge '000001'   
             and   deleteind     eq space.
    
    delete gt_zgrrnnh where lrcdate eq gv_update
                        and lrctime lt gy_uptime.
    

    Will it do ?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 10, 2009 at 08:10 PM

    define two different ranges for date and time, populate them accordingly, use them in a select

    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.