2016-06-14 7 views
1

안녕하십니까. Firebird로 시작했습니다. 내 bi-Visual Studio 2010에서 C#을 사용하여 직접 작성한 추가 기능 수액을 만들었습니다. 직접 Crystal Reports에 값을 보냈습니다. 기존에 내 버전 수액을 도울 수있는 사람은 내가이 코드를 시도 9.2 이지만crystalreport를 내 양식에 연결하는 방법 add-on sap

 //add crystalreport to my add-on 

     SAPbobsCOM.ReportTypesService rptTypeService = (SAPbobsCOM.ReportTypesService) 
     Menu.company.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ReportTypesService); 
     SAPbobsCOM.ReportType newType = (SAPbobsCOM.ReportType) 
     rptTypeService.GetDataInterface(SAPbobsCOM.ReportTypesServiceDataInterfaces.rtsReportType); 
     newType.TypeName = "CodeBarre_etat"; 
     newType.AddonName = "PRINT_CODEBARRE"; 
     newType.AddonFormType = "PRINT_CODEBARRE"; 
     newType.MenuID = "PRINT_CODEBARRE"; 
     SAPbobsCOM.ReportTypeParams newTypeParam = rptTypeService.AddReportType(newType); 


     //add layout to my report 

     SAPbobsCOM.ReportLayoutsService rptService = (SAPbobsCOM.ReportLayoutsService) 
     Menu.company.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ReportLayoutsService); 
     SAPbobsCOM.ReportLayout newReport = (SAPbobsCOM.ReportLayout) 
     rptService.GetDataInterface(SAPbobsCOM.ReportLayoutsServiceDataInterfaces.rlsdiReportLayout); 
     newReport.Author = Menu.company.UserName; 
     newReport.Category = SAPbobsCOM.ReportLayoutCategoryEnum.rlcCrystal; 
     newReport.Name = "PRINT_CODEBARREL"; 
     newReport.TypeCode = newTypeParam.TypeCode; 
     SAPbobsCOM.ReportLayoutParams newReportParam = rptService.AddReportLayout(newReport); 

     // Set the report layout into the report type. 

     newType = rptTypeService.GetReportType(newTypeParam); 
     newType.DefaultReportLayout = newReportParam.LayoutCode; 
     rptTypeService.UpdateReportType(newType); 




     SAPbobsCOM.BlobParams oBlobParams = (SAPbobsCOM.BlobParams) 
     Menu. company.GetCompanyService().GetDataInterface(SAPbobsCOM.CompanyServiceDataInterfaces.csdiBlobParams); 
     oBlobParams.Table = "OITM"; 
     oBlobParams.Field = "Template"; 
     SAPbobsCOM.BlobTableKeySegment oKeySegment = oBlobParams.BlobTableKeySegments.Add(); 
     oKeySegment.Name = "ItemCode"; 
     oKeySegment.Value = newReportParam.LayoutCode; 


     FileStream oFile = new FileStream("CodeBarre_etat.rpt", 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) 
     //Menu.company.GetCompanyService().GetDataInterface(SAPbobsCOM.CompanyServiceDataInterfaces.csdiBlob); 

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

답변

0

문제가 당신의 코드가 무엇인지 모르겠지만, 아래 당신이있어 어떤 작업 구현하지 작동하지 않습니다 (VB에서는 C#이 아니지만 번역은 상당히 사소한 일입니다).

setCrystalReport(REPORT_TITLE_SUMMARY, My.Settings.ReportsPath.TrimEnd("\") & "\" & "comm_report_summary.rpt", _ 
        oForm, "myFormTypeID", "My Add-On Name", "MENU_ID_VALUE") 

기능 :

'Returns new CR TypeCode 
Private Function setCrystalReport(ByVal rptName As String, ByVal rptPath As String, ByRef oForm As SAPbouiCOM.Form, ByVal formType As String, _ 
            ByVal addOnName As String, ByVal menuID As String) As String 
    Try 
     '1. Ad a new report type => ReportTypesService (8.81+ only) 
     Dim rptTypeService As SAPbobsCOM.ReportTypesService 
     Dim newType As SAPbobsCOM.ReportType 

     rptTypeService = SBO_Company.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ReportTypesService) 
     newType = rptTypeService.GetDataInterface(SAPbobsCOM.ReportTypesServiceDataInterfaces.rtsReportType) 

     newType.TypeName = rptName 
     newType.AddonName = addOnName 
     newType.AddonFormType = formType 
     newType.MenuID = menuID 
     Dim newTypeParam As SAPbobsCOM.ReportTypeParams 
     newTypeParam = rptTypeService.AddReportType(newType) 

     '2. Add a new report layout => ReportLayoutService 
     Dim rptService As SAPbobsCOM.ReportLayoutsService 
     Dim newReport As SAPbobsCOM.ReportLayout 

     rptService = SBO_Company.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ReportLayoutsService) 
     newReport = rptService.GetDataInterface(SAPbobsCOM.ReportLayoutsServiceDataInterfaces.rlsdiReportLayout) 
     newReport.Author = SBO_Company.UserName 
     newReport.Category = SAPbobsCOM.ReportLayoutCategoryEnum.rlcCrystal 
     newReport.Name = rptName 
     newReport.TypeCode = newTypeParam.TypeCode 

     Dim newReportParam As SAPbobsCOM.ReportLayoutParams 
     newReportParam = rptService.AddReportLayout(newReport) 

     '3. Set the report layout into the report type 
     newType = rptTypeService.GetReportType(newTypeParam) 
     newType.DefaultReportLayout = newReportParam.LayoutCode 
     rptTypeService.UpdateReportType(newType) 

     '4. Link the Report layout code to the Crystal Report file 
     Dim oBlobParams As SAPbobsCOM.BlobParams 
     Dim oKeySegment As SAPbobsCOM.BlobTableKeySegment 

     oBlobParams = SBO_Company.GetCompanyService().GetDataInterface(SAPbobsCOM.CompanyServiceDataInterfaces.csdiBlobParams) 
     oBlobParams.Table = "RDOC" 
     oBlobParams.Field = "Template" 

     oKeySegment = oBlobParams.BlobTableKeySegments.Add() 
     oKeySegment.Name = "DocCode" 
     oKeySegment.Value = newReportParam.LayoutCode 

     Dim oFile As New FileStream(rptPath, System.IO.FileMode.Open) 
     Dim fileSize As Integer 
     fileSize = oFile.Length 
     Dim buf(fileSize) As Byte 
     oFile.Read(buf, 0, fileSize) 
     oFile.Dispose() 

     Dim oBlob As SAPbobsCOM.Blob 
     oBlob = SBO_Company.GetCompanyService().GetDataInterface(SAPbobsCOM.CompanyServiceDataInterfaces.csdiBlob) 

     oBlob.Content = Convert.ToBase64String(buf, 0, fileSize) 
     SBO_Company.GetCompanyService().SetBlob(oBlobParams, oBlob) 

     '5. Link the new report type to your form 
     Return newType.TypeCode 
    Catch ex As Exception 
     Dim exString As String = "" 
     exString = "Exception caught in setCrystalReport Method. Details: " & ex.Message 
     If Not ex.InnerException Is Nothing Then 
      exString += " Inner Exception: " + ex.InnerException.Message 
     End If 
     SBO_Application.StatusBar.SetText(exString, SAPbouiCOM.BoMessageTime.bmt_Medium, _ 
          SAPbouiCOM.BoStatusBarMessageType.smt_Error) 
     Return "-1" 
    End Try 
End Function 
+0

TNX 많은 유 도움을 내가 그것을 시도 할 것이다 여기

샘플 호출입니다 –