Skip to Content
avatar image
Former Member

Connect VB form to sap b1 client

Hi, I'm new to sap b1

I want to know how to link VB form to sap b1 client without using SAP b1 studio

Created table with fields on SAP B1 client using configuration tools however i haven't used the wizard to create the form.

Form made using tools in VB.net (known so far: use "@_table name" and "u_fieldname" )

Example:

on SAP b1 client : have the table and field configured

on VB.net: create form using tool-bar, like edit-text for field, add button

i want to know how can i connect the VB Form edit-text to one of my field in SAP b1 client table without using the SAP B1 studio.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Sep 14, 2017 at 10:03 AM

    Hi Dipak,

    1. To create a Table using SAP Business One SDK:

    SAPbobsCOM.UserTablesMD oUserTablesMD = default(SAPbobsCOM.UserTablesMD);
    oUserTablesMD = (SAPbobsCOM.UserTablesMD)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);
    
    
    if (!oUserTablesMD.GetByKey(TableName))
    {
        oUserTablesMD.TableType = TableType;
        oUserTablesMD.TableName = TableName;
        oUserTablesMD.TableDescription = TableDesc;
        lRetCode = oUserTablesMD.Add();
        if (lRetCode != 0)
        {
            SBO_Company.GetLastError(out lErrCode, out sErrMsg);
            Interaction.MsgBox(sErrMsg, MsgBoxStyle.Critical, "ARECO");
    
    
            return (false);
        }
        else
        {
            ShowMessage("Table: " + oUserTablesMD.TableName + " was added successfully", SAPbouiCOM.BoStatusBarMessageType.smt_Success);
            Marshal.ReleaseComObject(oUserTablesMD);
            return (true);
        }
    }
    else
    {
        Marshal.ReleaseComObject(oUserTablesMD);
        return (true);
    }
    

    2. To create columns/fields in a Table, you need to use the following code:

    SAPbobsCOM.UserFieldsMD oUserFieldsMD = null;
    oUserFieldsMD = (SAPbobsCOM.UserFieldsMD)SBO_Value.SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields);
    
    
    string Table = null;
    if (TableType != 1)
    {
        Table = "@" + TableName;
    }
    else
    {
        Table = TableName;
    }
    
    
    if (!IsFieldExist(Table, FieldName))
    {
        oUserFieldsMD.TableName = TableName;
        oUserFieldsMD.Name = FieldName;
        oUserFieldsMD.Description = FieldDesc;
        oUserFieldsMD.Type = fieldType;
        oUserFieldsMD.SubType = fieldSubType;
        oUserFieldsMD.EditSize = fieldLength;
        oUserFieldsMD.LinkedTable = LinkedTable;
        if (ValidValues != null)
        {
    
    
            for (int i = 0; i <= ValidValues.GetLength(0) - 1; i++)
            {
                if (ValidValues[i, 0] != null)
                {
    oUserFieldsMD.ValidValues.Value = ValidValues[i, 0];
    oUserFieldsMD.ValidValues.Description = ValidValues[i, 1];
    oUserFieldsMD.ValidValues.Add();
                }
            }
        }
    
    
        lRetCode = oUserFieldsMD.Add();
        if (lRetCode != 0)
        {
            SBO_Value.SBO_Company.GetLastError(out lErrCode, out sErrMsg);
            Interaction.MsgBox(sErrMsg, MsgBoxStyle.Critical, "ARECO");
            return (false);
        }
        else
        {
            ShowMessage(oUserFieldsMD.Description + " Added Sucessfully in Table: " + oUserFieldsMD.TableName, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
            //SBO_Value.SBO_Application.MetadataAutoRefresh = true;
            Marshal.ReleaseComObject(oUserFieldsMD);
            return (true);
        }
    }
    else
    {
        Marshal.ReleaseComObject(oUserFieldsMD);
    
    
        return (true);
    }
    

    Hope it helps!

    Kind regards,

    ANKIT CHAUHAN

    SAP SME Support

    Add comment
    10|10000 characters needed characters exceeded