cancel
Showing results for 
Search instead for 
Did you mean: 

Save Generated PDF to desktop

Former Member
0 Kudos

Hi Experts

I have a program that needs to generate a form and save it to the local hard drive.

I use the following functions for populating the form:

CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
            EXPORTING
              i_name     ='ZSFPFLS_EX_WDA_CON'
            IMPORTING
              e_funcname = fm_name.

*   Set output parameters and open spool job
  fp_outputparams-nodialog = 'X'. " suppress printer dialog popup
  fp_outputparams-getpdf = 'X'. " launch print preview
  fp_outputparams-PDFCHANGESRESTRICTED = 'N'. "Form can be filled out and signed and you can also create comments

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

*   Set form language and country (->form locale)
  fp_docparams-langu   = 'E'.
  fp_docparams-country = 'ZA'.
  fp_docparams-dynamic = 'X'.


*   Now call the generated function module
  CALL FUNCTION fm_name
    EXPORTING
      /1bcdwb/docparams       = fp_docparams
      SCHEDULE                = ls_pdf_sched
      ADDITIONAL_INFO         = ls_convocation-additional_info
      ISSUE_DATE              = ls_convocation-issue_date
...
    IMPORTING
      /1bcdwb/formoutput      = fp_formoutput
    EXCEPTIONS
      usage_error             = 1
      system_error            = 2
      internal_error          = 3
      OTHERS                  = 4.

*   Close spool job
  CALL FUNCTION 'FP_JOB_CLOSE'
    EXCEPTIONS
      usage_error    = 1
      system_error   = 2
      internal_error = 3
      OTHERS         = 4.

*   Now you have the PDF form in xstring format inside the field fp_formoutput-pdf

  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer = fp_formoutput-pdf
    TABLES
      binary_tab = itab.

I then want to use the following method for selecting the location where to save the file:

CALL METHOD cl_gui_frontend_services=>file_save_dialog
...

What do I now need to do to actually save the file to that location?

Thanks in advance

Anton Kruse

Accepted Solutions (1)

Accepted Solutions (1)

OttoGold
Active Contributor
0 Kudos

Decide, whether you want to use this ABAP coding, or it is cleaner/ better/ proper to display the form to the user and let him save it. I recommend this:

Use outputparams to set up the preview every time. Then the form will be displayed with no additional clicks and waiting to the user, And he can check it first and save it using "save" in adobe reader.

Of course you could do this using ABAP, but why would you do this? (except some FTP silent save crazy function:))). And that I would use only for a server not a client purpose. Then I would place the save dialog code right after the conversion at the end of the code you provided.

Answers (1)

Answers (1)

Former Member
0 Kudos

That makes much more sense than I was originally thinking..

Thanks.