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

SELECT statement

Former Member
0 Likes
771

Friends,

Could you tell me the difference between below two select statements.

data : itab like ztab occurs 0 with header line.

1. SELECT * FROM ztab

INTO table itab

WHERE cust IN s_cust

AND shipdt IN s_date

AND Xflag NE 'Y'

AND status NE 'XX'

AND ddate LE gv_deldate

AND cflag EQ ' '.

2. SELECT * FROM ztab

WHERE cust IN s_cust

AND shipdt IN s_date

AND Xflag NE 'Y'

AND status NE 'XX'

AND ddate LE gv_deldate.

check ztab-cflag is initial.

move-corresponding ztab to itab.

append itab.

ENDSELECT.

I am looking up for a particular entry in the ztab but it would give me the result when i use the 2nd select statement. But i think both the statements should give the same results.

Thanks,

Dev

1 ACCEPTED SOLUTION
Read only

ferry_lianto
Active Contributor
0 Likes
721

Hi,

Please try this.


SELECT * FROM ztab
INTO table itab
WHERE cust IN s_cust
AND shipdt IN s_date
AND Xflag NE 'Y'
AND status NE 'XX'
AND ddate LE gv_deldate
AND cflag IS initial.             "Change here

Regards,

Ferry Lianto

7 REPLIES 7
Read only

Former Member
0 Likes
721

I do not see any diffrenece in both query's

data : itab like ztab occurs 0 with header line.

1. SELECT * FROM ztab

INTO table itab

WHERE cust IN s_cust

AND shipdt IN s_date

AND Xflag NE 'Y'

AND status NE 'XX'

AND ddate LE gv_deldate

AND cflag EQ <b>space</b>.

2. SELECT * FROM ztab

WHERE cust IN s_cust

AND shipdt IN s_date

AND Xflag NE 'Y'

AND status NE 'XX'

AND ddate LE gv_deldate.

check ztab-cflag is initial.

move-corresponding ztab to itab.

append itab.

ENDSELECT.

What is data type of cflag ?

sort the internal table and see the results.

Thanks

Seshu

Read only

0 Likes
721

cflag data type is 1 character in both cases.

I tried using space instead of ' ' in the select statement . It gives me result only when i use check statement.

Read only

Pawan_Kesari
Active Contributor
0 Likes
721

depending on the type of field CFLAG the select statement may give you different result.... Both statement will give same result of CFLAG is of type CHAR with lenth 1

Read only

ferry_lianto
Active Contributor
0 Likes
722

Hi,

Please try this.


SELECT * FROM ztab
INTO table itab
WHERE cust IN s_cust
AND shipdt IN s_date
AND Xflag NE 'Y'
AND status NE 'XX'
AND ddate LE gv_deldate
AND cflag IS initial.             "Change here

Regards,

Ferry Lianto

Read only

0 Likes
721

It works when i use cflag is NULL. But would like to know the difference. Why would it not show up in case of 1st select stmt.

Read only

former_member194669
Active Contributor
0 Likes
721

Hi,

Try this way


SELECT * FROM ztab
INTO table itab
WHERE cust IN s_cust
AND shipdt IN s_date
AND Xflag NE 'Y'
AND status NE 'XX'
AND ddate LE gv_deldate.
if sy-subrc eq 0.
 delete ztab where cflag ne space.
endif.

aRs

Read only

Former Member
0 Likes
721

Performance wise 2nd one is better..

though results will be same.

Reward if useful..

Regards

Prax