Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Select and update

Hi all !

Today, I have the problem which unresolvable as bellow:

1: clicking View Child button, how the system only can display the 1-1 employee information ( Employee No 1à only show his/her child not show all Employeeu2019s child in the company)

Becase ,I used

Private Sub CreateForm(ByRef EmplID As String).

oForm.DataSources.DataTables.Item(0).ExecuteQuery("select EmpID,U_Child1,U_DateOB,U_Child2,U_DateOB2,U_Child3,U_DateOB3,U_Child4,U_DateOB4 from OHEM where EmpID=" + EmplID)

Public Sub ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, _

ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

//

If ((pVal.ItemUID = "btnVC") And _

(pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK)) Then

CreateForm(1)

OForm = SBO_Application.Forms.Item("frmGrid")

OForm.Visible = True

End If

However,If I next EmpID=1 to EmpID=2 then can not display 1-1 employee information.Therefor,I was using:

Public Sub ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, _

ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

If "60100" = pVal.FormType And pVal.BeforeAction = False Then

Dim Emp As String

Emp = OForm.Items.Item("33")

//

If ((pVal.ItemUID = "btnVC") And _

(pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK)) Then

CreateForm(Emp)

OForm = SBO_Application.Forms.Item("frmGrid")

OForm.Visible = True

End If

2:if I edit nameu2019sChild1=Peter then I click on update button ,it can not save data on database

This is code which I used

oItem = oForm.Items.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)

oItem.Left = 700

oItem.Width = 65

oItem.Top = 330

oItem.Height = 19

oBtn = oItem.Specific

oBtn.Caption = "&Ok"

u2018Update Event

Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

If (FormUID = "frmGrid") Then

If pVal.ItemUID = "1" And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK) Then

oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE

oItem.AffectsFormMode = False

oItem.Update()

oForm.Update()

End If

End If

End Sub

Are you can help me resolvable this problem ?

Private Sub CreateForm(ByRef EmplID As String)

Dim CP As SAPbouiCOM.FormCreationParams

Dim oStat As SAPbouiCOM.StaticText

Dim oItem As SAPbouiCOM.Item

CP = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)

CP.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Sizable

CP.FormType = "SAMPLE"

CP.UniqueID = "frmGrid"

oForm = SBO_Application.Forms.AddEx(CP)

' Set form width and height

oForm.Height = 500

oForm.Width = 800

oForm.Title = "List Child's Employees"

oItem = oForm.Items.Add("StatHead", SAPbouiCOM.BoFormItemTypes.it_STATIC)

oItem.Left = 20

oItem.Top = 40

oItem.Width = 400

oStat = oItem.Specific

oStat.Caption = "In this grid you can view all List Child's Employees"

'/**********************

'// Adding an Ok button

'//*********************

oItem = oForm.Items.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)

oItem.Left = 700

oItem.Width = 65

oItem.Top = 330

oItem.Height = 19

oBtn = oItem.Specific

oBtn.Caption = "&Ok"

'oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE

'oItem = oForm.Items.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)

'oItem.Left = 5

'oItem.Width = 65

'oItem.Top = oForm.ClientHeight - 30

'oItem.Height = 19

'oItem.AffectsFormMode = False

'//************************

'// Adding a Cancel button

'//***********************

oItem = oForm.Items.Add("2", SAPbouiCOM.BoFormItemTypes.it_BUTTON)

oItem.Left = 700

oItem.Width = 65

oItem.Top = 360

oItem.Height = 19

oBtn = oItem.Specific

oBtn.Caption = "&Cancel"

' Add a Grid item to the form

oItem = oForm.Items.Add("MyGrid", SAPbouiCOM.BoFormItemTypes.it_GRID)

' Set the grid dimentions and position

oItem.Left = 20

oItem.Top = 60

oItem.Width = 650

oItem.Height = 300

oGrid = oItem.Specific

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

oForm.DataSources.DataTables.Item(0).ExecuteQuery("select EmpID,U_Child1,U_DateOB,U_Child2,U_DateOB2,U_Child3,U_DateOB3,U_Child4,U_DateOB4 from OHEM where EmpID=" + EmplID)

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

' Set columns size

oGrid.Columns.Item(0).Width = 50

oGrid.Columns.Item(1).Width = 60

oGrid.Columns.Item(2).Width = 130

End Sub

u2018Update Event

Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

If (FormUID = "frmGrid") Then

If pVal.ItemUID = "1" And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK) Then

oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE

oItem.AffectsFormMode = False

oItem.Update()

oForm.Update()

End If

End If

End Sub

Public Sub ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, _

ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

If "60100" = pVal.FormType And pVal.BeforeAction = False Then

Dim Emp As String

If pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD Then

Dim oItem1 As SAPbouiCOM.Item = Nothing

Dim OForm As SAPbouiCOM.Form = SBO_Application.Forms.Item(FormUID)

Dim oitems As SAPbouiCOM.Items = OForm.Items

oItem1 = OForm.Items.Add("btnVC", SAPbouiCOM.BoFormItemTypes.it_BUTTON oItem1.Top = 285

oItem1.Left = oitems.Item("3").Left

oItem = OForm.Items.Item("23")

'day button vao pane

oItem1.FromPane = 4

oItem1.ToPane = 4

Dim sndButton As SAPbouiCOM.Button = oItem1.Specific sndButton.Caption = "View child"

'tao an button khi chua co du lieu

oItem1 = SBO_Application.Forms.Item(FormUID).Items.Item("btnVC")

oItem1.Enabled = False

Emp = OForm.Items.Item("33")

If ((pVal.ItemUID = "btnVC") And _

(pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK)) Then

CreateForm(Emp)

OForm = SBO_Application.Forms.Item("frmGrid")

OForm.Visible = True

End If

End If

End If

End Sub

[[IMG]http://img509.imageshack.us/img509/4238/selectandupdateev0.png[/IMG] | http://imageshack.us]

[[IMG]http://img509.imageshack.us/img509/selectandupdateev0.png/1/w1012.png[/IMG] | http://g.imageshack.us/img509/selectandupdateev0.png/1/]

replied

Hello,

1.Use

CreateForm("1")

not

CreateForm(1)

2.Either use UDO + UI, you don't need care about the update. Form.Update or Item.Update won't save anything , they has nothing to do with data access, but update the UI only.

UDO+UI That is the simplest way.

- Create your own UDT and UDO instead of UDFs in OHEM, thus you can use UDO, you don't need to do with Add, Update.

Example: your UDT can be like this

AMI_OHEM : U_EmpID (This field works a link to EmpID in OHEM)

AMI_HEM1: U_Child, U_DateOB

- Use B1DE and UDO Form Generater to create the form xml

Either use DI:

EmployeeInfo.GetByKey(***)
EmployeeInfo.UserFields.Field("**").Value = ***. 
EmployeeInfo.Update()

By the way, the more specific and clearer the problem is, the more anwser from others. You can state the problem first, then paste code, use <> in eidtor tool pane to display your code as code. : )

Kind Regards

-Yatsea

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question