on 08-31-2005 10:37 AM
Hello all,
I have a problems with UDO. I use SAP B1 2004C. I create table (object type = document) with two fields name,sname. I registred this table as UDO with id TES. Than i created a form this udo (no default form). This form has a matrix and two standard buttons. The matrix has two columns for filed name and sname. When i open the form i dont view my data in table. I cannot add new data. In table i have two lines, but in form i dont view this lines.
How can i make that i view data from UDO in my form? How can i make add new line after clic the button uid 1 "Add"?
The standard form for UDO has all functions, which i need on my form? How to make it?
Thanks
Hi,
You will also need in your form:
Add a button with id = 1 for the Add/Update button. It will work automatically.
Add a button with id = 2 for the Cancel button. It will work automatically.
Add at the end BrowseBy = id of the edit text linked by a DbDataSource to the DocEntry field. To be able to use the navigation buttons (next, previous,...)
You must code by yourself the button to add a new line into the matrix.
Pay attention to the datas you create by yoursef (not using the UI) in the document/document_lines tables. They are releated by the DocEntry.
To test if it works fine please clear your tables and add the data from the UI form you have created. Maybe the datas you have entered by hand are not well formatted.
Regards
Trinidad.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
First of all I recommend you to remove all datas from your UDO tables.
Then try to create a simple form like the following one I give you the code.
In this first form there will be only 2 edit texts showing 2 user fields I have added to my Document table, and the 2 buttons Add/Update/Find and Cancel.
Remark: The button Add has nothing to do with adding a new line into the matrix representing the documents lines.
Here you have the creation of a form for a UDO:
'Creates an empty form
CP = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)
CP.FormType = "FrmDOC" ' Whatever you want
CP.ObjectType = "TT_DOC" 'UDO Object name
CP.UniqueID = "FDOC" ' Must be unique for each form you open
oFormDoc = SBO_Application.Forms.AddEx(CP)
oFormDoc.ClientWidth = 570
oFormDoc.ClientHeight = 400
' Add Edit Items
'BP(Code)
oItem = oFormDoc.Items.Add("txtBPCode", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oItem.Left = 67
oItem.Top = 10
oItem.LinkTo = "lblBPCode"
'Binding
txtBPCode = oItem.Specific
txtBPCode.DataBind.SetBound(True, "@T_DOC", "U_BPCode")
' BP Name
oItem = oFormDoc.Items.Add("txtBPName", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oItem.Left = 205
oItem.Top = 10
oItem.Width = 100
oItem.LinkTo = "lblBPName"
'Binding
txtBPName = oItem.Specific
txtBPName.DataBind.SetBound(True, "@T_DOC", "U_BPName")
' Adding Buttons
'* Create a Button to Support the Add ,Update, and Find Services
' ID must be "1" & no caption should be defined
oItem = oFormDoc.Items.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
oItem.Left = 6
oItem.Top = oFormDoc.ClientHeight - 24
oItem.Width = 65
oItem.Height = 18
oFormDoc.DefButton = "1"
' Add the Cancel button
oItem = oFormDoc.Items.Add("2", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
oItem.Left = 77
oItem.Top = oFormDoc.ClientHeight - 25
oItem.Width = 65
oItem.Height = 20
'To make the navigation buttons work
oFormDoc.DataBrowser.BrowseBy = "txtBPCode"
Please tell me if this code works fine by replacing the UID of your UDO and the name of your document table on the edit texts binding. You should be able to add new items to your document table by using this form, also to use the find button (Ctrl+F to change the label on the form) and the navigation buttons (next, previous,...).
If it works fine then I can show you how to add the matrix representing the document lines table.
You have also a complete sample on how to create a form with a matrix on the SDK UDO samples. Please try to have a look at it.
Regards
Trinidad.
Hi Vit,
You only have to add a normal matrix and link its columns with your table of type Document_Lines.
To be able to enter information into the matrix lines you need to implement (for example) a button to add a line on the matrix and another to delete a line.
Here you have a sample:
oItem = oFormDoc.Items.Add("matrixDocLines", SAPbouiCOM.BoFormItemTypes.it_MATRIX)
oItem.Top = 50
oItem.Left = 10
oItem.Width = 300
oItem.Height = 200
oMatrixDoc1 = oItem.Specific
oColumns = oMatrixDoc1.Columns
'Add Columns to the matrix
'The # column
oColumn = oColumns.Add("#", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oColumn.TitleObject.Caption = "#"
oColumn.Width = 20
oColumn.Editable = False
' ItemCode
oColumn = oColumns.Add("ItemCode1", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oColumn.TitleObject.Caption = "ItemCode1"
oColumn.Width = 100
'Bind column
oColumn.DataBind.SetBound(True, "@T_DOC1", "U_ItemCode")
' ItemName
oColumn = oColumns.Add("ItemName1", SAPbouiCOM.BoFormItemTypes.it_EDIT)
oColumn.TitleObject.Caption = "ItemName 1"
oColumn.Width = 100
'Bind column
oColumn.DataBind.SetBound(True, "@T_DOC1", "U_ItemName")
' Add the AddRow button for Matrix
oItem = oFormDoc.Items.Add("AddRowDoc", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
oItem.Left = 360
oItem.Top = 120
oButton = oItem.Specific
oButton.Caption = "Add Row"
You will need to capture the event et_ITEM_PRESSED on the AddRowDoc button and then add the row by hand.
Here you have a sample:
If ((pVal.FormTypeEx = "MyUDOFormType") And _
(pVal.ItemUID = "AddRowDoc") And _
(pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) And _
(pVal.BeforeAction = False)) Then
Dim ds As SAPbouiCOM.DBDataSource
ds = oFormMD.DataSources.DBDataSources.Item("@T_DOC")
'Clear the DataSources before adding a row
ds.Clear()
Dim count As Integer = oMatrixMD1.RowCount
'Add a new row
oMatrixMD1.AddRow(1, count)
'To have the cursor on the new line
oMatrixMD1.Columns.Item(1).Cells.Item(oMatrixMD1.RowCount).Click(SAPbouiCOM.BoCellClickType.ct_Regular)
After you make it work once please save it as Xml and then load the form using the class FormCreationParam by setting the property XmlData = string containing the xml information of your form.
Hope it works also fine
Regards
Trinidad.
Hi to everybody.
This conversation is very helpful for me. I was just trying to implement the same things.
But I've a question:
How can I use a custom form made by Screen Painter?
After the form is created by screen painter I load it by code (c#) and so I've not a FormCreationParams object where I can set the ObjectType property.
Can someone of you help me?
Thanks in advance,
Piero Cannizzaro
Ok, I have also seen that in Screen Painter I can set the ObjectType property by the Form Property Panel. Thanks anayway.
Now I've tow questions:
1. I've created two custom tables by SAP B1 in order to manage master/details data. To do this I've chosen "Master Data"/"Master Data Lines" as types o my tables.
I've also added to these tables some custom fileds.
The question is: are the fields created automatically from SAP B1 in that tables managed from SAPB1 or I've to manage them by code?
2. How can I implement databinding (for each item on my custom form) by Screen Painter? Is possible?
Message was edited by: Piero Cannizaro
Hi Piero,
1.
The most part of the fields created automatically by B1 will be managed automatically by B1 you don't have to touch at them.
But some of them like Code and Name for MasterData should be entered by the user or by your code, B1 cannot create them for you.
2.
You have the properties DataBound, TableName and Alias for the items you can do databinding.
Regards
Trinidad.
Sorry Trinidad,
can you tell me how I've to use the properties DataBound, TableName and Alias?
I think the following:
1) In "TableName" I've to set the value indicating the name of my custom table (with "@" char at the beginning or without?)
2) In "DataBound" I've to set the name of the field contained in my table.
3) What value I've to set in "Alias" property???
Thanks
Piero
There aren't errors in my code.
The error is raised why the table's field "Code" is empty.
I resolved the problem putting a hidden EDIT Field on my custom form binded with "Code" field and pupulate it by code. Now all the logic works very well.
Thanks anayway
Piero
p.s. Now I try to bind the matrix to handle the details data. Let's wish me good luck!
Hi Trinidad,
I'm tryng to handle the following operations on my matrix:
1)add a new row
2)delete a row
In order to do this I was reading your post on this topic where you write the following:
-
If ((pVal.FormTypeEx = "MyUDOFormType") And _
(pVal.ItemUID = "AddRowDoc") And _
(pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) And _
(pVal.BeforeAction = False)) Then
Dim ds As SAPbouiCOM.DBDataSource
ds = oFormMD.DataSources.DBDataSources.Item("@T_DOC")
'Clear the DataSources before adding a row
ds.Clear()
Dim count As Integer = oMatrixMD1.RowCount
'Add a new row
oMatrixMD1.AddRow(1, count)
'To have the cursor on the new line
oMatrixMD1.Columns.Item(1).Cells.Item(oMatrixMD1.RowCount).Click(SAPbouiCOM.BoCellClickType.ct_Regular)
-
The question is:
Why you add a DbDataSource (bound with your Master table) to the form??
Which is the reason? I've seen you don't use it.
Can you explain it to me?
Thanks in advance!
Piero
When you create a form to link with a UDO you must bind all the static texts and matrix columns to their corresponding TableName - Alias.
To be able to use a TableName you must first add to the form a DBDataSource containing the TableName.
In the button Add I only look for the DBDataSource of the matrix an clear it before adding the row, if you don't do it then the last line is copied in the new added one and you have problems to save the record.
ds = oFormMD.DataSources.DBDataSources.Item("@T_DOC")
ds.Clear()
Regards
Trinidad.
ok. In C# I use this code:
-
if (ie.ItemUID == "cmdAddRow")
{
SAPbouiCOM.DBDataSource dbDs = FormHandle.DataSources.DBDataSources.Item("@DSLAT"); // DSLAT is my MasterData table
dbDs.Clear();
mx.AddRow(1, mx.RowCount);
mx.Columns.Item(1).Cells.Item(mx.RowCount).Click(SAPbouiCOM.BoCellClickType.ct_Regular, 0);
}
else if (ie.ItemUID == "cmdDelRow")
{
int selectedRowIndex = mx.GetNextSelectedRow(0, SAPbouiCOM.BoOrderType.ot_RowOrder);
if (selectedRowIndex > -1)
{
mx.DeleteRow(selectedRowIndex);
}
else
MessageBoxToSAP("No rows selected"); //this is a custom method
}
-
Adding a new row the code above work fine.
Updating or Deleting a row the code NOT work fine!
In details the code delete the row from the matrix but the changes are not applied to database.
The same happens attempting to update a row.
Could you show me an example of how this code should be implemented?
Hi Piero,
I'm not sure what you are asking in your first question. Do you mean fields Code and Name? That are created automatically by B1? Once you had defined your own Tables and you linked your UDO to them, you dont have to do more than going through the Wizard or to indicate which fields are going to be visible (in case you select "Default Form").
Q2. You can bound data in the screen painter by selecting the field, then the "Items Tab" then in the "Specific" section you will give the "Alias" (name of the field in the DB), the "Databound" set to "true", and in "TableName" the name of the table that contains this field.
Hope this helps,
Felipe
Hi Vit Nemec
When u r creating a form there is a property of form "ObjectType" u have to give your UDO name there and bound all the files to the controls
u will get all the functionaly on yr form
Thanks
Ankush VACHHER
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
On the SDK documentation there's an example called Matrix&Data Sources. This should be very helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.