Focal Point
[SOLVED] 'OR' statement doesn't work properly.

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4927003766

February 14, 2014, 11:56 AM
hainguyen
[SOLVED] 'OR' statement doesn't work properly.
This is my join. I join VBAK with VBFA, VBAK with VBUK and then join VBFA with LIKP
  
JOIN
 LEFT_OUTER SAP_VBAK.VBAK.VBAK_VBELN IN SAP_VBAK TO MULTIPLE
 SAP_VBFA.VBFA.VBFA_VBELV IN SAP_VBFA TAG J0 AS J0
 END
JOIN
 LEFT_OUTER SAP_VBAK.VBAK.VBAK_VBELN IN SAP_VBAK TO MULTIPLE
 SAP_VBUK.VBUK.VBUK_VBELN IN SAP_VBUK TAG J1 AS J1
 END
JOIN
 LEFT_OUTER SAP_VBFA.VBFA.VBFA_VBELN IN SAP_VBFA TO MULTIPLE
 LIKP.LIKP.LIKP_VBELN IN SAP_VBUK TAG J2 AS J2
 END
TABLE FILE SAP_VBAK
PRINT 
     SAP_VBAK.VBAK.VBAK_VBELN
     J1.VBUK.VBUK_LFSTK
     J1.VBUK.VBUK_GBSTK
     J2.LIKP.LIKP_WADAT_IST
WHERE ( J1.VBUK.VBUK_LFGSK NE 'C' ) OR ( J1.VBUK.VBUK_GBSTK NE 'C' );
END

The issue I got is when I used OR to filter record from VBUK, I got the correct result.
EX : Output I got
  
   VBELN    LFSTK   GBSTK   WADAT_IST
   1111     A       C       
   2222     C       B    

But if I used 1 more OR with LIKP, I will not get those records ( 1111 and 2222) which suppose to be there.
  
WHERE ( J1.VBUK.VBUK_LFGSK NE 'C' ) OR ( J1.VBUK.VBUK_GBSTK NE 'C' ) OR (J2.LIKP.LIKP.WADAT_IST EQ '');

For me, It sounds like I only can use OR in one table. Anybody has suggestion for me. Thanks.

This message has been edited. Last edited by: hainguyen,


WebFOCUS 7.7.03
Windows, All Outputs
February 14, 2014, 12:54 PM
njsden
This may be related with dealing with a MISSING segment on J2 on not really with the number of OR's in your filter.

You're using LEFT_OUTER joins so I assume you expect records on either J1 or J2 to not exist for a given VBAK_VBELN. Try to test on J2.LIKP.LIKP.WADAT_IST EQ '' may be forcing the whole record to be excluded due to a missing segment on that end.

SET ALL=PASS is terrific at dealing with cases like that *if* you were dealing with FOCUS files but doesn't always help when using DBMS tables.

What happens if you do this instead? :

WHERE ( J1.VBUK.VBUK_LFGSK NE 'C' ) OR ( J1.VBUK.VBUK_GBSTK NE 'C' ) OR (J2.LIKP.LIKP.WADAT_IST EQ MISSING);

This message has been edited. Last edited by: njsden,



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
February 14, 2014, 03:52 PM
hainguyen
Thanks njsden. This is awesome. SET ALL=PASS solved the problem but I still have to use J2.LIKP.LIKP.WADAT_IST EQ ''.


WebFOCUS 7.7.03
Windows, All Outputs
February 14, 2014, 03:54 PM
njsden
Hmmm, isn't that interesting?



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
February 14, 2014, 04:05 PM
hainguyen
My bad, I did the wrong test. Both J2.LIKP.LIKP.WADAT_IST EQ '' and J2.LIKP.LIKP.WADAT_IST EQ MISSING work. Thanks and happy valentine.


WebFOCUS 7.7.03
Windows, All Outputs
February 15, 2014, 02:19 PM
Danny-SRL
So, you are using FOCUS files.

When you use SQL tables, don't forget to issue:
SET SHORTPATH=SQL


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF