Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

5 REPLIES 5

former_member194669
Active Contributor
0 Kudos

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 ?

Former Member
0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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