cancel
Showing results for 
Search instead for 
Did you mean: 

How do I print Attchment document via ABSL Code?

Former Member
0 Kudos

Hi Experts,

I configured the automatic printing (Cloud Print Manager) with my tenant. I need to print the attachment document. I'm using the bellow code. But It is not working. Am I missing anything?

var Useraccountid : UserAccountID;
var PDF : basisGlobal:BinaryObject;


PDF.Clear();
PDF.content = this.AttachmentFolder.Document.GetFirst().FileContent.BinaryObject.content;
PDF.fileName = "FileName";
PDF.mimeCode = this.AttachmentFolder.Document.GetFirst().FileContent.BinaryObject.mimeCode;
Useraccountid.Clear();
Useraccountid.content = "PRT_001";

var testPrint  = OutputManagementUtilities.CreatePrintQueueItem(Useraccountid, PDF.fileName, 1, PDF, "CustomForm");

Regards

Sankaran A

Accepted Solutions (1)

Accepted Solutions (1)

former_member200567
Active Contributor
0 Kudos

Hi Sankara,

You cannot send empty PDF to the print queue.

Only write these and test.

var Useraccountid : UserAccountID;
var PDF : basisGlobal:BinaryObject;
PDF.content = this.AttachmentFolder.Document.GetFirst().FileContent.BinaryObject.content;
Useraccountid.content = "PRT_001";
var testPrint  = OutputManagementUtilities.CreatePrintQueueItem(Useraccountid, "test1", 1, PDF, "CustomForm");

Best Regards,

Fred

Former Member
0 Kudos

Same Problem.

Am I missing anything?

Regards

Sankaran A

Former Member
0 Kudos

I'm also having one more doubt Fred,

I debugged the code. I got 89504E470D0A1A0A0000000D49484452000001DC0000.... this is the PDF Content value.

I checked in Backend. (Repository Explorer). The Content is :iVBORw0KGgoAAAANSUhEUgAAAdwAAACrCAYAAADM8y04AAAACXBIW.....

Is there any problem on this value mismatch?

Regards

Sankaran A

Former Member
0 Kudos

Hi @Fred,

How to print image file. It is good for PDF. But I need to print Image file.

Please help me to fullfill my requirnment.

Regards

Sankaran A

Answers (4)

Answers (4)

former_member299368
Participant
0 Kudos

Hi Sankaran,

Thank you for your quick reply.

The below logic i tried but i did'nt get image in byd screen.

import ABSL;

import BASIS.Global;

import DocumentServices.Global;

//var image.fileName = "FileName";

//var document = this.Im_AttachmentFolder.Document.GetFirst().FileContent.BinaryObject.mimeCode;

var documentlist = this.Im_AttachmentFolder.DocumentList.Where(n=>n.Name=="logo1.jpg");

var doc = documentlist.GetFirst();

if(doc.IsSet()){

//this.IM_BO = doc.FileContent.BinaryObject; doc.AlternativeName ="logo1.jpg"; doc.CategoryCode = "2";

doc.TypeCode.content = "10013";

doc.MIMECode = "image/jpg";

}

Thanks,

Kreddy.

former_member299368
Participant
0 Kudos

Hi Sankaran,

for pdf it is good. my requirement is get image from attachmentfolder.

can you just tell me the logic for image.

Thanks,

Kreddy.

,

Hi Sankaran,

For pdf it is good. my requirement is get image from attachment folder.

For image can you just tell me the logic.

Thanks,

Kreddy.

Former Member

Hi Kotesware,

I'm also facing the same problem. I will analysis the issue.

My Assumption is: In this scenario, SAP Printer Software trying to convert image file into PDF file. So the file get Corrupted. So it is not printing proper data.

I don't know whether my point is correct or not. I am keep on trying to get an answer.

In mean time, If you get an answer please update here.

Regards

Sankaran A

Former Member

Hi,

I have created separate question.

https://answers.sap.com/questions/95036/how-to-print-image-from-attachment-folder.html

If you get an idea/solution, Please update your answer there.

Regards

Sankaran A

former_member200567
Active Contributor
0 Kudos

Hi Sankaram,

Just to be sure, you need to call "Save after execution" in your event handler.

Best Regards,

Fred

Former Member
0 Kudos

Hi Fred,

Yes, I wrote this code in the Before Save script file. I saved the entire instance. But It is not working.

Regards

Sankaran A

former_member200567
Active Contributor

Hi Sankaran,

I think the method does not return anything.

Have you checked the print queue "CustomForm"?

Best Regards,

Fred

Former Member

Thank you so much, Fred.

It is working now. I did mistake in Print queue name. My Print Queue Name is "CustomFormTest".

Regards

Sankaran A

former_member200567
Active Contributor
0 Kudos

Hi Sankaran,

Have you debugged your codes and checked the value in PDF variable?

Is there any error message?

Best Regards,

Fred

Former Member
0 Kudos

Hi F red,

I debugged the code. But I didn't get any error.

var testPrint  = OutputManagementUtilities.CreatePrintQueueItem(Useraccountid, PDF.fileName,1, PDF,"CustomForm");

But the above line, the content of the PDF value will be empty.

PDF.content = this.AttachmentFolder.Document.GetFirst().FileContent.BinaryObject.content;

In the above line, the content will be set as byte array value.

Regards

Sankaran A