cancel
Showing results for 
Search instead for 
Did you mean: 

How to print a Sap B1 CR report layout on a custom printer

aldebra
Explorer

Dear Experts,
I'm using Sap Business One version 9.3 PL10 (sql/Hana) and I'm trying to print Crystal Reports Document on different printers using DI Api sdk.

I can print a cr report layout, using SAPbobsCOM.ReportLayoutsService and SAPbobsCOM.ReportLayoutPrintParams.

The problem is that the default windows printer is always used even if, in sap b1, another printer is associated with the report layout.

Is it possible to set a custom printer before printing report layout (oReportLayoutService.Print(oReportPrintParams) ) ?

Thank you in advance.

Kind regard,

Moreno

anrodse
Participant
0 Kudos

Did you solved it? I'm facing the same issue and I can't find any solution.

I've tried this code to update report printer but still not working:

reportLayoutParams = (ReportLayoutParams)reportLayoutsService.GetDataInterface(ReportLayoutsServiceDataInterfaces.rlsdiReportLayoutParams);
reportLayoutParams.LayoutCode = informe;
reportLayout = reportLayoutsService.GetReportLayout(reportLayoutParams);
reportLayout.Printer = "PRINTER";
reportLayoutsService.UpdatePrinterSettings(reportLayout);

This code update report default printer, and I can see it if I go to reports and layouts windows, but it has no effects at all. My report is still being printed by default printer at each device.

Maybe it only works for document layouts but not for custom reports.

aldebra
Explorer
0 Kudos

Hi Antonio,
personally I have no longer used the reportLayoutDocument and I had to print the report using SAP Crystal reports run time engine ... in this way I can also export it to pdf if necessary

Accepted Solutions (1)

Accepted Solutions (1)

CR for VS runtime by default uses the PrintToPrinter() API to print the report.

Search for this KBA and add the registry key and see if that works for you:

https://launchpad.support.sap.com/#/notes/2284485

Other option is to set the PC's default printer to the custom printer and set the report to use the same printer properties.

Don

aldebra
Explorer
0 Kudos

Hi Mr. Don,
To print cr Layout I don't directly use the crystal report libraries but the DI Api libraries made available by Sap Business one, in its sdk environment.
I believe that, at the moment, the only solution is to change the windows default printer.

thank you so much for your time ... Really appreciated !

Best Regards
Moreno

Answers (1)

Answers (1)

0 Kudos

Actually the B1 .NET SDK is the same CR for VS sdk package.

Registry key will work for you.

Don

aldebra
Explorer
0 Kudos

thank you very much for your time Mr. Williams !
Sorry but I find it hard to understand.
I have to print, from an external executable (DI Api only) and in the background, a cr report on different printers.
The problem is that I can't set up a custom printer in my subroutine:

This is my code

SAPbobsCOM.ReportLayoutsService oReportLayoutService = Common.oCompanySource.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ReportLayoutsService);
SAPbobsCOM.ReportLayoutPrintParams oReportPrintParams = oReportLayoutService.GetDataInterface(SAPbobsCOM.ReportLayoutsServiceDataInterfaces.rlsdiReportLayoutPrintParams);

oReportPrintParams.LayoutCode = 'INV20012';
oReportPrintParams.DocEntry = 35;

oReportLayoutService.Print(oReportPrintParams);