Application Development and Automation 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: 
Read only

Where condition

Former Member
0 Likes
996

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
Read only

Former Member
0 Likes
953

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
Read only

Former Member
0 Likes
954

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

Read only

Former Member
0 Likes
953

Well, how about:


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

Read only

Former Member
0 Likes
953

That was a good one Rob..

Regards

Naren

Read only

Former Member
0 Likes
953

Hi,

Please try this.


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

Regards,

Ferry Lianto

Read only

0 Likes
953

Thanks everyone.

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

Thanks again.

Read only

Former Member
0 Likes
953

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

Read only

0 Likes
953

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