cancel
Showing results for 
Search instead for 
Did you mean: 

iDW1.OBJECT.dw_izjave.insertrow(0)

Former Member
0 Kudos

Hello,

pb 11.2

I try to insert row in dw which is located in nested dw and I get error. What is wrong with this syntax?

Regards

Tomaz

Accepted Solutions (1)

Accepted Solutions (1)

arnd_schmidt
Active Contributor
0 Kudos

Is "dw_izsave" the name of the report objects as you have stored it in a pbl or

is "dw_izsave" the name of the report control in your main report?

You have to use  the nested report's control name.

Try to use getchild () and then an InsertRow() on that child.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Tomaz;

  Make sure that the DWO is really a "Nested" type. If its a "Composite" (which may look identical) - the GetChild ( ) method is not supported and the command will fail.

Good luck!

Regards ... Chris

Former Member
0 Kudos

Thanks Chris,

yes it's composite (sorry ). How to insert row and set data to report inside composite dwo?

Regards

Tomaz

Former Member
0 Kudos

Ouch!   

The only way to add information in a Composite style report is using the DOT notation. Its a little harder to use but the saviour here is the SQLSyntax utility that can be launched from the PB IDE in the File => New => Tool menu/tab sequence. The DOT notation can only copy data but should suffice in your case.

If for example you have a Composite DWO named "dw_comp" and a child DWO inside that called "dw_tomaz" then here is what the basic syntax would look like if you were loading the child DWO's primary buffer from a working DataStore ...

dw_comp.Object.dw_tomaz.Object.Data  =  DS..Object.Data

Note1: You might want to wrap this in a TRY.. CATCH as a DOT notation failure will cause a run-time error cascade

Note2: DOT notation is not dynamic and cannot be used in a generic loop

HTH

Regards ... Chris

PS: Please vote on enhancement #3686 to have GetChild ( ) method support added to nested DW's!

    http://my.isug.com/p/cm/ld?fid=187

arnd_schmidt
Active Contributor
0 Kudos

Chris,

I am not sure about your statement...

This is nice Article about Datawindow Reporting.

http://pbdj.sys-con.com/node/42527

Former Member
0 Kudos

Thanks Arnd;

  Great tip in the article on changing the DWO's Composite to Nested gender!  

FYI: This code works for me ....

DataStore  lo_ds

lo_ds = CREATE  DataStore

lo_ds.dataobject = 'dw_test2'

lo_ds.SetItem (1, 'name', 'Chris Pollach')

lo_ds.SetItem ( 1, 'phone', 6135551234)

dc_comp.Retrieve ()

// Load data into a nested DWO inside a Composite DWO.

dc_comp.object.dw_2.object.data    = lo_ds.object.data

Regards ... Chris

PS: Article states you can not use a getchild () on a composite DWO and then later says you can. I think that author got a little confused in the latter part. Otherwise ... a good synopsis of  child DWO's inside a parent DWO. 

Former Member
0 Kudos

Hello Chris,

your solution (dc_comp.object.dw_2.object.data    = lo_ds.object.data) work if dc_comp have only on row,

if it has more rows it returns error 39, Error accessing external object property object at line....

if I try solution from Arnd Powerbuilder just crash.

Any other option?

Regards

Tomaz

Former Member
0 Kudos

Hi Tomaz;

  This works perfectly for me in PB 12.1!  

Here is the modified test code I just used ...

DataStore  lo_ds

lo_ds  = CREATE  DataStore

lo_ds.dataobject = 'dw_test2'

lo_ds.InsertRow (0)

lo_ds.SetItem (1, 'name', 'Chris Pollach')

lo_ds.SetItem ( 1, 'phone', 6135551234)

lo_ds.InsertRow (0)

lo_ds.SetItem (2, 'name', 'Thomaz Kralj')

lo_ds.SetItem ( 2, 'phone', 6135554321)

lo_ds.InsertRow (0)

lo_ds.SetItem (3, 'name', 'Bruce Armstrong')

lo_ds.SetItem ( 3, 'phone', 6135559999)

dc_comp.Retrieve ()

dc_comp.object.dw_2.object.data    = lo_ds.object.data

Regards ... Chris

arnd_schmidt
Active Contributor
0 Kudos

Chris,

take a note on Tomaz' words...

dc_comp with only on row => working

dc_comp with more than one row => crash

Former Member
0 Kudos

I know .. I can not replicate the problem. All is well for me in PB 12.x.

I suspect that Tomaz either:

1) coded it differently

2) his version of PB has a bug

3) His DWO's structure is not kosher

etc

arnd_schmidt
Active Contributor
0 Kudos

So how many rows do you have in your dc_comp after retrieve?

.. I agree without concrete information about the DWs and Code it is hard to help.

Former Member
0 Kudos

   I do not have any because the parent DW is a "Composite" type - therefore, only each child DWO potentially has rows of its own. In my test Composite's case, the child DWO "dw_2" has zero as I  expected (used a NULL row in the DW's buffer). So now I start to populate a DS containing the same DWO as used in the Composite with data (of course you can do a retrieve here too instead).

   Now that the DS's DWO has a proper primary buffer, I copy the primary from the DS to the Child DW's in the Composite ... et voilà - data appears!  🙂

Former Member
0 Kudos

Note: The RETRIEVE command is crucial here in my example as it forces the parent DW to load the child DWO's and thus condition their buffers. Now they are ready for the data exchange!   🙂

arnd_schmidt
Active Contributor
0 Kudos

I know, I know..., you had no row in the "master"... but Tomaz wrote that he had more than one row.

Former Member
0 Kudos

That's no problem ... just change your (my) code to:

Long ll_row

lo_ds.object.data  = dc_comp.object.dw_2.object.data    // Get data

ll_row = lo_ds.InsertRow (0)                                          // Add to it

lo_ds.SetItem (ll_row, 'name', 'Chris Pollach')

lo_ds.SetItem ( ll_row, 'phone', 6135551234)

dc_comp.object.dw_2.object.data = lo_ds.object.data     // Put it back!

- OR -

a) Use a RETURN +2 on the RetrieveStart of your DS

    - preserves the DW's primary buffer)

    - adds new rows to the current data

b) Now use the DS.Retrieve () instead of the InsertRow's.  🙂

HTH

"Kool" ... n'est pas?  

arnd_schmidt
Active Contributor
0 Kudos

Sure.. Kool. Return +2 etc...

But again, you are talking about the dc_comp.Retrieve(), yes?

I got the feeling here is some misunderstanding...

Former Member
0 Kudos

No ... the D-A-T-A-S-T-O-R-E!    

arnd_schmidt
Active Contributor
0 Kudos

if dc_comp.RowRount () > 1 then

goto 

end if

Former Member
0 Kudos

So, my dw_comp  could have more than 1 row (it has select statement) and in this dw_comp I inserted report dw_report. If dw_report return after retrieve just 1 row than dc_comp.object.dw_report.object.data = lo_ds.object.data WORKS!

But if dw_comp has more than 1 row then dc_comp.object.dw_report.object.data = lo_ds.object.data DOESN'T WORK! 

It returns error 39, Error accessing external object property object at line....

I have no idea how to solve this

Regards

Tomaz


Former Member
0 Kudos

Hi Tomaz;

   A Composite DW parent has NO rows ... only the child DW's inside the Composite have rows. If you have rows in the parent DWO - then its a Nested DataWindow.

Regards ... Chris

Former Member
0 Kudos

Chris,

so this mean that dw_comp.getchild("column<2, dw_child) should work?

I tried this:

ids_datastore.GetChild("dw_izjave",mdw_child)

li_row=mdw_child.insertrow(0)

I get -1 as li_row.

In help is written that nested report in dw is read only  so this is the reason for -1?

Regards .. Tomaz

Former Member
0 Kudos

NO!

Let me repeat ....

  A Composite DW parent has NO rows => no result set => no primary buffer!!!!!!

Former Member
0 Kudos

Sorry Chris,

Parent DW has result set and it has report in it. In this report I would like to insert row after I retrieve parent DW.

Regards

Tomaz

Former Member
0 Kudos

In that case you have a NESTED DataWindow!

So, this should work on the parent DWO ....

DC.InsertRow (0)

Former Member
0 Kudos

but not on child DW.  it always return -1

Regards

Tomaz

Former Member
0 Kudos

Hi Tomaz;

  May I suggest:

1) Create a simple Composite DW and 1-2 child DWO's inside it.

2) Create a simple test application for the composite DW.

3) Upload the test application to the NNTP Sybase PB news group (this forum is useless for these such things).

That way, we can look at your DW construction and provide some expanded code that should demonstrate the approaches mentioned (or even expose a few more <bg>).

Regards ... Chris