cancel
Showing results for 
Search instead for 
Did you mean: 

Data Binding Issue

Former Member
0 Kudos

Hello,

I am trying to figure out how to Bind Data to a Custom form I created in Screen Painter. I would like to have all of the functionality(Add/Update/Find) of a standard form. I beleive this needs to be a UDO, but seem to be missing some key concepts in getting this to work. In programming this I am getting a "File Not Found" error when trying to bind the fields to my User Defined Table.

Below is the code I am attempting to do. The Form works and everything is fine until I attempt to Bind the Data at that point it throws an exception.

Dim CP As SAPbouiCOM.FormCreationParams

Dim oEdit As SAPbouiCOM.EditText

Dim SBOXMLDoc As System.Xml.XmlDocument

Dim SBOFormCreationParam As SAPbouiCOM.FormCreationParams

Dim SBOForm As SAPbouiCOM.Form

SBOXMLDoc = New Xml.XmlDocument()

SBOXMLDoc.Load("C:\WorkForm.srf")

SBOFormCreationParam = applic.CreateObject_(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)

SBOFormCreationParam.XmlData = SBOXMLDoc.InnerXml

SBOForm = pApp.Forms.AddEx(SBOFormCreationParams)

SBOForm.Freeze(True)

Try

'5 is the UID of the Text Field I am trying to bind

'@AB_OWCT is an existing User Defined Table

'U_WorkID is an existing field in that Table

oEdit = SBOForm.Items.Item("5").Specific

oEdit.DataBind.SetBound(True, "@AB_OWCT", "U_WorkID")

Catch

' Err.Desc = "File Not Found'

End Try

SBOForm.DataBrowser.BrowseBy = "5"

SBOForm.Freeze(False)

I have tried to look at the Source code of the UDO Examples but have not had much luck in figuring out what I am missing.

Thank You in Advance

Paul

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Paul !!

I'm kind of new with all this but maybe it will help you.

First bind all your fields in your form to your UDO table.

Dont Forget :

Alias = Your UDF or SBO field

Databind = True

Database = @......

Then try this....


 Private Function LoadFromXML(ByRef FileName As String) As String

        Dim oXmlDoc As Xml.XmlDocument
        oXmlDoc = New Xml.XmlDocument
        Dim sPath As String
        oXmlDoc.Load(your path & FileName)
        Return (oXmlDoc.InnerXml)

    End Function

Private Sub .....
Try
            oForm = SBO_Application.Forms.Item("Your Form ID")
            SBO_Application.MessageBox("Form Already Open")
        Catch ex As Exception
            Dim fcp As SAPbouiCOM.FormCreationParams
            fcp = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)
            fcp.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed
            fcp.FormType = "Your Form Type"
            fcp.UniqueID = "Your Form ID"
            fcp.XmlData = LoadFromXML("Your Form.SRF")

            oForm = SBO_Application.Forms.AddEx(fcp)
            oForm.DataBrowser.BrowseBy = "Your Field"
        End Try
End Sub .....

Make sure that the field you want to browse by is included in the search fields when you register your UDO... and that your application is refering to the path where your .SRF file is.

Normaly File not found error is not from the code but that it cant find your .SRF file...

HtH

Alain

Former Member
0 Kudos

Alain,

Thank you for the response. I am pretty sure that the error is not in being able to find the srf file. If I remove the Databinding in my code the Form comes up with no problem. When I put the binding line back in I get the "File Not Found" error.

I double checked the UDO Settings for this table and the field U_WorkID is set up in the Find Section. I want this tied to UniqueID 5 on the Form. In the browse by I did try to enter in both "5" and U_WorkID, neither worked. Not sure if this would help but this is set up as Master Data in the UDO, the Unique ID of the UDO is the same as my UDT(AB_OWCT).

It seems that somehow I need to tell Business One that I have this UDO Set up and I want to bind my data to the fields on the form I created. I don't know how close I actually am in getting this to work, but there is some piece I am missing in getting this all tied together.

Former Member
0 Kudos

When you are in screen Painter try the preview mode button doest it give you an error.. make sure your data bind is ok .

Table = @your table (dont forget the @sign)

Databind = True

Alias = Your UDO table field

Former Member
0 Kudos

Alain,

You mention the Preview Mode for Screen Painter. I see this option but when I select it nothing happens. So I don't know if that is an Error or I am not doing the correct thing for the preview. Here are some of the settings I have a question on on the Screen Painter.

Form:

Object Type: AB_OWCT (This is the UID of my UDO, or is this supposed to be my UDT(@AB_OWCT) or should it be the type "Master Data")

AutoManaged: False (It will not let me set to True)

Item:

Databound: True

Alias: U_WrkID

Is this Correct? and what should the Preview mode give.

Thanks Again for any help.

Paul

Former Member
0 Kudos

Hi Paul,

Your Object type is ok. Dont forget to give your form a Formtype and UniqueId for your code.

Databound : true

Alias: U_WrkID

Table : @AB_OWCT

When you click on the preview button you should see the form like it will be in SBO. If nothing appends remove the databound and try it again. The preview button is a good help to validate if your databind is allright.