on 12-26-2014 3:18 PM
Hi
Below is the code . I want when user select Code it should return Name also
Private Sub DrawAddForm(ByVal oForm As SAPbouiCOM.Form)
Dim oItem As SAPbouiCOM.Item
Dim oLabel As SAPbouiCOM.StaticText
Dim oEdit As SAPbouiCOM.EditText
Dim oButton As SAPbouiCOM.Button
Dim oStatic As SAPbouiCOM.StaticText
oForm0.Top = 150
oForm0.Left = 330
oForm0.ClientWidth = 200
oForm0.ClientHeight = 170
oForm0.Title = "Maintain Transaction"
oForm0.DataSources.UserDataSources.Add("EditDS", SAPbouiCOM.BoDataType.dt_SHORT_TEXT)
AddChooseFromList()
oItem = oForm0.Items.Add("EditTxt", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oItem.Left = 100
oItem.Top = 10
oItem.LinkTo = "StaticTxt"
oEdit = oItem.Specific
oItem = oForm0.Items.Add("StaticTxt", SAPbouiCOM.BoFormItemTypes.it_STATIC)
oItem.Left = 10
oItem.Top = 10
oItem.LinkTo = "EditTxt"
oStatic = oItem.Specific
oStatic.Caption = "Emp Code"
' Name
oItem = oForm0.Items.Add("lblName", SAPbouiCOM.BoFormItemTypes.it_STATIC)
oItem.Left = 10
oItem.Top = 40
oItem.AffectsFormMode = False
oLabel = oItem.Specific
oLabel.Caption = "Emp Name"
oItem = oForm0.Items.Add("txtName", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oItem.Left = 100
oItem.Top = 40
oItem.AffectsFormMode = False
oItem.Visible = True
oItem.Enabled = True
oItem = oForm0.Items.Add("btnAdd", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
oItem.Left = 10
oItem.Top = 130
oItem.AffectsFormMode = False
oButton = oItem.Specific
oButton.Caption = "Add"
oEdit.DataBind.SetBound(True, "", "EditDS")
oEdit.ChooseFromListUID = "CFL1"
End Sub
Private Sub AddChooseFromList()
Try
Dim oCFLs As SAPbouiCOM.ChooseFromListCollection
Dim oCons As SAPbouiCOM.Conditions
Dim oCon As SAPbouiCOM.Condition
oCFLs = oForm0.ChooseFromLists
Dim oCFL As SAPbouiCOM.ChooseFromList
Dim oCFLCreationParams As SAPbouiCOM.ChooseFromListCreationParams
oCFLCreationParams = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams)
oCFLCreationParams.MultiSelection = False
oCFLCreationParams.ObjectType = "171"
oCFLCreationParams.UniqueID = "CFL1"
oCFL = oCFLs.Add(oCFLCreationParams)
Catch
MsgBox(Err.Description)
End Try
End Sub
Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
If pVal.EventType = SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST Then
Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent
oCFLEvento = pVal
Dim sCFL_ID As String
sCFL_ID = oCFLEvento.ChooseFromListUID
Dim oForm As SAPbouiCOM.Form
oForm = SBO_Application.Forms.Item(FormUID)
Dim oCFL As SAPbouiCOM.ChooseFromList
oCFL = oForm.ChooseFromLists.Item(sCFL_ID)
If oCFLEvento.BeforeAction = False Then
Dim oDataTable As SAPbouiCOM.DataTable
oDataTable = oCFLEvento.SelectedObjects
Dim val As String
Try
val = oDataTable.GetValue(1, 0)
Catch ex As Exception
End Try
If (pVal.ItemUID = "EditTxt") Then
oForm.DataSources.UserDataSources.Item("EditDS").ValueEx = val
End If
End If
End If
end sub
Thanks
Hi Sunny,
Just use this code:
After ChooseFromList:
var lempID = Convert.ToString(aEvent.SelectedObjects.GetValue("empID", 0));
var lfirstName = Convert.ToString(aEvent.SelectedObjects.GetValue("firstName", 0));
I'm considering you want to select data from the
I suggest to add the code in After Validate the component, to clear the values when the value of the code is blank.
Regards,
Paulo Henrique
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sunny,
val = oDataTable.GetValue(1, 0) or you can use it as follows:
val = oDataTable.GetValue("firstName", 0) //This line gives you the first name of the employee in val variable.
EmpID = oDataTable.GetValue("empID", 0) //This line gives you the Employee Id of the employee in val variable.
Now you have to set these value in the EditText.
Hope it helps.
Thanks & Regards
Ankit Chauhan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ankit & Paulo
I have made following changes , i am getting value in ename but it is not going in this condition
If (pVal.ItemUID = "txtName") Then
oForm.DataSources.UserDataSources.Item("EditDS").ValueEx = ename
End If
Try
val = oDataTable.GetValue("empID", 0)
ename = oDataTable.GetValue("firstName", 0)
Catch ex As Exception
End Try
If (pVal.ItemUID = "EditTxt") Then
oForm.DataSources.UserDataSources.Item("EditDS").ValueEx = val
End If
If (pVal.ItemUID = "txtName") Then
oForm.DataSources.UserDataSources.Item("EditDS").ValueEx = ename
End If
Thanks
Hi Ankit
I have written the below lines in Application ItemEvent & chooseList Event but it is not working
You can see my above code & kindly tell where & what i should exactly write.
If (pVal.ItemUID = "txtName") Then
MessageBox.Show("haha")
oForm.DataSources.UserDataSources.Item("EditDS").ValueEx = ename
End If
Thanks
Hi Sunny,
Is your code going into the loop. Are you able to show the MessageBox which show you 'haha'.
Also please use these lines instead of your lines for a test:
Dim oEdit As SAPbouiCOM.EditText
oEdit = Me.oForm.Items.Item("UIDofTEXTBOX").Specific // UIDofTEXTBOX is the Unique Id of TextBox
oEdit.Value = "TestValue"
Hope it helps.
Thanks & Regards
Ankit Chauhan
Hi Ankit
No i am not able to show the MessageBox
Secondly when i write your below code it gives message "Object reference not set to an instance of the object"
Dim oEdit As SAPbouiCOM.EditText
oEdit = Me.oForm.Items.Item("txtName").Specific
oEdit.Value = ename
U can see my earlier complete code
Thanks
Hi Sunny,
For now, I can only say that you need to refer the correct FormID, ItemUID i.e. your EditText and also the correct event.
"Object reference not set to an instance of the object" Error clearly states that you are using an object that is not initialized correctly.
Hope it helps.
Thanks & Regards
Ankit Chauhan
User | Count |
---|---|
67 | |
14 | |
8 | |
6 | |
5 | |
5 | |
5 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.