Scripting Adding Conditions to Report (Bug?)

Hi,

I’m having problems adding conditions to a report through OLE (though the problem may well apply to standard scripts too).

I have successfully applied conditions to several objects through code (based on user selections) and these are displayed correctly in the Data | Edit dialog as well.

However I’m now adding some additional conditions which are failing. Or at least when I say fail theres no error but the condition isn’t applied, and furthermore all other conditions are removed.

The particular class/object set up I have is as follow :

Class : Activity
Object : Description
Sub Class : Activity Start
Objects : Activity Start (and several others to form a date hierarchy which includes, year month and quarter).

Now I apply the condition by using the Add method of the Conditions collection. I say

Conditions.Add (“Activity”, “Activity Start”, “Greater than or equal to”, “<>”, “Constant”)

And this causes the probs. No errors, but all conditions are removed. I’ve also noticed that I can say

Conditions.Add (“Foo”, “Activity Start”, “Greater than or equal to”, “<>”, “Constant”)

Where the Foo class doesn’t exist. Again theres no errors, and all conditions are removed. This leads me to two conclusions

a. Theres a bug which isn’t properly generating errors when non-existent classes are referenced in a query. Ideally an error should be displayed, or other indicator that the condition is incorrect. No error message, and complete removal of all conditions isn’t the best behaviour

b. My particular problem is one of referencing - Bus. Obj. doesn’t know which Class | Object combination I’m referring to. I can add a condition to description OK, but not object in the subclass

So I guess my questions are :

a. does anyone have any experience with this problem b. anyone have any idea how to correctly reference a Class | SubClass | Object within an Add call

Help/Comments appreciated.

btw. I’m using Bus. Obj 4.1.1 and am scripting the system through OLE.

Cheers,

L.

======================================================================
“Never do with more what can be achieved with less”
–William of Occam

====================================================================== LEIGH DODDS | 20 Manvers Street | leigh.dodds@dtcg.co.uk
Software Engineer | Bath BA1 1PX | TEL +44 (0)1225 444700
Deloitte Consulting | www.praxis.co.uk |


Listserv Archives (BOB member since 2002-06-25)

Leigh,

if
Sub Class : Activity Start
Object : Activity Start

then I think you should use

Conditions.Add (“Activity Start”, “Activity Start”, “Greater than or equal to”, “<>”, “Constant”)

I hope it helps

Peter

Leigh Dodds Leigh.Dodds@DTCG.CO.UK 30/07/98 13:20:20 >>>
Hi,

Class : Activity
Object : Description
Sub Class : Activity Start
Objects : Activity Start (and several others to form a date hierarchy which includes, year month and quarter).

Now I apply the condition by using the Add method of the Conditions collection. I say

Conditions.Add (“Activity”, “Activity Start”, “Greater than or equal to”, “<>”, “Constant”)


Listserv Archives (BOB member since 2002-06-25)

Hi,

thanks for the tip Peter, but I’ve examined this problem further and I’m now pretty sure its either a bug with Bus. Obj. or problem with interfacing with Oracle. And apologies outright for a rather long posting

Heres a simple test case I produced, I’d be interested if anyone else has the same error.

Database :

A single table (TableA), with two columns. One column is a DATE column, another is a VARCHAR2 (text) column.

Contains a single row, with any date / text you like.

Universe :

Straight import of table, creates single class (ClassA), and two objects (DateCol, TextCol).

Report :

Create a report based on the table. This works fine. Manually add a condition to the report, which selects all values prior to the date in the table. This works fine, and the report shows data correctly.

Code :

I’ve shown this error both with OLE and the scripting language. The first gives no feedback and no errors, the latter does (theres a warning there in itself).

Heres the script code :

Sub Main
Dim lobjDataProv as BODataProvider
Dim lobjDocument as BODocument
Dim lobjQuery as BOQuery

Set lobjDocument = Application.Documents.Item(1) Set lobjDataProv = lobjDocument.DataProviders.Item(1)

lobjDataProv.Load
Set lobjQuery = lobjDataProv.Queries.Item(1)

Dim lobjConditions as BOConditions
Dim lobjCondition as BOCondition

Set lobjConditions = lobjQuery.Conditions

MsgBox “Adding Condition”

’ Condition on date column
Set lobjCondition = lobjConditions.Add(“ClassA”, “DateCol”, “Greater than or equal to”,“01-JAN-98”)

’ Condition on text column
Set lobjCondition = lobjConditions.Add(“ClassA”, “TextCol”, “Greater than or equal to”,“Text”)

MsgBox “Added Condition”

lobjDataProv.Unload
lobjDataProv.Refresh
End Sub

Now if you comment out the line that adds the date condition, and just use the text one, everything is OK. The condition applies, and is visible in the Data provider editor dialog box.

Now comment out the text condition, and try the date condition. It fails. The message is an Oracle error saying “Unknown Column”. Now this is bizarre as there is only 1 table, 2 columns, no aliases or other mechanisms which ought to confuse Bus. Obj. The error arises that the Unload statement. If you comment out the unload and refresh statements, then there are no errors. However if you now attempt to View or Edit the data nothing happens. The dialogs do not appear (and on occasions Bus. Obj. crashes).

btw. the way I’m using 4.1.1 and Oracle 7.3.3.

Anyone have any ideas on this?

I’ve had the same problems through OLE, and also the same successes - text columns and conditions work fine.

Another unusual problem is that if I manually apply a query to the same object, to the date field, it works fine. Now if I copy the SQL out of the data provider and paste it to the SQL prompt, I get an Oracle error. Its obvious that the date formatting isn’t correct (not Oracle standard) - which suggests that some other processing occurs to the SQL in your Data Provider which isn’t immediately obvious.

Comments appreciated.

L.


Listserv Archives (BOB member since 2002-06-25)

Hi,

Test this syntax:

Set lobjCondition = lobjConditions.Add(“ClassA”, “DateCol”, “Greater than
or equal to”,"{d ‘01-01-1998’}")

CU

BERATA AG
Yves A. Liechti
Dep: Software-Development
liechti@berata.com / www.berata.com


Listserv Archives (BOB member since 2002-06-25)