Hi All! Has anyone an idea how to get the number of rows of a datawindow nested in another datawindow? I have a datastore l_ds = CREATE datastore l_ds.dataobject = "d_invoice" l_ds.SetTransObject(SQLCA) li_rows = l_ds.Retrieve(... and so on I am able to access a value in the nested datawindow like this: l_ds.Object.d_items[1].Object.item_description[1] l_ds.Object.d_items[1].Object.item_description[2] l_ds.Object.d_items[1].Object.item_description[3] (d_items is the nested datawindow) But I do not know how to retrieve the number of rows of the nested datawindow (so I cannot iterate). I tried l_ds.Object.d_items[1].DataWindow.RowCount() even I tried l_ds.GetChild("d_items", dwc) and dwc.RowCount() but it does no work Please let me know if someone knows Thank you!! Vaclav Jedlicka
![]() |
0 |
![]() |
May be: datawindowchild ldwc_1 if l_ds.GetChild("d_items", ldwc_1) > 0 then ldwc_1.settransobject (sqlca) ldwc_1.retrieve () ldwc_1.rowcount () else // some error handle end if "Vaclav Jedlicka" <vjedlicka@iol.cz> �������/�������� � �������� ���������: news:k96wCk1UBHA.357@forums.sybase.com... > Hi All! > > Has anyone an idea how to get the number of rows of a datawindow nested in > another datawindow? > > I have a datastore > > l_ds = CREATE datastore > l_ds.dataobject = "d_invoice" > l_ds.SetTransObject(SQLCA) > li_rows = l_ds.Retrieve(... and so on > > I am able to access a value in the nested datawindow like this: > > > l_ds.Object.d_items[1].Object.item_description[1] > l_ds.Object.d_items[1].Object.item_description[2] > l_ds.Object.d_items[1].Object.item_description[3] > > (d_items is the nested datawindow) > But I do not know how to retrieve the number of rows of the nested > datawindow (so I cannot iterate). I tried > > l_ds.Object.d_items[1].DataWindow.RowCount() > > even I tried > > l_ds.GetChild("d_items", dwc) > and > dwc.RowCount() > > > but it does no work > > Please let me know if someone knows > > Thank you!! > > Vaclav Jedlicka > > >
![]() |
0 |
![]() |
You could try loading an array with the data in a column, and then doing an upperbound on the array: String ls_Items[] ls_Items = l_ds.Object.d_items[1].Object.item_description.Primary ll_RowCount = UpperBound(ls_Items) BUT the assignment will fail if there is not at least one row. If you are in PB8, you can use a try/catch clause to catch the error in this case. IF you are not in PB8, then the way to handle this, and any other nested dw operations where GetChild doesn't work, is to: 1. Create a datastore with the same datawindow as the nested one. 2. load all the data from the nested into the copy. 3. Call RowCount on the copy. DataStore lds String ls_Syntax, ls_Error Long ll_RowCount lds = Create datastore ls_Syntax = l_ds.Object.d_items.DataObject.Syntax lds.Create(ls_Syntax,ls_Error) lds.Object.Data.Primary = l_ds.Object.Data.Primary ll_RowCount = lds.RowCount() Destroy lds Of course, if you are iterating through multiple rows each having the same nested dataobject, you would only create and destroy the datastore once.
![]() |
0 |
![]() |