2009 Mar 16 11:34 AM
hi experts..
i want to give 'OR' condition in the 'where' clause of 'SELECT' statement.
is it possible?
for examlpe..
IF EXIDV2 IS NOT INITIAL.
SELECT * FROM YSDT_SHIPLOAD
INTO TABLE IG_SHIPLOAD
WHERE EXIDV2 = EXIDV2 AND
VHILM = PC1 OR PC2 OR PC3.
ENDIF.
i want that VHILM should be one of those three.
how can i do this?
thanks..
2009 Mar 16 11:37 AM
IF EXIDV2 IS NOT INITIAL.
SELECT * FROM YSDT_SHIPLOAD
INTO TABLE IG_SHIPLOAD
WHERE EXIDV2 = EXIDV2 AND
( VHILM = PC1 OR VHILM = PC2 OR VHILM = PC3 )
ENDIF.
2009 Mar 16 11:38 AM
Yes it is possible,
[https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_bc_db/~form/handler%7b5f4150503d3030323030363832353030303030303031393732265f4556454e543d444953504c4159265f4e4e554d3d393531343136%7d]
[http://help.sap.com/saphelp_nw04s/helpdata/en/b6/1bfb3f8c040d5fe10000000a155106/frameset.htm]
2009 Mar 16 11:38 AM
use the IN condition
eg:
SELECT * FROM YSDT_SHIPLOAD
INTO TABLE IG_SHIPLOAD
WHERE EXIDV2 = EXIDV2 AND
VHILM in ( 'PC1','PC2','PC3' ).
or if you want to use OR
eg:
SELECT * FROM YSDT_SHIPLOAD
INTO TABLE IG_SHIPLOAD
WHERE EXIDV2 = EXIDV2 AND
( VHILM eq PC1 or VHILM eq PC2 or VHILM eq PC3 ).
2009 Mar 16 11:39 AM
Hi,
First create range for VHILM as:
ranges: rg_vhilm for vhilm.
rg_vhilm-sign = 'I'.
rg_vhilm-option = 'EQ'.
rg_vhilm-low = 'PC1'.
append rg_vhilm.
rg_vhilm-low = 'PC2'.
append rg_vhilm.
rg_vhilm-low = 'PC3.
append rg_vhilm.
IF EXIDV2 IS NOT INITIAL.
SELECT * FROM YSDT_SHIPLOAD
INTO TABLE IG_SHIPLOAD
WHERE EXIDV2 = EXIDV2 AND
VHILM in rg_vhilm
ENDIF.
Thanks & Regards,
Anagha Deshmukh
2009 Mar 16 11:39 AM
Tried it
SELECT * FROM YSDT_SHIPLOAD
INTO TABLE IG_SHIPLOAD
WHERE EXIDV2 = EXIDV2 AND
VHILM = PC1 OR
VHILM = PC2 OR
VHILM = PC3.
2009 Mar 16 11:40 AM
use 'in' like
IF EXIDV2 IS NOT INITIAL.
SELECT * FROM YSDT_SHIPLOAD
INTO TABLE IG_SHIPLOAD
WHERE EXIDV2 = EXIDV2 AND
VHILM in( PC1 ,PC2 ,PC3)
ENDIF.
that works same as or
and better in perfomance vise,\
Regards,
Alpesh
2009 Mar 16 11:40 AM
Hi,
Check this from F1 help.
DATA spfli_tab TYPE TABLE OF spfli.
SELECT *
FROM spfli
INTO TABLE spfli_tab
WHERE cityfrom = 'FRANKFURT' AND
( cityto = 'LOS ANGELES' OR
cityto = 'SAN FRANCISCO' ).
Try to code like this:
IF EXIDV2 IS NOT INITIAL.
SELECT * FROM YSDT_SHIPLOAD
INTO TABLE IG_SHIPLOAD
WHERE EXIDV2 = EXIDV2 AND
( VHILM = PC1 OR VHILM = PC2 OR VHILM = PC3 ).
ENDIF.
Cheers,
Rudhir
2009 Mar 16 11:42 AM
Hi -
Try this :
IF EXIDV2 IS NOT INITIAL.
SELECT * FROM YSDT_SHIPLOAD
INTO TABLE IG_SHIPLOAD
WHERE EXIDV2 = EXIDV2 AND
( VHILM = PC1 OR VHILM = PC2 OR VHILM = PC3 ).
ENDIF.
2009 Mar 16 11:43 AM
Hi ,
its possible,
Select * from ysdt_shipload int table ig_shipload where exidv2 = exidv2
AND vhilm = pc1
OR vhilm = pc2
OR vhilm = pc3.
OR
Select * from ysdt_shipload int table ig_shipload where exidv2 = exidv2
AND (vhilm = pc1 or vhilm = pc2 or vhilm = pc3).
Regards
Arani Bhaskar
Edited by: arani bhaskar on Mar 16, 2009 5:14 PM