Estoy tratando de refenciar un objeto en el sdk de sap bo pero al momento de tratar obtener el valor este me llega nulo, siendo que sigo todos los pasos que vi por internet para obtener el valor
Esta clase uso para crear el formulario en la ERP de sap conectando me mediante DI-API
public void crearFormulario()
{
try
{
oCompany = new SAPbobsCOM.Company();
oCompany = (SAPbobsCOM.Company)SBO_Application.Company.GetDICompany();
SAPbouiCOM.FormCreationParams myFormCreationParams;
SAPbouiCOM.Item oItem = null;
SAPbouiCOM.EditText oEditText = null;
SAPbouiCOM.Button oButton1 = null;
SAPbouiCOM.Button oButton2 = null;
SAPbouiCOM.ComboBox oComboBox = null;
SAPbouiCOM.StaticText oStaticText = null;
myFormCreationParams = (SAPbouiCOM.FormCreationParams)SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams);
myFormCreationParams.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed;
myFormCreationParams.UniqueID = "Formularios";
myForm = SBO_Application.Forms.AddEx(myFormCreationParams);
myForm.DataSources.UserDataSources.Add("CombSource", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 20);
myForm.Title = "Formulario";
myForm.Left = 300;
myForm.Height = 800;
myForm.Width = 500;
//label
oItem = myForm.Items.Add("StaticTxt1", SAPbouiCOM.BoFormItemTypes.it_STATIC);
oItem.Left = 50;
oItem.Top = 50;
oItem.LinkTo = "Texto1";
oStaticText = ((SAPbouiCOM.StaticText)(oItem.Specific));
oStaticText.Caption = "Nombre";
oItem = myForm.Items.Add("StaticTxt2", SAPbouiCOM.BoFormItemTypes.it_STATIC);
oItem.Left = 50;
oItem.Top = 75;
oItem.LinkTo = "IGT_ET_02";
oStaticText = ((SAPbouiCOM.StaticText)(oItem.Specific));
oStaticText.Caption = "Rut";
oItem = myForm.Items.Add("StaticTxt3", SAPbouiCOM.BoFormItemTypes.it_STATIC);
oItem.Left = 50;
oItem.Top = 100;
oItem.LinkTo = "IGT_ET_03";
oStaticText = ((SAPbouiCOM.StaticText)(oItem.Specific));
oStaticText.Caption = "Codigo";
oItem = myForm.Items.Add("StaticTxt4", SAPbouiCOM.BoFormItemTypes.it_STATIC);
oItem.Left = 50;
oItem.Top = 125;
oItem.LinkTo = "IGT_CB1";
oStaticText = ((SAPbouiCOM.StaticText)(oItem.Specific));
oStaticText.Caption = "Tipo";
//agregar edit text
oItem = myForm.Items.Add("Texto1", SAPbouiCOM.BoFormItemTypes.it_EDIT);
oItem.Left = 100;
oItem.Top = 50;
oEditText = (SAPbouiCOM.EditText)oItem.Specific;
oItem = myForm.Items.Add("IGT_ET_02", SAPbouiCOM.BoFormItemTypes.it_EDIT);
oItem.Left = 100;
oItem.Top = 75;
oEditText = (SAPbouiCOM.EditText)oItem.Specific;
oItem = myForm.Items.Add("IGT_ET_03", SAPbouiCOM.BoFormItemTypes.it_EDIT);
oItem.Left = 100;
oItem.Top = 100;
oEditText = (SAPbouiCOM.EditText)oItem.Specific;
////combocarga
//string query = "Select T0.CardCode, T0.CardName From OCRD T0";
//oItem = myForm.Items.Add("IGT_CB0", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX);
//oItem.Left = 200;
//oItem.Top = 135;
//oComboBox = (SAPbouiCOM.ComboBox)oItem.Specific;
//oComboBox.DataBind.SetBound(true, "", "CombSource");
//LoadComboQueryRecordset(query, oComboBox, "CardCode", "CardName", oCompany);
//Combobox
oItem = myForm.Items.Add("IGT_CB1", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX);
oItem.Left = 100;
oItem.Top = 125;
oComboBox = (SAPbouiCOM.ComboBox)oItem.Specific;
oComboBox.DataBind.SetBound(true, "", "CombSource");
oComboBox.ValidValues.Add("C", "Cliente");
oComboBox.ValidValues.Add("S", "Proveedor");
oComboBox.ValidValues.Add("L", "Lead");
//agregar boton
oItem = myForm.Items.Add("IGT_BT1", SAPbouiCOM.BoFormItemTypes.it_BUTTON);
oItem.Left = 50;
oItem.Top = 200;
oButton1 = (SAPbouiCOM.Button)oItem.Specific;
oButton1.Caption = "Crear";
//agregar boton
oItem = myForm.Items.Add("IGT_BT2", SAPbouiCOM.BoFormItemTypes.it_BUTTON);
oItem.Left = 120;
oItem.Top = 200;
oButton2 = (SAPbouiCOM.Button)oItem.Specific;
oButton2.Caption = "Cancelar";
myForm.Visible = true;
SBO_Application.StatusBar.SetText("Formulario Iniciado", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success);
//}
}
catch (Exception ex)
{
SBO_Application.StatusBar.SetText("Error en el Formulario" + ex.Message, BoMessageTime.bmt_Medium, BoStatusBarMessageType.smt_Error);
}
}
con esta clase manejo los eventos de los controles
private void manejadorEventosControles(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubleEvent)
{
BubleEvent = true;
try
{
if (pVal.FormType == 134)
{
if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_LOAD && pVal.BeforeAction == false)
{
SAPbouiCOM.IItems oItems = SBO_Application.Forms.Item(FormUID).Items;
SAPbouiCOM.Item oItem;
SAPbouiCOM.Button oButton;
oItem = oItems.Add("MyBtIGT", SAPbouiCOM.BoFormItemTypes.it_BUTTON);
oItem.Top = oItems.Item("2").Top;
oItem.Left = oItems.Item("2").Left + oItems.Item("2").Width + 10;
oButton = (SAPbouiCOM.Button)oItem.Specific;
oButton.Caption = "Boton SDK";
}
if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && pVal.ItemUID == "MyBtIGT")
{
//SBO_Application.MessageBox("Clic en mi Boton SDK");
crearFormulario();
}
}
if (pVal.FormUID == "Formularios")
{
if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && pVal.BeforeAction == false && pVal.ItemUID == "IGT_BT1")
{
crearSN();
//cargarInfoGrid();
}
if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && pVal.BeforeAction == false && pVal.ItemUID == "IGT_BT2")
{
//SBO_Application.MessageBox("Clic en Cancelar");
myForm.Close();
}
}
if (pVal.FormUID == "ListarSN")
{
if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && pVal.BeforeAction == false && pVal.ItemUID == "BT1")
{
cargarInfoGrid();
}
if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && pVal.BeforeAction == false && pVal.ItemUID == "BT2")
{
//SBO_Application.MessageBox("Clic en Cancelar");
myForm.Close();
}
}
if (pVal.FormUID == "cotForm")
{
if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && pVal.BeforeAction == false && pVal.ItemUID == "BT1")
{
crearCotizacion();
}
if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && pVal.BeforeAction == false && pVal.ItemUID == "BT2")
{
//SBO_Application.MessageBox("Clic en Cancelar");
myForm.Close();
}
if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && pVal.BeforeAction == false && pVal.ItemUID == "BT3")
{
cargarNombre();
}
}
}
catch (Exception ex)
{
SBO_Application.StatusBar.SetText("Error en el manejador de controles" + ex.Message, BoMessageTime.bmt_Medium, BoStatusBarMessageType.smt_Error);
}
}
y con esta clase obtengo los valores y los guardo en la ERP de sap
private void crearSN()
{
try
{
if (oCompany.Connect() != 0)
{
SBO_Application.StatusBar.SetText("Error en la conexion" + oCompany.GetLastErrorDescription(), BoMessageTime.bmt_Medium, BoStatusBarMessageType.smt_Error);
}
else
{
SAPbobsCOM.BusinessPartners mySN = null;
mySN = (SAPbobsCOM.BusinessPartners)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);
SAPbouiCOM.EditText myET_Nombre = (SAPbouiCOM.EditText)myForm.Items.Item("Texto1").Specific;
SAPbouiCOM.EditText myET_Rut = (SAPbouiCOM.EditText)myForm.Items.Item("IGT_ET_02").Specific;
SAPbouiCOM.EditText myET_Codigo = (SAPbouiCOM.EditText)myForm.Items.Item("IGT_ET_03").Specific;
SAPbouiCOM.ComboBox myCB = (SAPbouiCOM.ComboBox)myForm.Items.Item("IGT_CB1").Specific;
mySN.CardName = myET_Nombre.Value;
mySN.FederalTaxID = myET_Rut.Value;
mySN.CardCode = myET_Codigo.Value;
if (myCB.Value == "C")
{
mySN.CardType = SAPbobsCOM.BoCardTypes.cCustomer;
}
else if (myCB.Value == "S")
{
mySN.CardType = SAPbobsCOM.BoCardTypes.cSupplier;
}
else
{
mySN.CardType = SAPbobsCOM.BoCardTypes.cLid;
}
mySN.FreeText = "Socio Creado desde SDK";
if (mySN.Add() != 0)
{
SBO_Application.StatusBar.SetText("Error al crear el Socio" + oCompany.GetLastErrorDescription(), BoMessageTime.bmt_Medium, BoStatusBarMessageType.smt_Error);
}
else
{
SBO_Application.StatusBar.SetText("Exito en la Creacion del Socio de Negocio", BoMessageTime.bmt_Medium, BoStatusBarMessageType.smt_Success);
}
}
}
catch (Exception ex)
{
SBO_Application.StatusBar.SetText("Error al crear al Socio de Negocio" + ex.Message, BoMessageTime.bmt_Medium, BoStatusBarMessageType.smt_Error);
}
}
Variables Globales
public static Application SBO_Application = null;
public static SAPbobsCOM.Company oCompany;
public static SAPbouiCOM.Form myForm;
mi problema es que no entiendo por que myForm me llega nulo siempre que hago la petición