Cargar Reporte de crystal report a sap B1 SDK

Buenas amigos, una pregunta hay alguna forma de por medio del SDK cargar un reporte echo en cristal report a sap.

Puedes especificar un poco mas que necesitas. Si lo que quieres es mostrar un crystal en una ventana de un addon, si es posible, solo necesitas tener un componente de visualizacion de crystal en tu IDE.

1 me gusta

Hola @ldecameron
Con el siguiente metodo puede realizar lo que necesitas.

        public void cargaFormatos(string rutaArchivo)
        {

            //1. agregar nuevo report type 
            SAPbobsCOM.ReportTypesService rptTypeService = (SAPbobsCOM.ReportTypesService)oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ReportTypesService);
            SAPbobsCOM.ReportType newType = (SAPbobsCOM.ReportType)rptTypeService.GetDataInterface(SAPbobsCOM.ReportTypesServiceDataInterfaces.rtsReportType);
            newType.AddonName = "EmbalajeVentas";//NOMBRE DEL ADDON
            newType.TypeName = "ListaEmpaqueNacional"; //NOMBRE DE LA TRANSACCION
            newType.AddonFormType = "INV_EmbalajeVentas"; //Nombre del formulario 
            newType.MenuID = "INV_ListaEmpaqueNacional"; //id del menu
            SAPbobsCOM.ReportTypeParams newTypeParam = rptTypeService.AddReportType(newType);

            //2. agregar nuevo report layout => ReportLayoutsService.
            SAPbobsCOM.ReportLayoutsService rptService = (SAPbobsCOM.ReportLayoutsService)oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ReportLayoutsService);
            SAPbobsCOM.ReportLayout newReport = (SAPbobsCOM.ReportLayout)rptService.GetDataInterface(SAPbobsCOM.ReportLayoutsServiceDataInterfaces.rlsdiReportLayout);
            newReport.Author = oCompany.UserName;
            newReport.Category = SAPbobsCOM.ReportLayoutCategoryEnum.rlcCrystal;
            newReport.Name = "FormatoListaEmpaque";//nombre con el cual queda el formato
            newReport.TypeCode = newTypeParam.TypeCode;
            SAPbobsCOM.ReportLayoutParams newReportParam = rptService.AddReportLayout(newReport);

            //3. asignar report layout en el report type.
            newType = rptTypeService.GetReportType(newTypeParam);
            newType.DefaultReportLayout = newReportParam.LayoutCode;
            rptTypeService.UpdateReportType(newType);

            //4. enlazar el codigo del Report layout al archivo de Crystal Report
            //se utiliza CompanyService.SetBlob para cargar el archivo a la base de datos de sap
            SAPbobsCOM.BlobParams oBlobParams = (SAPbobsCOM.BlobParams)oCompany.GetCompanyService().GetDataInterface(SAPbobsCOM.CompanyServiceDataInterfaces.csdiBlobParams);
            oBlobParams.Table = "RDOC";
            oBlobParams.Field = "Template";
            SAPbobsCOM.BlobTableKeySegment oKeySegment = oBlobParams.BlobTableKeySegments.Add();
            oKeySegment.Name = "DocCode";
            oKeySegment.Value = newReportParam.LayoutCode;

            string rptFilePath =  rutaArchivo; //@"C:\MiReporte.rpt";
            FileStream oFile = new FileStream(rptFilePath, System.IO.FileMode.Open);            
            int fileSize = (int)oFile.Length;
            byte[] buf = new byte[fileSize];
            oFile.Read(buf, 0, fileSize);
            oFile.Dispose();

            SAPbobsCOM.Blob oBlob = (SAPbobsCOM.Blob)oCompany.GetCompanyService().GetDataInterface(SAPbobsCOM.CompanyServiceDataInterfaces.csdiBlob);
            oBlob.Content = Convert.ToBase64String(buf, 0, fileSize);
            oCompany.GetCompanyService().SetBlob(oBlobParams, oBlob);

            Application.SBO_Application.StatusBar.SetText("Formato Cargado en Layouts add-on", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);

            //5. se asigna el formato importado al formulario             
            SAPbouiCOM.Form oMyForm = (SAPbouiCOM.Form)Application.SBO_Application.Forms.ActiveForm;
            oMyForm.ReportType = newType.TypeCode;
            //6. manejar el evento LayoutKeyEvent
            
        }

Saludos,
Andres Ramirez Jaramillo :colombia:

2 Me gusta

Este tema se cerró automáticamente 91 días después del último post. No se permiten nuevas respuestas.