Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Print PDF attachments from DMS server

aba212
Participant
0 Likes
4,440

Hi All,

Can anybody help me to resolve my issue?

I have a requirement to print PDF attachments from DMS server. In CV04N we have PDF attachments for every batch and material. My custom program is configured with output type. This output type will executed from VL02N. If medium type is 'print output' the PDF attachments should print from DMS server which are related delivery batch and material.

Can body give me the solution to resolve this issue.?

Thanks in advance ,

Regards,

Satish

Hi All,

Can anybody help me to resolve my issue?

I have a requirement to print PDF attachments from DMS server. In CV04N we have PDF attachments for every batch and material. My custom program is configured with output type. This output type will executed from VL02N. If medium type is 'print output' the PDF attachments should print from DMS server which are related delivery batch and material.

Can body give me the solution to resolve this issue.?

Thanks in advance ,

Regards,

Satish

13 REPLIES 13
Read only

Sandra_Rossi
Active Contributor
0 Likes
3,924

This question has been recently asked exactly in the same way (Nov 29, Oct 9), and there was no answer. Don't you think you need to ask it differently?

I don't understand where your exact issue is. You have a custom program, you have a PDF already loaded via CV04N, and so, what then, where is the issue? Don't forget to tell about details: which print technology do you use, do you need to print immediately (local printer) or print in background (server printer)...

Read only

aba212
Participant
0 Likes
3,924

Hi Rossi,

Thanks for quick reply. The PDFs are uploaded into CV04N for every batch and material. The for this requirement we will have the output type which will trigger from VL02N/VT03N. Once output is triggered with medium type 'print output', all PDF attachments of delivery batch/shipment batch should be print. The printer name we will get in NAST. Based on the printer name PDFs should print. Here I need help to print the PDF from DMS server.

Do we have any function module/class-method to print PDF from DMS server?

Hope you understand my requirement.

Regards,

Satish

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,924

No, there's no function module/class method to print PDF from DMS server. You must first read the file from the "DMS server", this is easy as it has been answered many times in the forum. To print a PDF when you print immediately, the only simple solution is to execute the PDF print using cl_gui_frontend_services, and it has been answered on the forum too.

Read only

aba212
Participant
0 Likes
3,924

Hi Rossi,

Thanks for your quick reply. Could you provide the sequence of the methods execution of the class 'cl_gui_frontend_services' to print PDFs ?

If you have any sample code, kindly share the code to me.

Regards,

Satish

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,924

As I said, it has been already answered. When you find the answer, I can confirm your finding if you prefer.

Read only

aba212
Participant
3,924

Hi Rossi,

I've used class method cl_gui_frontend_services=>execute to print pdf from DMS server. initially I've downloaded the PDF attachment into my local drive and I've passed file path to parameter 'document' of cl_gui_frontend_services=>execute. But I'm not able to print attachment. Could you please give me any solution if you have?

CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
  EXPORTING
    DOCUMENT                = lv_file_name    "File path in local drive to print
    OPERATION               = 'PRINT'
*  EXCEPTIONS
*    CNTL_ERROR             = 1
*    ERROR_NO_GUI           = 2
*    BAD_PARAMETER          = 3
*    FILE_NOT_FOUND         = 4
*    PATH_NOT_FOUND         = 5
*    FILE_EXTENSION_UNKNOWN = 6
*    ERROR_EXECUTE_FAILED   = 7
*    SYNCHRONOUS_FAILED     = 8
*    NOT_SUPPORTED_BY_GUI   = 9
*    others                 = 10
        .
IF SY-SUBRC EQ 0.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_DELETE
  EXPORTING
    FILENAME             = lv_file_name      "File path in local drive to delete the file
  CHANGING
    RC                   = rc              "Integer type
  EXCEPTIONS
    FILE_DELETE_FAILED   = 1
*    CNTL_ERROR           = 2
*    ERROR_NO_GUI         = 3
*    FILE_NOT_FOUND       = 4
*    ACCESS_DENIED        = 5
*    UNKNOWN_ERROR        = 6
*    NOT_SUPPORTED_BY_GUI = 7
*    WRONG_PARAMETER      = 8
    others               = 9
        .
IF SY-SUBRC <> 0.


* Implement suitable error handling here
ENDIF.


ENDIF.


<br>

Regards,

Satish

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,924

Good job. Now please debug your program : check the return code after EXECUTE (check the value of the RC variable + uncomment the list of exceptions). The file name must be the full path, and the name must end with ".PDF" (in Windows that will link to your PDF reader software). It should work if Acrobat Reader is installed on your laptop.

By the way, one thing at a time: don't delete the file during your test, as it's the best way to be unable to troubleshoot the issue! First you should succeed printing. Then, delete the file. Make sure the call to EXECUTE is synchronous (= 'X') before deleting the file!

Read only

aba212
Participant
0 Likes
3,924

Hi Rossi,

I passed synchronous (= 'X') to method EXECUTE. But it's taking too much time even for printing one file also.

Some times I'm getting print from printer. Some times the print is not coming. But the PDF is opening with error (File path not found') once program is executed. I want to stop the PDF open. Could you please provide solution for this ?

Please find the attachment for PDF error. Because of the below code the file is opening.

"Below Method from CL_GUI_FRONTEND_SERVICES=>EXECUTE     
CALL METHOD CL_GUI_CFW=>FLUSH
        EXCEPTIONS
          CNTL_SYSTEM_ERROR = 1
          CNTL_ERROR        = 2
          others            = 3.
      IF SY-SUBRC <> 0.
        RAISE CNTL_ERROR.
      ENDIF.

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,924

About acrord32.exe options, search again, this is not ABAP anymore -> https://stackoverflow.com/questions/619158/adobe-reader-command-line-reference

For passing options to the command, use EXECUTE differently -> https://archive.sap.com/discussions/thread/1603209

application = 'AcroRd32.exe'
parameter = '/p /h <path>.pdf'    "P = Print, h = Hide Window
minimized = 'X'
synchronous = ' '
operation = ''

About the "not printing sometimes", maybe it's still because of the file deletion. Instead, try not deleting yourself, by downloading the file to the SAP GUI temporary folder, it will be deleted later automatically by the SAP GUI (after one hour or at next restart of the SAP GUI or something like that):

CL_GUI_FRONTEND_SERVICES=>GET_TEMP_DIRECTORY( ... )
CL_GUI_CFW=>FLUSH( ). " mandatory to return the temporary folder into the variable

.

Read only

aba212
Participant
0 Likes
3,924

Hi Rossi,

I've passed the parameter value as parameter = '/p /h <path>.pdf' "P = Print, h = Hide Window.

But no use. Still PDF is getting open. Is there any other to print PDF by generating the spool.?

Please let me know if you have any other way to print PDF documents from DMS server.

Regards,

Satish

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,924

All your questions are not related to ABAP. SAP don't know how to print PDF. Please post on relevant forums (not SAP).

Read only

mmcisme1
Active Contributor
0 Likes
3,924

Try the following search:

sap Print PDF attachments from DMS server

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,924

First, don't call FILE_DELETE when you test (otherwise, that could be a reason to not work, if you delete a file while it's being printed).

Second, replace 'PRINT' with 'OPEN', remove the call to FILE_DELETE. Does it open correctly?

If yes, then try 'PRINT' without FILE_DELETE.