cancel
Showing results for 
Search instead for 
Did you mean: 

DIAPI print to pdf document

Former Member
0 Kudos

Hi,

I am trying to print to pdf a invoice when I add it. Is there any way to do it by DIAPI?

Best Regards,

Ana Silva



Accepted Solutions (1)

Accepted Solutions (1)

pedro_magueija
Active Contributor
0 Kudos

Hi Ana,

I think that currently there is no native way of doing it via DI API.

I did post an idea in Idea Place about it, you can vote on it to have SAP implement it:

https://cw.sdn.sap.com/cw/ideas/6813

You can however, if it is a Crystal Report, use crystal runtime to print it.

Hope it helps.

Best regards,

Pedro Magueija

Former Member
0 Kudos

Hi Pedro,

Thank you for your answer. Do you have any sample code that you can send me?

Best Regards,

Ana Silva

pedro_magueija
Active Contributor
0 Kudos

Hi Ana,

    Dim crReport As New ReportDocument

    If (File.Exists(ReportPath)) Then

      crReport.Load(ReportPath)

      ' set parameters for your report

      crReport.SetParameterValue("@DocKey", "123")

      crReport.PrintOptions.PrinterName = ""

      crReport.DataSourceConnections(0).SetConnection(B1Connections.diCompany.Server, B1Connections.diCompany.CompanyDB, False)

      crReport.DataSourceConnections(0).SetLogon(B1Connections.diCompany.DbUserName, SqlServerPassword)

      crReport.PrintToPrinter(Copies, True, StartPage, EndPage)

    End If

Don't forget to include all necessary runtime dlls in the project. These are:

CrystalDecisions.CrystalReports.Engine.dll

CrystalDecisions.Shared.dll

Also, you need to have the correct version of the runtime, installed in each client machine. I think SAP B1 installs CR runtime 12.x (not 100% sure).

If you add the dlls from any other version you must install that runtime version in the client machine.

CR versions and downloads:

http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=56787567

I think you need the CR 2008.

Hope this helps,

Best regards,

Pedro Magueija

bhavank_gajjar
Active Contributor
0 Kudos

Hi Pedro Magueija,

Can you help me on this http://scn.sap.com/thread/3234644

awaiting for your reply.

Regards,

Bhavank

Former Member
0 Kudos

Hello Pedro, this works for PLD layouts?

Thank you.

LB

pedro_magueija
Active Contributor
0 Kudos

Hi Luis,

No I don't think so. This works only for crystal reports.

I'd like to help you but I don't know how to do it for PLD's.

Best regards,

Pedro Magueija

Former Member
0 Kudos

Hello Pedro,

i am always getting Falha de Logon on the database? Do you Know what can be?

Im using somthing like this:

Dim crReport As New ReportDocument

            If (File.Exists("C:\FT.rpt")) Then

                crReport.Load("C:\FT.rpt")

                ' set parameters for your report

                crReport.SetParameterValue("DocKey@", "8322")

                crReport.PrintOptions.PrinterName = ""

                'crReport.DataSourceConnections(0).SetConnection(oCompany.Server, oCompany.CompanyDB, False)

                crReport.DataSourceConnections(0).SetConnection("LB", "XXX_PRD", FALSE)

                'crReport.DataSourceConnections(0).SetLogon("sa", "sasa")

                crReport.VerifyDatabase() -> here i get "falha de logon"/"log on failed"

If i comment that line I get when try to print "Failed to load database information"

                crReport.PrintToPrinter(1, True, 1, 1)

            End If

I have the CR2008 Runtime Installed. If i try to print a blank RPT it works ok. So its the connection to the database that is failing somehow.

Thank you very much for your help.

LB

pedro_magueija
Active Contributor
0 Kudos

Hi Luis,

Tudo bem?

I honestly don't know, but you are using an "LB" as the server address. Is this correct? Can you try using the IP address of the server?

Best regards,

Pedro Magueija

edy_simon
Active Contributor
0 Kudos

Hi,

What data source connection you use in the report?

If you are using sap b1 connection, you might want to change to oledb/odbc.

And set the logon info in your code, should do it.

Regards,

Edy

Answers (0)