cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Accessing nested report's data

Former Member
0 Likes
2,049

Okay I have a nested report, not a composite so GetChild is of no use, and I'd like to get to the data in the nested report. This kind of thing works very well:

For ll_loop = 1 to dw_1.RowCount()

     la_any = dw_1.Object.d_nested[ll_loop].object.data

     For ll_loop2 = 1 to UpperBound(la_any)

          ll_ref = dw_validation.Object.dw_property[ll_loop].object.ref[ll_loop2]

     Next

Next

The problem is when dw_1.Object.d_nested[ll_loop].object.data has no rows, a System Error occurs. I can't think of a way to check if there are any rows in advance. Long searches of the internet have turned up the following:

If long(dw_1.Object.d_nested[ll_loop].object.DataWindow.FirstRowOnPage) > 0

     This always returns 0 for me and I know I have data in my first few nested reports

IsNull(dw_1.Object.d_nested[ll_loop])

     This is never TRUE

IsValid(dw_1.Object.d_nested[ll_loop])

     This is never FALSE

Anyone have any other ideas this is driving me crazy, it looks like it should be so simple!!!!

Thank you for any help.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Likes

Why not have datastore with the same dataobject as the nested report. Loop through the base report rows to obtain arguments and retrieve the datastore one base row at a time.

Former Member
0 Likes

The problem is we are loading the report from a saved PSR file and need access to the data in order to generate some charts and we can;t guarantee there is any database connection at that time. It's always more complicated than it should be

Former Member
0 Likes

wow. maybe the data would reveal itself if you did a saveas XML... long shot...

Former Member
0 Likes

One more thing you could do, is to load the PSR twice, one in a separate DS and the other on your original DW. In your DS, when you are going to access the nested report, modify a column's value first. It's going to be like this:

//If there's no row in the nested report this line below will insert one otherwise this will replace the column's value in row 1.

ds.object.nestedreport[i].object.columnX[1] = 1  

//Choose a column that supposed to contain a value (not null) when the row was loaded from PSR.

If IsNull(ds.object.nestedreport[i].object.columnY[1]) Then

  // Then this is a newly inserted row and this means the nested report was empty.

End If

The above is kind of ugly solution but I think would work in checking if the nested report contains a row when first loaded.

Former Member
0 Likes

I think this can be enhanced by just adding a dummy column to your nested report. Before looping through the nested report, set a value to the dummy column at row 1 and then check if the nested report contains only one row. If it has only one row, check if the value of the non-dummy columns are nulls or default values, if they are, then that nested report was empty and that lone row was just inserted when you set the value of the dummy column.

Former Member
0 Likes

Although you did not want to use a composite dw but just try to edit source of your dw and change the processing=0 to processing=5. Then you can use GetChild. See if that would work for you.

Former Member
0 Likes

Thanks for the suggestion but GetChild just doesn't work in situations like this it only returns the data in the first nested datawindow, i.e. the one for row 1 of the main report. I need to be able to see the data that belongs to each row, and the only way to do that is via dot notation, or at least not using GetChild. If only GetChild had a row number as an argument it would be very useful

Former Member
0 Likes

Looks like there's no simple solution. Some options you could do:

1. Manually do a Select to verify if the nested report got some rows to retrieve i.e. select count(*) from table1 where <your conditions same with the retrieval argument on the nested report>

OR

2. Add a dummy row to your dw, i.e. use a UNION clause so that your nested report should contain at least 1 row in every master row.

Former Member
0 Likes

Hi Aron;

  Just a Thought: May I suggest checking to see if their is an array of data first ...

Any   ls_data[]

la_data = dw_1.Object.d_nested.object.data

IF UpperBound (la_data) > 0 THEN

  la_any = dw_1.Object.d_nested[ll_loop].object.data

...

Regards ... Chris

Former Member
0 Likes

Good try Unfortunately it is the dw_1.Object.d_nested.Object.data that causes the crash so you can't get it back into the array in the first place.

Former Member
0 Likes

Hold on maybe I didn't get your code. I'm not sure I understand what you were getting at. Sorry, brain has slowed down, it's been one of those days. Can you explain a bit more?

Thanks.

Former Member
0 Likes

Hi Aron;

   The idea here is that you were trying to access (subscript) a NULL array. Since each of the DWO's buffers are an array, transferring a null array to the variable should not cause it to crash. Then the key is to see if the variable is a null array (ie: upperbound = 0) and then continue (subscript) the DWO's buffer if indeed data is present.

HTH

Regards ... Chris

Former Member
0 Likes

Thanks Chris, I will look at this one tomorrow when my head isn't spinning so much

Former Member
0 Likes

If your in the USA and celebrating Independence Day (July 4th) - you may want to wait another day for your head to stop spinning.  

Happy July 4th to all my US friends (from the Great White North of Canada)!

Former Member
0 Likes

As a Brit (with a Canadian passport) I have to say 'Boo, we should've won!!!'

But "Happy 4th of July" anyway, you hosers

Former Member
0 Likes

Hey, the US guys should thank us for burning the White House down in the war of 1812 (Burning of Washington - Wikipedia, the free encyclopedia ... an example of where the US actually lost a war). Now Mr Obama has some new updated "digs" to work from C/O us.  

PS: Have you hugged you DataWindow today?

Former Member
0 Likes

Hi,

It might be trial and error here, these things can be tricky.

Maybe there is no dw_1.Object.d_nested.Object ? Have you tried IsNull or IsValid?

>> dw_1.Object.d_nested.Object.data that causes the crash

If you don't find a property; and it might not be very elegant, but a systemerror is not a crash and you can capture it locally using a try catch in the loop and continue.

Ben

Former Member
0 Likes

IsNull and IsValid don't seem to be of any use unfortunately, but you're right I could just ignore the error, that may have to be the way to do it.

Former Member
0 Likes

Hi Aron;

  How about wrapping that code in a TRY..CATCH?

Regards .. Chris