Skip to Content
avatar image
Former Member

Problem when adding Crystal Report reports and layouts threw SDK

For Adding CR report we use this class:

class Report_Credit  {  ReportLayoutsService
oLayoutService;  ReportLayout
oReport;  string
newReportCode;   ReportLayoutParams
oNewReportParams;  CompanyService
oCompanyService;  string
BaseDirPath { get { return
AppDomain.CurrentDomain.BaseDirectory; } }  public
void CreateReport()  {  oLayoutService = (ReportLayoutsService)Program.oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ReportLayoutsService);  oReport = (ReportLayout)oLayoutService.GetDataInterface(ReportLayoutsServiceDataInterfaces.rlsdiReportLayout);  //Initialize critical properties   ////   //// Use TypeCode "RCRI" to specify a Crystal
Report.   //// Use other TypeCode to specify a layout for a document
type.   //// List of TypeCode types are in table RTYP.   oReport.Name = "Отчет: НДСКредит";  oReport.TypeCode = "RCRI";  oReport.Author = Program.oCompany.UserName;oReport.Category
= ReportLayoutCategoryEnum.rlcCrystal;  try
{   //
Add new object   oNewReportParams =
oLayoutService.AddReportLayoutToMenu(oReport, "2304");
  // Get code of the added ReportLayout object   newReportCode =
oNewReportParams.LayoutCode;   }   catch (System.Exception
err) {   string errMessage = err.Message;   return;   }   //// Wpload .rpt file using SetBlob interface   oCompanyService = Program.oCompany.GetCompanyService();   //// Specify the table and field to update   BlobParams oBlobParams = (BlobParams)oCompanyService.GetDataInterface(SAPbobsCOM.CompanyServiceDataInterfaces.csdiBlobParams);    oBlobParams.Table = "RDOC";   oBlobParams.Field = "VATCredit";   //// Specify the record whose blob field is to be set   BlobTableKeySegment oKeySegment =
oBlobParams.BlobTableKeySegments.Add();   oKeySegment.Name = "DocCode";   oKeySegment.Value =
newReportCode;   Blob oBlob = (Blob)oCompanyService.GetDataInterface(CompanyServiceDataInterfaces.csdiBlob);   //// Put the rpt file into buffer   FileStream oFile = new
FileStream(BaseDirPath + @"\НДСКредит_Новий.rpt", System.IO.FileMode.Open);   int fileSize = (int)oFile.Length;
  byte[] buf = new byte[fileSize];   oFile.Read(buf, 0,
fileSize);   oFile.Close();  int count = 0;  //// Convert memory buffer to Base64 string  oBlob.Content = Convert.ToBase64String(buf, 0, fileSize);   try {   //  //Upload Blob
to database   oCompanyService.SetBlob(oBlobParams,
oBlob);  }   catch (System.Exception
ex) {   string errmsg = ex.Message;   }  }  }

The problem occurs in this line:


It seems to us, that problem in Converting Byte massive in 64-bit string, because we use 32-bit B1 client. There are no method for converting byte massive in 32-bit string. Error you can see in screenshot below.

Maybe there is another solution for this problem.

screen1.png (21.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Apr 19, 2017 at 01:00 AM

    Hi Евгений,

    This error occured because you provided a wrong value for oBlobParams.Field. The correct is:

    oBlobParams.Field = "Template";

    The blob field on RDOC is the column called Template.

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded