on 11-28-2012 4:58 PM
Buenas Tardes.
En la Versión 8.8 para crear un objeto lo hacía de la siguiente manera y funcionaba correctamente creando el formulario por defecto, al igual que tomaba la selección de la opción de buscar, pero para la Versión 8.82 no esta haciendo bien el registro. No se que error pueda estar sucediendo, agradecería mucho cualquier aporte. Saludos!
public bool ADDDO(string Code, string TablaName, List<string> tablasHijas, string Nombre, SAPbobsCOM.BoYesNoEnum ManageSeries, SAPbobsCOM.BoYesNoEnum CanCancel, SAPbobsCOM.BoYesNoEnum CanClose, SAPbobsCOM.BoYesNoEnum CanDelete, SAPbobsCOM.BoYesNoEnum CanFind, SAPbobsCOM.BoYesNoEnum CanLog, SAPbobsCOM.BoYesNoEnum CanCreateForm, List<string> FindColumns, SAPbobsCOM.BoUDOObjType TipoObjeto, SAPbobsCOM.Company oCompany, SAPbouiCOM.Application oAplicacion)
{
SAPbobsCOM.IUserObjectsMD oUdo = null;
int retVal = 0;
try
{
oUdo = (SAPbobsCOM.IUserObjectsMD)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD);
if (!oUdo.GetByKey(Code))
{
oUdo.Code = Code;
oUdo.TableName = TablaName;
for (int i = 0; i < tablasHijas.Count; i++)
{
oUdo.ChildTables.TableName = tablasHijas[i];
}
oUdo.ObjectType = TipoObjeto;
oUdo.Name = Nombre;
oUdo.ManageSeries = ManageSeries;
oUdo.CanCancel = CanCancel;
oUdo.CanClose = CanClose;
oUdo.CanDelete = CanDelete;
oUdo.CanFind = CanFind;
oUdo.CanLog = CanLog;
oUdo.CanCreateDefaultForm = CanCreateForm;
for (int i = 0; i < FindColumns.Count; i++)
{
oUdo.FindColumns.ColumnAlias = FindColumns[i];
oUdo.FindColumns.Add();
}
retVal = oUdo.Add();
if (retVal != 0)
{
if (retVal != -1)
{
oAplicacion.MessageBox("ERROR ADD UDO : " + oCompany.GetLastErrorDescription() + " UDO " + Code, 1, "", "", "");
}
}
GC.Collect();
}
}
catch (Exception er)
{
oAplicacion.MessageBox("Error ADDUDO : " + er.Message + " Stack " + er.StackTrace, 1, "", "", "");
}
finally
{
try
{
Marshal.ReleaseComObject(oUdo);
}
catch
{
GC.Collect();
}
}
if (retVal == 0)
{
return true;
}
else return false;
}
Cual es el error que arroja el GetLastError?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Por lo que veo a simple vista es lo siguiente
Estas declarando el CanFind como un BoYesNoEnumm
Y cuando le das la propiedad al UDO lo estas asiento
oUDO.CanFind = CandFind;
Normalmente debería ser
oUDO.CanFind = SAPbobsCOM.BoYesNoEnum.tYES activando la propiedad en el formulario
En tu código en ningún momento le dices que el CandFind es un BoYesNoEnumm.tYES
No se si me explico...
Saludos
Felipe
Mira voy a pegar el código que viene en los samples del SDK para crear un UDO.
Estoy usando la versión 8.82 PL 09
private void AddUDO()
{
SAPbobsCOM.UserObjectsMD oUserObjectMD = null;
oUserObjectMD = ( ( SAPbobsCOM.UserObjectsMD )( oCompany.GetBusinessObject( SAPbobsCOM.BoObjectTypes.oUserObjectsMD ) ) );
oUserObjectMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tYES;
oUserObjectMD.CanClose = SAPbobsCOM.BoYesNoEnum.tYES;
oUserObjectMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tNO;
oUserObjectMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tYES;
oUserObjectMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES;
oUserObjectMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tYES;
oUserObjectMD.ChildTables.TableName = "SM_MOR1";
oUserObjectMD.Code = "SM_MOR";
oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tYES;
oUserObjectMD.Name = "SM_Meal_Order";
oUserObjectMD.ObjectType = SAPbobsCOM.BoUDOObjType.boud_Document;
oUserObjectMD.TableName = "SM_OMOR";
lRetCode = oUserObjectMD.Add();
// check for errors in the process
if ( lRetCode != 0 )
{
if ( lRetCode == -1 )
{
chkUDOAfter.SetItemChecked( 8, true );
}
else
{
oCompany.GetLastError( out lRetCode, out sErrMsg );
Interaction.MsgBox( sErrMsg, (Microsoft.VisualBasic.MsgBoxStyle)(0), null );
}
}
else
{
Interaction.MsgBox( "UDO: " + oUserObjectMD.Name + " was added successfully", (Microsoft.VisualBasic.MsgBoxStyle)(0), null );
chkUDOAfter.SetItemChecked( 8, true );
}
oUserObjectMD = null;
GC.Collect(); // Release the handle to the table
}
Atte.
Felipe
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.