cancel
Showing results for 
Search instead for 
Did you mean: 

how to duplicate the data in matrix single column........

Former Member
0 Kudos

hi all,

In my addon-form i have a matrix,in the matrix i have data for 5 rows....in that 3rd column when i enter any number & press tab key....the remaining 5 rows(downwards only) for that 3rd column only should be get updated with that number...can anybody suggest me some ideas????

example:-

custcode custname days

======= ======= ===

10001 John 3

10002 Peter 8

10003 David 5 -


>here when i type 5 & press tab remining rows for that column should get updated with no:5

10004 Kris

10005 Corter

10006 Albert

regards,

shangai.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

You need to handle KEY_DOWN event...

Look [here|; how you can do it.

Only, in your case you don'not need to disable writing,

you need to replicate value to all next rows ... Matrix_Replicate_5_To_Other_Rows(oForm, pVal.Row).

Regards

Sierdna S.

P.S.

(Remember to freeze your form or it can be nice show for users )

Edited by: Sierdna S on Oct 9, 2008 3:11 PM

Former Member
0 Kudos

hi sierdna,

here----Matrix_Replicate_5_To_Other_Rows(oForm, pVal.Row), here i may give any value in run time but as your coding it's hardcoded as '5'.......can tell me how to do it dynamically???

regards,

shangai.

Former Member
0 Kudos

You need to get value of the cell where are you press TAB key (only if pVal.ColUID = "col_3" , only if cursor is in the 3"d column) and set value to other, next rows, 3"d columns. You need to do all in the ItemEvent.

1 row 3.0

2 row 4.9

3 row 6.8

4 row 6.0 --> here your press TAB. so when you handle:

5 row ..

6 row ..

7 row ..


... ItemEvent Handler
  If pVal.EventType = et_KEY_DOWN  _
   And pVal.ItemUID = "YOUR_matrix_UID"  _
   And pVal.ColUID = "col_3"  _
   And pVal.CharPressed = "9" ' TAB KEY
 Then 
    If Matrix_ReplicateValue(oForm,pVal.Row) Then
    '
    End If
  End If
End Sub

Private Function Matrix_ReplicateValue(oForm,iRow) As Boolean

' 1st you need to get value in col_3 of the current row
Dim oEdit 
oEdit = oMatrix.Columns.Item("col_3").Cells.Item(iRow).Specific
Dim sValue As String = oEdit.Value
' 2nd you need to set value in col_3 of the other rows in matrix

For i = iRow To oMatrix.VisualRowCount
...
Next

End Function

Edited by: Sierdna S on Oct 9, 2008 3:49 PM

Former Member
0 Kudos

hi sierdhana,

Thanks a lot.....your coding solved my problem..

Regards,

shangai.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi...

use this code

menu event

If (pVal.MenuUID = "Duplicate") And (pVal.BeforeAction = False) Then

Try

Dim oDBDataSource As SAPbouiCOM.DBDataSource

Dim s As Integer = 0

Dim omat1 As SAPbouiCOM.Matrix

Dim newrowid As Integer = 0

omat1 = RFrm.Items.Item("5").Specific

For s = 1 To omat1.RowCount

If omat1.IsRowSelected(s) Then

Try

omat1.GetLineData(s)

newrowid = s + 1

omat1.AddRow(1, newrowid)

omat1.SetLineData(newrowid)

Catch ex As Exception

SBO_Application.MessageBox(ex.Message)

End Try

End If

Next

For i = 1 To omat1.RowCount

oedit1 = omat1.Columns.Item("0").Cells.Item(i).Specific

oedit1.Value = i

Next

Catch ex As Exception

SBO_Application.MessageBox(ex.Message)

End Try

End If

Right Click Event

If eventInfo.FormUID = "Routing" Then

If (eventInfo.BeforeAction = True) Then

Dim oMenuItem As SAPbouiCOM.MenuItem

Dim oMenus As SAPbouiCOM.Menus

omat1 = RFrm.Items.Item("5").Specific

GCols = omat1.Columns

Try

selItem = eventInfo.ItemUID

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

oCreationPackage = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Duplicate"

oCreationPackage.String = "Duplicate Row"

oCreationPackage.Enabled = True

oMenuItem = SBO_Application.Menus.Item("1280")

oMenus = oMenuItem.SubMenus

oMenus.AddEx(oCreationPackage)

Catch ex As Exception

SBO_Application.MessageBox(ex.Message)

End Try

Else

Dim oMenuItem As SAPbouiCOM.MenuItem

Dim oMenus As SAPbouiCOM.Menus

Try

SBO_Application.Menus.RemoveEx("Duplicate")

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End If

End If

It will work...

Regards...

Billa 2007

Former Member
0 Kudos

Hi shangai,

to give everybody a better basis for a solution: Could you tell us how you load the Matrix before the "number-downwards-action" has to be done? Is it by...

...DBDataSource

...UserDataSource or

...DataTable?

(one of these three I always would recommend)

Cheers,

Roland