Skip to Content
0

How do I print Attchment document via ABSL Code?

Nov 16, 2016 at 06:48 AM

450

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Best Answer
Fred K Nov 16, 2016 at 09:10 AM
0

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

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Same Problem.

Am I missing anything?

Regards

Sankaran A

0

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

0

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

0
Fred K Nov 16, 2016 at 07:56 AM
0

Hi Sankaran,

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

Is there any error message?

Best Regards,

Fred

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

0
Fred K Nov 16, 2016 at 09:29 AM
0

Hi Sankaram,

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

Best Regards,

Fred

Show 3 Share
10 |10000 characters needed characters left characters exceeded

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

0

Hi Sankaran,

I think the method does not return anything.

Have you checked the print queue "CustomForm"?

Best Regards,

Fred

1

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

1
K Reddy Jan 02, 2017 at 09:36 AM
0

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.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

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

1

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

1
K Reddy Jan 04, 2017 at 05:05 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded