Skip to Content
0

Connect VB form to sap b1 client

Sep 13, 2017 at 10:59 PM

85

avatar image
Former Member

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.

10 |10000 characters needed characters left characters exceeded

Hi,

Please add the SAP Business One SDK tag to your question to receive more answers.

Regards,

Johan

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
ANKIT CHAUHAN
Sep 14, 2017 at 10:03 AM
0

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

Show 5 Share
10 |10000 characters needed characters left characters exceeded
Former Member

i don't want to create table on the VB.net however i want to exist database on SAP b1 client to VB.net without using SAP B1 studio.

For example:

1) Invoice database (with fields) on SAP b1 client

2) create form with same fields name

3) now i want to link the fields and show the form on the SAP b1 client

0

Hi Dipak,

Unfortunately, your question is not very much clear! Kindly help to explain with screenshot.

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0
Former Member
ANKIT CHAUHAN

example of the demo database created on SAP B1 client

form created on VB, now i want to know how can i connect one of the "edit-text" to one of field on the demo database

field.png (228.0 kB)
vb.png (162.1 kB)
0

Hi Dipak,

Just click on the "EditText" on the form, go to its "Properties".

Under the properties, you need to fill in the "Table Name" and "Alias" property in order to get the data saved in the database. Alias is the column name in the table that you need to fill.

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0
Former Member

Thanks for the answer :) and also Thanks for earlier answer, it will help me in the future also :)

0