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

Need help with select statement

Former Member
0 Likes
757
SELECT  SINGLE * into corresponding fields of LS_JOB from DTAB
where
JOB_REPORT = JOBNAME and
JOBCOUNT = JOBCOUNT and
SCHED_START_DATE = today or SCHED_START_DATE = tomorrow .

In the select the requirement is that after the where condition select should be evaluated in the following way

(JOB_REPORT = JOBNAME and JOBCOUNT = JOBCOUNT and {SCHED_START_DATE = today or SCHED_START_DATE = tomorrow })

OR takes precedence over and and the statement is not evaluated as above. I thought of writing like code like this to achive my purpose

SELECT  SINGLE * into corresponding fields of LS_JOB from DTAB
where
JOB_REPORT = JOBNAME and
JOBCOUNT = JOBCOUNT and
SCHED_START_DATE = today .

IF SY-SUBRC NE 0.
SELECT  SINGLE * into corresponding fields of LS_JOB from DTAB
where
JOB_REPORT = JOBNAME and
JOBCOUNT = JOBCOUNT and
SCHED_START_DATE = tomorrow.
ENDIF.

Is there a way to do this with a single select statement.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
727

Hi,

Write the coding as :

SELECT SINGLE * into corresponding fields of LS_JOB from DTAB

where

JOB_REPORT = JOBNAME and

JOBCOUNT = JOBCOUNT and

( SCHED_START_DATE = today or

SCHED_START_DATE = tomorrow ) .

Regards,

Srini.

6 REPLIES 6
Read only

Former Member
0 Likes
727

Why dont you use the BETWEEN operator?


SELECT  SINGLE * into corresponding fields of LS_JOB from DTAB
where
JOB_REPORT = JOBNAME and
JOBCOUNT = JOBCOUNT and
SCHED_START_DATE BETWEEN today AND tomorrow. 

Vikranth

Read only

Former Member
0 Likes
727

same effect is achieved with:

and SCHED_START_DATE in (today, tomorrow).

Read only

Former Member
0 Likes
727

SELECT SINGLE * into corresponding fields of LS_JOB from DTAB

where

JOB_REPORT = JOBNAME and

JOBCOUNT = JOBCOUNT and

( SCHED_START_DATE = today or SCHED_START_DATE = tomorrow ).

This should work with paranthesis as written above.

Regards

Munish Garg

Read only

Former Member
0 Likes
728

Hi,

Write the coding as :

SELECT SINGLE * into corresponding fields of LS_JOB from DTAB

where

JOB_REPORT = JOBNAME and

JOBCOUNT = JOBCOUNT and

( SCHED_START_DATE = today or

SCHED_START_DATE = tomorrow ) .

Regards,

Srini.

Read only

matt
Active Contributor
0 Likes
727

It's fairly standard programming practice that when you have a logical expression, that you use brackets to override the default operator precendence.

Have you been programming long?

Read only

Former Member
0 Likes
727

Started in ABAP in recently.

I would not use my C or C++ background....

If I do that I will never get past the ABAP compiler....I am trying to not compare them

Edited by: Vighneswaran CE on Nov 17, 2010 3:30 PM