Application Development 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: 

How to tell if user printed Adobe Form

yes_sapteam
Participant
0 Kudos

Hi,

I'm calling a Z-Adobe-Form from a Z-program.

Since this Form is an Invoice, I need to be able to know whether the user actually printed the Form or not,

so I can manage the Original/Copy flag.

Searching the issue pointed to the NAST table, but printing my Form creates no entries there.

Also checked the to see if the Spool-ID is returned in the "FP_CLOSE_JOB" but it comes back empty.

The Form is printed from the Print-Preview, since the user want to see first before they print.

This is the main parts of my code:

*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
FORM set_printing_parameters

                       CHANGING es_outputparams   TYPE sfpoutputparams. "Print parameters

   es_outputparams-preview = 'X'.    "Print preview
   es_outputparams-dest          = 'SPT1'.
   es_outputparams-nodialog = ' '.       "No daialog
   es_outputparams-device      = 'PRINTER'. "Output for printer

ENDFORM.                    " SET_PRINTING_PARAMETERS


*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
FORM open_print_job

             CHANGING es_outputparams TYPE sfpoutputparams   "Parameters to PDF: display,print etc...
                                     ev_error                   TYPE flag.             "Error flag..

   DATA: lv_msg TYPE string.                                 "#EC NEEDED

   CALL FUNCTION 'FP_JOB_OPEN'
     CHANGING
       ie_outputparams = es_outputparams
     EXCEPTIONS
       cancel          = 1
       usage_error     = 2
       system_error    = 3
       internal_error  = 4
       OTHERS          = 5.

   IF sy-subrc <> 0.
     MESSAGE i007(zmm_tech) DISPLAY LIKE 'E'.
     ev_error = 'X'.

   ENDIF.

ENDFORM.                    " OPEN_FTP_JOB


*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
FORM execute_pdf_form
                 USING    iv_fm_name          TYPE funcname                   "Fuction name
                 CHANGING ev_error            TYPE flag.                      "Error flag.

   DATA: ls_docparams        TYPE sfpdocparams.
   DATA: ls_pdf_out              TYPE fpformoutput.


   ls_docparams-langu = 'B'.


   CALL FUNCTION iv_fm_name               "Dynamic name I got from other part of the code
     EXPORTING
       /1bcdwb/docparams  = ls_docparams
       iv_bukrs           = p_bukrs
       iv_belnr           = p_belnr
       iv_gjahr           = p_year
       iv_tax_line        = p_taxhdr   "Write Tax Line in Header
       iv_wire_payment    = p_paytrn   "Bank Transfer Payment
       iv_sum_lines       = p_line_d   "With Lines Datailing
     IMPORTING
       /1bcdwb/formoutput = ls_pdf_out
     EXCEPTIONS
       usage_error        = 1
       system_error       = 2
       internal_error     = 3
       OTHERS             = 4.

   IF sy-subrc NE 0.

     ev_error = 'X'.

     MESSAGE ID sy-msgid TYPE sy-msgty
                         NUMBER sy-msgno
                         WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
   ENDIF.

ENDFORM.                    " EXECUTE_PDF_FORM


*----------------------------------------------------------------------*
*----------------------------------------------------------------------*

FORM close_print_job
               CHANGING ev_error        TYPE flag.     "Error flag

   DATA: ls_result  TYPE sfpjoboutput.
   DATA: lv_msg     TYPE string.                             "#EC NEEDED


   CALL FUNCTION 'FP_JOB_CLOSE'
     IMPORTING
       e_result       = ls_result
     EXCEPTIONS
       usage_error    = 1
       system_error   = 2
       internal_error = 3
       OTHERS         = 4.

   IF sy-subrc <> 0.
     MESSAGE e008(zmm_tech) INTO lv_msg.     "close spool form to PDF failed
     ev_error = 'X'.
   ENDIF.

ENDFORM.                    " CLOSE_FTP_JOB


Any help will be appreciated.



Regards,

Ayal Telem.



4 REPLIES 4

0 Kudos

Hi Ayal ,

Print preview  and print will not generate Spool no ,

In order to generate spool no. pass below parameters to FP_JOB_OPEN.

0 Kudos

Dear Vankata,

I tried it:

es_outputparams-reqnew   = 'X'.
es_outputparams-reqimm   = 'X'.


If these are the expected values, it didn't change anything.


Here is something I thought: when I print the document I get the Adobe print dialog, not the SAPGUI's. Maybe it means that it doesn't go through the SAP's spool?



Regards,

Ayal Telem.


0 Kudos

Ayal,

Please try  one more time with below parameters . and don't pass any other than below


outputparams-nodialog = 'X'. " suppress printer dialog popup

outputparams-GETPDF   = 'X'. " launch print preview

outputparams-DEST     = 'Your printer'. " printer.

outputparams-reqnew   = 'X'. " Creates a new spool request

Still if did not get it . just try with below two parameters.


outputparams-nodialog = 'X'.

outputparams-getpdf    = 'X'.

REQNEW is an important parameter. If you do not set this parameter, the system tries

to attach the new documents to an existing spool request during print output. You

must decide for each application whether this behavior is desired.

NODIALOG "Suppresses the dialog box for the output

PREVIEW  "Initially selects a print preview

GETPDF     "Requests the return of a PDF document

DEST          "Defines the output device (printer)

REQNEW    "Creates a new spool request

REQIMM     "Immediate output of the spool request

REGDEL     "Deletes the spool request after the output has been implemented

REGFINAL  "Completes the spool request

SPOOLID    "Adds the output to this spool ID

COPIES       "Number of copies

The basic difference is the call to the FP_JOB_OPEN function module; by setting

the NODIALOG parameter, you suppress the print dialog. To notify the system that

you want to receive a PDF, you must set the GETPDF parameter to ‘X’. Now, when

the generated function module is called, the document in the PDF field of the

/1BCDWB/FORMOUTPUT import parameter is returned. At the end of the program,

save this document into the local file system.

if you set NODIALOG to ‘X’, then no print dialog is displayed. You can then use the

PREVIEW parameter to define whether the preview is to be displayed (‘X’ means

show preview). If you do not want to display a print dialog, you should implicitly

define an output device in the DEST field; otherwise, the value is taken from your

user defaults

Regards,

Sinagam.

0 Kudos

Dear Sinagam,

This is the code for the printing parameters I have:

As you can see all the parameters you mentioned are there.

What I want, if it is possible, is to allow the user to print the document from the print-preview:

And then be able to tell if the document was printed, or just viewed.

Regards,

Ayal Telem.