Moses Yap
:-) A happy IT Guy

SAP B1: Creating a User Defined Table using C#

May 20, 2008 07:02 by moses.yap

User defined tables are used to store custom information in SAP B1.  A user define table is a tabular container that can contain multiple user defined fields and can be grouped together to form a User Defined Object (UDO).  A user defined table can be of type Master Data, Master Data Row (parent-child relationship), Document, Document Row (another parent-child relationship) or could be just stand alone and is typed as "No Object".

Creating User Defined Tables From SAP B1

Just go to Tools -> Customization Tools -> User Defined Tables - Setup...

UserDefinedTablesMenu

UserDefinedTablesScreen

Creating User Defined Tables From Code

public int AddUserTable(ref SAPbobsCOM.Company oCompany, string name, string description,

    SAPbobsCOM.BoUTBTableType tableType)

{

    int returnCode = 0;

    string errorMessage = string.Empty;

    // The UserTablesMD represents a meta-data object which allows us

    // to add\remove tables, change a table name etc.

    SAPbobsCOM.UserTablesMD oUserTableMD =

        (SAPbobsCOM.UserTablesMD)oCompany.

                          GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);

    // set the table parameters

    oUserTableMD.TableName = name;

    oUserTableMD.TableDescription = description;

    oUserTableMD.TableType = tableType;

    returnCode = oUserTableMD.Add();

    //Note: a return code of -1 is successful

    if(returnCode != 0)

    {

        if(returnCode != - 1)

        {

            oCompany.GetLastError(out returnCode, out errorMessage);

            throw new ApplicationException(returnCode.ToString() + " - " + errorMessage);

        }

    }

    System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserTableMD);

    oUserTableMD = null;

    return returnCode;

}

Notes:
SAPbobsCOM.BoUTBTableType is the enumeration that defines what type of user defined table is created. (ie Master Data, Document, Document Row, etc.)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:
Categories: .NET | C# | SAP B1
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

January 5. 2009 16:07