Hello (and Happy New Year),
We have a simple function that iterates over the rows of a datawidnow and fill some objects from some of the items in the row. This function looks like the following:
public subroutine fill_recipe_components(datawindow a_dw)
long ll_index, ll_tot
ll_tot = a_dw.rowCount()
for ll_index = 1 to ll_tot
st_recipe_component lst_recipe_component
lst_recipe_component.s_code = a_dw.GetItemString(ll_index, 'article_code_article')
lst_recipe_component.d_percentage = a_dw.GetItemNumber(ll_index, 'pourcentage')
ist_recipe_component[ll_index] = lst_recipe_component
next
end subroutine
We have another function that does exactly the same thing, but on a datastore:
public subroutine fill_recipe_components(datastore a_dw)
long ll_index, ll_tot
ll_tot = a_dw.rowCount()
for ll_index = 1 to ll_tot
st_recipe_component lst_recipe_component
lst_recipe_component.s_code = a_dw.GetItemString(ll_index, 'article_code_article')
lst_recipe_component.d_percentage = a_dw.GetItemNumber(ll_index, 'pourcentage')
ist_recipe_component[ll_index] = lst_recipe_component
next
end subroutine
As one may notice, those functions are strictly identical (to the point we misnamed the datastore parameter a_dw). Is there a way to have a single function instead of 2? It seems like datastore and datawindow are related and have at least a subset of their methods as common interfaces, but the compiler rejects passing one when the other is expected. We tried wrapping a datawindow in a datastore by assigning the dw to the object property of a (new) datastore but this does not work.
1. The syntax for the rowscopy function is different in our case, probably because of different PB versions (we are on 2019R2)
2. leaving out the rowscopy did not work, eg. the datastore appeared empty so not sure how to do the sharing you are speaking of.
2. It works for me; you have to do the following:
n_ds lds_ds
lds_ds = of_dwtods(adw_yourdatawindow, Primary!)
adw_yourdatawindow.sharedata(lds_ds)
Then you can do any processing on the newly created Datastore and any data changes should be reflected in your source DW. You can then disconnect the datastore from the DW via lds_ds.sharedataoff() and safely destroy it.