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: 

Where condition

Former Member
0 Kudos

Hello friends I have to pull data from a table, based on records created from the last execution of the program till the current time.

I have written my logic as is below,

Can it be made more simple as it seems confusing to my lead.

where ( vbrkerdat EQ w_var_date AND vbrkerzet GT w_var_time )

OR ( vbrkerdat GT w_var_date AND vbrkerdat LT w_sys_date )

OR ( vbrkerdat EQ w_sys_date AND vbrkerzet LE w_sys_time ).

w_var_date - date when the program was executed last

w_var_time - time when the program was executed last

w_sys_date - sy-datum (Sysytm Date)

w_sys_time - sy-erzet (System time)

any advice,

Shejal Shetty.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

You don't have to consider the system date and time..

WHERE ( vbrkerdat >= w_var_date and vbrkerzet > w_var_time ).

I believe this should be enough..

Thanks,

Naren

7 REPLIES 7

Former Member
0 Kudos

Hi,

You don't have to consider the system date and time..

WHERE ( vbrkerdat >= w_var_date and vbrkerzet > w_var_time ).

I believe this should be enough..

Thanks,

Naren

Former Member
0 Kudos

Well, how about:


where ( vbrk~erdat EQ w_var_date AND vbrk~erzet GT w_var_time )
   OR ( vbrk~erdat GT w_var_date ).

Former Member
0 Kudos

That was a good one Rob..

Regards

Naren

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this.


SELECT vbrk~erdat vbrk~erzet 
...
ORDER BY vbrk~erdat DESCENDING
         vbrk~erzet DESCENDING.

Regards,

Ferry Lianto

0 Kudos

Thanks everyone.

I didnt think of not uding the current date and time.

Thanks again.

Former Member
0 Kudos

Hi Shejal,

To meet your requirement all conditions are necessary.

So, your WHERE condition is absolutely correct even though it looks confuse.

Note: You need to put additional parenthesis to your condition. Otherwise, it will leads to wrong results.

Your intention is meet to one of conditions, so all these conditions should be under one more pair of parenthesis.

where <b>(</b> ( vbrkerdat EQ w_var_date AND vbrkerzet GT w_var_time )

OR ( vbrkerdat GT w_var_date AND vbrkerdat LT w_sys_date )

OR ( vbrkerdat EQ w_sys_date AND vbrkerzet LE w_sys_time ) <b>)</b>.

Thanks,

Vinay

0 Kudos

Thanks Vinay for the suggestion but i am kind of thinking that the way Rob has said would also meet all the conditions..Dosent It?

and looks smuch simplier than the one i had written it.

Shejal