cancel
Showing results for 
Search instead for 
Did you mean: 

SP01: UI - Change DataTable with Grid

Former Member
0 Kudos

Hi,

i have a code that adds a DataTable to a form and then links this to a Grid.

this works fine.

the problem is even when i change the DataTable after it is created, the Grid only get cleard and shows the correct headers but the data it self is not shown.

any idea regarding the reson?

my code is:

'Create the DT and link to Grid

form.DataSources.DataTables.Add("DataTable")

form.DataSources.DataTables.Item("DataTable").ExecuteQuery("select * from OITM")

oGrid.DataTable = form.DataSources.DataTables.Item("DataTable")

'change the DataTable or just use the same one

form.DataSources.DataTables.Item("DataTable").ExecuteQuery("select * from OITM")

'which clears the Grid instead of updating it

Thanks

MM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

can you try, for the second update

oGrid.DataTable.ExecuteQuery("select * from OITM")

Message was edited by: Sébastien Danober

Former Member
0 Kudos

did it already, but got the same result. the grid just clears. (the column headers are ok, just data is not there)

Thanks Sebastien

MM

Former Member
0 Kudos

That's strange.

Are you sure that your second query return rows ?

if you have the header, it would mean that the query works, but returns no row.

What is you exact query ?

Former Member
0 Kudos

select * from OITM

it is strange

Former Member
0 Kudos

I just tried it by modifying the SAP sample 19, and it works.

It's always the same query (SELECT * FROM OITM), the Grid is always updated, and the data are present.

can you try also with this sample.

Sebastien

Former Member
0 Kudos

Hi Sebastien

thanks for your help.

i'm also using the sample 19

like this:

oGrid = oItem.Specific

oForm.DataSources.DataTables.Add("MyDataTable")

oForm.DataSources.DataTables.Item(0).ExecuteQuery("select CardCode, CardName, DocDate, DocNum, DocTotal, DocStatus from OINV")

oGrid.DataTable = oForm.DataSources.DataTables.Item("MyDataTable")

'this is the line i added for updating the grid

oGrid.DataTable.ExecuteQuery("select * from OITM")

and the grid just being cleared.

btw i'm using SAP 2005a SP1 PL2

Former Member
0 Kudos

OK, I'm back, just the time to install SBO2005 SP1

I tried and I get the same behaviour that you describe, the grid is empty for the second update

So I guess it's a problem with the SP1 (I was using PL3)

You should write a note about it.

Sebastien

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

The problem has been reported to support.

In the meanwhile a workaround has been proposed:

oForm.Freeze(True)

oGrid.DataTable = Nothing 'detach Grid and DataTable

oForm.DataSources.DataTables.Item("MyDataTable").ExecuteQuery(...)

oGrid.CollapseLevel = 0

oForm.Freeze(False)

Hope it helps

Trinidad.

Answers (0)