cancel
Showing results for 
Search instead for 
Did you mean: 

SAP to .Net then Print

david_fryda2
Participant
0 Kudos

Hi everyone,

I want to send a file path from SAP/R3 to a Windows Service written in C#.

I do succeed sending the file path from SAP to the windows service but when I try to print the file, it does not work.

If I create a Console Application in C# and print the document using the same code that is in the windows service, it works perfectly.

Is there a difference between a windows service and a console application (background processing ???).

Thanks in advance.

Regards.

Accepted Solutions (0)

Answers (1)

Answers (1)

rima-sirich
Advisor
Advisor
0 Kudos

Hi David,

Could you please paste the fragment from your code where you are printing the file ?

Regards,

Rima.

david_fryda2
Participant
0 Kudos

Hi Rima,

Before you see the code, I just want to tell that this code work perfectly with concole application.

Here is the code :


public void PrintDoc(String File_Path)
{
   Process myProcess = new Process();

   try
   {
        myProcess.StartInfo.FileName = File_Path; 
	myProcess.StartInfo.Verb = "Print";
				myProcess.StartInfo.CreateNoWindow = true;
	myProcess.Start();
   }
   catch (Exception e)
   {

   }
}

I've just tested the same code with a console application ruuning a SAP Proxy server and it work good.

The problem is that is a console app and not a windows service which is not so friendly for the end user.

Thanks.

Message was edited by: David Fryda

rima-sirich
Advisor
Advisor
0 Kudos

Hi David,

I would suggest you to throw an exception in the try ... catch block in order to investigate the problem:

try

{

your code

}

catch (Exception e)

{

throw e;

}

May be your service doesn't have a sufficient permissions to operate on the file. Check which user account used to run this service.

Regards,

Rima.

Message was edited by: Rima Rudnik-Sirich

david_fryda2
Participant
0 Kudos

Hi Rima,

It doesn't throw any Exception.

I am almost sure that you cannot access the printer via a windows service...but only by using a console application.

The user has enough right to perform printing : it's a super user. The file has no permission defined.

Thanks.

Regards.

rima-sirich
Advisor
Advisor
0 Kudos

Hi David,

I would advice you to verify that your code - PrintDocument function - is executed. Try to do something simple, like to write to EventLog instead of printing file. Check who and when calls to PrintDocument function.

Regards,

Rima.

david_fryda2
Participant
0 Kudos

Hi Rima,

When I get into the PrintDocument function, I do write to the EventLog but the it does not print.

As I told, the same code works with a Console Application.

The user who call the PrintDocument function is a super user with all the rights.

I thing that Windows Service cannot perform GUI stuff...and printing is a GUI stuff.

Thanks.