cancel
Showing results for 
Search instead for 
Did you mean: 

UDO registration through COde

Former Member
0 Kudos

Hi

I m unable to do registration of UDO through code.

I m having two tables.1. U_UDOM(Master) and the second one is U_UDOC(Child). As i add my UDO, after assigning all properties it gives me error code(-<b>50002</b>). Can u help me regarding this error???

Also i want to know these properties of SAPbobsCOM.UserObjectsMD(i mean what values we should assign to these properties)

oUserObjectMD.Code = "EMPID";

oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tYES;

oUserObjectMD.Name = "EMPNAME";

View Entire Topic
Former Member
0 Kudos

Hi Pankaj,

Please let us know what is the error desciption by adding line

MessageBox.Show(oCompany.GetLastErrorDescription)

Adele

Former Member
0 Kudos

hi

first of all thx to reply. I get overcome with that problem as i assign Code to "form column Alias".

oUserObjectMD.FormColumns.FormColumnAlias = "Code";

Now UDO has been created but now i stuck in another problem. As i write something to text box, <b>the OK button gets cobverted to Update</b> and as i click on this , in status bar it shows message "operation ended successfully", <b>but no entry is found in User Table</b>.

I m giving the code here how i add UDO, plz solve my problem.

private static void Add_UDO()

{

try

{

GC.Collect();// 'Release the handle to the table

int lRetCode=0;

int lErrCode = 0;

string sErrMsg = null;

SAPbobsCOM.UserObjectsMD oUserObjectMD;

oUserObjectMD = (SAPbobsCOM.UserObjectsMD)mCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD);

if (oUserObjectMD.GetByKey("UDONAME") == false )

{

oUserObjectMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tYES;

oUserObjectMD.CanClose = SAPbobsCOM.BoYesNoEnum.tYES;

oUserObjectMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tYES ;

oUserObjectMD.FormColumns.FormColumnAlias = "Code";//"U_EMPID";

oUserObjectMD.FormColumns.FormColumnDescription = "Emp ID";

oUserObjectMD.FindColumns.SetCurrentLine(0);

oUserObjectMD.FormColumns.Add();

oUserObjectMD.FormColumns.FormColumnAlias = "U_EMPNAME";

oUserObjectMD.FormColumns.FormColumnDescription = "Emp Name";

oUserObjectMD.FormColumns.Add();

oUserObjectMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tYES;

oUserObjectMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES;

oUserObjectMD.CanLog = SAPbobsCOM.BoYesNoEnum.tNO ;

oUserObjectMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tYES;

oUserObjectMD.ChildTables.TableName = "U_UDOC";

oUserObjectMD.Code = "UDONAME";

oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tYES;

oUserObjectMD.Name = "EMP MASTER DATA";

oUserObjectMD.ObjectType = SAPbobsCOM.BoUDOObjType.boud_MasterData;

oUserObjectMD.TableName = "U_UDOM";

lRetCode = oUserObjectMD.Add();

if (lRetCode != 0)

{

mCompany.GetLastError(out lErrCode,out sErrMsg);

//TODO: INSTANT C# TODO TASK: The following line could not be converted:

//MsgBox sErrMsg

string str="";

}

}

oUserObjectMD = null;

GC.Collect();// 'Release the handle to the table

}

catch(Exception ex)

{throw ex;}

}

Former Member
0 Kudos

Hi Pankaj,

You have to set a couple of properties on the form when it is opened.

If you create the form with screen painter, the following property can be set in screen painter. If not you can use creation params:

  Dim oCreationParams As SAPbouiCOM.FormCreationParams
  oCreationParams.ObjectType = "MY_UDO"

'other properties on the form...

  oForm.SupportedModes = -1
  oForm.AutoManaged = True
  oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE
  oForm.DataBrowser.BrowseBy = "eCode" 'your code field
  oForm.Items.Item("e_ID").Click()

Let me know if it helps.

Adele

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Looking at your code I suppose you are using the Default form provided by UDO.

In this case after pressing Update the only action is to add a new line on the form.

If you press Ok after, then the form will close and the line added to the database.

Hope it helps

Trinidad.

Former Member
0 Kudos

Hi

I have added these properties but still same problem is there. I m giving u the brief descripttion here.

Master Table : U_UDOM

Master Table Field: U_EMPID, U_EMPNAME

Child Table: U_UDOC

Child TAble Field: U_EMPID, U_CITY, U_STATE

These r the tables for That i have made UDO as code is given in previous reply.

1.

I have already added form object type to UDO and AutoMAnaged to true.

As i have added --

oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE

Noe form is always in Add mode and also in status bar no message shown like "Operation ended successfully".

2.

The other properties u give for navigation, as i added these, "Invalid Item error" occured. Also plz tell me about the value(eCode) u have assigned. Becoz now i have given u the table structure also fo UDO.

oForm.DataBrowser.BrowseBy = "eCode" 'your code field

3. Plz specify the reason for this statement.

oForm.Items.Item("e_ID").Click()

Former Member
0 Kudos

Hi

No i m using my own form having two edit box and one matrix for child table.

Master Table : U_UDOM

Master Table Field: U_EMPID, U_EMPNAME

Child Table: U_UDOC

Child TAble Field: U_EMPID, U_CITY, U_STATE

These r the tables for That i have made UDO as code is given in previous reply.

1.

I have already added form object type to UDO and AutoMAnaged to true.

As i have added --

oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE

Noe form is always in Add mode and also in status bar no message shown like "Operation ended successfully".

2.

Is it nessary to provide navigation for automanging of form mode when added with UDO. if yes then what value shod we assigned to BrowseBy property.

Plz suggest me.

Former Member
0 Kudos

Hi Pankaj,

Did you create the form using screen painter or using code?

The field "eCode" is the name of your first edit text box on your window. (BrowseBy)

Kindest regards,

Adele

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Pankaj,

If you are using a form you define then you should set the property oUserObjectMD.CanCreateDefaultForm to false.

After that to make the button Add work fine, then you must add this button with UID = "1".

For the Browse by if you must point to the editText representing the Code.

Hope it helps

Trinidad.

Former Member
0 Kudos

hi

yes i have made this form using screen painterand paste three controls over it, one for EMPID, one for EMPNAME and a blank matrix. Through coding i m adding columns to the matrix (CITY & STATE) for child tables.

Thx

Former Member
0 Kudos

Hi Pankaj,

Please paste code from where you load the UDO screen. Also, when you open your UDO screen, is the navigation, find and add buttons enabled in the toolbar at the top?

Thanks,

Adele

Message was edited by: Adele le Roux

Former Member
0 Kudos

hi

Thisis the code that i have written in Menu event.

-


Menu click----


createXMLForm();

oForm =mSBO_Application.Forms.GetFormByTypeAndCount(Convert.ToInt32("2000060004"),1);

AddColumn();

AddDataSourceToForm();

AddUserDefinedTable();

AddUserDefineField();

Add_UDO();

-


-


And here the called function

-


public static void createXMLForm()

{

try

{

string strPath=ConfigurationSettings.AppSettings["EmpUDO"];

string XMLString= GetFormXML(strPath);

mSBO_Application.LoadBatchActions(ref XMLString);

}

catch(Exception ex)

{

throw ex;

}

}

public static string GetFormXML(string Path)

{

try

{

XmlDocument oXmlDoc = new XmlDocument() ;

oXmlDoc.Load(Path);

return oXmlDoc.InnerXml.ToString();

}

catch(Exception ex)

{

throw ex;

}

}

YES find and add buttons are enabled in the toolbar.

One thing i would like to confirm isit necessary that the 'controls' whose id we assign to BrowseBy property of the form, should be link to one of the default fields that r added when we make our table as master or master line(like Code or DocEntry).

NOTE----->

Today i have made the fresh project and creating form through code not throgh Screen Painter and <b>it is working till now fine</b>. But i want to know why it is not working when it is through screen painter.

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Have you tried to save the form you have created by code into Xml and compare it to the one created with the ScreenPainter? Maybe you can find the difference this way...

Trinidad.