cancel
Showing results for 
Search instead for 
Did you mean: 

Delete line items using UDO

Former Member
0 Kudos

Hey All,

I have searched on the forums and found people with a similiar problem using the UDO in SBO 2004. How do I properly delete a document line item from a matrix and have that reflected back in the database? I get an error message and the records are not deleted

I am using the following code (I get a database error stating the usertable has already been modifed):

case "v33Add":
			oQuotationForm.DataSources.DBDataSources.Item("@PQUOTEVENDORS").Clear();
       OMatrix.AddRow(1,OMatrix.RowCount);
//							oQuotationForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE;
						case "v33Remove":
			oQuotationForm.DataSources.DBDataSources.Item("@PQUOTEVENDORS").Clear();
int selectedRowIndex = OMatrix.GetNextSelectedRow(0, SAPbouiCOM.BoOrderType.ot_RowOrder);
								if (selectedRowIndex > -1)
								{							OMatrix.DeleteRow(selectedRowIndex);
							}
//								if (oQuotationForm.Mode != SAPbouiCOM.BoFormMode.fm_ADD_MODE)
//							oQuotationForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE;

Accepted Solutions (1)

Accepted Solutions (1)

former_member184566
Active Contributor
0 Kudos

Hi Curtis

Try something like this, i find this works for me....might not be the best but it does the trick

If (pVal.BeforeAction = False) Then

if (pVal.ItemUID = "D") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then

Dim DBdatasource As SAPbouiCOM.DBDataSource

Dim f As SAPbouiCOM.Form

Dim oMatrix As SAPbouiCOM.Matrix

f = SBO_Application.Forms.Item(FormUID)

oMatrix = f.Items.Item("RecMat").Specific

f.DataSources.DBDataSources.Item(1).Clear()

omatrix.DeleteRow(1)

omatrix.FlushToDataSource()

End If

Hope this helps

Answers (2)

Answers (2)

former_member184566
Active Contributor
0 Kudos

Curtis

that should work perfectly. It should remove the first line then you click update and thats that. On mine it works perfect. Im on sbo 2004. It should work. the only thing i can think of is that you did something diffecrent or wrong. try just adding a test button on your screen. then place my code in there.....you'll see it should work.

Former Member
0 Kudos

I have tried your code exactly and it does not delete the record.

Any other suggestions? it is strange because add row works fine the exact same way

jaccomoolenaar
Participant
0 Kudos

Hi,

Following code works for me:

ds.Clear()

matr.DeleteRow(row)

matr.FlushToDataSource()

Form.Mode = BoFormMode.fm_UPDATE_MODE

Remember that the last line is very important and that you also have to push the update button afterwards to get the record deleted from the database.

Hope this helps...

Jacco

Former Member
0 Kudos

Thanks guys the code from Louis and j fixed the issue I was having

Former Member
0 Kudos

Hi J.Moolenaar,

I use the codes and also delete the record from database.

But then i have a problem with the LineId which i bound.

When i delete one row the LineId can change normally.But the more it can't.The LineId is the table's primary key.

Did you have the same problem before?

Can you help me ?

Best wishes!!

Following is my code :

selectedRowIndex(j)=oForm.DataSources.DBDataSources.Item("@MS_PLANORDERSUB").GetValue(1, rowSelectNO - 1)

sDocEntry(j) = oForm.DataSources.DBDataSources.Item("@MS_PLANORDERSUB").GetValue(0, 0)

j = j + 1

oForm.DataSources.DBDataSources.Item("@MS_PLANORDERSUB").Clear

oMatrix.DeleteRow (rowSelectNO)

oMatrix.FlushToDataSource

BubbleEvent = False

oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE

'//d’us†

For row = rowSelectNO To oMatrix.RowCount

oMatrix.Columns.Item("#").Cells.Item(row).Specific.Value = row

Next row

Former Member
0 Kudos

Hi J.Moolenaar,

I use the codes and also delete the record from database.

But then i have a problem with the LineId which i bound.

When i delete one row the LineId can change normally.But the more it can't.The LineId is the table's primary key.

Did you have the same problem before?

Can you help me ?

Best wishes!!

Following is my code :

selectedRowIndex(j)=oForm.DataSources.DBDataSources.Item("@MS_PLANORDERSUB").GetValue(1, rowSelectNO - 1)

sDocEntry(j) = oForm.DataSources.DBDataSources.Item("@MS_PLANORDERSUB").GetValue(0, 0)

j = j + 1

oForm.DataSources.DBDataSources.Item("@MS_PLANORDERSUB").Clear

oMatrix.DeleteRow (rowSelectNO)

oMatrix.FlushToDataSource

BubbleEvent = False

oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE

'//d’us†

For row = rowSelectNO To oMatrix.RowCount

oMatrix.Columns.Item("#").Cells.Item(row).Specific.Value = row

Next row

former_member184566
Active Contributor
0 Kudos

Oh, after that your form should be in update mode....but sometimes it doesnt so just add thsi extra

f.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE

After clicking update it will work.

Former Member
0 Kudos

Thanks for your help Louis. I am using this code below as suggested but it still only removes the row from the UI matrix and not the database.

Any other suggestions or does anyone else know why the deleting is not working?

OItem = oQuotationForm.Items.Item("v33Vend");
OMatrix = (SAPbouiCOM.Matrix)OItem.Specific;
int selectedRowIndex = OMatrix.GetNextSelectedRow(0, SAPbouiCOM.BoOrderType.ot_RowOrder);

if (selectedRowIndex > -1)
{
   oQuotationForm.DataSources.DBDataSources.Item("@PQUOTEVENDORS").Clear();
   OMatrix.DeleteRow(selectedRowIndex);
   OMatrix.FlushToDataSource();
}

if (oQuotationForm.Mode != SAPbouiCOM.BoFormMode.fm_ADD_MODE)								oQuotationForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE;